Skip to contentSkip to conversation

rev-parse: Identify short sha1 sums correctly.

PATCH In review James Bowes 2 participants 3 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 rev-parse: Identify short sha1 sums correctly.

find_short_packed_object was not loading the pack index files. Teach it to do so.

---
 sha1_name.c |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)
sha1_name.c +5 -2
index 8dfceb2..7df01af 100644
@@ -76,8 +76,11 @@ static int find_short_packed_object(int len, const unsigned char *match, unsigne
 
 	prepare_packed_git();
 	for (p = packed_git; p && found < 2; p = p->next) {
-		uint32_t num = p->num_objects;
-		uint32_t first = 0, last = num;
+		uint32_t num, last;
+		uint32_t first = 0;
+		open_pack_index(p);
+		num = p->num_objects;
+		last = num;
 		while (first < last) {
 			uint32_t mid = (first + last) / 2;
 			const unsigned char *now;
Signature · 1 line
1.5.2.869.g6b3ba
#1 lore raw

Thanks, James.

This seems to fix the bug I mentioned about 'next' in the last "What's cooking" message. Also I have been seeing a segfault from rev-parse in t5500 (rev-parse --short hits the same issue, because the bug caused object name not to be abreviated) but that is also fixed with this patch.

Will apply, instead of reverting the "lazy index loading".

#2 lore raw
Quoted 1 line · Junio C Hamano

Thanks, James.

Glad to help when I can.

Quoted 10 lines

This seems to fix the bug I mentioned about 'next' in the last "What's cooking" message. Also I have been seeing a segfault from rev-parse in t5500 (rev-parse --short hits the same issue, because the bug caused object name not to be abreviated) but that is also fixed with this patch.

Will apply, instead of reverting the "lazy index loading".

-James