🌐 AI搜索 & 代理 主页
blob: 8c0c44699335e65af07ee2ea3ebd4fb266db32a5 [file] [log] [blame]
Brandon Williamsec0cb492018-05-16 22:57:481#ifndef REFSPEC_H
2#define REFSPEC_H
3
4#define TAG_REFSPEC "refs/tags/*:refs/tags/*"
Brandon Williams0ad4a5f2018-05-16 22:57:495extern const struct refspec_item *tag_refspec;
Brandon Williamsec0cb492018-05-16 22:57:486
Jacob Keller0becfec2020-08-15 00:25:077/**
Jacob Kellerc0192df2020-09-30 21:25:298 * 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 "".
Jacob Keller0becfec2020-08-15 00:25:0715 *
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 */
Brandon Williams0ad4a5f2018-05-16 22:57:4921struct refspec_item {
Brandon Williamsec0cb492018-05-16 22:57:4822 unsigned force : 1;
23 unsigned pattern : 1;
24 unsigned matching : 1;
25 unsigned exact_sha1 : 1;
Jacob Kellerc0192df2020-09-30 21:25:2926 unsigned negative : 1;
Brandon Williamsec0cb492018-05-16 22:57:4827
28 char *src;
29 char *dst;
30};
31
Brandon Williams6d4c0572018-05-16 22:57:5132#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
Heba Walyd27eb352019-11-17 21:04:4538/**
Jacob Keller0becfec2020-08-15 00:25:0739 * An array of strings can be parsed into a struct refspec using
Heba Walyd27eb352019-11-17 21:04:4540 * parse_fetch_refspec() or parse_push_refspec().
Heba Walyd27eb352019-11-17 21:04:4541 */
Brandon Williams6d4c0572018-05-16 22:57:5142struct 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
Ævar Arnfjörð Bjarmasonc495fd32018-06-05 19:54:3954int refspec_item_init(struct refspec_item *item, const char *refspec,
55 int fetch);
Ævar Arnfjörð Bjarmasondc064222018-06-05 19:54:3856void refspec_item_init_or_die(struct refspec_item *item, const char *refspec,
57 int fetch);
Brandon Williams6d4c0572018-05-16 22:57:5158void refspec_item_clear(struct refspec_item *item);
59void refspec_init(struct refspec *rs, int fetch);
60void refspec_append(struct refspec *rs, const char *refspec);
René Scharfe1af8b8c2020-09-05 14:49:3061__attribute__((format (printf,2,3)))
62void refspec_appendf(struct refspec *rs, const char *fmt, ...);
Brandon Williams6d4c0572018-05-16 22:57:5163void refspec_appendn(struct refspec *rs, const char **refspecs, int nr);
64void refspec_clear(struct refspec *rs);
65
Brandon Williamsc8fa9ef2018-05-16 22:57:5266int valid_fetch_refspec(const char *refspec);
Sean Baragf2c6fda2020-10-01 03:46:1367int valid_remote_name(const char *name);
Brandon Williamsc8fa9ef2018-05-16 22:57:5268
Jeff King873cd282020-07-28 20:23:2569struct strvec;
Jonathan Nieder6c301ad2018-05-31 07:23:3970/*
71 * Determine what <prefix> values to pass to the peer in ref-prefix lines
Ævar Arnfjörð Bjarmason5db92102022-08-04 16:28:3672 * (see linkgit:gitprotocol-v2[5]).
Jonathan Nieder6c301ad2018-05-31 07:23:3973 */
Brandon Williams6373cb52018-05-16 23:48:2174void refspec_ref_prefixes(const struct refspec *rs,
Jeff King873cd282020-07-28 20:23:2575 struct strvec *ref_prefixes);
Brandon Williams6373cb52018-05-16 23:48:2176
Brandon Williamsec0cb492018-05-16 22:57:4877#endif /* REFSPEC_H */