|
56 | 56 | N_("git stash save [-p | --patch] [-S | --staged] [-k | --[no-]keep-index] [-q | --quiet]\n" \
|
57 | 57 | " [-u | --include-untracked] [-a | --all] [<message>]")
|
58 | 58 | #define BUILTIN_STASH_CREATE_USAGE \
|
59 |
| - N_("git stash create [<message>]") |
| 59 | + N_("git stash create [-u | --include-untracked] [<message>]") |
60 | 60 | #define BUILTIN_STASH_CLEAR_USAGE \
|
61 | 61 | "git stash clear"
|
62 | 62 |
|
@@ -110,6 +110,11 @@ static const char * const git_stash_clear_usage[] = {
|
110 | 110 | NULL
|
111 | 111 | };
|
112 | 112 |
|
| 113 | +static const char * const git_stash_create_usage[] = { |
| 114 | + BUILTIN_STASH_CREATE_USAGE, |
| 115 | + NULL |
| 116 | +}; |
| 117 | + |
113 | 118 | static const char * const git_stash_store_usage[] = {
|
114 | 119 | BUILTIN_STASH_STORE_USAGE,
|
115 | 120 | NULL
|
@@ -1499,22 +1504,28 @@ static int do_create_stash(const struct pathspec *ps, struct strbuf *stash_msg_b
|
1499 | 1504 | return ret;
|
1500 | 1505 | }
|
1501 | 1506 |
|
1502 |
| -static int create_stash(int argc, const char **argv, const char *prefix UNUSED, |
| 1507 | +static int create_stash(int argc, const char **argv, const char *prefix, |
1503 | 1508 | struct repository *repo UNUSED)
|
1504 | 1509 | {
|
1505 | 1510 | int ret;
|
| 1511 | + int include_untracked = 0; |
| 1512 | + struct option options[] = { |
| 1513 | + OPT_BOOL('u', "include-untracked", &include_untracked, |
| 1514 | + N_("include untracked files")), |
| 1515 | + OPT_END() |
| 1516 | + }; |
| 1517 | + |
1506 | 1518 | struct strbuf stash_msg_buf = STRBUF_INIT;
|
1507 | 1519 | struct stash_info info = STASH_INFO_INIT;
|
1508 | 1520 | struct pathspec ps;
|
1509 | 1521 |
|
1510 |
| - /* Starting with argv[1], since argv[0] is "create" */ |
1511 |
| - strbuf_join_argv(&stash_msg_buf, argc - 1, ++argv, ' '); |
| 1522 | + argc = parse_options(argc, argv, prefix, options, git_stash_create_usage, 0); |
| 1523 | + |
| 1524 | + strbuf_join_argv(&stash_msg_buf, argc, argv, ' '); |
1512 | 1525 |
|
1513 | 1526 | memset(&ps, 0, sizeof(ps));
|
1514 |
| - if (!check_changes_tracked_files(&ps)) |
1515 |
| - return 0; |
1516 | 1527 |
|
1517 |
| - ret = do_create_stash(&ps, &stash_msg_buf, 0, 0, 0, &info, |
| 1528 | + ret = do_create_stash(&ps, &stash_msg_buf, include_untracked, 0, 0, &info, |
1518 | 1529 | NULL, 0);
|
1519 | 1530 | if (!ret)
|
1520 | 1531 | printf_ln("%s", oid_to_hex(&info.w_commit));
|
|
0 commit comments