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>
Junio C Hamano committed
Jul 4, 2007 at 22:46 UTC
9f62e18a60dd2f636bbdf849f66a00a5906b1cea
1 file changed
+19
-6
git-stash.sh
+19
-6
@@ -23,6 +23,8 @@ clear_stash () {
23
}
24
25
save_stash () {
26
+ stash_msg="$1"
27
+
28
if no_changes
29
then
30
echo >&2 'No local changes to save'
@@ -67,13 +69,19 @@ save_stash () {
69
die "Cannot save the current worktree state"
70
71
# create the stash
70
- w_commit=$(printf 'WIP on %s\n' "$msg" |
72
+ if test -z "$stash_msg"
73
+ then
74
+ stash_msg=$(printf 'WIP on %s' "$msg")
75
+ else
76
+ stash_msg=$(printf 'On %s: %s' "$branch" "$stash_msg")
77
+ fi
78
+ w_commit=$(printf '%s\n' "$stash_msg" |
79
git commit-tree $w_tree -p $b_commit -p $i_commit) ||
80
die "Cannot record working tree state"
81
74
- git update-ref -m "WIP on $msg" $ref_stash $w_commit ||
82
+ git update-ref -m "$stash_msg" $ref_stash $w_commit ||
83
die "Cannot save the current status"
76
- printf >&2 'Saved WIP on %s\n' "$msg"
84
+ printf >&2 'Saved "%s"\n' "$stash_msg"
85
}
86
87
have_stash () {
@@ -157,9 +165,14 @@ apply)
165
clear)
166
clear_stash
167
;;
160
-save | '')
161
- save_stash && git-reset --hard
168
+help | usage)
169
+ usage
170
;;
171
*)
164
- usage
172
+ if test $# -gt 0 && test "$1" = save
173
+ then
174
+ shift
175
+ fi
176
+ save_stash "$*" && git-reset --hard
177
+ ;;
178
esac