diff options
author | Jeff King <peff@peff.net> | 2017-01-13 20:54:39 +0300 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2017-01-16 02:59:03 +0300 |
commit | 771e7d578ee93753f5ac0ed346effd0af3d5a4b4 (patch) | |
tree | 56e1e2fea24ed1a7ea83bedacc71cd6d31b6cf46 /t/t1450-fsck.sh | |
parent | 0b20f1a26604a4f43f4728acc56c6ffc6a976220 (diff) |
sha1_file: fix error message for alternate objects
When we fail to open a corrupt loose object, we report an
error and mention the filename via sha1_file_name().
However, that function will always give us a path in the
local repository, whereas the corrupt object may have come
from an alternate. The result is a very misleading error
message.
Teach the open_sha1_file() and stat_sha1_file() helpers to
pass back the path they found, so that we can report it
correctly.
Note that the pointers we return go to static storage (e.g.,
from sha1_file_name()), which is slightly dangerous.
However, these helpers are static local helpers, and the
names are used for immediately generating error messages.
The simplicity is an acceptable tradeoff for the danger.
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t1450-fsck.sh')
-rwxr-xr-x | t/t1450-fsck.sh | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/t/t1450-fsck.sh b/t/t1450-fsck.sh index 3297d4cb2f..f95174c9d8 100755 --- a/t/t1450-fsck.sh +++ b/t/t1450-fsck.sh @@ -550,4 +550,14 @@ test_expect_success 'fsck --name-objects' ' ) ' +test_expect_success 'alternate objects are correctly blamed' ' + test_when_finished "rm -rf alt.git .git/objects/info/alternates" && + git init --bare alt.git && + echo "../../alt.git/objects" >.git/objects/info/alternates && + mkdir alt.git/objects/12 && + >alt.git/objects/12/34567890123456789012345678901234567890 && + test_must_fail git fsck >out 2>&1 && + grep alt.git out +' + test_done |