git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] fix overstrict :<path> diagnosis

From
Junio C Hamano <gitster@pobox.com>
Date
May 10, 2011, 18:10 UTC
Message-ID
<7vhb92jujt.fsf@alter.siamese.dyndns.org>

Given "git log :", we get a disambiguation message that tries to be helpful and yet totally misses the point, i.e.

    $ git log :
    fatal: Path '' does not exist (neither on disk nor in the index).
    $ git log :/
    fatal: Path '/' exists on disk, but not in the index.

An empty path nor anything that begins with '/' cannot possibly in the index, and it is wrong to guess that the user might have meant to access such an index entry.

It should yield the same error message as "git log '*.c'", i.e.
    $ git log '*.c'
    fatal: ambiguous argument '*.c': unknown revision or path not in the working tree.
    Use '--' to separate paths from revisions
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 * I actually think the message should say
 	fatal: ambiguous argument '*.c': neither a rev nor a path.
        Use '--' to separate pathspec from revisions.
   for brevity, but that is a separate topic.
 sha1_name.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/sha1_name.c b/sha1_name.c
index faea58d..90d8bfa 100644
--- a/sha1_name.c
+++ b/sha1_name.c
@@ -1173,7 +1173,7 @@ int get_sha1_with_context_1(const char *name, unsigned char *sha1,
 			}
 			pos++;
 		}
-		if (!gently)
+		if (!gently && name[1] && name[1] != '/')
 			diagnose_invalid_index_path(stage, prefix, cp);
 		free(new_path);
 		return -1;
Next: Junio C Hamano
Message 1 of 5 in “fix overstrict :<path> diagnosis”
  1. fix overstrict :<path> diagnosisJunio C Hamano, May 10, 2011
  2. fix overslow :/no-such-string-ever-existed diagnosticsJunio C Hamano, May 10, 2011
  3. Re* [PATCH] fix overslow :/no-such-string-ever-existed diagnosticsJunio C Hamano, May 10, 2011
  4. Matthieu MoyMay 10, 2011
  5. Junio C HamanoMay 10, 2011

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.