Re: [PATCH] Document 'stash clear' recovery via unreachable commits
From: Björn Steinbrink <hidden>
Date: 2016-06-15 22:47:12
On 2009.08.08 18:25:55 -0700, Junio C Hamano wrote:
Thomas Rast [off-list ref] writes:quoted
Add an example to the stash documentation that shows how to quickly find candidate commits among the 'git fsck --unreachable' output.Thanks.quoted
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