summaryrefslogtreecommitdiff
path: root/t/t3013-ls-files-format.sh
diff options
context:
space:
mode:
authorAdam Johnson <me@adamj.eu>2023-03-10 13:04:33 (GMT)
committerJunio C Hamano <gitster@pobox.com>2023-03-10 17:16:16 (GMT)
commitcfb62dd006ae82dd1e06fb177095c8885b40b1c3 (patch)
tree6c995a3f114d4c4ab06295722a45cadf79b45265 /t/t3013-ls-files-format.sh
parentce74de931d7aea9746e37632534eacc63b0c1a90 (diff)
downloadgit-cfb62dd006ae82dd1e06fb177095c8885b40b1c3.zip
git-cfb62dd006ae82dd1e06fb177095c8885b40b1c3.tar.gz
git-cfb62dd006ae82dd1e06fb177095c8885b40b1c3.tar.bz2
ls-files: fix "--format" output of relative paths
Fix a bug introduced with the "--format" option in ce74de93 (ls-files: introduce "--format" option, 2022-07-23), where relative paths were computed using the output buffer, which could lead to random garbage data in the output. Signed-off-by: Adam Johnson <me@adamj.eu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t3013-ls-files-format.sh')
-rwxr-xr-xt/t3013-ls-files-format.sh16
1 files changed, 16 insertions, 0 deletions
diff --git a/t/t3013-ls-files-format.sh b/t/t3013-ls-files-format.sh
index efb7450..ef6fb53 100755
--- a/t/t3013-ls-files-format.sh
+++ b/t/t3013-ls-files-format.sh
@@ -54,6 +54,22 @@ test_expect_success 'git ls-files --format path v.s. -s' '
test_cmp expect actual
'
+test_expect_success 'git ls-files --format with relative path' '
+ cat >expect <<-\EOF &&
+ ../o1.txt
+ ../o2.txt
+ ../o3.txt
+ ../o4.txt
+ ../o5.txt
+ ../o6.txt
+ EOF
+ mkdir sub &&
+ cd sub &&
+ git ls-files --format="%(path)" ":/" >../actual &&
+ cd .. &&
+ test_cmp expect actual
+'
+
test_expect_success 'git ls-files --format with -m' '
echo change >o1.txt &&
cat >expect <<-\EOF &&