Subject: [PATCH 08/17] fixup! pack v4: code to obtain a SHA1 from a sha1ref

From: Nguyễn Thái Ngọc Duy <[email-masked]>
Date: Sat, 21 Sep 2013 20:57:54 +0700

Don't die or it'll upset t5303's recovery action by repacking from
loose objects

Signed-off-by: Nguyễn Thái Ngọc Duy <[email-masked]>
---
 packv4-parse.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/packv4-parse.c b/packv4-parse.c
index e833cd2..88b7aa1 100644
--- a/packv4-parse.c
+++ b/packv4-parse.c
@@ -18,13 +18,18 @@ const unsigned char *get_sha1ref(struct packed_git *p,
 {
 	const unsigned char *sha1;
 
+	if (!p->sha1_table)
+		return NULL;
+
 	if (!**bufp) {
 		sha1 = *bufp + 1;
 		*bufp += 21;
 	} else {
 		unsigned int index = decode_varint(bufp);
-		if (index < 1 || index - 1 > p->num_objects)
-			die("bad index in %s", __func__);
+		if (index < 1 || index - 1 > p->num_objects) {
+			error("bad index in get_sha1ref");
+			return NULL;
+		}
 		sha1 = p->sha1_table + (index - 1) * 20;
 	}
 
-- 
1.8.2.83.gc99314b