From: Miklos Vajna <vmiklos@frugalware.org>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org
Subject: [PATCH] rebase -i: use 'read -r' to avoid backslash acting as an escape character
Date: Wed, 7 Jul 2010 00:55:22 +0200 [thread overview]
Message-ID: <20100706225522.GA31048@genesis.frugalware.org> (raw)
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
next reply other threads:[~2010-07-06 22:55 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-07-06 22:55 Miklos Vajna [this message]
2010-07-07 5:25 ` [PATCH] rebase -i: use 'read -r' to avoid backslash acting as an escape character 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20100706225522.GA31048@genesis.frugalware.org \
--to=vmiklos@frugalware.org \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
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 read-only IMAP folder(s) and NNTP newsgroup(s).