refspec: introduce struct refspec
[git/git.git] / refspec.h
CommitLineData
ec0cb496
BW
1#ifndef REFSPEC_H
2#define REFSPEC_H
3
4#define TAG_REFSPEC "refs/tags/*:refs/tags/*"
0ad4a5ff 5extern const struct refspec_item *tag_refspec;
ec0cb496 6
0ad4a5ff 7struct refspec_item {
ec0cb496
BW
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
17int valid_fetch_refspec(const char *refspec);
0ad4a5ff
BW
18struct refspec_item *parse_fetch_refspec(int nr_refspec, const char **refspec);
19struct refspec_item *parse_push_refspec(int nr_refspec, const char **refspec);
ec0cb496 20
0ad4a5ff 21void free_refspec(int nr_refspec, struct refspec_item *refspec);
ec0cb496 22
6d4c0578
BW
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
29struct 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
41void refspec_item_init(struct refspec_item *item, const char *refspec, int fetch);
42void refspec_item_clear(struct refspec_item *item);
43void refspec_init(struct refspec *rs, int fetch);
44void refspec_append(struct refspec *rs, const char *refspec);
45void refspec_appendn(struct refspec *rs, const char **refspecs, int nr);
46void refspec_clear(struct refspec *rs);
47
ec0cb496 48#endif /* REFSPEC_H */