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

Re: [PATCH] Look at both unpacked and packed objects for short name expansion

From
Junio C Hamano <junkio@cox.net>
Date
Sep 16, 2005, 00:28 UTC
Message-ID
<7vfys5votr.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<Pine.LNX.4.63.0509160120470.3859@wgmdd8.biozentrum.uni-wuerzburg.de>
Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
> We used to check for a unique expansion in the unpacked objects, and if
> one was found, we forgot to check in the packed objects, too.
Show 13 quoted lines
> diff --git a/sha1_name.c b/sha1_name.c
> --- a/sha1_name.c
> +++ b/sha1_name.c
> @@ -115,7 +115,8 @@ static int get_short_sha1(const char *na
>  	if (i < 4)
>  		return -1;
>  	if (find_short_object_filename(i, canonical, sha1))
> -		return 0;
> +                /* do not allow non-unique short names */
> +                return find_short_packed_object(i, res, canonical)!=0?-1:0;
>  	if (find_short_packed_object(i, res, sha1))
>  		return 0;
>  	return -1;
Sorry, I do not understand what you are doing here.

We find an unpacked object file in the local object store, and then if we find a unique match (otherwise we try if short-packed-object finds unique match) we try to see if we have the same one in one of the packs we have and refuse? Wouldn't this make things inconvenient for people who run 'git repack' without running 'git prune-packed' afterwards?

And reading find_short_object_filename() I noticed it does not do anything with alternates, and wonder if is this intentional. Who did this part anyway?

Also find_short_packed_object() does not appear to require unique prefix when it does its thing.

I would prefer a proper fix to:
 - find_short_object_filename() to look at alt_odb as well;
 - find_short_packed_object() to make sure it is getting a
   unique match.
 - get_short_sha1() to make sure that the input is overall
   unique.  I think with the current code structure, with or
   without your patch, would do a wrong thing if you pass a
   prefix that matches two unpacked objects and two packed
   ones.

I suspect your patch is an attempt to fix the last one, but I am not sure..

Previous: Johannes SchindelinNext: Johannes Schindelin
Message 2 of 3 in “Look at both unpacked and packed objects for short name expansion”
  1. Look at both unpacked and packed objects for short name expansionJohannes Schindelin, Sep 15, 2005
  2. Junio C HamanoSep 16, 2005
  3. Johannes SchindelinSep 16, 2005

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.