diff options
author | Brandon Williams <bmwill@google.com> | 2018-05-16 15:57:51 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2018-05-18 06:19:42 +0900 |
commit | 6d4c05785946e302e611be9ac1f5ca0b5ada9214 (patch) | |
tree | 94e5e42fc1b0cc1895d23457b13d2bb504b5d5ae /refspec.h | |
parent | refspec: factor out parsing a single refspec (diff) | |
download | tgif-6d4c05785946e302e611be9ac1f5ca0b5ada9214.tar.xz |
refspec: introduce struct refspec
Introduce 'struct refspec', an abstraction around a collection of
'struct refspec_item's much like how 'struct pathspec' holds a
collection of 'struct pathspec_item's.
A refspec struct also contains an array of the original refspec strings
which will be used to facilitate the migration to using this new
abstraction throughout the code base.
Signed-off-by: Brandon Williams <bmwill@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'refspec.h')
-rw-r--r-- | refspec.h | 25 |
1 files changed, 25 insertions, 0 deletions
@@ -20,4 +20,29 @@ struct refspec_item *parse_push_refspec(int nr_refspec, const char **refspec); void free_refspec(int nr_refspec, struct refspec_item *refspec); +#define REFSPEC_FETCH 1 +#define REFSPEC_PUSH 0 + +#define REFSPEC_INIT_FETCH { .fetch = REFSPEC_FETCH } +#define REFSPEC_INIT_PUSH { .fetch = REFSPEC_PUSH } + +struct refspec { + struct refspec_item *items; + int alloc; + int nr; + + const char **raw; + int raw_alloc; + int raw_nr; + + int fetch; +}; + +void refspec_item_init(struct refspec_item *item, const char *refspec, int fetch); +void refspec_item_clear(struct refspec_item *item); +void refspec_init(struct refspec *rs, int fetch); +void refspec_append(struct refspec *rs, const char *refspec); +void refspec_appendn(struct refspec *rs, const char **refspecs, int nr); +void refspec_clear(struct refspec *rs); + #endif /* REFSPEC_H */ |