@matheusbsbs / matheus-bagliano / commits / ef07618fdd
Fork 0

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>

Linus Torvalds committed Nov 21, 2005 at 12:38 UTC ef07618fdd660057b80fe75007405c62502a5820
2 files changed +2 -2
git-repack.sh
+1 -1
@@ -41,7 +41,7 @@ esac
41 if [ "$local" ]; then
42 pack_objects="$pack_objects --local"
43 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 |
45 git-pack-objects --non-empty $pack_objects .tmp-pack) ||
46 exit 1
47 if [ -z "$name" ]; then
pack-objects.c
+1 -1
@@ -524,7 +524,7 @@ int main(int argc, char **argv)
524 unsigned char sha1[20];
525
526 if (get_sha1_hex(line, sha1))
527 - die("expected sha1, got garbage");
527 + die("expected sha1, got garbage:\n %s", line);
528 hash = 0;
529 p = line+40;
530 while (*p) {