Merge branch 'ns/am-abort'
authorJunio C Hamano <gitster@pobox.com>
Mon, 21 Jul 2008 01:00:13 +0000 (18:00 -0700)
committerJunio C Hamano <gitster@pobox.com>
Mon, 21 Jul 2008 01:00:13 +0000 (18:00 -0700)
* ns/am-abort:
git am --abort

1  2 
git-am.sh
diff --combined git-am.sh
index c5b0039d860d6820769488ed8f22272c9a25fdb7,a786ac5f1d905699ac3ed5923ea1cb859ef89621..60aaa4a583d3e2466ea788d7047a9fc8252b1fe6
+++ b/git-am.sh
@@@ -5,9 -5,9 +5,9 @@@
  SUBDIRECTORY_OK=Yes
  OPTIONS_KEEPDASHDASH=
  OPTIONS_SPEC="\
 -git-am [options] [<mbox>|<Maildir>...]
 -git-am [options] --resolved
 -git-am [options] --skip
 +git am [options] [<mbox>|<Maildir>...]
 +git am [options] --resolved
 +git am [options] --skip
  --
  d,dotest=       (removed -- do not use)
  i,interactive   run interactively
@@@ -22,6 -22,7 +22,7 @@@ p=              pass it through git-app
  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
@@@ -54,6 -55,7 +55,7 @@@ stop_here_user_resolve () 
      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
  }
@@@ -120,7 -122,7 +122,7 @@@ It does not apply to blobs recorded in 
  
  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 -147,8 +147,8 @@@ d
                resolved=t ;;
        --skip)
                skip=t ;;
+       --abort)
+               abort=t ;;
        --rebasing)
                rebasing=t threeway=t keep=t binary=t ;;
        -d|--dotest)
@@@ -177,7 -181,7 +181,7 @@@ f
  
  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.