summaryrefslogtreecommitdiff
path: root/git-checkout-script
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2005-06-21 22:40:00 (GMT)
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-06-21 22:40:00 (GMT)
commitef0bfa25e99627b809c0902d21072821955db3fe (patch)
tree5760644db3f9cb044c99aa0f9ce4fc8d4eb76da1 /git-checkout-script
parent6b38a402e97274037982a5346ca4168cc8ee026c (diff)
downloadgit-ef0bfa25e99627b809c0902d21072821955db3fe.zip
git-ef0bfa25e99627b809c0902d21072821955db3fe.tar.gz
git-ef0bfa25e99627b809c0902d21072821955db3fe.tar.bz2
Remove MERGE_HEAD in "git checkout/reset"
Both of these scripts will end up resetting the index to some specific head, and any unresolved merge will be forgotten.
Diffstat (limited to 'git-checkout-script')
-rwxr-xr-xgit-checkout-script13
1 files changed, 12 insertions, 1 deletions
diff --git a/git-checkout-script b/git-checkout-script
index 5b49662..870b1a3 100755
--- a/git-checkout-script
+++ b/git-checkout-script
@@ -37,4 +37,15 @@ then
git-checkout-cache -q -f -u -a
else
git-read-tree -m -u $old $new
-fi && [ "$branch" ] && ln -sf "refs/heads/$branch" "$GIT_DIR/HEAD"
+fi
+
+#
+# Switch the HEAD pointer to the new branch if it we
+# checked out a branch head, and remove any potential
+# old MERGE_HEAD's (subsequent commits will clearly not
+# be based on them, since we re-set the index)
+#
+if [ "$?" -eq 0 ]; then
+ [ "$branch" ] && ln -sf "refs/heads/$branch" "$GIT_DIR/HEAD"
+ rm -f "$GIT_DIR/MERGE_HEAD"
+fi