{"thread":{"id":"34322","subject":"[PATCH 0/2] Fix t1512 (disambiguation of object names)","startedAt":"2013-07-02T05:12:33Z","lastAt":"2013-07-02T05:12:35Z","messageCount":3,"participants":["Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"222334","messageId":"1372741955-20691-1-git-send-email-gitster@pobox.com","threadId":"34322","inReplyTo":null,"subject":"[PATCH 0/2] Fix t1512 (disambiguation of object names)","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2013-07-02T05:12:33Z","receivedAt":"2013-07-02T05:12:33Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Here is a small two-patch series to break a test that has been\npassing by mistake.\n\nJunio C Hamano (2):\n  t1512: correct leftover constants from earlier edition\n  get_short_sha1(): correctly disambiguate type-limited abbreviation\n\n sha1_name.c                         |  2 +-\n t/t1512-rev-parse-disambiguation.sh | 32 ++++++++++++++++++++++----------\n 2 files changed, 23 insertions(+), 11 deletions(-)\n\n-- \n1.8.3.2-795-g615e8f0\n"},{"id":"222335","messageId":"1372741955-20691-2-git-send-email-gitster@pobox.com","threadId":"34322","inReplyTo":"1372741955-20691-1-git-send-email-gitster@pobox.com","subject":"[PATCH 1/2] t1512: correct leftover constants from earlier edition","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2013-07-02T05:12:34Z","receivedAt":"2013-07-02T05:12:34Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"The earliest iteration of this test script used a magic string\n110282 as the common prefix for ambiguous object names, but the\nfinal edition switched the common prefix to 0000000000 (10 \"0\"s).\n\nUnfortunately, instances of the original prefix were left in the\ncomments and a few tests.  Replace them with the correct constants.\n\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n t/t1512-rev-parse-disambiguation.sh | 32 ++++++++++++++++++++++----------\n 1 file changed, 22 insertions(+), 10 deletions(-)\n\ndiff --git a/t/t1512-rev-parse-disambiguation.sh b/t/t1512-rev-parse-disambiguation.sh\nindex 6b3d797..5b58e4f 100755\n--- a/t/t1512-rev-parse-disambiguation.sh\n+++ b/t/t1512-rev-parse-disambiguation.sh\n@@ -77,6 +77,7 @@ test_expect_success 'disambiguate blob' '\n \n test_expect_success 'disambiguate tree' '\n \tcommit=$(echo \"d7xm\" | git commit-tree 000000000) &&\n+\t# this commit is fffff2e and not ambiguous with the 00000* objects\n \ttest $(git rev-parse $commit^{tree}) = $(git rev-parse 0000000000cdc)\n '\n \n@@ -99,10 +100,14 @@ test_expect_success 'disambiguate commit-ish' '\n \n test_expect_success 'disambiguate commit' '\n \tcommit=$(echo \"hoaxj\" | git commit-tree 0000000000cdc -p 000000000) &&\n+\t# this commit is ffffffd8 and not ambiguous with the 00000* objects\n \ttest $(git rev-parse $commit^) = $(git rev-parse 0000000000e4f)\n '\n \n test_expect_success 'log name1..name2 takes only commit-ishes on both ends' '\n+\t# These are underspecified from the prefix-length point of view\n+\t# to disambiguate the commit with other objects, but there is only\n+\t# one commit that has 00000* prefix at this point.\n \tgit log 000000000..000000000 &&\n \tgit log ..000000000 &&\n \tgit log 000000000.. &&\n@@ -112,16 +117,19 @@ test_expect_success 'log name1..name2 takes only commit-ishes on both ends' '\n '\n \n test_expect_success 'rev-parse name1..name2 takes only commit-ishes on both ends' '\n+\t# Likewise.\n \tgit rev-parse 000000000..000000000 &&\n \tgit rev-parse ..000000000 &&\n \tgit rev-parse 000000000..\n '\n \n test_expect_success 'git log takes only commit-ish' '\n+\t# Likewise.\n \tgit log 000000000\n '\n \n test_expect_success 'git reset takes only commit-ish' '\n+\t# Likewise.\n \tgit reset 000000000\n '\n \n@@ -131,26 +139,30 @@ test_expect_success 'first tag' '\n '\n \n test_expect_failure 'two semi-ambiguous commit-ish' '\n+\t# At this point, we have a tag 0000000000f8f that points\n+\t# at a commit 0000000000e4f, and a tree and a blob that\n+\t# share 0000000000 prefix with these tag and commit.\n+\t#\n \t# Once the parser becomes ultra-smart, it could notice that\n-\t# 110282 before ^{commit} name many different objects, but\n+\t# 0000000000 before ^{commit} name many different objects, but\n \t# that only two (HEAD and v1.0.0 tag) can be peeled to commit,\n \t# and that peeling them down to commit yield the same commit\n \t# without ambiguity.\n-\tgit rev-parse --verify 110282^{commit} &&\n+\tgit rev-parse --verify 0000000000^{commit} &&\n \n \t# likewise\n-\tgit log 000000000..000000000 &&\n-\tgit log ..000000000 &&\n-\tgit log 000000000.. &&\n-\tgit log 000000000...000000000 &&\n-\tgit log ...000000000 &&\n-\tgit log 000000000...\n+\tgit log 0000000000..0000000000 &&\n+\tgit log ..0000000000 &&\n+\tgit log 0000000000.. &&\n+\tgit log 0000000000...0000000000 &&\n+\tgit log ...0000000000 &&\n+\tgit log 0000000000...\n '\n \n test_expect_failure 'three semi-ambiguous tree-ish' '\n \t# Likewise for tree-ish.  HEAD, v1.0.0 and HEAD^{tree} share\n \t# the prefix but peeling them to tree yields the same thing\n-\tgit rev-parse --verify 000000000^{tree}\n+\tgit rev-parse --verify 0000000000^{tree}\n '\n \n test_expect_success 'parse describe name' '\n@@ -241,7 +253,7 @@ test_expect_success 'ambiguous commit-ish' '\n \t# Now there are many commits that begin with the\n \t# common prefix, none of these should pick one at\n \t# random.  They all should result in ambiguity errors.\n-\ttest_must_fail git rev-parse --verify 110282^{commit} &&\n+\ttest_must_fail git rev-parse --verify 00000000^{commit} &&\n \n \t# likewise\n \ttest_must_fail git log 000000000..000000000 &&\n-- \n1.8.3.2-795-g615e8f0\n"},{"id":"222336","messageId":"1372741955-20691-3-git-send-email-gitster@pobox.com","threadId":"34322","inReplyTo":"1372741955-20691-1-git-send-email-gitster@pobox.com","subject":"[PATCH 2/2] get_short_sha1(): correctly disambiguate type-limited abbreviation","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2013-07-02T05:12:35Z","receivedAt":"2013-07-02T05:12:35Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"One test in t1512 that expects a failure incorrectly passed.  The\ntest prepares a commit whose object name begins with ten \"0\"s, and\nalso prepares a tag that points at the commit.  The object name of\nthe tag also begins with ten \"0\"s.  There is no other commit-ish\nobject in the repository whose name begins with such a prefix.\n\nIdeally, in such a repository:\n\n    $ git rev-parse --verify 0000000000^{commit}\n\nshould yield that commit.  If 0000000000 is taken as the commit\n0000000000e4f, peeling it to a commmit yields that commit itself,\nand if 0000000000 is taken as the tag 0000000000f8f, peeling it to a\ncommit also yields the same commit, so in that twisted sense, the\nextended SHA-1 expression 0000000000^{commit} is unambigous.  The\ntest that expects a failure is to check the above command.\n\nThe reason the test expects a failure is that we did not implement\nsuch a \"unification\" of two candidate objects.  What we did (or at\nleast, meant to) implement was to recognise that a commit-ish is\nrequired to expand 0000000000, and notice that there are two succh\ncommit-ish, and diagnose the request as ambiguous.\n\nHowever, there was a bug in the logic to check the candidate\nobjects.  When the code saw 0000000000f8f (a tag) that shared the\nshortened prefix (ten \"0\"s), it tried to make sure that the tag is a\ncommit-ish by looking at the tag object.  Because it incorrectly\nused lookup_object() when the tag has not been parsed, however, we\nincorrectly declared that the tag is _not_ a commit-ish, leaving the\nsole commit in the repository, 0000000000e4f, that has the required\nprefix as \"unique match\", causing the test to pass when it shouldn't.\n\nThis fixes the logic to inspect the type of the object a tag refers\nto, to make the test that is expected to fail correctly fail.\n\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n sha1_name.c | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/sha1_name.c b/sha1_name.c\nindex 8bc20c5..13c3d75 100644\n--- a/sha1_name.c\n+++ b/sha1_name.c\n@@ -241,7 +241,7 @@ static int disambiguate_committish_only(const unsigned char *sha1, void *cb_data\n \t\treturn 0;\n \n \t/* We need to do this the hard way... */\n-\tobj = deref_tag(lookup_object(sha1), NULL, 0);\n+\tobj = deref_tag(parse_object(sha1), NULL, 0);\n \tif (obj && obj->type == OBJ_COMMIT)\n \t\treturn 1;\n \treturn 0;\n-- \n1.8.3.2-795-g615e8f0\n"}]}