aboutsummaryrefslogtreecommitdiff
path: root/git-stash.sh
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2007-07-04 22:46:09 -0700
committerJunio C Hamano <gitster@pobox.com>2007-07-05 21:47:12 -0700
commit9f62e18a60dd2f636bbdf849f66a00a5906b1cea (patch)
treeaf08c6c2e9f35756c9bd600aa0c0615137b38ac6 /git-stash.sh
parent37ba05619c76f9dbde35c418c6fc8af7bcda24c8 (diff)
downloadgit-9f62e18a60dd2f636bbdf849f66a00a5906b1cea.tar.gz
git-9f62e18a60dd2f636bbdf849f66a00a5906b1cea.tar.xz
git-stash: allow more descriptive reminder message when saving
This allows you to say: $ git stash starting to implement X while creating a stash, and the resulting "stash list entry would read as: $ git stash list stash@{0}: On master: starting to implement X instead of the default message which talks about the commit the stash happens to be based on (hence does not have much to do with what the stashed change is trying to do). Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'git-stash.sh')
-rwxr-xr-xgit-stash.sh25
1 files changed, 19 insertions, 6 deletions
diff --git a/git-stash.sh b/git-stash.sh
index fa8ae7bc2..f01494dc1 100755
--- a/git-stash.sh
+++ b/git-stash.sh
@@ -23,6 +23,8 @@ clear_stash () {
}
save_stash () {
+ stash_msg="$1"
+
if no_changes
then
echo >&2 'No local changes to save'
@@ -67,13 +69,19 @@ save_stash () {
die "Cannot save the current worktree state"
# create the stash
- w_commit=$(printf 'WIP on %s\n' "$msg" |
+ if test -z "$stash_msg"
+ then
+ stash_msg=$(printf 'WIP on %s' "$msg")
+ else
+ stash_msg=$(printf 'On %s: %s' "$branch" "$stash_msg")
+ fi
+ w_commit=$(printf '%s\n' "$stash_msg" |
git commit-tree $w_tree -p $b_commit -p $i_commit) ||
die "Cannot record working tree state"
- git update-ref -m "WIP on $msg" $ref_stash $w_commit ||
+ git update-ref -m "$stash_msg" $ref_stash $w_commit ||
die "Cannot save the current status"
- printf >&2 'Saved WIP on %s\n' "$msg"
+ printf >&2 'Saved "%s"\n' "$stash_msg"
}
have_stash () {
@@ -157,9 +165,14 @@ apply)
clear)
clear_stash
;;
-save | '')
- save_stash && git-reset --hard
+help | usage)
+ usage
;;
*)
- usage
+ if test $# -gt 0 && test "$1" = save
+ then
+ shift
+ fi
+ save_stash "$*" && git-reset --hard
+ ;;
esac