Add stash save to the helper and delete functions which are no
longer needed (`show_help()`, `save_stash()`, `push_stash()`,
`create_stash()`, `clear_stash()`, `untracked_files()` and
`no_changes()`).
The `-m` option is no longer supported as it might not make
sense to have two ways of passing a message. Even if this is
a change in behaviour, the documentation remains the same
because the `-m` parameter was omitted before.
Signed-off-by: Paul-Sebastian Ungureanu
---
builtin/stash--helper.c | 52 +++
git-stash.sh| 311 +---
2 files changed, 54 insertions(+), 309 deletions(-)
diff --git a/builtin/stash--helper.c b/builtin/stash--helper.c
index befb944871..a0413f5d00 100644
--- a/builtin/stash--helper.c
+++ b/builtin/stash--helper.c
@@ -26,6 +26,8 @@ static const char * const git_stash_helper_usage[] = {
N_("git stash--helper [push [-p|--patch] [-k|--[no-]keep-index]
[-q|--quiet]\n"
" [-u|--include-untracked] [-a|--all] [-m|--message
]\n"
" [--] [...]]"),
+ N_("git stash--helper save [-p|--patch] [-k|--[no-]keep-index]
[-q|--quiet]\n"
+ " [-u|--include-untracked] [-a|--all] []"),
NULL
};
@@ -81,6 +83,12 @@ static const char * const git_stash_helper_push_usage[] = {
NULL
};
+static const char * const git_stash_helper_save_usage[] = {
+ N_("git stash--helper save [-p|--patch] [-k|--[no-]keep-index]
[-q|--quiet]\n"
+ " [-u|--include-untracked] [-a|--all] []"),
+ NULL
+};
+
static const char *ref_stash = "refs/stash";
static struct strbuf stash_index_path = STRBUF_INIT;
@@ -1496,6 +1504,48 @@ static int push_stash(int argc, const char **argv, const
char *prefix)
keep_index, patch_mode, include_untracked);
}
+static int save_stash(int argc, const char **argv, const char *prefix)
+{
+ int keep_index = -1;
+ int patch_mode = 0;
+ int include_untracked = 0;
+ int quiet = 0;
+ int ret = 0;
+ char *stash_msg = NULL;
+ struct pathspec ps;
+ struct strbuf buf = STRBUF_INIT;
+ struct option options[] = {
+ OPT_BOOL('k', "keep-index", _index,
+N_("keep index")),
+ OPT_BOOL('p', "patch", _mode,
+N_("stash in patch mode")),
+ OPT__QUIET(, N_("quiet mode")),
+ OPT_BOOL('u', "include-untracked", _untracked,
+N_("include untracked files in stash")),
+ OPT_SET_INT('a', "all", _untracked,
+ N_("include ignore files"), 2),
+ OPT_STRING('m', "message", _msg, "message",
+ N_("stash message")),
+ OPT_END()
+ };
+
+ argc = parse_options(argc, argv, prefix, options,
+git_stash_helper_save_usage,
+PARSE_OPT_KEEP_DASHDASH);
+
+ if (argc) {
+ strbuf_join_argv(, argc, argv, ' ');
+ stash_msg = buf.buf;
+ }
+
+ memset(, 0, sizeof(ps));
+ ret = do_push_stash(ps, stash_msg, quiet, keep_index, patch_mode,
+ include_untracked);
+
+ strbuf_release();
+ return ret;
+}
+
int cmd_stash__helper(int argc, const char **argv, const char *prefix)
{
pid_t pid = getpid();
@@ -1536,6 +1586,8 @@ int cmd_stash__helper(int argc, const char **argv, const
char *prefix)
return !!create_stash(argc, argv, prefix);
else if (!strcmp(argv[0], "push"))
return !!push_stash(argc, argv, prefix);
+ else if (!strcmp(argv[0], "save"))
+ return !!save_stash(argc, argv, prefix);
usage_msg_opt(xstrfmt(_("unknown subcommand: %s"), argv[0]),
git_stash_helper_usage, options);
diff --git a/git-stash.sh b/git-stash.sh
index c3146f62ab..695f1feba3 100755
--- a/git-stash.sh
+++ b/git-stash.sh
@@ -36,314 +36,6 @@ else
reset_color=
fi
-no_changes () {
- git diff-index --quiet --cached HEAD --ignore-submodules -- "$@" &&
- git diff-files --quiet --ignore-submodules -- "$@" &&
- (test -z "$untracked" || test -z "$(untracked_files "$@")")
-}
-
-untracked_files () {
- if test "$1" = "-z"
- then
- shift
- z=-z
- else
- z=
- fi
- excl_opt=--exclude-standard
- test "$untracked" = "all" && excl_opt=
- git ls-files -o $z $excl_opt -- "$@"
-}
-
-clear_stash () {
- if test $# != 0
- then
- die "$(gettext "git stash clear with parameters is
unimplemented")"
- fi
- if current=$(git rev-parse --verify --quiet $ref_stash)
- then
- git update-ref -d $ref_stash $current
- fi
-}
-
-create_stash () {
- stash_msg=
- untracked=
- while test $# != 0
- do
-