diff options
author | Nguyễn Thái Ngọc Duy <pclouds@gmail.com> | 2019-03-29 11:39:04 +0100 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2019-04-02 06:56:59 +0200 |
commit | 208718227207480b0f58e35e045e36ed36a59205 (patch) | |
tree | 0a79f4b7e5bac50b7fbab27f6aafd316a0a2cf5a /parse-options-cb.c | |
parent | checkout: move 'confict_style' and 'dwim_..' to checkout_opts (diff) | |
download | git-208718227207480b0f58e35e045e36ed36a59205.tar.xz git-208718227207480b0f58e35e045e36ed36a59205.zip |
checkout: split options[] array in three pieces
This is a preparation step for introducing new commands that do parts
of what checkout does. There will be two new commands, one is about
switching branches, detaching HEAD... one about checking out
paths. These share the a subset of command line options. The rest of
command line options are separate.
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'parse-options-cb.c')
-rw-r--r-- | parse-options-cb.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/parse-options-cb.c b/parse-options-cb.c index 2733393546..caaeed896f 100644 --- a/parse-options-cb.c +++ b/parse-options-cb.c @@ -122,6 +122,23 @@ int parse_opt_tertiary(const struct option *opt, const char *arg, int unset) return 0; } +struct option *parse_options_dup(const struct option *o) +{ + struct option *opts; + int nr = 0; + + while (o && o->type != OPTION_END) { + nr++; + o++; + } + + ALLOC_ARRAY(opts, nr + 1); + memcpy(opts, o - nr, sizeof(*o) * nr); + memset(opts + nr, 0, sizeof(*opts)); + opts[nr].type = OPTION_END; + return opts; +} + struct option *parse_options_concat(struct option *a, struct option *b) { struct option *ret; |