sha1_file: fix error message for alternate objects
commit771e7d578ee93753f5ac0ed346effd0af3d5a4b4
authorJeff King <peff@peff.net>
Fri, 13 Jan 2017 17:54:39 +0000 (13 12:54 -0500)
committerJunio C Hamano <gitster@pobox.com>
Sun, 15 Jan 2017 23:59:03 +0000 (15 15:59 -0800)
tree56e1e2fea24ed1a7ea83bedacc71cd6d31b6cf46
parent0b20f1a26604a4f43f4728acc56c6ffc6a976220
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>
sha1_file.c
t/t1450-fsck.sh