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