Skip to content

Commit 32173e6

Browse files
author
Junio C Hamano
committed
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 <[email protected]>
1 parent 045f82c commit 32173e6

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

git-reset-script

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22
. git-sh-setup-script || die "Not a git archive"
33
rev=$(git-rev-parse --revs-only --verify --default HEAD "$@") || exit
44
rev=$(git-rev-parse --revs-only --verify $rev^0) || exit
5-
git-read-tree --reset "$rev" && echo "$rev" > "$GIT_DIR/HEAD"
5+
git-read-tree --reset "$rev" && {
6+
if orig=$(git-rev-parse --verify HEAD 2>/dev/null)
7+
then
8+
echo "$orig" >"$GIT_DIR/ORIG_HEAD"
9+
fi
10+
echo "$rev" > "$GIT_DIR/HEAD"
11+
}
612
git-update-cache --refresh
713
rm -f "$GIT_DIR/MERGE_HEAD"

0 commit comments

Comments
 (0)