# [PATCH] git-reset --hard: tell the user what the HEAD was reset to

5 messages from 2006-12-20 to 2007-01-04. Participants: Johannes Schindelin, Andy Whitcroft, Han-Wen Nienhuys.
Thread: https://gitlist.dev/t/6062

## Han-Wen Nienhuys, 2006-12-20 22:55

Subject: UI nitpick
Message-ID: <emcf17$esj$1@sea.gmane.org>
URL: https://gitlist.dev/e/emcf17%24esj%241%40sea.gmane.org

```

Hi,

git-reset is really neat when you messed something up, but it 
spews messages.

  [lilydev@haring lilypond]$ git-reset  HEAD
  lily/accidental-engraver.cc: needs update
  lily/lyric-combine-music-iterator.cc: needs update

this makes me think that the reset was unsuccesful.

After a few more experiments with 

  git-reset <stuff> HEAD^ 

I started noticing that the list grew longer and longer.


It would be nice if git-reset printed 

 HEAD is now <sha1> - <excerpt of commit message>


-- 
 Han-Wen Nienhuys - hanwen@xs4all.nl - http://www.xs4all.nl/~hanwen

```

## Johannes Schindelin, 2006-12-21 14:26

Subject: [PATCH] git-reset --hard: tell the user what the HEAD was reset to
Message-ID: <Pine.LNX.4.63.0612211525070.19693@wbgn013.biozentrum.uni-wuerzburg.de>
URL: https://gitlist.dev/e/Pine.LNX.4.63.0612211525070.19693%40wbgn013.biozentrum.uni-wuerzburg.de
In-Reply-To: <emcf17$esj$1@sea.gmane.org>

```

Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
---

	On Wed, 20 Dec 2006, Han-Wen Nienhuys wrote:

	> It would be nice if git-reset printed 
	> 
	>  HEAD is now <sha1> - <excerpt of commit message>

	This patch does that, but only for --reset.

	Without reset, HEAD is _not_ changed, just the contents of the
	working directory and/or the index.

 git-reset.sh |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/git-reset.sh b/git-reset.sh
index 8d95e37..2379db0 100755
--- a/git-reset.sh
+++ b/git-reset.sh
@@ -86,7 +86,12 @@ update_ref_status=$?
 
 case "$reset_type" in
 --hard )
-	;; # Nothing else to do
+	test $update_ref_status = 0 && {
+		echo -n "HEAD is now at "
+		GIT_PAGER= git log --max-count=1 --pretty=oneline \
+			--abbrev-commit HEAD
+	}
+	;;
 --soft )
 	;; # Nothing else to do
 --mixed )
-- 
1.4.4.3.gdb8fb-dirty

```

## Andy Whitcroft, 2007-01-03 13:17

Subject: Re: [PATCH] git-reset --hard: tell the user what the HEAD was reset to
Message-ID: <459BACE1.5020406@shadowen.org>
URL: https://gitlist.dev/e/459BACE1.5020406%40shadowen.org
In-Reply-To: <Pine.LNX.4.63.0612211525070.19693@wbgn013.biozentrum.uni-wuerzburg.de>

```
Johannes Schindelin wrote:
> Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
> ---
> 
> 	On Wed, 20 Dec 2006, Han-Wen Nienhuys wrote:
> 
> 	> It would be nice if git-reset printed 
> 	> 
> 	>  HEAD is now <sha1> - <excerpt of commit message>
> 
> 	This patch does that, but only for --reset.
> 
> 	Without reset, HEAD is _not_ changed, just the contents of the
> 	working directory and/or the index.
> 
>  git-reset.sh |    7 ++++++-
>  1 files changed, 6 insertions(+), 1 deletions(-)
> 
> diff --git a/git-reset.sh b/git-reset.sh
> index 8d95e37..2379db0 100755
> --- a/git-reset.sh
> +++ b/git-reset.sh
> @@ -86,7 +86,12 @@ update_ref_status=$?
>  
>  case "$reset_type" in
>  --hard )
> -	;; # Nothing else to do
> +	test $update_ref_status = 0 && {
> +		echo -n "HEAD is now at "
> +		GIT_PAGER= git log --max-count=1 --pretty=oneline \
> +			--abbrev-commit HEAD
> +	}
> +	;;
>  --soft )
>  	;; # Nothing else to do
>  --mixed )

Ok, this sounds like a good change in principle, but the output format
it introduces seems likely to cause confusion.  For sure the first
couple of times I saw it I though there was a bug and I was seeing an
error from the plumbing.  See below for an example where you would swear
something bad had occured.

  apw@pinky$ git checkout -b bar master
  apw@pinky$ git reset --hard ac9c1108d8915f0937795e354ad72c4ae6890a3f
  HEAD is now at ac9c110... git-fetch: remove .keep file at the end.

Huh, fetch?  Remove what .keep file?  Did I do a fetch?  What?

I think we need to delimit the name better, probabally we need to quote
it.  Perhaps something like:

  HEAD is now at ac9c110: "git-fetch: remove .keep file at the end".

-apw

```

## Johannes Schindelin, 2007-01-04 12:59

Subject: Re: [PATCH] git-reset --hard: tell the user what the HEAD was reset to
Message-ID: <Pine.LNX.4.63.0701041357380.22628@wbgn013.biozentrum.uni-wuerzburg.de>
URL: https://gitlist.dev/e/Pine.LNX.4.63.0701041357380.22628%40wbgn013.biozentrum.uni-wuerzburg.de
In-Reply-To: <459BACE1.5020406@shadowen.org>

```
Hi,

On Wed, 3 Jan 2007, Andy Whitcroft wrote:

> I think we need to delimit the name better, probabally we need to quote
> it.  Perhaps something like:
> 
>   HEAD is now at ac9c110: "git-fetch: remove .keep file at the end".

Fine. But this is "git log --pretty=oneline --abbrev-commit". I don't know 
how many things break if you change _that_.

Alternatively, you could pipe that into a sed command adding the colon and 
the quotes.

Ciao,
Dscho

```

## Andy Whitcroft, 2007-01-04 15:59

Subject: Re: [PATCH] git-reset --hard: tell the user what the HEAD was reset to
Message-ID: <459D2470.2090001@shadowen.org>
URL: https://gitlist.dev/e/459D2470.2090001%40shadowen.org
In-Reply-To: <Pine.LNX.4.63.0701041357380.22628@wbgn013.biozentrum.uni-wuerzburg.de>

```
Johannes Schindelin wrote:
> Hi,
> 
> On Wed, 3 Jan 2007, Andy Whitcroft wrote:
> 
>> I think we need to delimit the name better, probabally we need to quote
>> it.  Perhaps something like:
>>
>>   HEAD is now at ac9c110: "git-fetch: remove .keep file at the end".
> 
> Fine. But this is "git log --pretty=oneline --abbrev-commit". I don't know 
> how many things break if you change _that_.
> 
> Alternatively, you could pipe that into a sed command adding the colon and 
> the quotes.

Quack, so it is.

apw@pinky$ git log --pretty=oneline --abbrev-commit | head -1
f4bf218... Update clone/fetch documentation with --depth (shallow clone)
option

Perhaps we could do something like:

Head is now at "f4bf218... Update clone/fetch documentation with --depth
(shallow clone) option"

Hmmm ... oh well I guess I'll just get used to it.

-apw

```
