@matheusbsbs / matheus-bagliano / commits / fc12aa7bfd
Fork 0

t1450: increase test coverage of in-tree d/f detection

Exercise the case of putting a conflict candidate file name back on the stack because a matching directory might yet come up later. Do that by factoring out the test code into a function to allow for more concise notation in the form of parameters indicating names of trees (with trailing slash) and blobs (without trailing slash) in no particular order (they are sorted by git mktree). Then add the new test case as a second function call. Fix a typo in the test title while at it ("dublicate"). Reported-by: Derrick Stolee <stolee@gmail.com> Signed-off-by: René Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>

René Scharfe committed May 21, 2020 at 11:52 UTC fc12aa7bfd50fd175a0760b446de1e4514a69d46
1 file changed +27 -15
t/t1450-fsck.sh
+27 -15
@@ -234,21 +234,33 @@ test_expect_success 'tree object with duplicate entries' '
234 test_i18ngrep "error in tree .*contains duplicate file entries" out
235 '
236
237 -test_expect_success 'tree object with dublicate names' '
238 - test_when_finished "remove_object \$blob" &&
239 - test_when_finished "remove_object \$tree" &&
240 - test_when_finished "remove_object \$badtree" &&
241 - blob=$(echo blob | git hash-object -w --stdin) &&
242 - printf "100644 blob %s\t%s\n" $blob x.2 >tree &&
243 - tree=$(git mktree <tree) &&
244 - printf "100644 blob %s\t%s\n" $blob x.1 >badtree &&
245 - printf "100644 blob %s\t%s\n" $blob x >>badtree &&
246 - printf "040000 tree %s\t%s\n" $tree x >>badtree &&
247 - badtree=$(git mktree <badtree) &&
248 - test_must_fail git fsck 2>out &&
249 - test_i18ngrep "$badtree" out &&
250 - test_i18ngrep "error in tree .*contains duplicate file entries" out
251 -'
237 +check_duplicate_names () {
238 + expect=$1 &&
239 + shift &&
240 + names=$@ &&
241 + test_expect_$expect "tree object with duplicate names: $names" '
242 + test_when_finished "remove_object \$blob" &&
243 + test_when_finished "remove_object \$tree" &&
244 + test_when_finished "remove_object \$badtree" &&
245 + blob=$(echo blob | git hash-object -w --stdin) &&
246 + printf "100644 blob %s\t%s\n" $blob x.2 >tree &&
247 + tree=$(git mktree <tree) &&
248 + for name in $names
249 + do
250 + case "$name" in
251 + */) printf "040000 tree %s\t%s\n" $tree "${name%/}" ;;
252 + *) printf "100644 blob %s\t%s\n" $blob "$name" ;;
253 + esac
254 + done >badtree &&
255 + badtree=$(git mktree <badtree) &&
256 + test_must_fail git fsck 2>out &&
257 + test_i18ngrep "$badtree" out &&
258 + test_i18ngrep "error in tree .*contains duplicate file entries" out
259 + '
260 +}
261 +
262 +check_duplicate_names success x x.1 x/
263 +check_duplicate_names success x x.1.2 x.1/ x/
264
265 test_expect_success 'unparseable tree object' '
266 test_oid_cache <<-\EOF &&