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 --- sha1_name.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sha1_name.c') diff --git a/sha1_name.c b/sha1_name.c index 03ffc2caa..aff224b2a 100644 --- a/sha1_name.c +++ b/sha1_name.c @@ -1115,7 +1115,7 @@ int get_sha1_with_context_1(const char *name, unsigned char *sha1, if (new_filename) filename = new_filename; ret = get_tree_entry(tree_sha1, filename, sha1, &oc->mode); - if (only_to_die) { + if (ret && only_to_die) { diagnose_invalid_sha1_path(prefix, filename, tree_sha1, object_name); free(object_name); -- cgit v1.2.1