|
12 | 12 | #include "rerere.h"
|
13 | 13 |
|
14 | 14 | static const char * const git_stash_helper_usage[] = {
|
| 15 | + N_("git stash--helper list [<options>]"), |
15 | 16 | N_("git stash--helper drop [-q|--quiet] [<stash>]"),
|
16 | 17 | N_("git stash--helper ( pop | apply ) [--index] [-q|--quiet] [<stash>]"),
|
17 | 18 | N_("git stash--helper branch <branchname> [<stash>]"),
|
18 | 19 | N_("git stash--helper clear"),
|
19 | 20 | NULL
|
20 | 21 | };
|
21 | 22 |
|
| 23 | +static const char * const git_stash_helper_list_usage[] = { |
| 24 | + N_("git stash--helper list [<options>]"), |
| 25 | + NULL |
| 26 | +}; |
| 27 | + |
22 | 28 | static const char * const git_stash_helper_drop_usage[] = {
|
23 | 29 | N_("git stash--helper drop [-q|--quiet] [<stash>]"),
|
24 | 30 | NULL
|
@@ -615,6 +621,29 @@ static int branch_stash(int argc, const char **argv, const char *prefix)
|
615 | 621 | return ret;
|
616 | 622 | }
|
617 | 623 |
|
| 624 | +static int list_stash(int argc, const char **argv, const char *prefix) |
| 625 | +{ |
| 626 | + struct child_process cp = CHILD_PROCESS_INIT; |
| 627 | + struct option options[] = { |
| 628 | + OPT_END() |
| 629 | + }; |
| 630 | + |
| 631 | + argc = parse_options(argc, argv, prefix, options, |
| 632 | + git_stash_helper_list_usage, |
| 633 | + PARSE_OPT_KEEP_UNKNOWN); |
| 634 | + |
| 635 | + if (!ref_exists(ref_stash)) |
| 636 | + return 0; |
| 637 | + |
| 638 | + cp.git_cmd = 1; |
| 639 | + argv_array_pushl(&cp.args, "log", "--format=%gd: %gs", "-g", |
| 640 | + "--first-parent", "-m", NULL); |
| 641 | + argv_array_pushv(&cp.args, argv); |
| 642 | + argv_array_push(&cp.args, ref_stash); |
| 643 | + argv_array_push(&cp.args, "--"); |
| 644 | + return run_command(&cp); |
| 645 | +} |
| 646 | + |
618 | 647 | int cmd_stash__helper(int argc, const char **argv, const char *prefix)
|
619 | 648 | {
|
620 | 649 | pid_t pid = getpid();
|
@@ -645,6 +674,8 @@ int cmd_stash__helper(int argc, const char **argv, const char *prefix)
|
645 | 674 | return !!pop_stash(argc, argv, prefix);
|
646 | 675 | else if (!strcmp(argv[0], "branch"))
|
647 | 676 | return !!branch_stash(argc, argv, prefix);
|
| 677 | + else if (!strcmp(argv[0], "list")) |
| 678 | + return !!list_stash(argc, argv, prefix); |
648 | 679 |
|
649 | 680 | usage_msg_opt(xstrfmt(_("unknown subcommand: %s"), argv[0]),
|
650 | 681 | git_stash_helper_usage, options);
|
|
0 commit comments