git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Jul 1, 2007, 00:16 UTC
Message-ID
<Pine.LNX.4.64.0707010111340.4438@racer.site>
In-Reply-To
<200706302327.l5UNRMtc027974@mi0.bluebottle.com>
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

Message 1 of 1 in “Re: [PATCH (3rd try)] Add git-stash script”
  1. Johannes SchindelinJul 1, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.