[PATCH v4 0/2] Fix interactive rebase when the editor saves with CR/LF

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 fix provided by Junio works around this issue by testing for an
explicit trailing carriage return and handles it like an empty line.

Unfortunately, this is the best we can do for now as there is
disagreement about a more general fix.

This iteration clarifies the comments in git-rebase--interactive,
updates the commit message to state that this has been tested with Git
for Windows, and replaces the description of the proposed fix with a
description of the actual work-around provided by Junio.


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    | 12 ++++++++++++
 t/t3404-rebase-interactive.sh | 12 ++++++++++++
 2 files changed, 24 insertions(+)

Interdiff vs v3:

diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh
index daadf2d..34cfe66 100644
--- a/git-rebase--interactive.sh
+++ b/git-rebase--interactive.sh
@@ -77,8 +77,7 @@ 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.
+# Work around Git for Windows' Bash that strips only LFs but no CRs.
 cr=$(printf "\015")
 
 strategy_args=
@@ -523,8 +522,8 @@ do_next () {
 		mark_action_done
 		;;
 	"$cr")
-		# Windows port of shell not stripping the newline
-		# at the end of an empty line correctly.
+		# Work around Carriage Returns not being stripped (e.g. with
+		# Git for Windows' Bash).
 		mark_action_done
 		;;
 	pick|p)
@@ -906,8 +905,8 @@ check_bad_cmd_and_sha () {
 			# Doesn't expect a SHA-1
 			;;
 		"$cr")
-			# Windows port of shell not stripping the newline
-			# at the end of an empty line correctly.
+			# Work around Carriage Returns not being stripped
+			# (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"

-- 
2.1.4

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



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]