diff options
author | Jeff King <peff@peff.net> | 2021-05-01 11:41:38 -0400 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2021-05-03 14:41:08 +0900 |
commit | 9e1947cb482c8fc7e1d0c8334f126ced5062b895 (patch) | |
tree | d10901aeed79f906bc04a84401bf7e6d010cac9a /builtin/update-index.c | |
parent | t7415: remove out-dated comment about translation (diff) | |
download | tgif-9e1947cb482c8fc7e1d0c8334f126ced5062b895.tar.xz |
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 'builtin/update-index.c')
0 files changed, 0 insertions, 0 deletions