Skip to content

Commit

Permalink
detached-stash: simplify git stash branch
Browse files Browse the repository at this point in the history
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
parse_flags_and_rev().

Signed-off-by: Jon Seymour <jon.seymour@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Jon Seymour authored and Junio C Hamano committed Aug 22, 2010
1 parent f276872 commit fb433dc
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions git-stash.sh
Original file line number Diff line number Diff line change
Expand Up @@ -441,20 +441,17 @@ drop_stash () {
}

apply_to_branch () {
have_stash || die 'Nothing to apply'

test -n "$1" || die 'No branch name specified'
branch=$1
shift 1

if test -z "$2"
then
set x "$ref_stash@{0}"
fi
stash=$2
set -- --index "$@"
assert_stash_like "$@"

git checkout -b $branch $REV^ &&
apply_stash "$@"

git checkout -b $branch $stash^ &&
apply_stash --index $stash &&
drop_stash $stash
test -z "$IS_STASH_REF" || drop_stash "$@"
}

PARSE_CACHE='--not-parsed'
Expand Down

0 comments on commit fb433dc

Please sign in to comment.