Merge branch 'ba/object-info' into maint
[git.git] / refspec.h
blob8b79891d3218d526ef1216bc1525b6040730185a
1 #ifndef REFSPEC_H
2 #define REFSPEC_H
4 #define TAG_REFSPEC "refs/tags/*:refs/tags/*"
5 extern const struct refspec_item *tag_refspec;
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 "".
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).
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;
28 char *src;
29 char *dst;
32 #define REFSPEC_FETCH 1
33 #define REFSPEC_PUSH 0
35 #define REFSPEC_INIT_FETCH { .fetch = REFSPEC_FETCH }
36 #define REFSPEC_INIT_PUSH { .fetch = REFSPEC_PUSH }
38 /**
39 * An array of strings can be parsed into a struct refspec using
40 * parse_fetch_refspec() or parse_push_refspec().
42 struct refspec {
43 struct refspec_item *items;
44 int alloc;
45 int nr;
47 const char **raw;
48 int raw_alloc;
49 int raw_nr;
51 int fetch;
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);
66 int valid_fetch_refspec(const char *refspec);
67 int valid_remote_name(const char *name);
69 struct strvec;
71 * Determine what <prefix> values to pass to the peer in ref-prefix lines
72 * (see Documentation/technical/protocol-v2.txt).
74 void refspec_ref_prefixes(const struct refspec *rs,
75 struct strvec *ref_prefixes);
77 #endif /* REFSPEC_H */