git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH v2] rebase -i: replace an echo command by printf
@ 2014-03-14 23:56 Uwe Storbeck
  2014-03-17 19:22 ` Junio C Hamano
  0 siblings, 1 reply; 3+ messages in thread
From: Uwe Storbeck @ 2014-03-14 23:56 UTC (permalink / raw
  To: git

to avoid shell dependent behavior.

When your system shell (/bin/sh) is a dash backslash sequences
in strings are interpreted by the echo command. A commit message
which ends with the string '\n' may result in a garbage line in
the todo list of an interactive rebase which causes the rebase
to fail.

To reproduce the behavior (with dash as /bin/sh):

  mkdir test && cd test && git init
  echo 1 >foo && git add foo
  git commit -m"this commit message ends with '\n'"
  echo 2 >foo && git commit -a --fixup HEAD
  git rebase -i --autosquash --root

Now the editor opens with garbage in line 3 which has to be
removed or the rebase fails.

Signed-off-by: Uwe Storbeck <uwe@ibr.ch>
---
 git-rebase--interactive.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh
index 43c19e0..43631b4 100644
--- a/git-rebase--interactive.sh
+++ b/git-rebase--interactive.sh
@@ -739,7 +739,7 @@ rearrange_squash () {
 					;;
 				esac
 			done
-			echo "$sha1 $action $prefix $rest"
+			printf '%s %s %s %s\n' "$sha1" "$action" "$prefix" "$rest"
 			# if it's a single word, try to resolve to a full sha1 and
 			# emit a second copy. This allows us to match on both message
 			# and on sha1 prefix
-- 
1.9.0

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

* Re: [PATCH v2] rebase -i: replace an echo command by printf
  2014-03-14 23:56 [PATCH v2] rebase -i: replace an echo command by printf Uwe Storbeck
@ 2014-03-17 19:22 ` Junio C Hamano
  2014-03-18  0:10   ` Uwe Storbeck
  0 siblings, 1 reply; 3+ messages in thread
From: Junio C Hamano @ 2014-03-17 19:22 UTC (permalink / raw
  To: Uwe Storbeck; +Cc: git

Uwe Storbeck <uwe@ibr.ch> writes:

> to avoid shell dependent behavior.

Please do not start the body of the log message half-sentence.  The
title ought to be a freestanding "title", not just a beginning half
of a sentence that needs to be read with the rest to be understood.

Something like this, perhaps.

    Subject: [PATCH] rebase -i: do not "echo" random user-supplied strings

    In some places we "echo" a string that come from a commit log message,
    which may have a backslash sequence that is interpreted by shells
    (POSIX.1 allows this), most notably "dash".

    A commit message which contains the string '\n' (or ends with the
    string '\c') may result in a garbage line in the todo list of an
    interactive rebase which causes the rebase to fail.

Will tentatively queue with the above rewrite, but if you feel
strongly, please send an replacement.

Thanks.

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

* Re: [PATCH v2] rebase -i: replace an echo command by printf
  2014-03-17 19:22 ` Junio C Hamano
@ 2014-03-18  0:10   ` Uwe Storbeck
  0 siblings, 0 replies; 3+ messages in thread
From: Uwe Storbeck @ 2014-03-18  0:10 UTC (permalink / raw
  To: Junio C Hamano; +Cc: git

On Mar 17, Junio C Hamano wrote:
> Will tentatively queue with the above rewrite, but if you feel
> strongly, please send an replacement.

No need for a replacement, your wording is good. I couldn't do
it better.

I'll borrow your commit message for my other patch to fix the
continued title there too. If you already have queued and
rewritten that patch you may keep your version.

Thanks

Uwe

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

end of thread, other threads:[~2014-03-18  0:11 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-03-14 23:56 [PATCH v2] rebase -i: replace an echo command by printf Uwe Storbeck
2014-03-17 19:22 ` Junio C Hamano
2014-03-18  0:10   ` Uwe Storbeck

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