[PATCH v3 10/12] get_short_oid / peel_onion: ^{commit} should be commit, not committish
From: Ævar Arnfjörð Bjarmason <hidden>
Date: 2018-05-01 18:41:01
Subsystem:
the rest · Maintainer:
Linus Torvalds
Change the ^{commit} syntax to mean just commits instead of committish
for the purpose of disambiguation. Before this e8f2^{commit} would
show the v2.17.0 tag as a disambiguation candidate, but now it'll just
show ambiguous commits:
$ git rev-parse e8f2^{commit}
error: short SHA1 e8f2 is ambiguous
hint: The candidates are:
hint: e8f21caf94 commit 2013-06-24 - bash prompt: print unique detached HEAD abbreviated object name
hint: e8f26250fa commit 2017-02-03 - Merge pull request #996 from jeffhostetler/jeffhostetler/register_rename_src
hint: e8f2bc0c06 commit 2015-05-10 - Documentation: note behavior for multiple remote.url entries
[...]
Signed-off-by: Ævar Arnfjörð Bjarmason <redacted>
---
sha1-name.c | 2 +-
t/t1512-rev-parse-disambiguation.sh | 7 ++++---
2 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/sha1-name.c b/sha1-name.c
index b61c0558d9..1d2a74a29c 100644
--- a/sha1-name.c
+++ b/sha1-name.c@@ -966,7 +966,7 @@ static int peel_onion(const char *name, int len, struct object_id *oid, lookup_flags &= ~GET_OID_DISAMBIGUATORS; if (expected_type == OBJ_COMMIT) - lookup_flags |= GET_OID_COMMITTISH; + lookup_flags |= GET_OID_COMMIT; else if (expected_type == OBJ_TAG) lookup_flags |= GET_OID_TAG; else if (expected_type == OBJ_TREE)
diff --git a/t/t1512-rev-parse-disambiguation.sh b/t/t1512-rev-parse-disambiguation.sh
index 81076449a2..b17973a266 100755
--- a/t/t1512-rev-parse-disambiguation.sh
+++ b/t/t1512-rev-parse-disambiguation.sh@@ -341,8 +341,8 @@ test_expect_success C_LOCALE_OUTPUT 'ambiguity hints' ' test_expect_success C_LOCALE_OUTPUT 'ambiguity hints respect type' ' test_must_fail git rev-parse 000000000^{commit} 2>stderr && grep ^hint: stderr >hints && - # 5 commits, 1 tag (which is a commitish), plus intro line - test_line_count = 7 hints && + # 5 commits plus intro line + test_line_count = 6 hints && git rev-parse 000000000^{tag} >stdout && test_line_count = 1 stdout && grep -q ^0000000000f8f stdout &&
@@ -366,7 +366,8 @@ test_expect_success 'core.disambiguate config can prefer types' ' # ambiguous between tree and tag sha1=0000000000f && test_must_fail git rev-parse $sha1 && - git rev-parse $sha1^{commit} && + # there is no commit so ^{commit} comes up empty + test_must_fail git rev-parse $sha1^{commit} && git -c core.disambiguate=committish rev-parse $sha1 '
--
2.17.0.290.gded63e768a