Merge branch 'ds/read-cache-mempool-leakfix'
[git/gitster.git] / refspec.h
blob3760fdaf2bb1833b0314adf8e66265150c74ccce
1 #ifndef REFSPEC_H
2 #define REFSPEC_H
4 #define TAG_REFSPEC "refs/tags/*:refs/tags/*"
6 /**
7 * A struct refspec_item holds the parsed interpretation of a refspec. If it
8 * will force updates (starts with a '+'), force is true. If it is a pattern
9 * (sides end with '*') pattern is true. If it is a negative refspec, (starts
10 * with '^'), negative is true. src and dest are the two sides (including '*'
11 * characters if present); if there is only one side, it is src, and dst is
12 * NULL; if sides exist but are empty (i.e., the refspec either starts or ends
13 * with ':'), the corresponding side is "".
15 * remote_find_tracking(), given a remote and a struct refspec_item with either src
16 * or dst filled out, will fill out the other such that the result is in the
17 * "fetch" specification for the remote (note that this evaluates patterns and
18 * returns a single result).
20 struct refspec_item {
21 unsigned force : 1;
22 unsigned pattern : 1;
23 unsigned matching : 1;
24 unsigned exact_sha1 : 1;
25 unsigned negative : 1;
27 char *src;
28 char *dst;
31 #define REFSPEC_FETCH 1
32 #define REFSPEC_PUSH 0
34 #define REFSPEC_INIT_FETCH { .fetch = REFSPEC_FETCH }
35 #define REFSPEC_INIT_PUSH { .fetch = REFSPEC_PUSH }
37 /**
38 * An array of strings can be parsed into a struct refspec using
39 * parse_fetch_refspec() or parse_push_refspec().
41 struct refspec {
42 struct refspec_item *items;
43 int alloc;
44 int nr;
46 char **raw;
47 int raw_alloc;
48 int raw_nr;
50 int fetch;
53 int refspec_item_init(struct refspec_item *item, const char *refspec,
54 int fetch);
55 void refspec_item_init_or_die(struct refspec_item *item, const char *refspec,
56 int fetch);
57 void refspec_item_clear(struct refspec_item *item);
58 void refspec_init(struct refspec *rs, int fetch);
59 void refspec_append(struct refspec *rs, const char *refspec);
60 __attribute__((format (printf,2,3)))
61 void refspec_appendf(struct refspec *rs, const char *fmt, ...);
62 void refspec_appendn(struct refspec *rs, const char **refspecs, int nr);
63 void refspec_clear(struct refspec *rs);
65 int valid_fetch_refspec(const char *refspec);
66 int valid_remote_name(const char *name);
68 struct strvec;
70 * Determine what <prefix> values to pass to the peer in ref-prefix lines
71 * (see linkgit:gitprotocol-v2[5]).
73 void refspec_ref_prefixes(const struct refspec *rs,
74 struct strvec *ref_prefixes);
76 #endif /* REFSPEC_H */