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

Re: [PATCH] Add git-save script

From
Junio C Hamano <gitster@pobox.com>
Date
Jun 25, 2007, 07:52 UTC
Message-ID
<7vir9c1nek.fsf@assigned-by-dhcp.pobox.com>
In-Reply-To
<200706250632.l5P6Wu6A028140@mi0.bluebottle.com>
しらいしななこ  <nanako3@bluebottle.com> writes:
Show 15 quoted lines
> Quoting Johannes Schindelin <Johannes.Schindelin@gmx.de>:
>
>> On Sat, 23 Jun 2007, Nanako Shiraishi wrote:
>> 
>> > Here is how to use my script:
>> > 
>> >     $ git save
>> >     $ git pull
>> >     $ git save restore
>> 
>> This use case has been discussed often, under the name "git-stash".
>
> Thank you for your comments.  Do you suggest I rename the
> script to git-stash and re-submit after fixing according to
> Junio's comments?
        Side note: get into the habit of trimming the quote to
        remove "Hi," and signatures, please.

Because many people on the list (not just me, as I was not initially involved in the "wish: pulling into dirty tree" discussion myself) already used the word "stash" for the concept of the operation, I think it would give continuity to our discussion if you used that word.

I have to also say that the "restore" subcommand had a certain "Huh?" factor when I first saw the above "git save restore" command line. I would have said "git stash" to save away, and "git stash apply" to propagate the changes to updated HEAD.

That would make the set of subcommands to:
	$ git stash		-- to save away
	$ git stash list	-- to get the list
        $ git stash show [$it]	-- to view a single stash
        $ git stash apply [$it]	-- to apply changes from a stash

Right now you seem to use reflog so that "list" gives saved@{$n} and the user is expected to pick from it and say something like "git stash show saved@{2}", but I suspect that there is some room for UI improvements.

 * Is comandeering a branch name "saved" for the purpose of the
   stash command a right thing to do?
   Perhaps we would want to use refs/stash/ hierarchy;
 * Is it more convenient to have a single stash that holds
   changes you make anywhere, or is it better to have one stash
   per branch?
   Unlike StGIT and guilt, that are systems to manage patches
   for longer term, I think the concept of stash is more geared
   towards quickly stashing away local changes while you have to
   'get distracted", as you described in your commit log
   message.  So in that sense, I think anything elaborate like
   one stash per branch is a mistake, and a single stash that is
   quickly aged and pruned automatically when reflog expires, as
   you implemented, is the right approach.  Taken together with
   the previous point, I would actually suggest refs/stash as
   the refname.
 * If we settle on the design of having a single stash per
   repository, the name of whatever the ref we use to implement
   the stash should not have to be spelled out by the end user
   (e.g. saved@{2} should not be necessary---the user should be
   able to say "the stash marked with letter '2' in 'git stash
   list' output).

So perhaps as a UI improvement, "git stash list" should show them just numbered (strip away saved@{$N} part down to just "$N:" or something), and "git stash show" and "git stash apply" should take that number.

I think "git stash" is usable standalone, but in the particular use case you mentioned, I was planning to follow Linus's suggestion of stashing and unstashing automatically inside "git pull" (most likely in "git merge", which is the underlying command to do the actual merging part), when the pull results in a fast-forward situation. But that would be a separate change that uses "git stash" command.

Previous: しらいしななこNext: Junio C Hamano
Message 6 of 12 in “Add git-save script”
  1. Add git-save scriptNanako Shiraishi, Jun 23, 2007
  2. Johannes SchindelinJun 23, 2007
  3. Bill LearJun 23, 2007
  4. Johannes SchindelinJun 23, 2007
  5. しらいしななこJun 25, 2007
  6. Junio C HamanoJun 25, 2007
  7. Junio C HamanoJun 23, 2007
  8. Nanako ShiraishiJun 24, 2007
  9. Junio C HamanoJun 24, 2007
  10. Junio C HamanoJun 27, 2007
  11. しらいしななこJun 27, 2007
  12. Johannes SchindelinJun 25, 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.