diff options
author | Paul-Sebastian Ungureanu <ungureanupaulsebastian@gmail.com> | 2019-02-25 23:16:19 +0000 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2019-03-07 09:41:40 +0900 |
commit | 130f2697daf60f09a15884a4510b4fa0230eee98 (patch) | |
tree | 940f22d481d6ddc74c25b3514be6980079df38ad /builtin/stash--helper.c | |
parent | stash: convert pop to builtin (diff) | |
download | tgif-130f2697daf60f09a15884a4510b4fa0230eee98.tar.xz |
stash: convert list to builtin
Add stash list to the helper and delete the list_stash function
from the shell script.
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/stash--helper.c')
-rw-r--r-- | builtin/stash--helper.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/builtin/stash--helper.c b/builtin/stash--helper.c index 63e1e84e78..f296224577 100644 --- a/builtin/stash--helper.c +++ b/builtin/stash--helper.c @@ -12,6 +12,7 @@ #include "rerere.h" static const char * const git_stash_helper_usage[] = { + N_("git stash--helper list [<options>]"), N_("git stash--helper drop [-q|--quiet] [<stash>]"), N_("git stash--helper ( pop | apply ) [--index] [-q|--quiet] [<stash>]"), N_("git stash--helper branch <branchname> [<stash>]"), @@ -19,6 +20,11 @@ static const char * const git_stash_helper_usage[] = { NULL }; +static const char * const git_stash_helper_list_usage[] = { + N_("git stash--helper list [<options>]"), + NULL +}; + static const char * const git_stash_helper_drop_usage[] = { N_("git stash--helper drop [-q|--quiet] [<stash>]"), NULL @@ -615,6 +621,29 @@ static int branch_stash(int argc, const char **argv, const char *prefix) return ret; } +static int list_stash(int argc, const char **argv, const char *prefix) +{ + struct child_process cp = CHILD_PROCESS_INIT; + struct option options[] = { + OPT_END() + }; + + argc = parse_options(argc, argv, prefix, options, + git_stash_helper_list_usage, + PARSE_OPT_KEEP_UNKNOWN); + + if (!ref_exists(ref_stash)) + return 0; + + cp.git_cmd = 1; + argv_array_pushl(&cp.args, "log", "--format=%gd: %gs", "-g", + "--first-parent", "-m", NULL); + argv_array_pushv(&cp.args, argv); + argv_array_push(&cp.args, ref_stash); + argv_array_push(&cp.args, "--"); + return run_command(&cp); +} + int cmd_stash__helper(int argc, const char **argv, const char *prefix) { pid_t pid = getpid(); @@ -645,6 +674,8 @@ int cmd_stash__helper(int argc, const char **argv, const char *prefix) return !!pop_stash(argc, argv, prefix); else if (!strcmp(argv[0], "branch")) return !!branch_stash(argc, argv, prefix); + else if (!strcmp(argv[0], "list")) + return !!list_stash(argc, argv, prefix); usage_msg_opt(xstrfmt(_("unknown subcommand: %s"), argv[0]), git_stash_helper_usage, options); |