[PATCH] rebase -i: use 'read -r' to avoid backslash acting as an escape character

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

 



The last backslash in the commit message will make 'read' read two lines
without '-r', loosing the next commit, so use it.

Signed-off-by: Miklos Vajna <vmiklos@xxxxxxxxxxxxxx>
---
 git-rebase--interactive.sh    |    4 ++--
 t/t3404-rebase-interactive.sh |   14 ++++++++++++++
 2 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh
index 6b86abc..4b822e3 100755
--- a/git-rebase--interactive.sh
+++ b/git-rebase--interactive.sh
@@ -591,7 +591,7 @@ do_rest () {
 # skip picking commits whose parents are unchanged
 skip_unnecessary_picks () {
 	fd=3
-	while read command sha1 rest
+	while read -r command sha1 rest
 	do
 		# fd=3 means we skip the command
 		case "$fd,$command,$(git rev-parse --verify --quiet $sha1^)" in
@@ -890,7 +890,7 @@ first and then run 'git rebase --continue' again."
 		git rev-list $MERGES_OPTION --pretty=oneline --abbrev-commit \
 			--abbrev=7 --reverse --left-right --topo-order \
 			$REVISIONS | \
-			sed -n "s/^>//p" | while read shortsha1 rest
+			sed -n "s/^>//p" | while read -r shortsha1 rest
 		do
 			if test t != "$PRESERVE_MERGES"
 			then
diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh
index ee9a1b2..ddfa790 100755
--- a/t/t3404-rebase-interactive.sh
+++ b/t/t3404-rebase-interactive.sh
@@ -630,4 +630,18 @@ test_expect_success 'always cherry-pick with --no-ff' '
 	test_cmp empty out
 '
 
+test_expect_success 'commit message with backslash at the end' '
+	echo a > file &&
+	git add file &&
+	git commit -m 1st &&
+	echo b >> file &&
+	git commit -a -m "escape \\t, \\{, \\} and \\" &&
+	echo c >> file &&
+	git commit -a -m 3rd &&
+	orig=$(git rev-parse HEAD) &&
+	git rebase -i HEAD~2 &&
+	git diff $orig HEAD > out &&
+	test_cmp empty out
+'
+
 test_done
-- 
1.7.1
--
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]