sequencer: update reading author-script
[gitweb.git] / t / t1512-rev-parse-disambiguation.sh
index 1d8f550996caf0207a25fcf7d0901aa51dc41f0d..711704ba5a052b15d94ff1ce958ada3fb86530a9 100755 (executable)
@@ -42,7 +42,7 @@ test_expect_success 'blob and tree' '
 
 test_expect_success 'warn ambiguity when no candidate matches type hint' '
        test_must_fail git rev-parse --verify 000000000^{commit} 2>actual &&
-       grep "short SHA1 000000000 is ambiguous" actual
+       test_i18ngrep "short SHA1 000000000 is ambiguous" actual
 '
 
 test_expect_success 'disambiguate tree-ish' '
@@ -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