]> git.ipfire.org Git - thirdparty/git.git/blob - refspec.h
config: improve error message for boolean config
[thirdparty/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 /**
8 * A struct refspec_item holds the parsed interpretation of a refspec. If it
9 * will force updates (starts with a '+'), force is true. If it is a pattern
10 * (sides end with '*') pattern is true. If it is a negative refspec, (starts
11 * with '^'), negative is true. src and dest are the two sides (including '*'
12 * characters if present); if there is only one side, it is src, and dst is
13 * NULL; if sides exist but are empty (i.e., the refspec either starts or ends
14 * with ':'), the corresponding side is "".
15 *
16 * remote_find_tracking(), given a remote and a struct refspec_item with either src
17 * or dst filled out, will fill out the other such that the result is in the
18 * "fetch" specification for the remote (note that this evaluates patterns and
19 * returns a single result).
20 */
21 struct refspec_item {
22 unsigned force : 1;
23 unsigned pattern : 1;
24 unsigned matching : 1;
25 unsigned exact_sha1 : 1;
26 unsigned negative : 1;
27
28 char *src;
29 char *dst;
30 };
31
32 #define REFSPEC_FETCH 1
33 #define REFSPEC_PUSH 0
34
35 #define REFSPEC_INIT_FETCH { .fetch = REFSPEC_FETCH }
36 #define REFSPEC_INIT_PUSH { .fetch = REFSPEC_PUSH }
37
38 /**
39 * An array of strings can be parsed into a struct refspec using
40 * parse_fetch_refspec() or parse_push_refspec().
41 */
42 struct refspec {
43 struct refspec_item *items;
44 int alloc;
45 int nr;
46
47 const char **raw;
48 int raw_alloc;
49 int raw_nr;
50
51 int fetch;
52 };
53
54 int refspec_item_init(struct refspec_item *item, const char *refspec,
55 int fetch);
56 void refspec_item_init_or_die(struct refspec_item *item, const char *refspec,
57 int fetch);
58 void refspec_item_clear(struct refspec_item *item);
59 void refspec_init(struct refspec *rs, int fetch);
60 void refspec_append(struct refspec *rs, const char *refspec);
61 __attribute__((format (printf,2,3)))
62 void refspec_appendf(struct refspec *rs, const char *fmt, ...);
63 void refspec_appendn(struct refspec *rs, const char **refspecs, int nr);
64 void refspec_clear(struct refspec *rs);
65
66 int valid_fetch_refspec(const char *refspec);
67 int valid_remote_name(const char *name);
68
69 struct strvec;
70 /*
71 * Determine what <prefix> values to pass to the peer in ref-prefix lines
72 * (see Documentation/technical/protocol-v2.txt).
73 */
74 void refspec_ref_prefixes(const struct refspec *rs,
75 struct strvec *ref_prefixes);
76
77 #endif /* REFSPEC_H */