Merge branch 'da/mergetool-diff-order'
[gitweb.git] / t / t1512-rev-parse-disambiguation.sh
index 1d8f550996caf0207a25fcf7d0901aa51dc41f0d..7c659eb5852e986dc5605e082f773e68e746c789 100755 (executable)
@@ -323,4 +323,42 @@ test_expect_success C_LOCALE_OUTPUT 'ambiguity errors are not repeated (peel)' '
        test_line_count = 1 errors
 '
 
+test_expect_success C_LOCALE_OUTPUT 'ambiguity hints' '
+       test_must_fail git rev-parse 000000000 2>stderr &&
+       grep ^hint: stderr >hints &&
+       # 16 candidates, plus one intro line
+       test_line_count = 17 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
+'
+
+test_expect_success C_LOCALE_OUTPUT 'failed type-selector still shows hint' '
+       # these two blobs share the same prefix "ee3d", but neither
+       # will pass for a commit
+       echo 851 | git hash-object --stdin -w &&
+       echo 872 | git hash-object --stdin -w &&
+       test_must_fail git rev-parse ee3d^{commit} 2>stderr &&
+       grep ^hint: stderr >hints &&
+       test_line_count = 3 hints
+'
+
+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} &&
+       git -c core.disambiguate=committish rev-parse $sha1
+'
+
+test_expect_success 'core.disambiguate does not override context' '
+       # treeish ambiguous between tag and tree
+       test_must_fail \
+               git -c core.disambiguate=committish rev-parse $sha1^{tree}
+'
+
 test_done