summaryrefslogtreecommitdiff
path: root/http-walker.c
diff options
context:
space:
mode:
authorMike Hommey <mh@glandium.org>2007-12-14 21:18:01 (GMT)
committerJunio C Hamano <gitster@pobox.com>2007-12-15 05:31:59 (GMT)
commita096bb18af5b7214d9b87b64ae733d106eb96544 (patch)
treeabb43fcc181397e9db77ff0d5fece1b23366d705 /http-walker.c
parent3b683b91cd78dec027105a2810079eb0b27ab2c0 (diff)
downloadgit-a096bb18af5b7214d9b87b64ae733d106eb96544.zip
git-a096bb18af5b7214d9b87b64ae733d106eb96544.tar.gz
git-a096bb18af5b7214d9b87b64ae733d106eb96544.tar.bz2
Fix random sha1 in error message in http-fetch and http-push
When a downloaded ref doesn't contain a sha1, the error message displays a random sha1 because of uninitialized memory. This happens when cloning a repository that is already a clone of another one, in which case refs/remotes/origin/HEAD is a symref. Signed-off-by: Mike Hommey <mh@glandium.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'http-walker.c')
-rw-r--r--http-walker.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/http-walker.c b/http-walker.c
index a3fb596..0faafbc 100644
--- a/http-walker.c
+++ b/http-walker.c
@@ -986,9 +986,10 @@ static int fetch_ref(struct walker *walker, char *ref, unsigned char *sha1)
return error("Unable to start request");
}
+ if (buffer.posn != 41)
+ return 1;
hex[40] = '\0';
- get_sha1_hex(hex, sha1);
- return 0;
+ return get_sha1_hex(hex, sha1);
}
static void cleanup(struct walker *walker)