Code

Merge branch 'jc/rebase-orig-head'
authorJunio C Hamano <gitster@pobox.com>
Tue, 15 Jul 2008 06:45:49 +0000 (23:45 -0700)
committerJunio C Hamano <gitster@pobox.com>
Tue, 15 Jul 2008 06:45:49 +0000 (23:45 -0700)
* jc/rebase-orig-head:
  Documentation: mention ORIG_HEAD in am, merge, and rebase
  Teach "am" and "rebase" to mark the original position with ORIG_HEAD

Documentation/git-am.txt
Documentation/git-merge.txt
Documentation/git-rebase.txt
git-am.sh
git-rebase--interactive.sh
git-rebase.sh

index eeb23b25b0d70c4ccc3eb9d091971b1f20ad4b4b..1395c7d986c82eb1e7e91140c8f97b80e7a8a41d 100644 (file)
@@ -145,6 +145,12 @@ directory exists, so if you decide to start over from scratch,
 run `rm -f -r .dotest` before running the command with mailbox
 names.
 
+Before any patches are applied, ORIG_HEAD is set to the tip of the
+current branch.  This is useful if you have problems with multiple
+commits, like running 'git am' on the wrong branch or an error in the
+commits that is more easily fixed by changing the mailbox (e.g.
+errors in the "From:" lines).
+
 
 SEE ALSO
 --------
index 62f99b5f3b8991c93d0f2e06cd382312069bccaf..019e4ca8f503e146814bf7b9f6e2ef2920d940e2 100644 (file)
@@ -81,7 +81,9 @@ Otherwise, merge will refuse to do any harm to your repository
 (that is, it may fetch the objects from remote, and it may even
 update the local branch used to keep track of the remote branch
 with `git pull remote rbranch:lbranch`, but your working tree,
-`.git/HEAD` pointer and index file are left intact).
+`.git/HEAD` pointer and index file are left intact).  In addition,
+merge always sets `.git/ORIG_HEAD` to the original state of HEAD so
+a problematic merge can be removed by using `git reset ORIG_HEAD`.
 
 You may have local modifications in the working tree files.  In
 other words, 'git-diff' is allowed to report changes.
index f3459c7de7c9629f2abfdb684a359bb264ea82ed..e30f6a6982a8d9ee48c6a7d46fa435c7aee773af 100644 (file)
@@ -26,7 +26,8 @@ of commits that would be shown by `git log <upstream>..HEAD`.
 
 The current branch is reset to <upstream>, or <newbase> if the
 --onto option was supplied.  This has the exact same effect as
-`git reset --hard <upstream>` (or <newbase>).
+`git reset --hard <upstream>` (or <newbase>).  ORIG_HEAD is set
+to point at the tip of the branch before the reset.
 
 The commits that were previously saved into the temporary area are
 then reapplied to the current branch, one by one, in order. Note that
index 4e73f93a1f1906db8212a1aa9236bdfa03ae1a00..52b5669b431140cb44cc65a25ae980f45d70fbe0 100755 (executable)
--- a/git-am.sh
+++ b/git-am.sh
@@ -242,6 +242,7 @@ else
                : >"$dotest/rebasing"
        else
                : >"$dotest/applying"
+               git update-ref ORIG_HEAD HEAD
        fi
 fi
 
index 3d85486c88069b98cff72f84001bc1897ef85941..a35212d9de23e97055936b23dd8657a584116d76 100755 (executable)
@@ -574,6 +574,7 @@ EOF
                has_action "$TODO" ||
                        die_abort "Nothing to do"
 
+               git update-ref ORIG_HEAD $HEAD
                output git checkout $ONTO && do_rest
                ;;
        esac
index e2d85eeeab79e60ef46a65cfee1fb4682dd4ba68..2597d777d6fa8e9beb2a660ecdc10366747b4e23 100755 (executable)
@@ -378,7 +378,7 @@ fi
 echo "First, rewinding head to replay your work on top of it..."
 git checkout "$onto^0" >/dev/null 2>&1 ||
        die "could not detach HEAD"
-# git reset --hard "$onto^0"
+git update-ref ORIG_HEAD $branch
 
 # If the $onto is a proper descendant of the tip of the branch, then
 # we just fast forwarded.