2007-06-30 07:37:09 +02:00
|
|
|
#!/bin/sh
|
|
|
|
# Copyright (c) 2007, Nanako Shiraishi
|
|
|
|
|
2008-08-16 05:27:31 +02:00
|
|
|
dashless=$(basename "$0" | sed -e 's/-/ /')
|
|
|
|
USAGE="list [<options>]
|
2009-06-18 03:07:37 +02:00
|
|
|
or: $dashless show [<stash>]
|
|
|
|
or: $dashless drop [-q|--quiet] [<stash>]
|
|
|
|
or: $dashless ( pop | apply ) [--index] [-q|--quiet] [<stash>]
|
2008-08-16 05:27:31 +02:00
|
|
|
or: $dashless branch <branchname> [<stash>]
|
2017-02-28 21:33:39 +01:00
|
|
|
or: $dashless save [--patch] [-k|--[no-]keep-index] [-q|--quiet]
|
|
|
|
[-u|--include-untracked] [-a|--all] [<message>]
|
|
|
|
or: $dashless [push [--patch] [-k|--[no-]keep-index] [-q|--quiet]
|
|
|
|
[-u|--include-untracked] [-a|--all] [-m <message>]
|
|
|
|
[-- <pathspec>...]]
|
2008-08-16 05:27:31 +02:00
|
|
|
or: $dashless clear"
|
2007-06-30 07:37:09 +02:00
|
|
|
|
2007-07-06 21:57:47 +02:00
|
|
|
SUBDIRECTORY_OK=Yes
|
2007-11-06 10:50:02 +01:00
|
|
|
OPTIONS_SPEC=
|
2014-04-23 15:44:01 +02:00
|
|
|
START_DIR=$(pwd)
|
2007-06-30 07:37:09 +02:00
|
|
|
. git-sh-setup
|
|
|
|
require_work_tree
|
2017-06-13 13:38:34 +02:00
|
|
|
prefix=$(git rev-parse --show-prefix) || exit 1
|
2007-07-26 00:32:22 +02:00
|
|
|
cd_to_toplevel
|
2007-06-30 07:37:09 +02:00
|
|
|
|
|
|
|
TMP="$GIT_DIR/.git-stash.$$"
|
2014-11-30 09:24:32 +01:00
|
|
|
TMPindex=${GIT_INDEX_FILE-"$(git rev-parse --git-path index)"}.stash.$$
|
2011-03-16 09:18:49 +01:00
|
|
|
trap 'rm -f "$TMP-"* "$TMPindex"' 0
|
2007-06-30 07:37:09 +02:00
|
|
|
|
|
|
|
ref_stash=refs/stash
|
|
|
|
|
2009-08-13 14:29:44 +02:00
|
|
|
if git config --get-colorbool color.interactive; then
|
|
|
|
help_color="$(git config --get-color color.interactive.help 'red bold')"
|
|
|
|
reset_color="$(git config --get-color '' reset)"
|
|
|
|
else
|
|
|
|
help_color=
|
|
|
|
reset_color=
|
|
|
|
fi
|
|
|
|
|
2010-08-21 06:46:22 +02:00
|
|
|
#
|
|
|
|
# Parses the remaining options looking for flags and
|
|
|
|
# at most one revision defaulting to ${ref_stash}@{0}
|
|
|
|
# if none found.
|
|
|
|
#
|
|
|
|
# Derives related tree and commit objects from the
|
|
|
|
# revision, if one is found.
|
|
|
|
#
|
|
|
|
# stash records the work tree, and is a merge between the
|
|
|
|
# base commit (first parent) and the index tree (second parent).
|
|
|
|
#
|
|
|
|
# REV is set to the symbolic version of the specified stash-like commit
|
|
|
|
# IS_STASH_LIKE is non-blank if ${REV} looks like a stash
|
|
|
|
# IS_STASH_REF is non-blank if the ${REV} looks like a stash ref
|
|
|
|
# s is set to the SHA1 of the stash commit
|
|
|
|
# w_commit is set to the commit containing the working tree
|
|
|
|
# b_commit is set to the base commit
|
|
|
|
# i_commit is set to the commit containing the index tree
|
2011-06-25 02:56:06 +02:00
|
|
|
# u_commit is set to the commit containing the untracked files tree
|
2010-08-21 06:46:22 +02:00
|
|
|
# w_tree is set to the working tree
|
|
|
|
# b_tree is set to the base tree
|
|
|
|
# i_tree is set to the index tree
|
2011-06-25 02:56:06 +02:00
|
|
|
# u_tree is set to the untracked files tree
|
2010-08-21 06:46:22 +02:00
|
|
|
#
|
|
|
|
# GIT_QUIET is set to t if -q is specified
|
|
|
|
# INDEX_OPTION is set to --index if --index is specified.
|
2015-05-20 20:01:32 +02:00
|
|
|
# FLAGS is set to the remaining flags (if allowed)
|
2010-08-21 06:46:22 +02:00
|
|
|
#
|
|
|
|
# dies if:
|
|
|
|
# * too many revisions specified
|
|
|
|
# * no revision is specified and there is no stash stack
|
|
|
|
# * a revision is specified which cannot be resolve to a SHA1
|
|
|
|
# * a non-existent stash reference is specified
|
2015-05-20 20:01:32 +02:00
|
|
|
# * unknown flags were set and ALLOW_UNKNOWN_FLAGS is not "t"
|
2010-08-21 06:46:22 +02:00
|
|
|
#
|
|
|
|
|
2017-02-28 21:33:40 +01:00
|
|
|
test "$1" = "-p" && set "push" "$@"
|
|
|
|
|
2010-08-21 06:46:22 +02:00
|
|
|
PARSE_CACHE='--not-parsed'
|
2017-02-28 21:33:39 +01:00
|
|
|
# The default command is "push" if nothing but options are given
|
2009-08-18 23:38:40 +02:00
|
|
|
seen_non_option=
|
|
|
|
for opt
|
|
|
|
do
|
|
|
|
case "$opt" in
|
2017-02-28 21:33:40 +01:00
|
|
|
--) break ;;
|
2009-08-18 23:38:40 +02:00
|
|
|
-*) ;;
|
|
|
|
*) seen_non_option=t; break ;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
2017-02-28 21:33:39 +01:00
|
|
|
test -n "$seen_non_option" || set "push" "$@"
|
2009-08-18 23:38:40 +02:00
|
|
|
|
2007-06-30 07:37:09 +02:00
|
|
|
# Main command set
|
|
|
|
case "$1" in
|
2007-07-03 08:15:45 +02:00
|
|
|
list)
|
|
|
|
shift
|
2019-02-26 00:16:19 +01:00
|
|
|
git stash--helper list "$@"
|
2007-06-30 07:37:09 +02:00
|
|
|
;;
|
|
|
|
show)
|
|
|
|
shift
|
2019-02-26 00:16:20 +01:00
|
|
|
git stash--helper show "$@"
|
2007-06-30 07:37:09 +02:00
|
|
|
;;
|
2007-12-03 03:34:05 +01:00
|
|
|
save)
|
|
|
|
shift
|
2019-02-26 00:16:25 +01:00
|
|
|
cd "$START_DIR"
|
|
|
|
git stash--helper save "$@"
|
2007-12-03 03:34:05 +01:00
|
|
|
;;
|
2017-02-19 12:03:08 +01:00
|
|
|
push)
|
|
|
|
shift
|
2019-02-26 00:16:23 +01:00
|
|
|
cd "$START_DIR"
|
|
|
|
git stash--helper push "$@"
|
2017-02-19 12:03:08 +01:00
|
|
|
;;
|
2007-06-30 07:37:09 +02:00
|
|
|
apply)
|
|
|
|
shift
|
2019-02-26 00:16:15 +01:00
|
|
|
cd "$START_DIR"
|
|
|
|
git stash--helper apply "$@"
|
2007-06-30 07:37:09 +02:00
|
|
|
;;
|
|
|
|
clear)
|
2008-01-05 10:35:54 +01:00
|
|
|
shift
|
2019-02-26 00:16:16 +01:00
|
|
|
git stash--helper clear "$@"
|
2007-06-30 07:37:09 +02:00
|
|
|
;;
|
2007-07-08 10:38:32 +02:00
|
|
|
create)
|
2013-06-15 15:13:24 +02:00
|
|
|
shift
|
2019-02-26 00:16:22 +01:00
|
|
|
git stash--helper create --message "$*"
|
2007-07-08 10:38:32 +02:00
|
|
|
;;
|
2013-06-15 15:13:25 +02:00
|
|
|
store)
|
|
|
|
shift
|
2019-02-26 00:16:21 +01:00
|
|
|
git stash--helper store "$@"
|
2013-06-15 15:13:25 +02:00
|
|
|
;;
|
2008-02-22 20:04:54 +01:00
|
|
|
drop)
|
|
|
|
shift
|
2019-02-26 00:16:16 +01:00
|
|
|
git stash--helper drop "$@"
|
2008-02-22 20:04:54 +01:00
|
|
|
;;
|
2008-02-22 23:52:50 +01:00
|
|
|
pop)
|
|
|
|
shift
|
2019-02-26 00:16:18 +01:00
|
|
|
cd "$START_DIR"
|
|
|
|
git stash--helper pop "$@"
|
2008-02-22 23:52:50 +01:00
|
|
|
;;
|
2008-07-03 08:16:05 +02:00
|
|
|
branch)
|
|
|
|
shift
|
2019-02-26 00:16:17 +01:00
|
|
|
cd "$START_DIR"
|
|
|
|
git stash--helper branch "$@"
|
2008-07-03 08:16:05 +02:00
|
|
|
;;
|
2007-06-30 07:37:09 +02:00
|
|
|
*)
|
2009-08-18 23:38:40 +02:00
|
|
|
case $# in
|
|
|
|
0)
|
2019-02-26 00:16:23 +01:00
|
|
|
cd "$START_DIR"
|
|
|
|
git stash--helper push &&
|
2011-05-21 20:44:12 +02:00
|
|
|
say "$(gettext "(To restore them type \"git stash apply\")")"
|
2009-07-27 20:37:10 +02:00
|
|
|
;;
|
|
|
|
*)
|
2007-12-03 03:34:05 +01:00
|
|
|
usage
|
2009-07-27 20:37:10 +02:00
|
|
|
esac
|
2007-07-05 07:46:09 +02:00
|
|
|
;;
|
2007-06-30 07:37:09 +02:00
|
|
|
esac
|