Skip to content
This repository was archived by the owner on Nov 9, 2017. It is now read-only.

Commit 47be066

Browse files
Uwe Storbeckgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 16216b6 commit 47be066

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

git-rebase--interactive.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -739,7 +739,7 @@ rearrange_squash () {
739739
;;
740740
esac
741741
done
742-
echo "$sha1 $action $prefix $rest"
742+
printf '%s %s %s %s\n' "$sha1" "$action" "$prefix" "$rest"
743743
# if it's a single word, try to resolve to a full sha1 and
744744
# emit a second copy. This allows us to match on both message
745745
# and on sha1 prefix

0 commit comments

Comments
 (0)