summaryrefslogtreecommitdiff
path: root/git-reset-script
diff options
context:
space:
mode:
authorJunio C Hamano <junkio@cox.net>2005-08-07 03:59:47 (GMT)
committerJunio C Hamano <junkio@cox.net>2005-08-10 06:38:49 (GMT)
commit32173e69881a35e4e7a53be3ba80091ae9fa8f35 (patch)
treec9402158278e1ba219ee478337d2b2449eff21fe /git-reset-script
parent045f82cbee3135a3d75256828b0cf101eedf38c8 (diff)
downloadgit-32173e69881a35e4e7a53be3ba80091ae9fa8f35.zip
git-32173e69881a35e4e7a53be3ba80091ae9fa8f35.tar.gz
git-32173e69881a35e4e7a53be3ba80091ae9fa8f35.tar.bz2
Stash away the original head in ORIG_HEAD when resetting.
When rewinding the head, stash away the value of the original HEAD in ORIG_HEAD, just like git-resolve-script does. Signed-off-by: Junio C Hamano <junkio@cox.net>
Diffstat (limited to 'git-reset-script')
-rwxr-xr-xgit-reset-script8
1 files changed, 7 insertions, 1 deletions
diff --git a/git-reset-script b/git-reset-script
index b6476ed..49994df 100755
--- a/git-reset-script
+++ b/git-reset-script
@@ -2,6 +2,12 @@
. git-sh-setup-script || die "Not a git archive"
rev=$(git-rev-parse --revs-only --verify --default HEAD "$@") || exit
rev=$(git-rev-parse --revs-only --verify $rev^0) || exit
-git-read-tree --reset "$rev" && echo "$rev" > "$GIT_DIR/HEAD"
+git-read-tree --reset "$rev" && {
+ if orig=$(git-rev-parse --verify HEAD 2>/dev/null)
+ then
+ echo "$orig" >"$GIT_DIR/ORIG_HEAD"
+ fi
+ echo "$rev" > "$GIT_DIR/HEAD"
+}
git-update-cache --refresh
rm -f "$GIT_DIR/MERGE_HEAD"