Skip to content

Commit 6c722cb

Browse files
chwarrgitster
authored andcommitted
bisect: allow CRLF line endings in "git bisect replay" input
We advertise that the bisect log can be corrected in your editor before being fed to "git bisect replay", but some editors may turn the line endings to CRLF. Update the parser of the input lines so that the CR at the end of the line gets ignored. Were anyone to intentionally be using terms/revs with embedded CRs, replaying such bisects will no longer work with this change. I suspect that this is incredibly rare. Signed-off-by: Christopher Warrington <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent af6b65d commit 6c722cb

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

git-bisect.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,7 @@ bisect_replay () {
209209
test "$#" -eq 1 || die "$(gettext "No logfile given")"
210210
test -r "$file" || die "$(eval_gettext "cannot read \$file for replaying")"
211211
git bisect--helper --bisect-reset || exit
212+
oIFS="$IFS" IFS="$IFS$(printf '\015')"
212213
while read git bisect command rev
213214
do
214215
test "$git $bisect" = "git bisect" || test "$git" = "git-bisect" || continue
@@ -232,6 +233,7 @@ bisect_replay () {
232233
die "$(gettext "?? what are you talking about?")" ;;
233234
esac
234235
done <"$file"
236+
IFS="$oIFS"
235237
bisect_auto_next
236238
}
237239

t/t6030-bisect-porcelain.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -792,6 +792,13 @@ test_expect_success 'bisect replay with old and new' '
792792
git bisect reset
793793
'
794794

795+
test_expect_success 'bisect replay with CRLF log' '
796+
append_cr <log_to_replay.txt >log_to_replay_crlf.txt &&
797+
git bisect replay log_to_replay_crlf.txt >bisect_result_crlf &&
798+
grep "$HASH2 is the first new commit" bisect_result_crlf &&
799+
git bisect reset
800+
'
801+
795802
test_expect_success 'bisect cannot mix old/new and good/bad' '
796803
git bisect start &&
797804
git bisect bad $HASH4 &&

0 commit comments

Comments
 (0)