refspec: convert valid_fetch_refspec to use parse_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 struct refspec_item *parse_fetch_refspec(int nr_refspec, const char **refspec);
18 struct refspec_item *parse_push_refspec(int nr_refspec, const char **refspec);
19
20 void free_refspec(int nr_refspec, struct refspec_item *refspec);
21
22 #define REFSPEC_FETCH 1
23 #define REFSPEC_PUSH 0
24
25 #define REFSPEC_INIT_FETCH { .fetch = REFSPEC_FETCH }
26 #define REFSPEC_INIT_PUSH { .fetch = REFSPEC_PUSH }
27
28 struct refspec {
29 struct refspec_item *items;
30 int alloc;
31 int nr;
32
33 const char **raw;
34 int raw_alloc;
35 int raw_nr;
36
37 int fetch;
38 };
39
40 void refspec_item_init(struct refspec_item *item, const char *refspec, int fetch);
41 void refspec_item_clear(struct refspec_item *item);
42 void refspec_init(struct refspec *rs, int fetch);
43 void refspec_append(struct refspec *rs, const char *refspec);
44 void refspec_appendn(struct refspec *rs, const char **refspecs, int nr);
45 void refspec_clear(struct refspec *rs);
46
47 int valid_fetch_refspec(const char *refspec);
48
49 #endif /* REFSPEC_H */