]> git.ipfire.org Git - thirdparty/git.git/commitdiff
t7001: use "ls-files --format" instead of "cut"
authorJeff King <peff@peff.net>
Mon, 8 May 2023 19:01:46 +0000 (15:01 -0400)
committerJunio C Hamano <gitster@pobox.com>
Mon, 8 May 2023 21:50:28 +0000 (14:50 -0700)
Since ls-files recently learned a "--format" option, we can use that
rather than asking for all of "--stage" and then pulling out the bits we
want with "cut". That's simpler and avoids two extra processes (one for
cut, and one for the subshell to hold the intermediate result).

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/t7001-mv.sh

index ea70419928be6cde94cf8b3152e90f751314844e..2e6a3c0a5445c67fe77eaa2b8b0e04fb81b0510c 100755 (executable)
@@ -5,8 +5,7 @@ test_description='git mv in subdirs'
 . "$TEST_DIRECTORY"/lib-diff-data.sh
 
 index_at_path () {
-       entry=$(git ls-files --stage "$@") &&
-       echo "$entry" | cut -f 1
+       git ls-files --format='%(objectmode) %(objectname) %(stage)' "$@"
 }
 
 test_expect_success 'mv -f refreshes updated index entry' '