Skip to content

Commit 754e66b

Browse files
committed
Merge branch 'jc/rebase-i-commit-msg-fix'
* jc/rebase-i-commit-msg-fix: rebase-i: do not get fooled by a log message ending with backslash rebase-i: style fix
2 parents 8498657 + 57f2b6b commit 754e66b

File tree

2 files changed

+28
-9
lines changed

2 files changed

+28
-9
lines changed

git-rebase--interactive.sh

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -263,10 +263,10 @@ pick_one_preserving_merges () {
263263
then
264264
if test "$fast_forward" = t
265265
then
266-
cat "$DOTEST"/current-commit | while read current_commit
266+
while read current_commit
267267
do
268268
git rev-parse HEAD > "$REWRITTEN"/$current_commit
269-
done
269+
done <"$DOTEST"/current-commit
270270
rm "$DOTEST"/current-commit ||
271271
die "Cannot write current commit's replacement sha1"
272272
fi
@@ -440,17 +440,17 @@ record_in_rewritten() {
440440
echo "$oldsha1" >> "$REWRITTEN_PENDING"
441441

442442
case "$(peek_next_command)" in
443-
squash|s|fixup|f)
443+
squash|s|fixup|f)
444444
;;
445-
*)
445+
*)
446446
flush_rewritten_pending
447447
;;
448448
esac
449449
}
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"*)
@@ -890,7 +890,8 @@ first and then run 'git rebase --continue' again."
890890
git rev-list $MERGES_OPTION --pretty=oneline --abbrev-commit \
891891
--abbrev=7 --reverse --left-right --topo-order \
892892
$REVISIONS | \
893-
sed -n "s/^>//p" | while read shortsha1 rest
893+
sed -n "s/^>//p" |
894+
while read -r shortsha1 rest
894895
do
895896
if test t != "$PRESERVE_MERGES"
896897
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)