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

Re: [PATCH] Document 'stash clear' recovery via unreachable commits

From
Björn Steinbrink <b.steinbrink@gmx.de>
Date
Aug 9, 2009, 02:21 UTC
Message-ID
<20090809022134.GA4141@atjola.homenet>
In-Reply-To
<7veirlbwws.fsf@alter.siamese.dyndns.org>
On 2009.08.08 18:25:55 -0700, Junio C Hamano wrote:
Show 14 quoted lines
> Thomas Rast <trast@student.ethz.ch> writes:
> 
> > Add an example to the stash documentation that shows how to quickly
> > find candidate commits among the 'git fsck --unreachable' output.
> 
> Thanks.
> 
> > Unless you have merges of branch names containing WIP, or edit your
> > merge messages to say WIP, there will be no false positives.
> 
> That may be true, but I suspect that people's stash entries that are worth
> saving are given their own messages with "git stash save 'message'" and do
> not necessarily say WIP.  I wish if there were a better way to identify
> them, but I do not think of any offhand.
Here's what I have now:
git fsck --unreachable | grep commit | cut -d\  -f3 |
xargs git log --no-walk --merges \
	--grep='^\(WIP on \|On \)\((no branch)\|[^ ]\+\):'

Should catch stashes with and without user-supplied messages and avoid most false-positives. Drop the "WIP on " option from the grep to capture just those that have a user-supplied message.

To try really really hard to get stash stuff only, one could add some extra stuff to verify that the second parent's commit message is "index on \2:" (\2 being the second group from the above --grep). But that's probably total overkill...

Björn
Previous: Junio C HamanoNext: Sitaram Chamarty
Message 3 of 4 in “Document 'stash clear' recovery via unreachable commits”
  1. Document 'stash clear' recovery via unreachable commitsThomas Rast, Aug 9, 2009
  2. Junio C HamanoAug 9, 2009
  3. Björn SteinbrinkAug 9, 2009
  4. Sitaram ChamartyAug 9, 2009

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.