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

Re: [PATCH 3/3] Remove stray error message from sed

From
Junio C Hamano <gitster@pobox.com>
Date
Jun 1, 2010, 17:44 UTC
Message-ID
<7veigqvea6.fsf@alter.siamese.dyndns.org>
In-Reply-To
<1275384022-12131-4-git-send-email-artagnon@gmail.com>
Ramkumar Ramachandra <artagnon@gmail.com> writes:
> When --continue is invoked without any changes, the following stray
> error message appears- sed: can't read $dotest/final-commit: No such
> file or directory. Remove this by making sure that the file actually
> exists.
Show 16 quoted lines
>
> Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
> ---
>  git-am.sh |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/git-am.sh b/git-am.sh
> index 04f02a8..e61f47a 100755
> --- a/git-am.sh
> +++ b/git-am.sh
> @@ -693,7 +693,7 @@ do
>  	else
>  	    action=yes
>  	fi
> -	FIRSTLINE=$(sed 1q "$dotest/final-commit")
> +	test -e "$dotest/final-commit" && FIRSTLINE=$(sed 1q "$dotest/final-commit")

This will let the command follow the same codepath as before but the change in behaviour is that it does not reset FIRSTLINE to an empty string. Does this difference affect what the user sees after this part of the code?

I would generally prefer to use "test -f" not "-e" (simply because it came later and I am an old-timer), but if you want to use something newer than "test -f", it might be worth using "test -r" instead, as readability (not existence) is what you are after anyway.

Show 5 quoted lines
>  
>  	if test $action = skip
>  	then
> -- 
> 1.7.1
Previous: Ramkumar Ramachandra
Message 7 of 7 in “Improve git-am error messages”
  1. 0/3 Improve git-am error messagesRamkumar Ramachandra, Jun 1, 2010
  2. 1/3 Set cmdline globally, not in stop_here_user_resolveRamkumar Ramachandra, Jun 1, 2010
  3. Johannes SixtJun 1, 2010
  4. Ramkumar RamachandraJun 1, 2010
  5. 2/3 Display some help text when patch is emptyRamkumar Ramachandra, Jun 1, 2010
  6. 3/3 Remove stray error message from sedRamkumar Ramachandra, Jun 1, 2010
  7. Junio C HamanoJun 1, 2010

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.