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

Re: [PATCH] builtin/stash: configs keepIndex, includeUntracked

From
Junio C Hamano <gitster@pobox.com>
Date
Feb 20, 2024, 17:47 UTC
Message-ID
<xmqqjzmzqb85.fsf@gitster.g>
In-Reply-To
<78a8733b-c74a-4017-8905-d29b2e05adb1@gmail.com>
Phillip Wood <phillip.wood123@gmail.com> writes:
> That's a good idea but I think it would be better to test that "git
> stash create" is not affected by the config as we don't want to change
> the behavior of its behavior.

Yup. Making sure "stash create" stays the same is a very good thing. Thanks for suggesting it.

Regardling the need to have an escape hatch that is well publicized long before a potentially harmful switch can safely happen, one way out might be to

 - Declare "git stash create" is a plumbing, but the rest is
   considered Porcelain.  Publicize it well and wait for the word to
   spread out.  Folks who are in favor of adding these configuration
   variables to the system may need to do some legwork, spreading
   the word around at stackoverflow and various other venues,
   scouring public repositories at GitHub and other hosting sites
   and studying third-party uses of "git stash" that should be
   replaced with "git stash create" followed by "git update-ref",
   and raising issues to notify the owners of such projects, etc.
 - Add breaking configuration variables after a few years.

We cannot do the usual "start warning when we detect problematic use without changing the current behaviour, wait, and then switch" dance in this case, unfortunately, because we lack a good way to detect a "problematic use". We cannot tell a direct use of "git stash" via the command prompt (which may want to honor the configuration) from an IDE running "git stash" reacting to the "[Stash Now]" UI element (which might want to honor the configuration) and from a third-party tool that acts like "rebase --autostash" that wants to save away all local changes to clear the slate to do its thing (which we should definitely not interfare). If we could do so reliably, then we wouldn't be having this discussion---we'd be using the same logic as we would use to tell when to warn and instead of warning, just silently refraining to honor the configuration variables.

An eve easier way out of course is not to do these variables, of course.

FWIW, I can see how permanently enabling "include untracked" may be OK in a workflow, but I cannot see the utility of permanently enabling "keepindex" at all. Sometimes I'd want to clear the slate so that I can try building and testing what I added to the index and that is why I want to use the option. But a lot of other times, I want to clear the slate to go back to the very pristine state that is equal to the HEAD. As the need to switch between the two modes happens quite often, the way to defeat configured stash.keepindex takes quite many keystrokes, and in general I think the regular stashing happens far more often than keepindex stashing, I'd find that using shorthand "-k" on the command line occasionally without having this configuration variable would be what people would end up using anyway.

And there is always "[alias] stk = stash -k" available ;-)
Previous: Phillip WoodNext: Ricardo C
Message 5 of 16 in “builtin/stash: configs keepIndex, includeUntracked”
  1. builtin/stash: configs keepIndex, includeUntrackedMithicSpirit, Feb 18, 2024
  2. Phillip WoodFeb 18, 2024
  3. Ricardo CFeb 18, 2024
  4. Phillip WoodFeb 20, 2024
  5. Junio C HamanoFeb 20, 2024
  6. Ricardo CFeb 21, 2024
  7. Junio C HamanoFeb 21, 2024
  8. Ricardo CFeb 21, 2024
  9. Junio C HamanoFeb 21, 2024
  10. Junio C HamanoFeb 20, 2024
  11. Ricardo CFeb 20, 2024
  12. Junio C HamanoFeb 20, 2024
  13. Ricardo CFeb 20, 2024
  14. Kristoffer HaugsbakkFeb 20, 2024
  15. Jean-Noël AvilaFeb 19, 2024
  16. Ricardo CFeb 19, 2024

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.