summaryrefslogtreecommitdiff
path: root/git-stash.sh
diff options
context:
space:
mode:
authorLibravatar Shawn O. Pearce <spearce@spearce.org>2008-09-29 10:52:34 -0700
committerLibravatar Shawn O. Pearce <spearce@spearce.org>2008-09-29 10:52:34 -0700
commit5a139ba483efea47e103fef47afe87157e3bba77 (patch)
tree9b387acffb4bd7b886d2a1b05e18832ad079bff9 /git-stash.sh
parentt4018-diff-funcname: test syntax of builtin xfuncname patterns (diff)
parentMerge branch 'bc/maint-diff-hunk-header-fix' into maint (diff)
downloadtgif-5a139ba483efea47e103fef47afe87157e3bba77.tar.xz
Merge branch 'maint' into bc/master-diff-hunk-header-fix
* maint: (41 commits) Clarify commit error message for unmerged files Use strchrnul() instead of strchr() plus manual workaround Use remove_path from dir.c instead of own implementation Add remove_path: a function to remove as much as possible of a path git-submodule: Fix "Unable to checkout" for the initial 'update' Clarify how the user can satisfy stash's 'dirty state' check. Remove empty directories in recursive merge Documentation: clarify the details of overriding LESS via core.pager Update release notes for 1.6.0.3 checkout: Do not show local changes when in quiet mode for-each-ref: Fix --format=%(subject) for log message without newlines git-stash.sh: don't default to refs/stash if invalid ref supplied maint: check return of split_cmdline to avoid bad config strings builtin-prune.c: prune temporary packs in <object_dir>/pack directory Do not perform cross-directory renames when creating packs Use dashless git commands in setgitperms.perl git-remote: do not use user input in a printf format string make "git remote" report multiple URLs Start draft release notes for 1.6.0.3 git-repack uses --no-repack-object, not --no-repack-delta. ... Conflicts: RelNotes
Diffstat (limited to 'git-stash.sh')
-rwxr-xr-xgit-stash.sh19
1 files changed, 16 insertions, 3 deletions
diff --git a/git-stash.sh b/git-stash.sh
index d799c76378..42f626f9d5 100755
--- a/git-stash.sh
+++ b/git-stash.sh
@@ -144,7 +144,14 @@ show_stash () {
then
flags=--stat
fi
- s=$(git rev-parse --revs-only --no-flags --default $ref_stash "$@")
+
+ if test $# = 0
+ then
+ set x "$ref_stash@{0}"
+ shift
+ fi
+
+ s=$(git rev-parse --revs-only --no-flags "$@")
w_commit=$(git rev-parse --verify "$s") &&
b_commit=$(git rev-parse --verify "$s^") &&
@@ -154,7 +161,7 @@ show_stash () {
apply_stash () {
git update-index -q --refresh &&
git diff-files --quiet --ignore-submodules ||
- die 'Cannot restore on top of a dirty state'
+ die 'Cannot apply to a dirty working tree, please stage your changes'
unstash_index=
case "$1" in
@@ -163,13 +170,19 @@ apply_stash () {
shift
esac
+ if test $# = 0
+ then
+ set x "$ref_stash@{0}"
+ shift
+ fi
+
# current index state
c_tree=$(git write-tree) ||
die 'Cannot apply a stash in the middle of a merge'
# stash records the work tree, and is a merge between the
# base commit (first parent) and the index tree (second parent).
- s=$(git rev-parse --revs-only --no-flags --default $ref_stash "$@") &&
+ s=$(git rev-parse --revs-only --no-flags "$@") &&
w_tree=$(git rev-parse --verify "$s:") &&
b_tree=$(git rev-parse --verify "$s^1:") &&
i_tree=$(git rev-parse --verify "$s^2:") ||