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

3 messages, 3 authors, 2016-06-15 · open the first message on its own page

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

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:47:12

Thomas Rast [off-list ref] 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.

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

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

From: Sitaram Chamarty <hidden>
Date: 2016-06-15 22:47:12

2009/8/9 Junio C Hamano [off-list ref]
Thomas Rast [off-list ref] writes:
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.
gitk $(git fsck | grep commit | cut -f3 -d' ') --since='1 week ago'

The --since clause limits the display to stashes lost recently; adjust to taste.

A "stash" has a very recognisable, triangular, shape in the commit DAG
-- with gitk you can visually find stashes really fast even if your
time limit is too broad or you have too many other kinds of
unreachable commits perhaps due to too many rebase etc.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help