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