Merge branch 'gr/rebase-i-drop-warn'
authorJunio C Hamano <gitster@pobox.com>
Fri, 30 Oct 2015 20:07:06 +0000 (13:07 -0700)
committerJunio C Hamano <gitster@pobox.com>
Fri, 30 Oct 2015 20:07:06 +0000 (13:07 -0700)
Recent update to "rebase -i" that tries to sanity check the edited
insn sheet before it uses it has become too picky on Windows where
CRLF left by the editor is turned into a trailing CR on the line
read via the "read" built-in command.

* gr/rebase-i-drop-warn:
rebase-i: work around Windows CRLF line endings
t3404: "rebase -i" gets broken when insn sheet uses CR/LF line endings

git-rebase--interactive.sh
t/t3404-rebase-interactive.sh
index d65c06eff36f09c982d66b11684d8f3ab3784393..30edb179259d634f20649fe7f74df3f0c58f10ec 100644 (file)
@@ -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
 
@@ -896,6 +904,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
index 3de0b1dcfdc9c5948c10e5e8c107a3820df9f357..98eb49ac236e9e9d08d5da5167f7e257db173c41 100755 (executable)
@@ -1261,4 +1261,16 @@ test_expect_success 'static check of bad SHA-1' '
        test E = $(git cat-file commit HEAD | sed -ne \$p)
 '
 
+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 &&
+       mv -f "$1".new "$1"
+       EOF
+       (
+               test_set_editor "$(pwd)/add-crs.sh" &&
+               git rebase -i HEAD^
+       )
+'
+
 test_done