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

Re: [PATCH 2/2] git-gc: skip stashes when expiring reflogs

From
Junio C Hamano <gitster@pobox.com>
Date
Jun 13, 2008, 09:47 UTC
Message-ID
<7vtzfxwtt0.fsf@gitster.siamese.dyndns.org>
In-Reply-To
<20080613074257.GA513@sigill.intra.peff.net>
Jeff King <peff@peff.net> writes:
Show 17 quoted lines
> Reading your (and others') responses, it seems like there are two
> things:
>
>   1. Stashing is about saying "save everything about where I am now with
>      no hassle". IOW, it's one command, you don't have to decide what
>      goes and what stays, and you can pull it back out with one command.
>      And maybe there is a psychological component that you are not ready
>      to "commit" such a work-in-progress (I am extrapolating here, but I
>      know that when I first started with git, I was hesitant to commit
>      because of my experience with other systems).
>
>   2. Branches tend to get shared, and you don't want people to see your
>      stashes, because they are messy works in progress.
>
> To deal with '2', I wonder if it would be worth making some branches
> inaccessible to pushing/pulling (either via config, or through a special
> naming convention).

I personally do not find the example that Andreas gave unconvincing, not because I doubt it happens in practice, but because I think it shows a bad inter-developer communication.

It is natural to have branches that are private and/or not meant to be built on top of by others. We all have them --- heck, I have one that is called 'pu' (not private but it is meant to be "only look, never touch" and advertised as such). But if we need a strong mechanism to enforce that "never touch" policy by not allowing fetch, there is something wrong with the inter-developer communication.

While digging the original thread earlier today (eh, it is already yesterday here), I was thinking about what other alternative design and implementation would have been sensible. Here are some thoughts.

 * We _did not have to_ make stashes into refs/stash@{$N}.  We could have
   implemented them as individual refs under "refs/stash/$N" hierarchy.
   E.g. refs/stashes/1, refs/stash/2, etc.
   As a side note, we also could have implemented per-branch stash as
   refs/stashes/master@{$N} or refs/stashes/$branch/$N (and we still can.
   Perhaps we can have "git stash save -B" option that tells the command
   to send the resulting stash to the per-branch namespace).
 * We however chose to take advantage of the auto reclamation behaviour of
   reflog, and for most practical purposes, it is a good thing.
 * We later introduced "drop" because even as a volatile and short-lived
   collection of local modifications, you can tell that some stashes are
   utter crap immediately while deciding that some are worth keeping, even
   for a short term.
   This mechanism was however meant for uncluttering the set of stashes.
   "drop" names what you want to discard right now, and by doing so,
   implicitly names what you want to keep for a bit longer (by not naming
   them).  It's a reverse operation -- to make your gems easier to find,
   you discard garbage stash entries.  It is a useful work element.
 * We could add "keep" which is a complementary operation to "drop".  This
   would mark a stash as a gem in a more direct way, excempt even from the
   usual auto pruning.
   We probably implement this by marking the entry with a magic timestamp
   value, and teach reflog expiry machinery to keep it indefinitely.  You
   can still explicitly "drop" it.

I do not want to conflate two possibly independent issues, but I wonder if there is a correlation between a change that people would want to stash to a per-branch stash (if such a thing existed) and a change the people would want to "keep" (if such a feature existed).

If there is a strong correlation between the two, one possible solution would be to introduce refs/stashes/$branch/ namespace that holds each stash as an individual, numbered ref under it. They will live forever until the user explicitly asks for their removal. If we go this route, we would need a few niceties such as a way to move a "quick stash" that is represented as a reflog entry into a "longlived stash" that is represented as an individual ref under refs/stashes/$branch/.

But let's not talk nor think about per-branch stash for now. How does the "keep" thing sound to people?

Previous: Miles BaderNext: Jakub Narebski
Message 43 of 69 in “git-gc: skip stashes when expiring reflogs”
  1. 2/2 git-gc: skip stashes when expiring reflogsBrandon Casey, Jun 11, 2008
  2. Mike HommeyJun 11, 2008
  3. Johannes SchindelinJun 11, 2008
  4. Jeff KingJun 11, 2008
  5. Nicolas PitreJun 11, 2008
  6. Eric RaibleJun 12, 2008
  7. Wincent ColaiutaJun 12, 2008
  8. Nicolas PitreJun 12, 2008
  9. Junio C HamanoJun 12, 2008
  10. Eric RaibleJun 12, 2008
  11. Junio C HamanoJun 12, 2008
  12. Eric RaibleJun 12, 2008
  13. Johannes SchindelinJun 13, 2008
  14. Wincent ColaiutaJun 13, 2008
  15. Jeff KingJun 13, 2008
  16. Johannes SchindelinJun 13, 2008
  17. Christian JaegerJun 13, 2008
  18. Wincent ColaiutaJun 14, 2008
  19. しらいしななこJun 14, 2008
  20. Junio C HamanoJun 15, 2008
  21. Eric RaibleJun 16, 2008
  22. Junio C HamanoJun 16, 2008
  23. Johannes SchindelinJun 17, 2008
  24. Junio C HamanoJun 17, 2008
  25. Johannes SchindelinJun 18, 2008
  26. Junio C HamanoJun 18, 2008
  27. Brandon CaseyJun 16, 2008
  28. Jakub NarebskiJun 16, 2008
  29. Mikael MagnussonJun 13, 2008
  30. Brandon CaseyJun 12, 2008
  31. Junio C HamanoJun 12, 2008
  32. Brandon CaseyJun 12, 2008
  33. しらいしななこJun 13, 2008
  34. Andreas EricssonJun 13, 2008
  35. Jeff KingJun 13, 2008
  36. Andreas EricssonJun 13, 2008
  37. Jeff KingJun 13, 2008
  38. Andreas EricssonJun 13, 2008
  39. Jakub NarebskiJun 13, 2008
  40. Sverre RabbelierJun 13, 2008
  41. Jeff KingJun 13, 2008
  42. Miles BaderJun 13, 2008
  43. Junio C HamanoJun 13, 2008
  44. Jakub NarebskiJun 13, 2008
  45. Sverre RabbelierJun 13, 2008
  46. Olivier MarinJun 13, 2008
  47. Junio C HamanoJun 13, 2008
  48. Wincent ColaiutaJun 13, 2008
  49. Brandon CaseyJun 13, 2008
  50. Olivier MarinJun 13, 2008
  51. しらいしななこJun 14, 2008
  52. Wincent ColaiutaJun 13, 2008
  53. Jeff KingJun 13, 2008
  54. Olivier MarinJun 13, 2008
  55. Jon LoeligerJun 13, 2008
  56. Brandon CaseyJun 13, 2008
  57. Brandon CaseyJun 11, 2008
  58. Jeff KingJun 12, 2008
  59. Brandon CaseyJun 12, 2008
  60. Jeff KingJun 13, 2008
  61. Wincent ColaiutaJun 13, 2008
  62. Sverre RabbelierJun 13, 2008
  63. Teemu LikonenJun 13, 2008
  64. Jeff KingJun 13, 2008
  65. Miles BaderJun 13, 2008
  66. Brandon CaseyJun 13, 2008
  67. Jeff KingJun 13, 2008
  68. Brandon CaseyJun 11, 2008
  69. Johannes SchindelinJun 15, 2008

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.