threads / patch / 8788

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

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

## tl;dr

One message between Jul 1, 2007 and Jul 1, 2007. Diffs are folded; open one to read it.

replies: 0people: 1as markdown or json

Johannes Schindelin· Jul 1, 2007, 00:16 UTC · lore
Hi,
On Sun, 1 Jul 2007, しらいしななこ wrote:
Show 15 quoted lines
> Quoting Johannes Schindelin <Johannes.Schindelin@gmx.de>:
> 
> > 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
Show 8 quoted lines
> >> +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.
Show 9 quoted lines
> >> +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

← back to recent threads