{"thread":{"id":"1816","subject":"[PATCH] Look at both unpacked and packed objects for short name expansion","startedAt":"2005-09-15T23:21:18Z","lastAt":"2005-09-16T00:49:16Z","messageCount":3,"participants":["Johannes Schindelin","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"8645","messageId":"Pine.LNX.4.63.0509160120470.3859@wgmdd8.biozentrum.uni-wuerzburg.de","threadId":"1816","inReplyTo":null,"subject":"[PATCH] Look at both unpacked and packed objects for short name expansion","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2005-09-15T23:21:18Z","receivedAt":"2005-09-15T23:21:18Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"We used to check for a unique expansion in the unpacked objects, and if\none was found, we forgot to check in the packed objects, too.\n\nSigned-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>\n\n---\n\n sha1_name.c |    3 ++-\n 1 files changed, 2 insertions(+), 1 deletions(-)\n\n213fff36f398fbbbee9b76a9d59339ba60f1d58c\ndiff --git a/sha1_name.c b/sha1_name.c\n--- a/sha1_name.c\n+++ b/sha1_name.c\n@@ -115,7 +115,8 @@ static int get_short_sha1(const char *na\n \tif (i < 4)\n \t\treturn -1;\n \tif (find_short_object_filename(i, canonical, sha1))\n-\t\treturn 0;\n+                /* do not allow non-unique short names */\n+                return find_short_packed_object(i, res, canonical)!=0?-1:0;\n \tif (find_short_packed_object(i, res, sha1))\n \t\treturn 0;\n \treturn -1;\n"},{"id":"8650","messageId":"7vfys5votr.fsf@assigned-by-dhcp.cox.net","threadId":"1816","inReplyTo":"Pine.LNX.4.63.0509160120470.3859@wgmdd8.biozentrum.uni-wuerzburg.de","subject":"Re: [PATCH] Look at both unpacked and packed objects for short name expansion","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2005-09-16T00:28:00Z","receivedAt":"2005-09-16T00:28:00Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:\n\n> We used to check for a unique expansion in the unpacked objects, and if\n> one was found, we forgot to check in the packed objects, too.\n\n> diff --git a/sha1_name.c b/sha1_name.c\n> --- a/sha1_name.c\n> +++ b/sha1_name.c\n> @@ -115,7 +115,8 @@ static int get_short_sha1(const char *na\n>  \tif (i < 4)\n>  \t\treturn -1;\n>  \tif (find_short_object_filename(i, canonical, sha1))\n> -\t\treturn 0;\n> +                /* do not allow non-unique short names */\n> +                return find_short_packed_object(i, res, canonical)!=0?-1:0;\n>  \tif (find_short_packed_object(i, res, sha1))\n>  \t\treturn 0;\n>  \treturn -1;\n\nSorry, I do not understand what you are doing here.\n\nWe find an unpacked object file in the local object store, and\nthen if we find a unique match (otherwise we try if\nshort-packed-object finds unique match) we try to see if we have\nthe same one in one of the packs we have and refuse?  Wouldn't\nthis make things inconvenient for people who run 'git repack'\nwithout running 'git prune-packed' afterwards?\n\nAnd reading find_short_object_filename() I noticed it does not\ndo anything with alternates, and wonder if is this intentional.\nWho did this part anyway?\n\nAlso find_short_packed_object() does not appear to require\nunique prefix when it does its thing.\n\nI would prefer a proper fix to:\n\n - find_short_object_filename() to look at alt_odb as well;\n\n - find_short_packed_object() to make sure it is getting a\n   unique match.\n\n - get_short_sha1() to make sure that the input is overall\n   unique.  I think with the current code structure, with or\n   without your patch, would do a wrong thing if you pass a\n   prefix that matches two unpacked objects and two packed\n   ones.\n\nI suspect your patch is an attempt to fix the last one, but I am\nnot sure..\n"},{"id":"8651","messageId":"Pine.LNX.4.63.0509160246280.10401@wgmdd8.biozentrum.uni-wuerzburg.de","threadId":"1816","inReplyTo":"7vfys5votr.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] Look at both unpacked and packed objects for short name expansion","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2005-09-16T00:49:16Z","receivedAt":"2005-09-16T00:49:16Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Thu, 15 Sep 2005, Junio C Hamano wrote:\n\n> I suspect your patch is an attempt to fix the last one, but I am\n> not sure..\n\nHalf correct. I was not thinking it through... I had that case where I \ncalled git-whatchanged with a short sha1 and I kept getting the wrong \nhistory until I realized that the short sha1 was only unique when looking \nat the unpacked objects only.\n\nMaybe I find time tomorrow to do something about the three problems you \nmentioned.\n\nCiao,\nDscho\n"}]}