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

Re: [PATCH] blame: display a more helpful error message if the file was deleted

From
Junio C Hamano <gitster@pobox.com>
Date
Dec 16, 2015, 19:56 UTC
Message-ID
<xmqq37v2dv5s.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<1450224047-25527-1-git-send-email-alexhenrie24@gmail.com>
Alex Henrie <alexhenrie24@gmail.com> writes:
Show 11 quoted lines
> `git blame 22414770 generate-cmdlist.perl` currently results in:
>     fatal: cannot stat path '22414770': No such file or directory
>
> This patch changes the error message to:
>     fatal: ambiguous argument 'generate-cmdlist.perl': unknown revision
>     or path not in the working tree.
>     Use '--' to separate paths from revisions, like this:
>     'git <command> [<revision>...] -- [<file>...]'"
>
> That way, the user knows to rewrite the command as
> `git blame 22414770 -- generate-cmdlist.perl`.

It is unfortunate that the command line parser of 'blame' needs to cater to an oddball syntax, 'git annotate <path> [<rev>]'.

This change still makes us emit the following funny errors:
    $ ./git blame 00000000 generate-cmdlist.prel
    fatal: bad revision 'generate-cmdlist.prel'
    $ ./git blame generate-cmdlist.prel 00000000
    fatal: bad revision '00000000'

and gives the users a wrong impression that the early argument is the path and then comes the revision.

I'll take the patch as-is, because the original is not better, i.e.
    $ git blame 00000000 generate-cmdlist.prel
    fatal: cannot stat path '00000000': No such file or directory
    $ git blame generate-cmdlist.prel 00000000
    fatal: cannot stat path 'generate-cmdlist.prel': No such file or directory
and the change is not making things worse.

But I think in the longer term we should deprecate and eventually remove 'git annotate' with its odd syntax, so that we can lose the special case we have in the command line parser of 'git blame'.

Thanks.
Show 19 quoted lines
>
> Signed-off-by: Alex Henrie <alexhenrie24@gmail.com>
> ---
>  builtin/blame.c | 2 --
>  1 file changed, 2 deletions(-)
>
> diff --git a/builtin/blame.c b/builtin/blame.c
> index 1df13cf..f070272 100644
> --- a/builtin/blame.c
> +++ b/builtin/blame.c
> @@ -2683,8 +2683,6 @@ parse_done:
>  		argv[argc - 1] = "--";
>  
>  		setup_work_tree();
> -		if (!file_exists(path))
> -			die_errno("cannot stat path '%s'", path);
>  	}
>  
>  	revs.disable_stdin = 1;
Previous: Alex Henrie
Message 2 of 2 in “blame: display a more helpful error message if the file was deleted”
  1. blame: display a more helpful error message if the file was deletedAlex Henrie, Dec 16, 2015
  2. Junio C HamanoDec 16, 2015

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.