summaryrefslogtreecommitdiff
path: root/refspec.h
diff options
context:
space:
mode:
authorBrandon Williams <bmwill@google.com>2018-05-16 22:57:51 (GMT)
committerJunio C Hamano <gitster@pobox.com>2018-05-17 21:19:42 (GMT)
commit6d4c05785946e302e611be9ac1f5ca0b5ada9214 (patch)
tree94e5e42fc1b0cc1895d23457b13d2bb504b5d5ae /refspec.h
parent3eec3700fdc4d5b0a33729d45e7fb9735ed7e0f5 (diff)
downloadgit-6d4c05785946e302e611be9ac1f5ca0b5ada9214.zip
git-6d4c05785946e302e611be9ac1f5ca0b5ada9214.tar.gz
git-6d4c05785946e302e611be9ac1f5ca0b5ada9214.tar.bz2
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.h25
1 files changed, 25 insertions, 0 deletions
diff --git a/refspec.h b/refspec.h
index fc9c1af..da31358 100644
--- a/refspec.h
+++ b/refspec.h
@@ -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 */