From: Junio C Hamano Date: Fri, 21 Mar 2014 19:48:51 +0000 (-0700) Subject: Merge branch 'jc/stash-pop-not-popped' X-Git-Tag: v2.0.0-rc0~78 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/10bdb20d6a6841b22a3327e3e0fbdd6b5521eb96?ds=inline;hp=-c Merge branch 'jc/stash-pop-not-popped' "stash pop", upon failing to apply the stash, refrains from discarding the stash to avoid information loss. Be more explicit in the error message. The wording may want to get a bit more bikeshedding. * jc/stash-pop-not-popped: stash pop: mention we did not drop the stash upon failing to apply --- 10bdb20d6a6841b22a3327e3e0fbdd6b5521eb96 diff --combined git-stash.sh index f0a94abf14,72941be4da..4798bcf0e5 --- a/git-stash.sh +++ b/git-stash.sh @@@ -358,7 -358,7 +358,7 @@@ parse_flags_and_rev( i_tree= u_tree= - REV=$(git rev-parse --no-flags --symbolic "$@") || exit 1 + REV=$(git rev-parse --no-flags --symbolic --sq "$@") || exit 1 FLAGS= for opt @@@ -376,7 -376,7 +376,7 @@@ esac done - set -- $REV + eval set -- $REV case $# in 0) @@@ -391,13 -391,13 +391,13 @@@ ;; esac - REV=$(git rev-parse --quiet --symbolic --verify $1 2>/dev/null) || { + REV=$(git rev-parse --quiet --symbolic --verify "$1" 2>/dev/null) || { reference="$1" die "$(eval_gettext "\$reference is not valid reference")" } - i_commit=$(git rev-parse --quiet --verify $REV^2 2>/dev/null) && - set -- $(git rev-parse $REV $REV^1 $REV: $REV^1: $REV^2: 2>/dev/null) && + i_commit=$(git rev-parse --quiet --verify "$REV^2" 2>/dev/null) && + set -- $(git rev-parse "$REV" "$REV^1" "$REV:" "$REV^1:" "$REV^2:" 2>/dev/null) && s=$1 && w_commit=$1 && b_commit=$2 && @@@ -408,8 -408,8 +408,8 @@@ test "$ref_stash" = "$(git rev-parse --symbolic-full-name "${REV%@*}")" && IS_STASH_REF=t - u_commit=$(git rev-parse --quiet --verify $REV^3 2>/dev/null) && - u_tree=$(git rev-parse $REV^3: 2>/dev/null) + u_commit=$(git rev-parse --quiet --verify "$REV^3" 2>/dev/null) && + u_tree=$(git rev-parse "$REV^3:" 2>/dev/null) } is_stash_like() @@@ -512,8 -512,14 +512,14 @@@ apply_stash () pop_stash() { assert_stash_ref "$@" - apply_stash "$@" && - drop_stash "$@" + if apply_stash "$@" + then + drop_stash "$@" + else + status=$? + say "The stash is kept in case you need it again." + exit $status + fi } drop_stash () {