Skip to content

Commit f60b5dc

Browse files
committed
Merge branch 'gr/rebase-i-drop-warn'
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
2 parents 7fd4181 + 39743cf commit f60b5dc

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

git-rebase--interactive.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,10 @@ amend="$state_dir"/amend
7777
rewritten_list="$state_dir"/rewritten-list
7878
rewritten_pending="$state_dir"/rewritten-pending
7979

80+
# Work around Git for Windows' Bash whose "read" does not strip CRLF
81+
# and leaves CR at the end instead.
82+
cr=$(printf "\015")
83+
8084
strategy_args=
8185
if test -n "$do_merge"
8286
then
@@ -518,6 +522,10 @@ do_next () {
518522
"$comment_char"*|''|noop|drop|d)
519523
mark_action_done
520524
;;
525+
"$cr")
526+
# Work around CR left by "read" (e.g. with Git for Windows' Bash).
527+
mark_action_done
528+
;;
521529
pick|p)
522530
comment_for_reflog pick
523531

@@ -896,6 +904,10 @@ check_bad_cmd_and_sha () {
896904
"$comment_char"*|''|noop|x|exec)
897905
# Doesn't expect a SHA-1
898906
;;
907+
"$cr")
908+
# Work around CR left by "read" (e.g. with Git for
909+
# Windows' Bash).
910+
;;
899911
pick|p|drop|d|reword|r|edit|e|squash|s|fixup|f)
900912
if ! check_commit_sha "${rest%%[ ]*}" "$lineno" "$1"
901913
then

t/t3404-rebase-interactive.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1261,4 +1261,16 @@ test_expect_success 'static check of bad SHA-1' '
12611261
test E = $(git cat-file commit HEAD | sed -ne \$p)
12621262
'
12631263

1264+
test_expect_success 'editor saves as CR/LF' '
1265+
git checkout -b with-crlf &&
1266+
write_script add-crs.sh <<-\EOF &&
1267+
sed -e "s/\$/Q/" <"$1" | tr Q "\\015" >"$1".new &&
1268+
mv -f "$1".new "$1"
1269+
EOF
1270+
(
1271+
test_set_editor "$(pwd)/add-crs.sh" &&
1272+
git rebase -i HEAD^
1273+
)
1274+
'
1275+
12641276
test_done

0 commit comments

Comments
 (0)