]> git.ipfire.org Git - thirdparty/git.git/blame - refspec.h
Documentation/RelNotes/2.45.0.txt: fix typo
[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 7/**
c0192df6
JK
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 "".
0becfec5
JK
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 */
0ad4a5ff 21struct refspec_item {
ec0cb496
BW
22 unsigned force : 1;
23 unsigned pattern : 1;
24 unsigned matching : 1;
25 unsigned exact_sha1 : 1;
c0192df6 26 unsigned negative : 1;
ec0cb496
BW
27
28 char *src;
29 char *dst;
30};
31
6d4c0578
BW
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
d27eb356 38/**
0becfec5 39 * An array of strings can be parsed into a struct refspec using
d27eb356 40 * parse_fetch_refspec() or parse_push_refspec().
d27eb356 41 */
6d4c0578
BW
42struct 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
c495fd3d
ÆAB
54int refspec_item_init(struct refspec_item *item, const char *refspec,
55 int fetch);
dc064221
ÆAB
56void refspec_item_init_or_die(struct refspec_item *item, const char *refspec,
57 int fetch);
6d4c0578
BW
58void refspec_item_clear(struct refspec_item *item);
59void refspec_init(struct refspec *rs, int fetch);
60void refspec_append(struct refspec *rs, const char *refspec);
1af8b8c0
RS
61__attribute__((format (printf,2,3)))
62void refspec_appendf(struct refspec *rs, const char *fmt, ...);
6d4c0578
BW
63void refspec_appendn(struct refspec *rs, const char **refspecs, int nr);
64void refspec_clear(struct refspec *rs);
65
c8fa9efe 66int valid_fetch_refspec(const char *refspec);
f2c6fda8 67int valid_remote_name(const char *name);
c8fa9efe 68
873cd28a 69struct strvec;
6c301adb
JN
70/*
71 * Determine what <prefix> values to pass to the peer in ref-prefix lines
5db92105 72 * (see linkgit:gitprotocol-v2[5]).
6c301adb 73 */
6373cb59 74void refspec_ref_prefixes(const struct refspec *rs,
873cd28a 75 struct strvec *ref_prefixes);
6373cb59 76
ec0cb496 77#endif /* REFSPEC_H */