Commit fb433dc9 authored by Jon Seymour's avatar Jon Seymour Committed by Junio C Hamano

detached-stash: simplify git stash branch

This patch teaches git stash branch to tolerate stash-like arguments.

In particular, a stash is only required if an argument isn't specified
and the stash is only dropped if a stash entry reference was
specified or implied.

The implementation has been simplified by taking advantage of
assert_stash_like() and the variables established by
Signed-off-by: Jon Seymour's avatarJon Seymour <[email protected]>
Signed-off-by: default avatarJunio C Hamano <[email protected]>
parent f276872d
......@@ -441,20 +441,17 @@ drop_stash () {
apply_to_branch () {
have_stash || die 'Nothing to apply'
test -n "$1" || die 'No branch name specified'
shift 1
if test -z "$2"
set x "$ref_stash@{0}"
set -- --index "[email protected]"
assert_stash_like "[email protected]"
git checkout -b $branch $REV^ &&
apply_stash "[email protected]"
git checkout -b $branch $stash^ &&
apply_stash --index $stash &&
drop_stash $stash
test -z "$IS_STASH_REF" || drop_stash "[email protected]"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment