2011/1/27 Marc Herbert <[email protected]>:
> I *finally* found the command line solution (cause I typically prefer
> emacs/magit than
> git gui)
>
> git reset HEAD^ . # with trailing dot
> stg refresh --index
> And that's it, the patch is spilled on the workspace.
Except... the trick above only works at the top level. So find below
my best solution so far. This "stg-defresh-top()" shell function works
at any level, has some sanity checks and . Could such a "defresh-top"
feature be added to Stacked Git?
I could not really come with a better name since "reset" was already
taken. "restart" maybe? By the way it could be useful to have stack
and patch commands respectively prefixed, something like:
Patch commands:
stgp reset < see stg-defresh-top function below>
stgp show Show the commit corresponding to a patch
Stack commands:
stgs *reset* Reset the patch stack to an earlier state
stgs show = today's stg series
# Transfers all hunks from the top patch, into the workspace. This
# command is for restarting the work on the top patch from
# scratch. Technically it blanks the top patch leaving the workspace
# untouched. Since the implementation relies on the index it must be
# empty.
# If not all but only a few hunks should be transferred then git reset
# --patch HEAD^ (or git gui; amend last, no commit) are more appropriate.
stg-defresh-top()
{
(
set -e; # set -x
stg top >/dev/null # Is there stacked git here?
# We need an empty index otherwise it would pollute the patch.
if git diff --staged | grep -q '.'; then
git status
1>&2 printf '\nFailed: index already in use\n'
return 1
fi
local hd; hd=$(git show -s --format=%H HEAD)
git reset --mixed HEAD^
git reset --soft $hd # restore HEAD
stg refresh --index
)
}
_______________________________________________
stgit-users mailing list
[email protected]
https://mail.gna.org/listinfo/stgit-users