threads / patch / 6062

patchgit-reset --hard: tell the user what the HEAD was reset to

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

## tl;dr

5 messages between Dec 20, 2006 and Jan 4, 2007. Diffs are folded; open one to read it.

replies: 4people: 3as markdown or json

Han-Wen Nienhuys· Dec 20, 2006, 22:55 UTC · lore

UI nitpick

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· Dec 21, 2006, 14:26 UTC · re: Han-Wen Nienhuys · lore
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(-)
Show changes to git-reset.sh +6 −1
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· Jan 3, 2007, 13:17 UTC · re: Johannes Schindelin · lore

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

Johannes Schindelin wrote:
Show 35 quoted lines
> 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· Jan 4, 2007, 12:59 UTC · re: Andy Whitcroft · lore

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

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· Jan 4, 2007, 15:59 UTC · re: Johannes Schindelin · lore

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

Johannes Schindelin wrote:
Show 14 quoted lines
> 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

← back to recent threads