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

Re: [PATCH 0/2] git stash drop stash@{2.days.ago}

From
Junio C Hamano <gitster@pobox.com>
Date
Jul 30, 2026, 20:29 UTC
Message-ID
<xmqqjyqcjk5o.fsf@gitster.g>
In-Reply-To
<20260730034108.765430-1-gitster@pobox.com>
Junio C Hamano <gitster@pobox.com> writes:
Show 23 quoted lines
> Because 'stash' is implemented in terms of the reflog, it can accept
> not only a small integer index (such as 'stash@{4}') but also a
> time-based reference.  This is not a good thing.
>
>  - 'git stash pop stash@{2.days.ago}' picks the first stash entry
>    that is no younger than the specified time and uses it to modify
>    the working tree and the index, but then removes all stash
>    entries that are no younger than that specified time.
>
>  - 'git stash drop stash@{2.days.ago}' does the same, except that
>    no entry is used to affect the working tree and the index.
>
> These two patches forbid passing time-based stash references to the
> 'git stash drop' and 'git stash pop' commands as minor safety
> improvements.
>
>  1/2: stash: record positional index in 'struct stash_info'
>  2/2: stash: reject time-based selectors in drop and pop
>
>  Documentation/git-stash.adoc |  8 ++++++++
>  builtin/stash.c              | 18 ++++++++++++++++++
>  t/t3903-stash.sh             | 13 +++++++++++++
>  3 files changed, 39 insertions(+)

Sorry, it turns out that the collateral damange claim was completely bogus. We do abuse the reflog expiration machinery but make sure we only remove a single entry, it seems, so only one entry is consumed and then removed. Consider these patches retracted.

Thanks.
Previous: Junio C Hamano
Message 6 of 6 in “git stash drop stash@{2.days.ago}”
  1. 0/2 git stash drop stash@{2.days.ago}Junio C Hamano, Jul 30, 2026
  2. 1/2 stash: record positional index in 'struct stash_info'Junio C Hamano, Jul 30, 2026
  3. Ben KnobleJul 30, 2026
  4. Junio C HamanoJul 30, 2026
  5. 2/2 stash: reject time-based selectors in drop and popJunio C Hamano, Jul 30, 2026
  6. Junio C HamanoJul 30, 2026

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.