t7605: use test_path_is_file instead of test -f
PATCH 1/1 t7605: use test_path_is_file instead of test -f
From: Mansi <[email protected]>
Replace old-style 'test -f' path checks with the modern test_path_is_file helper in the merge_c1_to_c2_cmds block.
The helper provides clearer failure messages and is the established convention in Git's test suite.
These instances were found using:
grep -rn "test -[efd]" t/ --include="*.sh"
---
t7605: use test_path_is_file instead of test -f
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-2050%2FMansiSingh17%2Fgsoc-t7605-test-path-helpers-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-2050/MansiSingh17/gsoc-t7605-test-path-helpers-v1
Pull-Request: https://github.com/gitgitgadget/git/pull/2050
t/t7605-merge-resolve.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
t/t7605-merge-resolve.sh +3 -3
@@ -34,9 +34,9 @@ merge_c1_to_c2_cmds=' test "$(git rev-parse c1)" = "$(git rev-parse HEAD^1)" && test "$(git rev-parse c2)" = "$(git rev-parse HEAD^2)" && git diff --exit-code && - test -f c0.c && - test -f c1.c && - test -f c2.c && + test_path_is_file c0.c && + test_path_is_file c1.c && + test_path_is_file c2.c && test 3 = $(git ls-tree -r HEAD | wc -l) && test 3 = $(git ls-files | wc -l) '
base-commit: 7c02d39fc2ed2702223c7674f73150d9a7e61ba4
Signature · 1 line
gitgitgadget
Hi, Mansi!
Quoted 8 lines
Replace old-style 'test -f' path checks with the modern
test_path_is_filehelper in themerge_c1_to_c2_cmdsblock.The helper provides clearer failure messages and is the established convention in Git's test suite.
These instances were found using:
grep -rn "test -[efd]" t/ --include="*.sh"
I don't think this information is relevant to be placed in the commit description. Perhaps it would better placed after the scissors mark (the --- after the message) which is sent to the mailing list but ignored in the final commit.
Btw, since we're in Git we can use Git's special powers to do that. This is equivalent to your command line:
$ git grep 'test -[efd]' -- 't/*.sh'
And this may be more useful, separating the output per file and using pathspecs to filter the tests (files that begin with "t") from other helper scripts inside t/:
$ git grep --heading --break 'test -[efd]' -- 't/t*.sh'
I wrote a blog post about git-grep and other tools [1] that may be useful for you.
Quoted 6 lines
- test -f
c0.c&&
- test -fc1.c&&
- test -fc2.c&&
+test_path_is_filec0.c&&
+test_path_is_filec1.c&&
+test_path_is_filec2.c&&
The code itself looks good to me!
[1] https://lucasoshiro.github.io/posts-en/2023-02-13-git-debug/#git-grep
PATCH v2 1/1 t7605: use test_path_is_file instead of test -f
In reply to Mansi Singh via GitGitGadgetFrom: Mansi <[email protected]>
Replace old-style 'test -f' path checks with the modern test_path_is_file helper in the merge_c1_to_c2_cmds block.
The helper provides clearer failure messages and is the established convention in Git's test suite.
---
t7605: use test_path_is_file instead of test -f
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-2050%2FMansiSingh17%2Fgsoc-t7605-test-path-helpers-v2
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-2050/MansiSingh17/gsoc-t7605-test-path-helpers-v2
Pull-Request: https://github.com/gitgitgadget/git/pull/2050
Range-diff vs v1:
1: 11724e9310 ! 1: 0a0c9de263 t7605: use test_path_is_file instead of test -f
@@ Commit message
The helper provides clearer failure messages and is the established convention in Git's test suite.
- These instances were found using:
- grep -rn "test -[efd]" t/ --include="*.sh"
-
## t/t7605-merge-resolve.sh ##
t/t7605-merge-resolve.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
t/t7605-merge-resolve.sh +3 -3
@@ -34,9 +34,9 @@ merge_c1_to_c2_cmds=' test "$(git rev-parse c1)" = "$(git rev-parse HEAD^1)" && test "$(git rev-parse c2)" = "$(git rev-parse HEAD^2)" && git diff --exit-code && - test -f c0.c && - test -f c1.c && - test -f c2.c && + test_path_is_file c0.c && + test_path_is_file c1.c && + test_path_is_file c2.c && test 3 = $(git ls-tree -r HEAD | wc -l) && test 3 = $(git ls-files | wc -l) '
base-commit: 7c02d39fc2ed2702223c7674f73150d9a7e61ba4
Signature · 1 line
gitgitgadget