git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Junio C Hamano <junkio@cox.net>
Date
May 29, 2007, 23:40 UTC
Message-ID
<7vabvn5hca.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<1180478596243-git-send-email-jbowes@dangerouslyinc.com>
James Bowes <jbowes@dangerouslyinc.com> writes:
> find_short_packed_object was not loading the pack index files.
> Teach it to do so.
>
> Signed-off-by: James Bowes <jbowes@dangerouslyinc.com>

I think this is the proper fix of the problem I was unhappy about with 'next', rather than reverting the lazy index loading. But I wonder how many _other_ places like this there are that we might be missing...

Shawn, an Ack, and any ideas for futureproofing?
Show 23 quoted lines
>  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
Next: Shawn O. Pearce
Message 1 of 3 in “Re: [PATCH] rev-parse: Identify short sha1 sums correctly.”
  1. Junio C HamanoMay 29, 2007
  2. Shawn O. PearceMay 30, 2007
  3. Shawn O. PearceMay 30, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.