summaryrefslogtreecommitdiff
path: root/parse-options-cb.c
diff options
context:
space:
mode:
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>2019-03-29 10:39:04 (GMT)
committerJunio C Hamano <gitster@pobox.com>2019-04-02 04:56:59 (GMT)
commit208718227207480b0f58e35e045e36ed36a59205 (patch)
tree0a79f4b7e5bac50b7fbab27f6aafd316a0a2cf5a /parse-options-cb.c
parent55cf704a9d139bca0cb5cca1bf047eb043e13bd2 (diff)
downloadgit-208718227207480b0f58e35e045e36ed36a59205.zip
git-208718227207480b0f58e35e045e36ed36a59205.tar.gz
git-208718227207480b0f58e35e045e36ed36a59205.tar.bz2
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.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/parse-options-cb.c b/parse-options-cb.c
index 2733393..caaeed8 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;