]> git.ipfire.org Git - thirdparty/git.git/blame - refspec.h
Merge branch 'jk/escaped-wildcard-dwim'
[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
0ad4a5ff 7struct refspec_item {
ec0cb496
BW
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
6d4c0578
BW
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
d27eb356
HW
23/**
24 * A struct refspec holds the parsed interpretation of a refspec. If it will
25 * force updates (starts with a '+'), force is true. If it is a pattern
26 * (sides end with '*') pattern is true. src and dest are the two sides
27 * (including '*' characters if present); if there is only one side, it is src,
28 * and dst is NULL; if sides exist but are empty (i.e., the refspec either
29 * starts or ends with ':'), the corresponding side is "".
30 *
31 * An array of strings can be parsed into an array of struct refspecs using
32 * parse_fetch_refspec() or parse_push_refspec().
33 *
34 * remote_find_tracking(), given a remote and a struct refspec with either src
35 * or dst filled out, will fill out the other such that the result is in the
36 * "fetch" specification for the remote (note that this evaluates patterns and
37 * returns a single result).
38 */
6d4c0578
BW
39struct refspec {
40 struct refspec_item *items;
41 int alloc;
42 int nr;
43
44 const char **raw;
45 int raw_alloc;
46 int raw_nr;
47
48 int fetch;
49};
50
c495fd3d
ÆAB
51int refspec_item_init(struct refspec_item *item, const char *refspec,
52 int fetch);
dc064221
ÆAB
53void refspec_item_init_or_die(struct refspec_item *item, const char *refspec,
54 int fetch);
6d4c0578
BW
55void refspec_item_clear(struct refspec_item *item);
56void refspec_init(struct refspec *rs, int fetch);
57void refspec_append(struct refspec *rs, const char *refspec);
58void refspec_appendn(struct refspec *rs, const char **refspecs, int nr);
59void refspec_clear(struct refspec *rs);
60
c8fa9efe
BW
61int valid_fetch_refspec(const char *refspec);
62
6373cb59 63struct argv_array;
6c301adb
JN
64/*
65 * Determine what <prefix> values to pass to the peer in ref-prefix lines
66 * (see Documentation/technical/protocol-v2.txt).
67 */
6373cb59
BW
68void refspec_ref_prefixes(const struct refspec *rs,
69 struct argv_array *ref_prefixes);
70
ec0cb496 71#endif /* REFSPEC_H */