From: Linus Torvalds Date: Mon, 21 Nov 2005 20:38:31 +0000 (-0800) Subject: git-repack: Properly abort in corrupt repository X-Git-Tag: v0.99.9k^2~30 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=ef07618fdd660057b80fe75007405c62502a5820;p=git.git 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 Signed-off-by: Junio C Hamano --- diff --git a/git-repack.sh b/git-repack.sh index 4e16d3497..c0f271d10 100755 --- a/git-repack.sh +++ b/git-repack.sh @@ -41,7 +41,7 @@ esac if [ "$local" ]; then pack_objects="$pack_objects --local" fi -name=$(git-rev-list --objects $rev_list $(git-rev-parse $rev_parse) | +name=$(git-rev-list --objects $rev_list $(git-rev-parse $rev_parse) 2>&1 | git-pack-objects --non-empty $pack_objects .tmp-pack) || exit 1 if [ -z "$name" ]; then diff --git a/pack-objects.c b/pack-objects.c index 4e941e739..8864a31cc 100644 --- a/pack-objects.c +++ b/pack-objects.c @@ -524,7 +524,7 @@ int main(int argc, char **argv) unsigned char sha1[20]; if (get_sha1_hex(line, sha1)) - die("expected sha1, got garbage"); + die("expected sha1, got garbage:\n %s", line); hash = 0; p = line+40; while (*p) {