refspec: introduce struct refspec
[git/git.git] / refspec.h
1 #ifndef REFSPEC_H
2 #define REFSPEC_H
3
4 #define TAG_REFSPEC "refs/tags/*:refs/tags/*"
5 extern const struct refspec_item *tag_refspec;
6
7 struct refspec_item {
8 unsigned force : 1;
9 unsigned pattern : 1;
10 unsigned matching : 1;
11 unsigned exact_sha1 : 1;
12
13 char *src;
14 char *dst;
15 };
16
17 int valid_fetch_refspec(const char *refspec);
18 struct refspec_item *parse_fetch_refspec(int nr_refspec, const char **refspec);
19 struct refspec_item *parse_push_refspec(int nr_refspec, const char **refspec);
20
21 void free_refspec(int nr_refspec, struct refspec_item *refspec);
22
23 #define REFSPEC_FETCH 1
24 #define REFSPEC_PUSH 0
25
26 #define REFSPEC_INIT_FETCH { .fetch = REFSPEC_FETCH }
27 #define REFSPEC_INIT_PUSH { .fetch = REFSPEC_PUSH }
28
29 struct refspec {
30 struct refspec_item *items;
31 int alloc;
32 int nr;
33
34 const char **raw;
35 int raw_alloc;
36 int raw_nr;
37
38 int fetch;
39 };
40
41 void refspec_item_init(struct refspec_item *item, const char *refspec, int fetch);
42 void refspec_item_clear(struct refspec_item *item);
43 void refspec_init(struct refspec *rs, int fetch);
44 void refspec_append(struct refspec *rs, const char *refspec);
45 void refspec_appendn(struct refspec *rs, const char **refspecs, int nr);
46 void refspec_clear(struct refspec *rs);
47
48 #endif /* REFSPEC_H */