path: root/t/
diff options
authorJeff King <>2016-09-26 11:59:15 (GMT)
committerJunio C Hamano <>2016-09-26 18:46:30 (GMT)
commit7243ffdd78d56738e568abb544eba00e8079f329 (patch)
treeef971ab138686a1dd32ecef9c5a5960a2a543072 /t/
parent259942f549eb235e9d7d095c2db8f3dc279f3958 (diff)
get_sha1: avoid repeating ourselves via ONLY_TO_DIE
When the revision code cannot parse an argument like "HEAD:foo", it will call maybe_die_on_misspelt_object_name(), which re-runs get_sha1() with an extra ONLY_TO_DIE flag. We then spend more effort to generate a better error message. Unfortunately, a side effect is that our second call may repeat the same error messages from the original get_sha1() call. You can see this with: $ git show 0017 error: short SHA1 0017 is ambiguous. error: short SHA1 0017 is ambiguous. fatal: ambiguous argument '0017': unknown revision or path not in the working tree. Use '--' to separate paths from revisions, like this: 'git <command> [<revision>...] -- [<file>...]' where the second "error:" line comes from the ONLY_TO_DIE call. To fix this, we can make ONLY_TO_DIE imply QUIETLY. This is a little odd, because the whole point of ONLY_TO_DIE is to output error messages. But what we want to do is tell the rest of the get_sha1() code (particularly get_sha1_1()) that the _regular_ messages should be quiet, but the only-to-die ones should not. Signed-off-by: Jeff King <> Signed-off-by: Junio C Hamano <>
Diffstat (limited to 't/')
1 files changed, 6 insertions, 0 deletions
diff --git a/t/ b/t/
index e221167..16f9709 100755
--- a/t/
+++ b/t/
@@ -291,4 +291,10 @@ test_expect_success 'ambiguous short sha1 ref' '
grep "refname.*${REF}.*ambiguous" err
+test_expect_success C_LOCALE_OUTPUT 'ambiguity errors are not repeated' '
+ test_must_fail git rev-parse 00000 2>stderr &&
+ grep "is ambiguous" stderr >errors &&
+ test_line_count = 1 errors