summaryrefslogtreecommitdiff
path: root/git-stash.sh
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2008-07-13 22:16:09 (GMT)
committerJunio C Hamano <gitster@pobox.com>2008-07-13 22:16:09 (GMT)
commit671d3220359145edd1002dc0afe76bc5782597f3 (patch)
treed79dad70ad5ae378362aec6d4d3b1c8f12f02c60 /git-stash.sh
parent15fc1c02fce2ee6a8a3f625bf24dd782fd905904 (diff)
parent4a588075c54cd5902e5f4d43b9d6b0c31d0f9769 (diff)
downloadgit-671d3220359145edd1002dc0afe76bc5782597f3.zip
git-671d3220359145edd1002dc0afe76bc5782597f3.tar.gz
git-671d3220359145edd1002dc0afe76bc5782597f3.tar.bz2
Merge branch 'am/stash-branch'
* am/stash-branch: Add a test for "git stash branch" Implement "git stash branch <newbranch> <stash>"
Diffstat (limited to 'git-stash.sh')
-rwxr-xr-xgit-stash.sh21
1 files changed, 21 insertions, 0 deletions
diff --git a/git-stash.sh b/git-stash.sh
index 92531a2..e4cb6c3 100755
--- a/git-stash.sh
+++ b/git-stash.sh
@@ -233,6 +233,23 @@ drop_stash () {
git rev-parse --verify "$ref_stash@{0}" > /dev/null 2>&1 || clear_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}"
+ fi
+ stash=$2
+
+ git-checkout -b $branch $stash^ &&
+ apply_stash --index $stash &&
+ drop_stash $stash
+}
+
# Main command set
case "$1" in
list)
@@ -279,6 +296,10 @@ pop)
drop_stash "$@"
fi
;;
+branch)
+ shift
+ apply_to_branch "$@"
+ ;;
*)
if test $# -eq 0
then