[PATCH v4 6/9] stash: teach git stash branch to tolerate stash-like arguments
- From
Jon Seymour <jon.seymour@gmail.com>
- Date
- Aug 10, 2010, 00:04 UTC
- Message-ID
- <1281398688-21008-7-git-send-email-jon.seymour@gmail.com>
- In-Reply-To
- <1281242771-24764-1-git-send-email-jon.seymour@gmail.com>
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.
Signed-off-by: Jon Seymour <jon.seymour@gmail.com> --- git-stash.sh | 15 +++++++++++---- 1 files changed, 11 insertions(+), 4 deletions(-)
diff --git a/git-stash.sh b/git-stash.sh index 86cd446..97e3749 100755 --- a/git-stash.sh +++ b/git-stash.sh @@ -390,20 +390,27 @@ drop_stash () { } apply_to_branch () { - have_stash || die 'Nothing to apply' - test -n "$1" || die 'No branch name specified' branch=$1 if test -z "$2" then set x "$ref_stash@{0}" + have_stash || die 'Nothing to apply' fi stash=$2 + assert_stash_like "$stash" + git checkout -b $branch $stash^ && - apply_stash --index $stash && - drop_stash $stash + apply_stash --index $stash + + if is_stash_ref "$stash" + then + drop_stash "$stash" + else + true + fi } # The default command is "save" if nothing but options are given
-- 1.6.5.rc3.8.g8ba5e