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

Re: error(?) in "man git-stash" regarding "--keep-index"

From
SPSybille Peters <sypets@gmx.de>
Date
May 19, 2018, 10:05 UTC
Message-ID
<2472f005-4d60-7342-2e59-f60da036f622@gmx.de>
In-Reply-To
<CAN0heSq6YLarECVtHiPFNyUMNb-XwLQqTULpB_pSW+JZsCMw0Q@mail.gmail.com>
On 18.05.2018 19:14, Martin Ågren wrote:
> On 18 May 2018 at 17:43, Robert P. J. Day <rpjday@crashcourse.ca> wrote:
...
> Ah, this is about saving to the stash vs stashing away. The latter is
> what `git stash` is all about -- stashing changes *away*. At least
> according to my mental model and the top of the man-page.

Stashing changes *away* would mean a move in my mental model (as in command line mv): Whatever gets copied to stash gets removed in working area. And what doesn't get removed, doesn't get copied to stash.

Thus, --keep-index *would* ignore the index and only move working-tree to the stash minus the changes already staged.

BUT, that might lead to other problems, I suppose.

The current behaviour can cause problems as in the Stackoverflow question where someone already staged some hunks, and on stashing with -p gets asked about these *again*. Which does make the workflow more tedious.

Show 7 quoted lines
> 
> ...
> 
> The work flow in the example is about temporarily stashing a few changes
> (changes B) to test a couple of others (changes A). Whether the stash
> entry contains changes A or not is practically irrelevant to the use
> case. At pop-time, auto-merging will do the correct thing.

Aha, now it gets interesting. So you are saying, it doesn't matter if the stash entry also contains the already staged changes A? Well in the combination with -p it does (see Stackoverflow question and above).

Even if auto-merging will take care of it (?), it would be good to have the manpage clarify things that might confuse people.

Disclaimer: I am not a git expert, so I may be getting things wrong. I
just noticed the Stackoverflow question, answered it (only because
an adequate answer did not exist yet) and then saw a similar topic
being raised here.
Show 8 quoted lines
> 
> So how about "All changes are saved to the stash. Those that have been
> added to the index are left intact in the working tree, all others are
> removed from the working tree."? That's quite a lot of text. Maybe
> "save all changes to the stash, make the working tree match the index"?
> 
> Or more to the point: "make the working directory match the index" or
> "keep only what is in the index"?
I am not sure yet about the text. Still in the clarifying phase.
Sybille
> 
> Martin
> 
Previous: Martin ÅgrenNext: Robert P. J. Day
Message 8 of 9 in “error(?) in "man git-stash" regarding "--keep-index"”
  1. Robert P. J. DayMay 18, 2018
  2. Martin ÅgrenMay 18, 2018
  3. Robert P. J. DayMay 18, 2018
  4. Martin ÅgrenMay 18, 2018
  5. Sybille PetersMay 18, 2018
  6. Robert P. J. DayMay 18, 2018
  7. Martin ÅgrenMay 18, 2018
  8. Sybille PetersMay 19, 2018
  9. Robert P. J. DayMay 18, 2018

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.