summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2021-05-01 15:41:38 (GMT)
committerJunio C Hamano <gitster@pobox.com>2021-05-03 05:41:08 (GMT)
commit9e1947cb482c8fc7e1d0c8334f126ced5062b895 (patch)
treed10901aeed79f906bc04a84401bf7e6d010cac9a /t
parent963d02a24a1e6cec02cadf0d682af0bf222647ab (diff)
downloadgit-9e1947cb482c8fc7e1d0c8334f126ced5062b895.zip
git-9e1947cb482c8fc7e1d0c8334f126ced5062b895.tar.gz
git-9e1947cb482c8fc7e1d0c8334f126ced5062b895.tar.bz2
fsck_tree(): fix shadowed variable
Commit b2f2039c2b (fsck: accept an oid instead of a "struct tree" for fsck_tree(), 2019-10-18) introduced a new "oid" parameter to fsck_tree(), and we pass it to the report() function when we find problems. However, that is shadowed within the tree-walking loop by the existing "oid" variable which we use to store the oid of each tree entry. As a result, we may report the wrong oid for some problems we detect within the loop (the entry oid, instead of the tree oid). Our tests didn't catch this because they checked only that we found the expected fsck problem, not that it was attached to the correct object. Let's rename both variables in the function to avoid confusion. This makes the diff a little noisy (e.g., all of the report() calls outside the loop were already correct but need to be touched), but makes sure we catch all cases and will avoid similar confusion in the future. And we can update the test to be a bit more specific and catch this problem. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't')
-rwxr-xr-xt/t7415-submodule-names.sh5
1 files changed, 3 insertions, 2 deletions
diff --git a/t/t7415-submodule-names.sh b/t/t7415-submodule-names.sh
index fef6561..6a8cf3f 100755
--- a/t/t7415-submodule-names.sh
+++ b/t/t7415-submodule-names.sh
@@ -148,12 +148,13 @@ test_expect_success 'fsck detects symlinked .gitmodules file' '
{
printf "100644 blob $content\t$tricky\n" &&
printf "120000 blob $target\t.gitmodules\n"
- } | git mktree &&
+ } >bad-tree &&
+ tree=$(git mktree <bad-tree) &&
# Check not only that we fail, but that it is due to the
# symlink detector
test_must_fail git fsck 2>output &&
- grep gitmodulesSymlink output
+ grep "tree $tree: gitmodulesSymlink" output
)
'