threads / patch / 1449

patchStash away the original head in ORIG_HEAD when resetting.

Subject: [PATCH] Stash away the original head in ORIG_HEAD when resetting.

## tl;dr

4 messages between Aug 8, 2005 and Aug 9, 2005. Diffs are folded; open one to read it.

replies: 3people: 2as markdown or json

Junio C Hamano· Aug 8, 2005, 06:06 UTC · lore

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>
---

Since rewinding the head is a dangerous operation, saving it somewhere just in case would make life a bit safer. This also lets you do:

    $ git commit
    ... "oops, I forgot to include that fix."
    $ git reset HEAD^1
    ... edit away and update-cache
    $ git commit -m ORIG_HEAD
to reuse the old commit message.
 git-reset-script |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)
87aced8864d926cf870ddfb2ca7ac5784fccb911
Show changes to git-reset-script +7 −1
diff --git a/git-reset-script b/git-reset-script
--- 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"
Johannes Schindelin· Aug 8, 2005, 09:13 UTC · re: Junio C Hamano · lore

Re: [PATCH] Stash away the original head in ORIG_HEAD when resetting.

Hi,
On Sun, 7 Aug 2005, Junio C Hamano wrote:
>     $ git commit -m ORIG_HEAD

Since there are not many users of git-commit's *-m* flag right now: Is it necessary to confuse CVS people, who expect to be able to write

	git commit -m "I did this and that"

I do not want to be too intrusive, but I think up to now there is just the mailbox tools which use this feature, and users of git-reset. Thoughts?

Ciao, Dscho

Johannes Schindelin· Aug 8, 2005, 09:22 UTC · re: Johannes Schindelin · lore

Re: [PATCH] Stash away the original head in ORIG_HEAD when resetting.

Hi,
On Mon, 8 Aug 2005, Johannes Schindelin wrote:
Show 13 quoted lines
> Hi,
> 
> On Sun, 7 Aug 2005, Junio C Hamano wrote:
> 
> >     $ git commit -m ORIG_HEAD
> 
> Since there are not many users of git-commit's *-m* flag right now: Is it 
> necessary to confuse CVS people, who expect to be able to write
> 
> 	git commit -m "I did this and that"
> 
> I do not want to be too intrusive, but I think up to now there is just the 
> mailbox tools which use this feature, and users of git-reset. Thoughts?
Sorry, forgot -rebase and -cherry.

Ciao, Dscho

Junio C Hamano· Aug 9, 2005, 02:48 UTC · re: Johannes Schindelin · lore

Re: [PATCH] Stash away the original head in ORIG_HEAD when resetting.

Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
Show 7 quoted lines
> Since there are not many users of git-commit's *-m* flag right now: Is it 
> necessary to confuse CVS people, who expect to be able to write
>
> 	git commit -m "I did this and that"
>
> I do not want to be too intrusive, but I think up to now there is just the 
> mailbox tools which use this feature, and users of git-reset. Thoughts?

I could be talked into renaming the option to something else and using -m in a way that is CVS compatible.

That flag originally came from JIT, which uses:
  -M <commit>	literally take the commit message, no editing necessary;
  -m <commit>	start with commit message in this one but have user edit;
  -l <file>	use the log message in this file;
  -l -		read the log message from stdin.

← back to recent threads