diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh index c42ba34c6fecc0eb9f30b5fdcfc5f7f576b61250..b20cafcde4c8730cfe7c247274746cd4fa541676 100644 --- a/git-rebase--interactive.sh +++ b/git-rebase--interactive.sh @@ -77,6 +77,10 @@ amend="$state_dir"/amend rewritten_list="$state_dir"/rewritten-list rewritten_pending="$state_dir"/rewritten-pending +# Work around Git for Windows' Bash whose "read" does not strip CRLF +# and leaves CR at the end instead. +cr=$(printf "\015") + strategy_args= if test -n "$do_merge" then @@ -518,6 +522,10 @@ do_next () { "$comment_char"*|''|noop|drop|d) mark_action_done ;; + "$cr") + # Work around CR left by "read" (e.g. with Git for Windows' Bash). + mark_action_done + ;; pick|p) comment_for_reflog pick @@ -888,6 +896,10 @@ check_bad_cmd_and_sha () { "$comment_char"*|''|noop|x|exec) # Doesn't expect a SHA-1 ;; + "$cr") + # Work around CR left by "read" (e.g. with Git for + # Windows' Bash). + ;; pick|p|drop|d|reword|r|edit|e|squash|s|fixup|f) if ! check_commit_sha "${rest%%[ ]*}" "$lineno" "$1" then diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh index 65474dc13aa1931757c6fae4721059f89c5655aa..2f97a3d9b7bd95494221b1dfdff7eb4ace940c8a 100755 --- a/t/t3404-rebase-interactive.sh +++ b/t/t3404-rebase-interactive.sh @@ -1240,7 +1240,7 @@ test_expect_success 'static check of bad SHA-1' ' test E = $(git cat-file commit HEAD | sed -ne \$p) ' -test_expect_failure 'editor saves as CR/LF' ' +test_expect_success 'editor saves as CR/LF' ' git checkout -b with-crlf && write_script add-crs.sh <<-\EOF && sed -e "s/\$/Q/" <"$1" | tr Q "\\015" >"$1".new &&