git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH] blame: display a more helpful error message if the file was deleted
@ 2015-12-16  0:00 Alex Henrie
  2015-12-16 19:56 ` Junio C Hamano
  0 siblings, 1 reply; 4+ messages in thread
From: Alex Henrie @ 2015-12-16  0:00 UTC (permalink / raw)
  To: git, gitster; +Cc: Alex Henrie

`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`.

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;
-- 
2.6.4

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] blame: display a more helpful error message if the file was deleted
  2015-12-16  0:00 [PATCH] blame: display a more helpful error message if the file was deleted Alex Henrie
@ 2015-12-16 19:56 ` Junio C Hamano
  0 siblings, 0 replies; 4+ messages in thread
From: Junio C Hamano @ 2015-12-16 19:56 UTC (permalink / raw)
  To: Alex Henrie; +Cc: git

Alex Henrie <alexhenrie24@gmail.com> writes:

> `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.

>
> 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;

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH] blame: display a more helpful error message if the file was deleted
@ 2016-01-29  3:09 Alex Henrie
  2016-01-29  3:10 ` Alex Henrie
  0 siblings, 1 reply; 4+ messages in thread
From: Alex Henrie @ 2016-01-29  3:09 UTC (permalink / raw)
  To: tklauser, gitster, git; +Cc: Alex Henrie

`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`.

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 55bf5fa..9461a73 100644
--- a/builtin/blame.c
+++ b/builtin/blame.c
@@ -2704,8 +2704,6 @@ parse_done:
 		argv[argc - 1] = "--";
 
 		setup_work_tree();
-		if (!file_exists(path))
-			die_errno("cannot stat path '%s'", path);
 	}
 
 	revs.disable_stdin = 1;
-- 
2.7.0

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] blame: display a more helpful error message if the file was deleted
  2016-01-29  3:09 Alex Henrie
@ 2016-01-29  3:10 ` Alex Henrie
  0 siblings, 0 replies; 4+ messages in thread
From: Alex Henrie @ 2016-01-29  3:10 UTC (permalink / raw)
  To: tklauser, Junio C Hamano, Git mailing list; +Cc: Alex Henrie

Sorry, wrong patch...this issue has already been fixed

-Alex

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-01-29  3:10 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-12-16  0:00 [PATCH] blame: display a more helpful error message if the file was deleted Alex Henrie
2015-12-16 19:56 ` Junio C Hamano
  -- strict thread matches above, loose matches on Subject: below --
2016-01-29  3:09 Alex Henrie
2016-01-29  3:10 ` Alex Henrie

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).