summaryrefslogtreecommitdiff
path: root/builtin
diff options
context:
space:
mode:
authorLibravatar Joel Teichroeb <joel@teichroeb.net>2019-02-25 23:16:18 +0000
committerLibravatar Junio C Hamano <gitster@pobox.com>2019-03-07 09:41:40 +0900
commitc4de61d7a95ebb7197191bc51475d19068b6d526 (patch)
tree3acbbd5c77c4d8207cc506ff19a83644fb0d47e4 /builtin
parentstash: convert branch to builtin (diff)
downloadtgif-c4de61d7a95ebb7197191bc51475d19068b6d526.tar.xz
stash: convert pop to builtin
Add stash pop to the helper and delete the pop_stash, drop_stash, assert_stash_ref functions from the shell script now that they are no longer needed. Signed-off-by: Joel Teichroeb <joel@teichroeb.net> Signed-off-by: Paul-Sebastian Ungureanu <ungureanupaulsebastian@gmail.com> Signed-off-by: Thomas Gummerer <t.gummerer@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin')
-rw-r--r--builtin/stash--helper.c39
1 files changed, 38 insertions, 1 deletions
diff --git a/builtin/stash--helper.c b/builtin/stash--helper.c
index c9874e2f5d..63e1e84e78 100644
--- a/builtin/stash--helper.c
+++ b/builtin/stash--helper.c
@@ -13,7 +13,7 @@
static const char * const git_stash_helper_usage[] = {
N_("git stash--helper drop [-q|--quiet] [<stash>]"),
- N_("git stash--helper apply [--index] [-q|--quiet] [<stash>]"),
+ N_("git stash--helper ( pop | apply ) [--index] [-q|--quiet] [<stash>]"),
N_("git stash--helper branch <branchname> [<stash>]"),
N_("git stash--helper clear"),
NULL
@@ -24,6 +24,11 @@ static const char * const git_stash_helper_drop_usage[] = {
NULL
};
+static const char * const git_stash_helper_pop_usage[] = {
+ N_("git stash--helper pop [--index] [-q|--quiet] [<stash>]"),
+ NULL
+};
+
static const char * const git_stash_helper_apply_usage[] = {
N_("git stash--helper apply [--index] [-q|--quiet] [<stash>]"),
NULL
@@ -542,6 +547,36 @@ static int drop_stash(int argc, const char **argv, const char *prefix)
return ret;
}
+static int pop_stash(int argc, const char **argv, const char *prefix)
+{
+ int ret;
+ int index = 0;
+ int quiet = 0;
+ struct stash_info info;
+ struct option options[] = {
+ OPT__QUIET(&quiet, N_("be quiet, only report errors")),
+ OPT_BOOL(0, "index", &index,
+ N_("attempt to recreate the index")),
+ OPT_END()
+ };
+
+ argc = parse_options(argc, argv, prefix, options,
+ git_stash_helper_pop_usage, 0);
+
+ if (get_stash_info(&info, argc, argv))
+ return -1;
+
+ assert_stash_ref(&info);
+ if ((ret = do_apply_stash(prefix, &info, index, quiet)))
+ printf_ln(_("The stash entry is kept in case "
+ "you need it again."));
+ else
+ ret = do_drop_stash(prefix, &info, quiet);
+
+ free_stash_info(&info);
+ return ret;
+}
+
static int branch_stash(int argc, const char **argv, const char *prefix)
{
int ret;
@@ -606,6 +641,8 @@ int cmd_stash__helper(int argc, const char **argv, const char *prefix)
return !!clear_stash(argc, argv, prefix);
else if (!strcmp(argv[0], "drop"))
return !!drop_stash(argc, argv, prefix);
+ else if (!strcmp(argv[0], "pop"))
+ return !!pop_stash(argc, argv, prefix);
else if (!strcmp(argv[0], "branch"))
return !!branch_stash(argc, argv, prefix);