From: Junio C Hamano <gitster@pobox.com>
To: Theodore Tso <tytso@mit.edu>, Nanako Shiraishi <nanako3@lavabit.com>
Cc: "Johannes Schindelin" <Johannes.Schindelin@gmx.de>,
"René Scharfe" <rene.scharfe@lsrfire.ath.cx>,
gitster@pobox.com, "Stephan Beyer" <s-beyer@gmx.net>,
"Joe Fiorini" <joe@faithfulgeek.org>,
git@vger.kernel.org, "Jari Aalto" <jari.aalto@cante.net>
Subject: Re: [PATCH] Rename ".dotest/" to ".git/rebase" and ".dotest-merge" to "rebase-merge"
Date: Wed, 16 Jul 2008 12:18:04 -0700 [thread overview]
Message-ID: <7viqv5r637.fsf@gitster.siamese.dyndns.org> (raw)
In-Reply-To: <20080716012619.GM8185@mit.edu> (Theodore Tso's message of "Tue, 15 Jul 2008 21:26:19 -0400")
Theodore Tso <tytso@mit.edu> writes:
> While you have "git am" open, how about adding an "git am --abort"
> which nukes the .dotest aka .git/rebase directory, and resets HEAD
> back to the original position?
This does not seem to have reached the list nor its archives. I cannot
say I have really looked at it deeply but it may be a good starting
point. It needs docs ;-)
-- >8 --
From: Nanako Shiraishi <nanako3@lavabit.com>
Date: Wed, 16 Jul 2008 19:39:10 +0900
Subject: [PATCH] git am --abort
After failing to apply patches in the middle of a series, "git am --abort"
lets you go back to the original commit.
Signed-off-by: Nanako Shiraishi <nanako3@lavabit.com>
---
git-am.sh | 19 +++++++++++++++----
t/t4151-am-abort.sh | 48 ++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 63 insertions(+), 4 deletions(-)
create mode 100755 t/t4151-am-abort.sh
diff --git a/git-am.sh b/git-am.sh
index cc8787b..a44bd7a 100755
--- a/git-am.sh
+++ b/git-am.sh
@@ -22,6 +22,7 @@ p= pass it through git-apply
resolvemsg= override error message when patch failure occurs
r,resolved to be used after a patch failure
skip skip the current patch
+abort abandon patch application and clear .dotest directory
rebasing (internal use for git-rebase)"
. git-sh-setup
@@ -120,7 +121,7 @@ It does not apply to blobs recorded in its index."
prec=4
dotest="$GIT_DIR/rebase"
-sign= utf8=t keep= skip= interactive= resolved= binary= rebasing=
+sign= utf8=t keep= skip= interactive= resolved= binary= rebasing= abort=
resolvemsg= resume=
git_apply_opt=
@@ -145,6 +146,8 @@ do
resolved=t ;;
--skip)
skip=t ;;
+ --abort)
+ abort=t ;;
--rebasing)
rebasing=t threeway=t keep=t binary=t ;;
-d|--dotest)
@@ -177,7 +180,7 @@ fi
if test -d "$dotest"
then
- case "$#,$skip$resolved" in
+ case "$#,$skip$resolved$abort" in
0,*t*)
# Explicit resume command and we do not have file, so
# we are happy.
@@ -197,9 +200,17 @@ then
esac ||
die "previous rebase directory $dotest still exists but mbox given."
resume=yes
+
+ case "$abort" in
+ t)
+ rm -fr "$dotest" &&
+ git read-tree -m -u ORIG_HEAD &&
+ git reset ORIG_HEAD && :
+ exit ;;
+ esac
else
- # Make sure we are not given --skip nor --resolved
- test ",$skip,$resolved," = ,,, ||
+ # Make sure we are not given --skip, --resolved, nor --abort
+ test "$skip$resolved$abort" = "" ||
die "Resolve operation not in progress, we are not resuming."
# Start afresh.
diff --git a/t/t4151-am-abort.sh b/t/t4151-am-abort.sh
new file mode 100755
index 0000000..96b2cd5
--- /dev/null
+++ b/t/t4151-am-abort.sh
@@ -0,0 +1,48 @@
+#!/bin/sh
+
+test_description='am --abort'
+
+. ./test-lib.sh
+
+test_expect_success setup '
+ for i in a b c d e f g
+ do
+ echo $i
+ done >file-1 &&
+ cp file-1 file-2 &&
+ test_tick &&
+ git add file-1 file-2 &&
+ git commit -m initial &&
+ git tag initial &&
+ for i in 2 3 4 5
+ do
+ echo $i >>file-1 &&
+ test_tick &&
+ git commit -a -m $i || break
+ done &&
+ git format-patch initial &&
+ git checkout -b side initial &&
+ echo local change >file-2 &&
+ cp file-2 file-2-expect
+'
+
+test_expect_success 'am stops at a patch that does not apply' '
+ test_must_fail git am 000[124]-*.patch &&
+ git log --pretty=tformat:%s >actual &&
+ for i in 3 2 initial
+ do
+ echo $i
+ done >expect &&
+ test_cmp expect actual
+'
+
+test_expect_success 'am --abort goes back' '
+ git am --abort &&
+ git rev-parse HEAD >actual &&
+ git rev-parse initial >expect &&
+ test_cmp expect actual &&
+ test_cmp file-2-expect file-2 &&
+ git diff-index --exit-code --cached HEAD
+'
+
+test_done
--
1.5.6
next prev parent reply other threads:[~2008-07-16 19:19 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-07-15 21:08 Git rebase failure: .dotest overwritten Joe Fiorini
2008-07-15 21:22 ` Stephan Beyer
2008-07-15 21:48 ` René Scharfe
2008-07-16 0:47 ` [PATCH] Rename ".dotest/" to ".git/rebase" and ".dotest-merge" to "rebase-merge" Johannes Schindelin
2008-07-16 0:57 ` Linus Torvalds
2008-07-16 1:10 ` Junio C Hamano
2008-07-16 1:15 ` Johannes Schindelin
2008-07-16 1:19 ` Junio C Hamano
2008-07-16 1:33 ` [PATCH for master] " Johannes Schindelin
2008-07-16 1:52 ` [PATCH] " Linus Torvalds
2008-07-16 2:30 ` Johannes Schindelin
2008-07-16 3:05 ` Junio C Hamano
2008-07-16 21:27 ` Petr Baudis
2008-07-16 21:44 ` Junio C Hamano
2008-07-16 1:26 ` Theodore Tso
2008-07-16 1:47 ` Stephan Beyer
2008-07-16 19:18 ` Junio C Hamano [this message]
2008-07-19 18:40 ` Olivier Marin
2008-07-19 22:18 ` Junio C Hamano
2008-07-19 22:27 ` Junio C Hamano
2008-07-22 23:47 ` Stephan Beyer
2008-07-23 0:48 ` Junio C Hamano
2008-07-23 1:13 ` Stephan Beyer
2008-07-23 14:54 ` Olivier Marin
2008-07-23 16:47 ` Stephan Beyer
2008-07-23 20:40 ` Junio C Hamano
2008-07-23 0:10 ` [PATCH] am --abort: Add to bash-completion and mention in git-rerere documentation Stephan Beyer
2008-07-19 19:49 ` [PATCH] Rename ".dotest/" to ".git/rebase" and ".dotest-merge" to "rebase-merge" Olivier Marin
2008-07-19 19:59 ` Stephan Beyer
2008-07-19 20:25 ` Olivier Marin
2008-07-19 21:52 ` Junio C Hamano
2008-07-19 22:39 ` Jakub Narebski
2008-07-21 13:39 ` Olivier Marin
2008-07-23 0:16 ` Junio C Hamano
2008-07-23 12:24 ` Olivier Marin
2008-07-23 18:31 ` Junio C Hamano
2008-07-24 12:44 ` Olivier Marin
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=7viqv5r637.fsf@gitster.siamese.dyndns.org \
--to=gitster@pobox.com \
--cc=Johannes.Schindelin@gmx.de \
--cc=git@vger.kernel.org \
--cc=jari.aalto@cante.net \
--cc=joe@faithfulgeek.org \
--cc=nanako3@lavabit.com \
--cc=rene.scharfe@lsrfire.ath.cx \
--cc=s-beyer@gmx.net \
--cc=tytso@mit.edu \
/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.
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).