Brandon Williams | ec0cb49 | 2018-05-16 15:57:48 -0700 | [diff] [blame] | 1 | #ifndef REFSPEC_H |
| 2 | #define REFSPEC_H |
| 3 | |
| 4 | #define TAG_REFSPEC "refs/tags/*:refs/tags/*" |
Brandon Williams | 0ad4a5f | 2018-05-16 15:57:49 -0700 | [diff] [blame] | 5 | extern const struct refspec_item *tag_refspec; |
Brandon Williams | ec0cb49 | 2018-05-16 15:57:48 -0700 | [diff] [blame] | 6 | |
Brandon Williams | 0ad4a5f | 2018-05-16 15:57:49 -0700 | [diff] [blame] | 7 | struct refspec_item { |
Brandon Williams | ec0cb49 | 2018-05-16 15:57:48 -0700 | [diff] [blame] | 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 | |
Brandon Williams | 6d4c057 | 2018-05-16 15:57:51 -0700 | [diff] [blame] | 17 | #define REFSPEC_FETCH 1 |
| 18 | #define REFSPEC_PUSH 0 |
| 19 | |
| 20 | #define REFSPEC_INIT_FETCH { .fetch = REFSPEC_FETCH } |
| 21 | #define REFSPEC_INIT_PUSH { .fetch = REFSPEC_PUSH } |
| 22 | |
| 23 | struct refspec { |
| 24 | struct refspec_item *items; |
| 25 | int alloc; |
| 26 | int nr; |
| 27 | |
| 28 | const char **raw; |
| 29 | int raw_alloc; |
| 30 | int raw_nr; |
| 31 | |
| 32 | int fetch; |
| 33 | }; |
| 34 | |
Ævar Arnfjörð Bjarmason | c495fd3 | 2018-06-05 19:54:39 +0000 | [diff] [blame] | 35 | int refspec_item_init(struct refspec_item *item, const char *refspec, |
| 36 | int fetch); |
Ævar Arnfjörð Bjarmason | dc06422 | 2018-06-05 19:54:38 +0000 | [diff] [blame] | 37 | void refspec_item_init_or_die(struct refspec_item *item, const char *refspec, |
| 38 | int fetch); |
Brandon Williams | 6d4c057 | 2018-05-16 15:57:51 -0700 | [diff] [blame] | 39 | void refspec_item_clear(struct refspec_item *item); |
| 40 | void refspec_init(struct refspec *rs, int fetch); |
| 41 | void refspec_append(struct refspec *rs, const char *refspec); |
| 42 | void refspec_appendn(struct refspec *rs, const char **refspecs, int nr); |
| 43 | void refspec_clear(struct refspec *rs); |
| 44 | |
Brandon Williams | c8fa9ef | 2018-05-16 15:57:52 -0700 | [diff] [blame] | 45 | int valid_fetch_refspec(const char *refspec); |
| 46 | |
Brandon Williams | 6373cb5 | 2018-05-16 16:48:21 -0700 | [diff] [blame] | 47 | struct argv_array; |
Jonathan Nieder | 6c301ad | 2018-05-31 00:23:39 -0700 | [diff] [blame] | 48 | /* |
| 49 | * Determine what <prefix> values to pass to the peer in ref-prefix lines |
| 50 | * (see Documentation/technical/protocol-v2.txt). |
| 51 | */ |
Brandon Williams | 6373cb5 | 2018-05-16 16:48:21 -0700 | [diff] [blame] | 52 | void refspec_ref_prefixes(const struct refspec *rs, |
| 53 | struct argv_array *ref_prefixes); |
| 54 | |
Brandon Williams | ec0cb49 | 2018-05-16 15:57:48 -0700 | [diff] [blame] | 55 | #endif /* REFSPEC_H */ |