git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] rebase -i: use 'read -r' to avoid backslash acting as an escape character
@ 2010-07-06 22:55 Miklos Vajna
  2010-07-07  5:25 ` Junio C Hamano
  0 siblings, 1 reply; 16+ messages in thread
From: Miklos Vajna @ 2010-07-06 22:55 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

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@frugalware.org>
---
 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

^ permalink raw reply related	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2010-07-09 16:31 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-07-06 22:55 [PATCH] rebase -i: use 'read -r' to avoid backslash acting as an escape character Miklos Vajna
2010-07-07  5:25 ` Junio C Hamano
2010-07-07  9:16   ` Miklos Vajna
2010-07-07  9:22     ` Santi Béjar
2010-07-07  9:46       ` Miklos Vajna
2010-07-08  0:29         ` Junio C Hamano
2010-07-08 10:35           ` Miklos Vajna
2010-07-08 17:14             ` [RFC] war on echo in scripts Jonathan Nieder
2010-07-08 22:57               ` Andreas Schwab
2010-07-09  2:46                 ` Jonathan Nieder
2010-07-09  3:47                   ` Sverre Rabbelier
2010-07-09  4:46                   ` Junio C Hamano
2010-07-09 14:30                     ` Jonathan Nieder
2010-07-09 16:30                       ` Junio C Hamano
2010-07-09 11:52                   ` Ævar Arnfjörð Bjarmason
2010-07-09 14:10                     ` Jonathan Nieder

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).