t7611: replace test -f with test_path_is* helpers

Replace `test -f` and `test ! -f` with `test_path_is_file` and `test_path_is_missing` for better debuggability. While `test -f` ensures that the file exists and is a regular file, `test_path_is_file` provides clearer error messages on failure. On the other hand, `test ! -f` checks either the absence of a regular file or the presence of any other filesystem object, but looking at them in the test individually, all of them should've said `test ! -e`, i.e. "there shouldn't be anything at given path on filesystem." Replace these cases with `test_path_is_missing` for better debuggability. Helped-by: karthik nayak <karthik.188@gmail.com> Helped-by: Junio C Hamano <gitster@pobox.com> Signed-off-by: Meet Soni <meetsoni3017@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Meet Soni committed Dec 27, 2024 at 16:23 UTC cef3d4a89f8d21fae6669822cbb540927020d93b
1 file changed +17 -17
t/t7611-merge-abort.sh
+17 -17
@@ -54,13 +54,13 @@ test_expect_success 'fails without MERGE_HEAD (unstarted merge)' '
54 '
55
56 test_expect_success 'fails without MERGE_HEAD (unstarted merge): .git/MERGE_HEAD sanity' '
57 - test ! -f .git/MERGE_HEAD &&
57 + test_path_is_missing .git/MERGE_HEAD &&
58 test "$pre_merge_head" = "$(git rev-parse HEAD)"
59 '
60
61 test_expect_success 'fails without MERGE_HEAD (completed merge)' '
62 git merge clean_branch &&
63 - test ! -f .git/MERGE_HEAD &&
63 + test_path_is_missing .git/MERGE_HEAD &&
64 # Merge successfully completed
65 post_merge_head="$(git rev-parse HEAD)" &&
66 test_must_fail git merge --abort 2>output &&
@@ -68,7 +68,7 @@ test_expect_success 'fails without MERGE_HEAD (completed merge)' '
68 '
69
70 test_expect_success 'fails without MERGE_HEAD (completed merge): .git/MERGE_HEAD sanity' '
71 - test ! -f .git/MERGE_HEAD &&
71 + test_path_is_missing .git/MERGE_HEAD &&
72 test "$post_merge_head" = "$(git rev-parse HEAD)"
73 '
74
@@ -79,10 +79,10 @@ test_expect_success 'Forget previous merge' '
79 test_expect_success 'Abort after --no-commit' '
80 # Redo merge, but stop before creating merge commit
81 git merge --no-commit clean_branch &&
82 - test -f .git/MERGE_HEAD &&
82 + test_path_is_file .git/MERGE_HEAD &&
83 # Abort non-conflicting merge
84 git merge --abort &&
85 - test ! -f .git/MERGE_HEAD &&
85 + test_path_is_missing .git/MERGE_HEAD &&
86 test "$pre_merge_head" = "$(git rev-parse HEAD)" &&
87 test -z "$(git diff)" &&
88 test -z "$(git diff --staged)"
@@ -91,10 +91,10 @@ test_expect_success 'Abort after --no-commit' '
91 test_expect_success 'Abort after conflicts' '
92 # Create conflicting merge
93 test_must_fail git merge conflict_branch &&
94 - test -f .git/MERGE_HEAD &&
94 + test_path_is_file .git/MERGE_HEAD &&
95 # Abort conflicting merge
96 git merge --abort &&
97 - test ! -f .git/MERGE_HEAD &&
97 + test_path_is_missing .git/MERGE_HEAD &&
98 test "$pre_merge_head" = "$(git rev-parse HEAD)" &&
99 test -z "$(git diff)" &&
100 test -z "$(git diff --staged)"
@@ -105,7 +105,7 @@ test_expect_success 'Clean merge with dirty index fails' '
105 git add foo &&
106 git diff --staged > expect &&
107 test_must_fail git merge clean_branch &&
108 - test ! -f .git/MERGE_HEAD &&
108 + test_path_is_missing .git/MERGE_HEAD &&
109 test "$pre_merge_head" = "$(git rev-parse HEAD)" &&
110 test -z "$(git diff)" &&
111 git diff --staged > actual &&
@@ -114,7 +114,7 @@ test_expect_success 'Clean merge with dirty index fails' '
114
115 test_expect_success 'Conflicting merge with dirty index fails' '
116 test_must_fail git merge conflict_branch &&
117 - test ! -f .git/MERGE_HEAD &&
117 + test_path_is_missing .git/MERGE_HEAD &&
118 test "$pre_merge_head" = "$(git rev-parse HEAD)" &&
119 test -z "$(git diff)" &&
120 git diff --staged > actual &&
@@ -129,10 +129,10 @@ test_expect_success 'Reset index (but preserve worktree changes)' '
129
130 test_expect_success 'Abort clean merge with non-conflicting dirty worktree' '
131 git merge --no-commit clean_branch &&
132 - test -f .git/MERGE_HEAD &&
132 + test_path_is_file .git/MERGE_HEAD &&
133 # Abort merge
134 git merge --abort &&
135 - test ! -f .git/MERGE_HEAD &&
135 + test_path_is_missing .git/MERGE_HEAD &&
136 test "$pre_merge_head" = "$(git rev-parse HEAD)" &&
137 test -z "$(git diff --staged)" &&
138 git diff > actual &&
@@ -141,10 +141,10 @@ test_expect_success 'Abort clean merge with non-conflicting dirty worktree' '
141
142 test_expect_success 'Abort conflicting merge with non-conflicting dirty worktree' '
143 test_must_fail git merge conflict_branch &&
144 - test -f .git/MERGE_HEAD &&
144 + test_path_is_file .git/MERGE_HEAD &&
145 # Abort merge
146 git merge --abort &&
147 - test ! -f .git/MERGE_HEAD &&
147 + test_path_is_missing .git/MERGE_HEAD &&
148 test "$pre_merge_head" = "$(git rev-parse HEAD)" &&
149 test -z "$(git diff --staged)" &&
150 git diff > actual &&
@@ -159,7 +159,7 @@ test_expect_success 'Fail clean merge with conflicting dirty worktree' '
159 echo xyzzy >> bar &&
160 git diff > expect &&
161 test_must_fail git merge --no-commit clean_branch &&
162 - test ! -f .git/MERGE_HEAD &&
162 + test_path_is_missing .git/MERGE_HEAD &&
163 test "$pre_merge_head" = "$(git rev-parse HEAD)" &&
164 test -z "$(git diff --staged)" &&
165 git diff > actual &&
@@ -168,7 +168,7 @@ test_expect_success 'Fail clean merge with conflicting dirty worktree' '
168
169 test_expect_success 'Fail conflicting merge with conflicting dirty worktree' '
170 test_must_fail git merge conflict_branch &&
171 - test ! -f .git/MERGE_HEAD &&
171 + test_path_is_missing .git/MERGE_HEAD &&
172 test "$pre_merge_head" = "$(git rev-parse HEAD)" &&
173 test -z "$(git diff --staged)" &&
174 git diff > actual &&
@@ -183,7 +183,7 @@ test_expect_success 'Fail clean merge with matching dirty worktree' '
183 echo bart > bar &&
184 git diff > expect &&
185 test_must_fail git merge --no-commit clean_branch &&
186 - test ! -f .git/MERGE_HEAD &&
186 + test_path_is_missing .git/MERGE_HEAD &&
187 test "$pre_merge_head" = "$(git rev-parse HEAD)" &&
188 test -z "$(git diff --staged)" &&
189 git diff > actual &&
@@ -194,7 +194,7 @@ test_expect_success 'Fail conflicting merge with matching dirty worktree' '
194 echo barf > bar &&
195 git diff > expect &&
196 test_must_fail git merge conflict_branch &&
197 - test ! -f .git/MERGE_HEAD &&
197 + test_path_is_missing .git/MERGE_HEAD &&
198 test "$pre_merge_head" = "$(git rev-parse HEAD)" &&
199 test -z "$(git diff --staged)" &&
200 git diff > actual &&