Thread (1 message) 1 message, 1 author, 2016-06-15

Re: [PATCH v4 14/18] sha1_name.c: many short names can only be committish

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:54:12

Junio C Hamano [off-list ref] writes:
quoted hunk
diff --git a/sha1_name.c b/sha1_name.c
index 6f6c49c..35ad473 100644
--- a/sha1_name.c
+++ b/sha1_name.c
@@ -519,6 +539,7 @@ static int peel_onion(const char *name, int len, unsigned char *sha1)
 	unsigned char outer[20];
 	const char *sp;
 	unsigned int expected_type = 0;
+	unsigned lookup_flags;
This needs to be initialized to 0, i.e.

	unsigned lookup_flags = 0;

for the following two hunks to make sense.
quoted hunk
@@ -554,7 +575,10 @@ static int peel_onion(const char *name, int len, unsigned char *sha1)
 	else
 		return -1;
 
-	if (get_sha1_1(name, sp - name - 2, outer, 0))
+	if (expected_type == OBJ_COMMIT)
+		lookup_flags = GET_SHA1_COMMITTISH;
+
+	if (get_sha1_1(name, sp - name - 2, outer, lookup_flags))
 		return -1;
 
 	o = parse_object(outer);
@@ -666,7 +690,7 @@ static int get_sha1_1(const char *name, int len, unsigned char *sha1, unsigned l
 	if (!ret)
 		return 0;
 
-	return get_short_sha1(name, len, sha1, 0);
+	return get_short_sha1(name, len, sha1, lookup_flags);
 }
 
 /*
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help