Chad Boles reported that `git rebase -i` recently started producing
errors when the editor saves files with DOS line endings. The symptom
is:

        Warning: the command isn't recognized in the following line:
         -

        You can fix this with 'git rebase --edit-todo'.
        Or you can abort the rebase with 'git rebase --abort'.

The real bummer is that simply calling `git rebase --continue` "fixes"
it.

Turns out that we now check whether a single Carriage Return is a valid
command. This new check was introduced recently (1db168ee9, ironically
named "rebase-i: loosen over-eager check_bad_cmd check").

The proposed fix is to teach *all* shell scripts in Git to accept CR as
a field separator. Since LF is already specified as such, it should be
an uncontentious change.


Johannes Schindelin (1):
  Demonstrate rebase fails when the editor saves with CR/LF

Junio C Hamano (1):
  rebase-i: work around Windows CRLF line endings

 git-rebase--interactive.sh    | 13 +++++++++++++
 t/t3404-rebase-interactive.sh | 12 ++++++++++++
 2 files changed, 25 insertions(+)

Interdiff vs v2:

diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh
index d65c06e..daadf2d 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 a Windows port of shell that does not strip
+# the newline at the end of a line correctly.
+cr=$(printf "\015")
+
 strategy_args=
 if test -n "$do_merge"
 then
@@ -518,6 +522,11 @@ do_next () {
        "$comment_char"*|''|noop|drop|d)
                mark_action_done
                ;;
+       "$cr")
+               # Windows port of shell not stripping the newline
+               # at the end of an empty line correctly.
+               mark_action_done
+               ;;
        pick|p)
                comment_for_reflog pick
 
@@ -896,6 +905,10 @@ check_bad_cmd_and_sha () {
                "$comment_char"*|''|noop|x|exec)
                        # Doesn't expect a SHA-1
                        ;;
+               "$cr")
+                       # Windows port of shell not stripping the newline
+                       # at the end of an empty line correctly.
+                       ;;
                pick|p|drop|d|reword|r|edit|e|squash|s|fixup|f)
                        if ! check_commit_sha "${rest%%[        ]*}" "$lineno" 
"$1"
                        then
diff --git a/git-sh-setup.sh b/git-sh-setup.sh
index e34673d..4691fbc 100644
--- a/git-sh-setup.sh
+++ b/git-sh-setup.sh
@@ -11,9 +11,9 @@ unset CDPATH
 
 # Similarly for IFS, but some shells (e.g. FreeBSD 7.2) are buggy and
 # do not equate an unset IFS with IFS with the default, so here is
-# an explicit SP HT LF CR.
+# an explicit SP HT LF.
 IFS='  
-'"$(printf '\r')"
+'
 
 git_broken_path_fix () {
        case ":$PATH:" in

-- 
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to