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 <>
--- | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

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

To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to
More majordomo info at

Reply via email to