Re: [PATCH (3rd try)] Add git-stash script

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

On Sun, 1 Jul 2007, しらいしななこ wrote:

> Quoting Johannes Schindelin <Johannes.Schindelin@xxxxxx>:
> 
> > On Sat, 30 Jun 2007, しらいしななこ wrote:
> >
> >> diff --git a/git-stash.sh b/git-stash.sh
> >> [...]
> >> +	printf >&2 'Saved WIP on %s\n' "$msg"
> >
> > You have an awful lot of printfs in the code. Why not just use echos?
> 
> I just imitated other scripts.  I can change it to
> 
> echo >&2 "Saved WIP on $msg"
> 
> but after reading Junio's comments, I think I probably should not.

You can leave them as-are, but I am actually more used to reading 
something like

	echo "Saved WIP on $msg" >&2

> >> +list_stash () {
> >> +	git-log --pretty=oneline -g "$@" $ref_stash |
> >
> > Wouldn't you want "--default $ref_stash" here?
> 
> I do not know, and I'm sorry I do not understand Junio's comments.
> 
> What does --default do in this case?

I had the impression that

	git stash list stash@{3}

would make sense. Probably I was mistaken.

> >> +apply_stash () {
> >> +	git-diff-files --quiet ||
> >> +		die 'Cannot restore on top of a dirty state'
> >
> > You meant "no_changes", right? I think you miss changes in the index 
> > otherwise.
> 
> After I read exchanges between you and Junio I do not know which way is 
> preferred.

Well, there are two differing, and contradicting, preferences: Junio's and 
mine.

Now you can have a third preference, but in the end what weighs most is 
the opinion of the person implementing it.

> Using no_changes does not forbid me from doing that, but I think Junio's 
> example will be forbidden.  The original scenario was that I apply a 
> stashed change to an unmodified state, and there is no problem either 
> way.

Oh, but there is. Imagine this:

File "f" contains "1" in HEAD, "2" in the index and "3" in the working 
directory. Now you say "git stash". Okay, file "f" now contains "1" in all 
three, and the working directory is clean. Suppose you decide the stash 
was a mistake. "git stash apply". File "f" contains "1" in _both_ the HEAD 
and the index, and "3" in the working directory.

Now, you might say that it does not matter. But then we should not even 
save the index.

Can I make one further request? Add "git stash save" to do the same as 
"git stash"?

Ciao,
Dscho

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux