die "$(gettext "Cannot record working tree state")"
}
-store_stash () {
- while test $# != 0
- do
- case "$1" in
- -m|--message)
- shift
- stash_msg="$1"
- ;;
- -m*)
- stash_msg=${1#-m}
- ;;
- --message=*)
- stash_msg=${1#--message=}
- ;;
- -q|--quiet)
- quiet=t
- ;;
- *)
- break
- ;;
- esac
- shift
- done
- test $# = 1 ||
- die "$(eval_gettext "\"$dashless store\" requires one <commit> argument")"
-
- w_commit="$1"
- if test -z "$stash_msg"
- then
- stash_msg="Created via \"git stash store\"."
- fi
-
- git update-ref --create-reflog -m "$stash_msg" $ref_stash $w_commit
- ret=$?
- test $ret != 0 && test -z "$quiet" &&
- die "$(eval_gettext "Cannot update \$ref_stash with \$w_commit")"
- return $ret
-}
-
push_stash () {
keep_index=
patch_mode=
clear_stash || die "$(gettext "Cannot initialize stash")"
create_stash -m "$stash_msg" -u "$untracked" -- "$@"
- store_stash -m "$stash_msg" -q $w_commit ||
+ git stash--helper store -m "$stash_msg" -q $w_commit ||
die "$(gettext "Cannot save the current status")"
say "$(eval_gettext "Saved working directory and index state \$stash_msg")"
fi
}
-have_stash () {
- git rev-parse --verify --quiet $ref_stash >/dev/null
-}
-
-list_stash () {
- have_stash || return 0
- git log --format="%gd: %gs" -g --first-parent -m "$@" $ref_stash --
-}
-
-show_stash () {
- ALLOW_UNKNOWN_FLAGS=t
- assert_stash_like "$@"
-
- if test -z "$FLAGS"
- then
- if test "$(git config --bool stash.showStat || echo true)" = "true"
- then
- FLAGS=--stat
- fi
-
- if test "$(git config --bool stash.showPatch || echo false)" = "true"
- then
- FLAGS=${FLAGS}${FLAGS:+ }-p
- fi
-
- if test -z "$FLAGS"
- then
- return 0
- fi
- fi
-
- git diff ${FLAGS} $b_commit $w_commit
-}
-
show_help () {
exec git help stash
exit 1
# * unknown flags were set and ALLOW_UNKNOWN_FLAGS is not "t"
#
-parse_flags_and_rev()
-{
- test "$PARSE_CACHE" = "$*" && return 0 # optimisation
- PARSE_CACHE="$*"
-
- IS_STASH_LIKE=
- IS_STASH_REF=
- INDEX_OPTION=
- s=
- w_commit=
- b_commit=
- i_commit=
- u_commit=
- w_tree=
- b_tree=
- i_tree=
- u_tree=
-
- FLAGS=
- REV=
- for opt
- do
- case "$opt" in
- -q|--quiet)
- GIT_QUIET=-t
- ;;
- --index)
- INDEX_OPTION=--index
- ;;
- --help)
- show_help
- ;;
- -*)
- test "$ALLOW_UNKNOWN_FLAGS" = t ||
- die "$(eval_gettext "unknown option: \$opt")"
- FLAGS="${FLAGS}${FLAGS:+ }$opt"
- ;;
- *)
- REV="${REV}${REV:+ }'$opt'"
- ;;
- esac
- done
-
- eval set -- $REV
-
- case $# in
- 0)
- have_stash || die "$(gettext "No stash entries found.")"
- set -- ${ref_stash}@{0}
- ;;
- 1)
- :
- ;;
- *)
- die "$(eval_gettext "Too many revisions specified: \$REV")"
- ;;
- esac
-
- case "$1" in
- *[!0-9]*)
- :
- ;;
- *)
- set -- "${ref_stash}@{$1}"
- ;;
- esac
-
- REV=$(git rev-parse --symbolic --verify --quiet "$1") || {
- reference="$1"
- die "$(eval_gettext "\$reference is not a valid reference")"
- }
-
- i_commit=$(git rev-parse --verify --quiet "$REV^2") &&
- set -- $(git rev-parse "$REV" "$REV^1" "$REV:" "$REV^1:" "$REV^2:" 2>/dev/null) &&
- s=$1 &&
- w_commit=$1 &&
- b_commit=$2 &&
- w_tree=$3 &&
- b_tree=$4 &&
- i_tree=$5 &&
- IS_STASH_LIKE=t &&
- test "$ref_stash" = "$(git rev-parse --symbolic-full-name "${REV%@*}")" &&
- IS_STASH_REF=t
-
- u_commit=$(git rev-parse --verify --quiet "$REV^3") &&
- u_tree=$(git rev-parse "$REV^3:" 2>/dev/null)
-}
-
-is_stash_like()
-{
- parse_flags_and_rev "$@"
- test -n "$IS_STASH_LIKE"
-}
-
-assert_stash_like() {
- is_stash_like "$@" || {
- args="$*"
- die "$(eval_gettext "'\$args' is not a stash-like commit")"
- }
-}
-
test "$1" = "-p" && set "push" "$@"
PARSE_CACHE='--not-parsed'
case "$1" in
list)
shift
- list_stash "$@"
+ git stash--helper list "$@"
;;
show)
shift
- show_stash "$@"
+ git stash--helper show "$@"
;;
save)
shift
;;
create)
shift
- create_stash -m "$*" && echo "$w_commit"
+ git stash--helper create --message "$*"
;;
store)
shift
- store_stash "$@"
+ git stash--helper store "$@"
;;
drop)
shift