Skip to content

Commit dbea72a

Browse files
Thomas Rastgitster
authored andcommitted
sha1_file: silence sha1_loose_object_info
sha1_object_info() returns -1 (OBJ_BAD) if it cannot find the object for some reason, which suggests that it wants the _caller_ to report this error. However, part of its work happens in sha1_loose_object_info, which _does_ report errors itself. This is doubly strange because: * packed_object_info(), which is the other half of the duo, does _not_ report this. * In the event that an object is packed and pruned while sha1_object_info_extended() goes looking for it, we would erroneously show the error -- even though the code of the latter function purports to handle this case gracefully. * A caller might invoke sha1_object_info() to find the type of an object even if that object is not known to exist. Silence this error. The others remain untouched as a corrupt object is a much more grave error than it merely being absent. Signed-off-by: Thomas Rast <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent b1d04bf commit dbea72a

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

sha1_file.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2140,7 +2140,7 @@ static int sha1_loose_object_info(const unsigned char *sha1, unsigned long *size
21402140

21412141
map = map_sha1_file(sha1, &mapsize);
21422142
if (!map)
2143-
return error("unable to find %s", sha1_to_hex(sha1));
2143+
return -1;
21442144
if (unpack_sha1_header(&stream, map, mapsize, hdr, sizeof(hdr)) < 0)
21452145
status = error("unable to unpack %s header",
21462146
sha1_to_hex(sha1));

0 commit comments

Comments
 (0)