Skip to content

Commit ef07618

Browse files
Linus TorvaldsJunio C Hamano
authored andcommitted
git-repack: Properly abort in corrupt repository
In a corrupt repository, git-repack produces a pack that does not contain needed objects without complaining, and the result of this combined with -d flag can be very painful -- e.g. a lossage of one tree object can lead to lossage of blobs reachable only through that tree. Signed-off-by: Linus Torvalds <torvalds@osdl.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
1 parent b17e659 commit ef07618

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

git-repack.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ esac
4141
if [ "$local" ]; then
4242
pack_objects="$pack_objects --local"
4343
fi
44-
name=$(git-rev-list --objects $rev_list $(git-rev-parse $rev_parse) |
44+
name=$(git-rev-list --objects $rev_list $(git-rev-parse $rev_parse) 2>&1 |
4545
git-pack-objects --non-empty $pack_objects .tmp-pack) ||
4646
exit 1
4747
if [ -z "$name" ]; then

pack-objects.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -524,7 +524,7 @@ int main(int argc, char **argv)
524524
unsigned char sha1[20];
525525

526526
if (get_sha1_hex(line, sha1))
527-
die("expected sha1, got garbage");
527+
die("expected sha1, got garbage:\n %s", line);
528528
hash = 0;
529529
p = line+40;
530530
while (*p) {

0 commit comments

Comments
 (0)