@matheusbsbs / matheus-bagliano / commits / 6c722cbe5a
Fork 0

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 <chwarr@microsoft.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Christopher Warrington committed May 7, 2020 at 21:29 UTC 6c722cbe5a919166eb0d7369762b09393eb5b518
2 files changed +9
git-bisect.sh
+2
@@ -209,6 +209,7 @@ bisect_replay () {
209 test "$#" -eq 1 || die "$(gettext "No logfile given")"
210 test -r "$file" || die "$(eval_gettext "cannot read \$file for replaying")"
211 git bisect--helper --bisect-reset || exit
212 + oIFS="$IFS" IFS="$IFS$(printf '\015')"
213 while read git bisect command rev
214 do
215 test "$git $bisect" = "git bisect" || test "$git" = "git-bisect" || continue
@@ -232,6 +233,7 @@ bisect_replay () {
233 die "$(gettext "?? what are you talking about?")" ;;
234 esac
235 done <"$file"
236 + IFS="$oIFS"
237 bisect_auto_next
238 }
239
t/t6030-bisect-porcelain.sh
+7
@@ -792,6 +792,13 @@ test_expect_success 'bisect replay with old and new' '
792 git bisect reset
793 '
794
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 +
802 test_expect_success 'bisect cannot mix old/new and good/bad' '
803 git bisect start &&
804 git bisect bad $HASH4 &&