]> git.ipfire.org Git - thirdparty/git.git/commitdiff
bisect: allow CRLF line endings in "git bisect replay" input
authorChristopher Warrington <chwarr@microsoft.com>
Thu, 7 May 2020 21:29:40 +0000 (21:29 +0000)
committerJunio C Hamano <gitster@pobox.com>
Fri, 8 May 2020 17:54:27 +0000 (10:54 -0700)
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>
git-bisect.sh
t/t6030-bisect-porcelain.sh

index efee12b8b1e6d53d3cd5275683ebb0a4198b4b95..71b367a9447a6fb448e20fc606918103fc4f1bfc 100755 (executable)
@@ -209,6 +209,7 @@ bisect_replay () {
        test "$#" -eq 1 || die "$(gettext "No logfile given")"
        test -r "$file" || die "$(eval_gettext "cannot read \$file for replaying")"
        git bisect--helper --bisect-reset || exit
+       oIFS="$IFS" IFS="$IFS$(printf '\015')"
        while read git bisect command rev
        do
                test "$git $bisect" = "git bisect" || test "$git" = "git-bisect" || continue
@@ -232,6 +233,7 @@ bisect_replay () {
                        die "$(gettext "?? what are you talking about?")" ;;
                esac
        done <"$file"
+       IFS="$oIFS"
        bisect_auto_next
 }
 
index 821a0c88cf0221c3662693afaadf9280dab0be8d..bb84c8a411f07b7ef139070758ceebc84ef0706b 100755 (executable)
@@ -792,6 +792,13 @@ test_expect_success 'bisect replay with old and new' '
        git bisect reset
 '
 
+test_expect_success 'bisect replay with CRLF log' '
+       append_cr <log_to_replay.txt >log_to_replay_crlf.txt &&
+       git bisect replay log_to_replay_crlf.txt >bisect_result_crlf &&
+       grep "$HASH2 is the first new commit" bisect_result_crlf &&
+       git bisect reset
+'
+
 test_expect_success 'bisect cannot mix old/new and good/bad' '
        git bisect start &&
        git bisect bad $HASH4 &&