From d7236c4395a0c8742871a72d920f789b5bd4abf6 Mon Sep 17 00:00:00 2001 From: Matthieu Moy Date: Mon, 18 Jun 2012 20:18:20 +0200 Subject: sha1_name: do not trigger detailed diagnosis for file arguments diagnose_invalid_sha1_path() is meant to be called to diagnose a misspelt : when does not exist in . However, the code may call it if : 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 in fails before triggering the diagnosis. Signed-off-by: Matthieu Moy Signed-off-by: Junio C Hamano --- t/t1506-rev-parse-diagnosis.sh | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 't') diff --git a/t/t1506-rev-parse-diagnosis.sh b/t/t1506-rev-parse-diagnosis.sh index 0843a1c13b..e81dcd6de6 100755 --- a/t/t1506-rev-parse-diagnosis.sh +++ b/t/t1506-rev-parse-diagnosis.sh @@ -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 ':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 + EOF + test_cmp expect actual +' + test_done -- cgit v1.2.3 From 023e37c37780d6a56f2870a979c8eb3a9ee9a44d Mon Sep 17 00:00:00 2001 From: Matthieu Moy Date: Mon, 18 Jun 2012 20:18:21 +0200 Subject: verify_filename(): ask the caller to chose the kind of diagnosis verify_filename() can be called in two different contexts. Either we just tried to interpret a string as an object name, and it fails, so we try looking for a working tree file (i.e. we finished looking at revs that come earlier on the command line, and the next argument must be a pathname), or we _know_ that we are looking for a pathname, and shouldn't even try interpreting the string as an object name. For example, with this change, we get: $ git log COPYING HEAD:inexistant fatal: HEAD:inexistant: no such path in the working tree. Use '-- ...' to specify paths that do not exist locally. $ git log HEAD:inexistant fatal: Path 'inexistant' does not exist in 'HEAD' Signed-off-by: Matthieu Moy Signed-off-by: Junio C Hamano --- t/t1506-rev-parse-diagnosis.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 't') diff --git a/t/t1506-rev-parse-diagnosis.sh b/t/t1506-rev-parse-diagnosis.sh index e81dcd6de6..c5cb77a0e1 100755 --- a/t/t1506-rev-parse-diagnosis.sh +++ b/t/t1506-rev-parse-diagnosis.sh @@ -174,7 +174,7 @@ test_expect_success 'relative path when startup_info is NULL' ' test_expect_success ':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 && + test_i18ngrep "no such path in the working tree" error && cat >expect <<-\EOF && file.txt HEAD:file.txt -- cgit v1.2.3