Skip to content

Commit 57f2b6b

Browse files
committed
rebase-i: do not get fooled by a log message ending with backslash
Signed-off-by: Junio C Hamano <[email protected]>
1 parent 41f556b commit 57f2b6b

File tree

2 files changed

+23
-5
lines changed

2 files changed

+23
-5
lines changed

git-rebase--interactive.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,7 @@ record_in_rewritten() {
450450

451451
do_next () {
452452
rm -f "$MSG" "$AUTHOR_SCRIPT" "$AMEND" || exit
453-
read command sha1 rest < "$TODO"
453+
read -r command sha1 rest < "$TODO"
454454
case "$command" in
455455
'#'*|''|noop)
456456
mark_action_done
@@ -591,7 +591,7 @@ do_rest () {
591591
# skip picking commits whose parents are unchanged
592592
skip_unnecessary_picks () {
593593
fd=3
594-
while read command sha1 rest
594+
while read -r command sha1 rest
595595
do
596596
# fd=3 means we skip the command
597597
case "$fd,$command,$(git rev-parse --verify --quiet $sha1^)" in
@@ -644,13 +644,13 @@ rearrange_squash () {
644644
test -s "$1.sq" || return
645645

646646
used=
647-
while read pick sha1 message
647+
while read -r pick sha1 message
648648
do
649649
case " $used" in
650650
*" $sha1 "*) continue ;;
651651
esac
652652
echo "$pick $sha1 $message"
653-
while read squash action msg
653+
while read -r squash action msg
654654
do
655655
case "$message" in
656656
"$msg"*)
@@ -891,7 +891,7 @@ first and then run 'git rebase --continue' again."
891891
--abbrev=7 --reverse --left-right --topo-order \
892892
$REVISIONS | \
893893
sed -n "s/^>//p" |
894-
while read shortsha1 rest
894+
while read -r shortsha1 rest
895895
do
896896
if test t != "$PRESERVE_MERGES"
897897
then

t/t3404-rebase-interactive.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -630,4 +630,22 @@ test_expect_success 'always cherry-pick with --no-ff' '
630630
test_cmp empty out
631631
'
632632

633+
test_expect_success 'set up commits with funny messages' '
634+
git checkout -b funny A &&
635+
echo >>file1 &&
636+
test_tick &&
637+
git commit -a -m "end with slash\\" &&
638+
echo >>file1 &&
639+
test_tick &&
640+
git commit -a -m "another commit"
641+
'
642+
643+
test_expect_success 'rebase-i history with funny messages' '
644+
git rev-list A..funny >expect &&
645+
test_tick &&
646+
FAKE_LINES="1 2" git rebase -i A &&
647+
git rev-list A.. >actual &&
648+
test_cmp expect actual
649+
'
650+
633651
test_done

0 commit comments

Comments
 (0)