]> git.ipfire.org Git - thirdparty/git.git/blame - refspec.h
Merge branch 'jk/add-i-fixes'
[thirdparty/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
0becfec5
JK
7/**
8 * A struct refspec_item holds the parsed interpretation of a refspec. If it will
9 * force updates (starts with a '+'), force is true. If it is a pattern
10 * (sides end with '*') pattern is true. src and dest are the two sides
11 * (including '*' characters if present); if there is only one side, it is src,
12 * and dst is NULL; if sides exist but are empty (i.e., the refspec either
13 * starts or ends with ':'), the corresponding side is "".
14 *
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).
19 */
0ad4a5ff 20struct refspec_item {
ec0cb496
BW
21 unsigned force : 1;
22 unsigned pattern : 1;
23 unsigned matching : 1;
24 unsigned exact_sha1 : 1;
25
26 char *src;
27 char *dst;
28};
29
6d4c0578
BW
30#define REFSPEC_FETCH 1
31#define REFSPEC_PUSH 0
32
33#define REFSPEC_INIT_FETCH { .fetch = REFSPEC_FETCH }
34#define REFSPEC_INIT_PUSH { .fetch = REFSPEC_PUSH }
35
d27eb356 36/**
0becfec5 37 * An array of strings can be parsed into a struct refspec using
d27eb356 38 * parse_fetch_refspec() or parse_push_refspec().
d27eb356 39 */
6d4c0578
BW
40struct refspec {
41 struct refspec_item *items;
42 int alloc;
43 int nr;
44
45 const char **raw;
46 int raw_alloc;
47 int raw_nr;
48
49 int fetch;
50};
51
c495fd3d
ÆAB
52int refspec_item_init(struct refspec_item *item, const char *refspec,
53 int fetch);
dc064221
ÆAB
54void refspec_item_init_or_die(struct refspec_item *item, const char *refspec,
55 int fetch);
6d4c0578
BW
56void refspec_item_clear(struct refspec_item *item);
57void refspec_init(struct refspec *rs, int fetch);
58void refspec_append(struct refspec *rs, const char *refspec);
1af8b8c0
RS
59__attribute__((format (printf,2,3)))
60void refspec_appendf(struct refspec *rs, const char *fmt, ...);
6d4c0578
BW
61void refspec_appendn(struct refspec *rs, const char **refspecs, int nr);
62void refspec_clear(struct refspec *rs);
63
c8fa9efe
BW
64int valid_fetch_refspec(const char *refspec);
65
873cd28a 66struct strvec;
6c301adb
JN
67/*
68 * Determine what <prefix> values to pass to the peer in ref-prefix lines
69 * (see Documentation/technical/protocol-v2.txt).
70 */
6373cb59 71void refspec_ref_prefixes(const struct refspec *rs,
873cd28a 72 struct strvec *ref_prefixes);
6373cb59 73
ec0cb496 74#endif /* REFSPEC_H */