git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH] Look at both unpacked and packed objects for short name expansion
@ 2005-09-15 23:21 Johannes Schindelin
  2005-09-16  0:28 ` Junio C Hamano
  0 siblings, 1 reply; 3+ messages in thread
From: Johannes Schindelin @ 2005-09-15 23:21 UTC (permalink / raw
  To: git

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.

Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>

---

 sha1_name.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

213fff36f398fbbbee9b76a9d59339ba60f1d58c
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;

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Look at both unpacked and packed objects for short name expansion
  2005-09-15 23:21 [PATCH] Look at both unpacked and packed objects for short name expansion Johannes Schindelin
@ 2005-09-16  0:28 ` Junio C Hamano
  2005-09-16  0:49   ` Johannes Schindelin
  0 siblings, 1 reply; 3+ messages in thread
From: Junio C Hamano @ 2005-09-16  0:28 UTC (permalink / raw
  To: Johannes Schindelin; +Cc: git

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.

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Look at both unpacked and packed objects for short name expansion
  2005-09-16  0:28 ` Junio C Hamano
@ 2005-09-16  0:49   ` Johannes Schindelin
  0 siblings, 0 replies; 3+ messages in thread
From: Johannes Schindelin @ 2005-09-16  0:49 UTC (permalink / raw
  To: Junio C Hamano; +Cc: git

Hi,

On Thu, 15 Sep 2005, Junio C Hamano wrote:

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

Half correct. I was not thinking it through... I had that case where I 
called git-whatchanged with a short sha1 and I kept getting the wrong 
history until I realized that the short sha1 was only unique when looking 
at the unpacked objects only.

Maybe I find time tomorrow to do something about the three problems you 
mentioned.

Ciao,
Dscho

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2005-09-16  0:49 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-09-15 23:21 [PATCH] Look at both unpacked and packed objects for short name expansion Johannes Schindelin
2005-09-16  0:28 ` Junio C Hamano
2005-09-16  0:49   ` Johannes Schindelin

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).