diff options
author | Junio C Hamano <gitster@pobox.com> | 2007-11-14 14:05:47 -0800 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2007-11-14 14:05:47 -0800 |
commit | 5e389c430d232e8b1a16e7357596328985111eab (patch) | |
tree | cec4f0c0e6281c537798c61be9127d0ee0ac9175 /git-stash.sh | |
parent | 55571f7861b81b033b378f3abe145ecbdbc1fdb6 (diff) | |
parent | a9ee9bf9f9840498f2369ebafe6c220deb4327fd (diff) | |
download | git-5e389c430d232e8b1a16e7357596328985111eab.tar.gz |
Merge branch 'jc/stash-create'
* jc/stash-create:
git-stash: Fix listing stashes
git-merge: no reason to use cpio anymore
Revert "rebase: allow starting from a dirty tree."
rebase: allow starting from a dirty tree.
stash: implement "stash create"
Diffstat (limited to 'git-stash.sh')
-rwxr-xr-x | git-stash.sh | 34 |
1 files changed, 26 insertions, 8 deletions
diff --git a/git-stash.sh b/git-stash.sh index 5bbda47b7b..1c8b7f9259 100755 --- a/git-stash.sh +++ b/git-stash.sh @@ -21,23 +21,17 @@ no_changes () { clear_stash () { if current=$(git rev-parse --verify $ref_stash 2>/dev/null) then - git update-ref -d refs/stash $current + git update-ref -d $ref_stash $current fi } -save_stash () { +create_stash () { stash_msg="$1" if no_changes then - echo >&2 'No local changes to save' exit 0 fi - test -f "$GIT_DIR/logs/$ref_stash" || - clear_stash || die "Cannot initialize stash" - - # Make sure the reflog for stash is kept. - : >>"$GIT_DIR/logs/$ref_stash" # state of the base commit if b_commit=$(git rev-parse --verify HEAD) @@ -84,6 +78,23 @@ save_stash () { w_commit=$(printf '%s\n' "$stash_msg" | git commit-tree $w_tree -p $b_commit -p $i_commit) || die "Cannot record working tree state" +} + +save_stash () { + stash_msg="$1" + + if no_changes + then + echo >&2 'No local changes to save' + exit 0 + fi + test -f "$GIT_DIR/logs/$ref_stash" || + clear_stash || die "Cannot initialize stash" + + create_stash "$stash_msg" + + # Make sure the reflog for stash is kept. + : >>"$GIT_DIR/logs/$ref_stash" git update-ref -m "$stash_msg" $ref_stash $w_commit || die "Cannot save the current status" @@ -202,6 +213,13 @@ apply) clear) clear_stash ;; +create) + if test $# -gt 0 && test "$1" = create + then + shift + fi + create_stash "$*" && echo "$w_commit" + ;; help | usage) usage ;; |