# [PATCH] rev-parse: Identify short sha1 sums correctly.

3 messages from 2007-05-29 to 2007-05-30. Participants: James Bowes, Junio C Hamano.
Thread: https://gitlist.dev/t/8352

## James Bowes, 2007-05-29 23:29

Subject: [PATCH] rev-parse: Identify short sha1 sums correctly.
Message-ID: <1180481391179-git-send-email-jbowes@dangerouslyinc.com>
URL: https://gitlist.dev/e/1180481391179-git-send-email-jbowes%40dangerouslyinc.com

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

Signed-off-by: James Bowes <jbowes@dangerouslyinc.com>
---
 sha1_name.c |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/sha1_name.c b/sha1_name.c
index 8dfceb2..7df01af 100644
--- a/sha1_name.c
+++ b/sha1_name.c
@@ -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;
-- 
1.5.2.869.g6b3ba

```

## Junio C Hamano, 2007-05-30 00:53

Subject: Re: [PATCH] rev-parse: Identify short sha1 sums correctly.
Message-ID: <7vtztv3zf1.fsf@assigned-by-dhcp.cox.net>
URL: https://gitlist.dev/e/7vtztv3zf1.fsf%40assigned-by-dhcp.cox.net
In-Reply-To: <1180481391179-git-send-email-jbowes@dangerouslyinc.com>

```
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".

```

## James Bowes, 2007-05-30 01:09

Subject: Re: [PATCH] rev-parse: Identify short sha1 sums correctly.
Message-ID: <3f80363f0705291809y23b1bf06j4076ecc09fe8c0d5@mail.gmail.com>
URL: https://gitlist.dev/e/3f80363f0705291809y23b1bf06j4076ecc09fe8c0d5%40mail.gmail.com
In-Reply-To: <7vtztv3zf1.fsf@assigned-by-dhcp.cox.net>

```
On 5/29/07, Junio C Hamano <junkio@cox.net> wrote:
> Thanks, James.

Glad to help when I can.

> 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

```
