git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Johannes Schindelin <johannes.schindelin@gmx.de>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org, Matthieu Moy <Matthieu.Moy@imag.fr>,
	Chad Boles <chadbo@microsoft.com>,
	"brian m. carlson" <sandals@crustytoothpaste.net>,
	Philip Oakley <philipoakley@iee.org>
Subject: [PATCH v3 0/2] Fix interactive rebase when the editor saves with CR/LF
Date: Tue, 27 Oct 2015 10:47:10 +0100 (CET)	[thread overview]
Message-ID: <cover.1445939154.git.johannes.schindelin@gmx.de> (raw)
In-Reply-To: <cover.1445782122.git.johannes.schindelin@gmx.de>

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

  parent reply	other threads:[~2015-10-27  9:47 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-25 12:49 [PATCH 0/2] Fix interactive rebase when the editor saves with CR/LF Johannes Schindelin
2015-10-25 12:50 ` [PATCH 1/2] Demonstrate rebase fails " Johannes Schindelin
2015-10-25 12:50 ` [PATCH 2/2] sh-setup: explicitly mark CR as a field separator Johannes Schindelin
2015-10-25 13:16   ` Philip Oakley
2015-10-25 13:26     ` Johannes Schindelin
     [not found]   ` <20151025131059.GA370025@vauxhall.crustytoothpaste.net>
2015-10-25 13:25     ` Johannes Schindelin
2015-10-25 13:56       ` shell scripting woes, was " Johannes Schindelin
2015-10-25 14:10 ` [PATCH v2 0/2] Fix interactive rebase when the editor saves with CR/LF Johannes Schindelin
2015-10-25 14:10   ` [PATCH v2 1/2] Demonstrate rebase fails " Johannes Schindelin
2015-10-25 14:10   ` [PATCH v2 2/2] sh-setup: explicitly mark CR as a field separator Johannes Schindelin
2015-10-26  9:34     ` Matthieu Moy
2015-10-26 18:31       ` Junio C Hamano
2015-10-26 20:07         ` Junio C Hamano
2015-10-27  9:46           ` Johannes Schindelin
2015-10-27  9:19         ` Johannes Schindelin
2015-10-27 17:46           ` Junio C Hamano
2015-10-27 10:01         ` Matthieu Moy
2015-10-25 19:12   ` [PATCH v2 0/2] Fix interactive rebase when the editor saves with CR/LF Junio C Hamano
2015-10-26 10:43     ` Johannes Schindelin
2015-10-26 19:13       ` Junio C Hamano
2015-10-27  9:34         ` Johannes Schindelin
2015-10-27  9:47   ` Johannes Schindelin [this message]
2015-10-27  9:47     ` [PATCH v3 1/2] Demonstrate rebase fails " Johannes Schindelin
2015-10-27  9:47     ` [PATCH v3 2/2] rebase-i: work around Windows CRLF line endings Johannes Schindelin
2015-10-27  9:55       ` Johannes Schindelin
2015-10-27 17:25         ` Junio C Hamano
2015-10-28 14:56           ` Johannes Schindelin
2015-10-28 14:54     ` [PATCH v4 0/2] Fix interactive rebase when the editor saves with CR/LF Johannes Schindelin
2015-10-28 14:54       ` [PATCH v4 1/2] Demonstrate rebase fails " Johannes Schindelin
2015-10-28 14:54       ` [PATCH v4 2/2] rebase-i: work around Windows CRLF line endings Johannes Schindelin
2015-10-28 17:12       ` [PATCH v4 0/2] Fix interactive rebase when the editor saves with CR/LF Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=cover.1445939154.git.johannes.schindelin@gmx.de \
    --to=johannes.schindelin@gmx.de \
    --cc=Matthieu.Moy@imag.fr \
    --cc=chadbo@microsoft.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=philipoakley@iee.org \
    --cc=sandals@crustytoothpaste.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).