path: root/t
diff options
authorMatthieu Moy <>2012-06-18 18:18:20 (GMT)
committerJunio C Hamano <>2012-06-18 22:13:16 (GMT)
commitd7236c4395a0c8742871a72d920f789b5bd4abf6 (patch)
tree19a28a50e4e05a607409603b4cab19b3e40e8e9a /t
parent828ea97de486c1693d6e4f2c7347acb50235a85d (diff)
sha1_name: do not trigger detailed diagnosis for file arguments
diagnose_invalid_sha1_path() is meant to be called to diagnose a misspelt <treeish>:<pathname> when <pathname> does not exist in <treeish>. However, the code may call it if <treeish>:<pathname> is invalid (which triggers another call with only_to_die == 1), but for another reason. This happens when calling e.g. git log existing-file HEAD:existing-file because existing-file is a path and not a revision, the code verifies that the arguments that follow to be paths. This leads to an incorrect message like "existing-file does not exist in HEAD", even though the path exists in HEAD. Check that the search for <pathname> in <treeish> fails before triggering the diagnosis. Signed-off-by: Matthieu Moy <> Signed-off-by: Junio C Hamano <>
Diffstat (limited to 't')
1 files changed, 11 insertions, 0 deletions
diff --git a/t/ b/t/
index 0843a1c..e81dcd6 100755
--- a/t/
+++ b/t/
@@ -171,4 +171,15 @@ test_expect_success 'relative path when startup_info is NULL' '
grep "BUG: startup_info struct is not initialized." error
+test_expect_success '<commit>:file correctly diagnosed after a pathname' '
+ test_must_fail git rev-parse file.txt HEAD:file.txt 1>actual 2>error &&
+ test_i18ngrep ! "exists on disk" error &&
+ test_i18ngrep "unknown revision or path not in the working tree" error &&
+ cat >expect <<-\EOF &&
+ file.txt
+ HEAD:file.txt
+ test_cmp expect actual