summaryrefslogtreecommitdiff
path: root/git-rebase--interactive.sh
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2015-10-28 14:54:48 (GMT)
committerJunio C Hamano <gitster@pobox.com>2015-10-28 17:06:46 (GMT)
commit39743cf554caaed462464b55315ab5b37f5ab1b9 (patch)
treea6bcca9a398c11620f3a1b8e49edc88d88ddd4e6 /git-rebase--interactive.sh
parent1db25aae5ef7c518b46a9f5b30f317e882ac505a (diff)
downloadgit-39743cf554caaed462464b55315ab5b37f5ab1b9.zip
git-39743cf554caaed462464b55315ab5b37f5ab1b9.tar.gz
git-39743cf554caaed462464b55315ab5b37f5ab1b9.tar.bz2
rebase-i: work around Windows CRLF line endings
Editors on Windows can and do save text files with CRLF line endings, which is the convention on the platform. We are seeing reports that the "read" command in a port of bash to the environment however does not strip the CRLF at the end, not adjusting for the same convention on the platform. This breaks the recently added sanity checks for the insn sheet fed to "rebase -i"; instead of an empty line (hence nothing in $command), the script was getting a lone CR in there. Special case a lone CR and treat it the same way as an empty line to work this around. This patch (also) passes the test with Git for Windows, where the issue was seen first. Signed-off-by: Junio C Hamano <gitster@pobox.com> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'git-rebase--interactive.sh')
-rw-r--r--git-rebase--interactive.sh12
1 files changed, 12 insertions, 0 deletions
diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh
index c42ba34..b20cafc 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