summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: fcab40a)
raw | patch | inline | side by side (parent: fcab40a)
author | Nanako Shiraishi <nanako3@lavabit.com> | |
Wed, 16 Jul 2008 10:39:10 +0000 (19:39 +0900) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Sat, 19 Jul 2008 22:26:28 +0000 (15:26 -0700) |
After failing to apply patches in the middle of a series, "git am --abort"
lets you go back to the original commit.
[jc: doc/help update from Olivier, and fixups for "am -3" squashed in]
Signed-off-by: Nanako Shiraishi <nanako3@lavabit.com>
Signed-off-by: Olivier Marin <dkr@freesurf.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
lets you go back to the original commit.
[jc: doc/help update from Olivier, and fixups for "am -3" squashed in]
Signed-off-by: Nanako Shiraishi <nanako3@lavabit.com>
Signed-off-by: Olivier Marin <dkr@freesurf.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Documentation/git-am.txt | patch | blob | history | |
git-am.sh | patch | blob | history | |
t/t4151-am-abort.sh | [new file with mode: 0755] | patch | blob |
index 2d7f162594cb69d5a5f6d8ef1714111ad0bbc67a..e010a164930362dea6990a4e3dda1655bc8c3500 100644 (file)
--- a/Documentation/git-am.txt
+++ b/Documentation/git-am.txt
[--3way] [--interactive] [--binary]
[--whitespace=<option>] [-C<n>] [-p<n>]
[<mbox> | <Maildir>...]
-'git am' (--skip | --resolved)
+'git am' (--skip | --resolved | --abort)
DESCRIPTION
-----------
or `--skip` to handle the failure. This is solely
for internal use between 'git-rebase' and 'git-am'.
+--abort::
+ Restore the original branch and abort the patching operation.
+
DISCUSSION
----------
diff --git a/git-am.sh b/git-am.sh
index cc8787b460e601889fd90c5dba2055e9eb85bc22..a786ac5f1d905699ac3ed5923ea1cb859ef89621 100755 (executable)
--- a/git-am.sh
+++ b/git-am.sh
resolvemsg= override error message when patch failure occurs
r,resolved to be used after a patch failure
skip skip the current patch
+abort restore the original branch and abort the patching operation.
rebasing (internal use for git-rebase)"
. git-sh-setup
fi
echo "When you have resolved this problem run \"$cmdline --resolved\"."
echo "If you would prefer to skip this patch, instead run \"$cmdline --skip\"."
+ echo "To restore the original branch and stop patching run \"$cmdline --abort\"."
stop_here $1
}
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=
resolved=t ;;
--skip)
skip=t ;;
+ --abort)
+ abort=t ;;
--rebasing)
rebasing=t threeway=t keep=t binary=t ;;
-d|--dotest)
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.
esac ||
die "previous rebase directory $dotest still exists but mbox given."
resume=yes
+
+ case "$abort" in
+ t)
+ git rerere clear
+ git read-tree --reset -u HEAD ORIG_HEAD
+ git reset ORIG_HEAD
+ rm -fr "$dotest"
+ 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
--- /dev/null
+++ b/t/t4151-am-abort.sh
@@ -0,0 +1,56 @@
+#!/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-expect
+'
+
+for with3 in '' ' -3'
+do
+ test_expect_success "am$with3 stops at a patch that does not apply" '
+
+ git reset --hard initial &&
+ cp file-2-expect file-2 &&
+
+ test_must_fail git am$with3 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 after failed am$with3" '
+ 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 ! -f .git/rr-cache/MERGE_RR
+ '
+
+done
+
+test_done