From: Uwe Storbeck Date: Fri, 14 Mar 2014 23:56:43 +0000 (+0100) Subject: rebase -i: do not "echo" random user-supplied strings X-Git-Tag: v1.9.2~15^2~1 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=47be06602656ee9cac860f675d2c8d1f0deabdbe;p=thirdparty%2Fgit.git rebase -i: do not "echo" random user-supplied strings In some places we "echo" a string that comes from a commit log message, which may have a backslash sequence that is interpreted by the command (POSIX.1 allows this), most notably "dash"'s built-in 'echo'. 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. 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 Signed-off-by: Junio C Hamano --- diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh index 43c19e0829..43631b4723 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