]>
git.ipfire.org Git - thirdparty/git.git/blob - refspec.h
8b04f9995ef2a8bb518d155f195899c8af0284e9
4 #define TAG_REFSPEC "refs/tags/*:refs/tags/*"
7 * A struct refspec_item holds the parsed interpretation of a refspec. If it
8 * will force updates (starts with a '+'), force is true. If it is a pattern
9 * (sides end with '*') pattern is true. If it is a negative refspec, (starts
10 * with '^'), negative is true. src and dest are the two sides (including '*'
11 * characters if present); if there is only one side, it is src, and dst is
12 * NULL; if sides exist but are empty (i.e., the refspec either starts or ends
13 * with ':'), the corresponding side is "".
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).
23 unsigned matching
: 1;
24 unsigned exact_sha1
: 1;
25 unsigned negative
: 1;
35 #define REFSPEC_INIT_FETCH { .fetch = 1 }
36 #define REFSPEC_INIT_PUSH { .fetch = 0 }
39 * An array of strings can be parsed into a struct refspec using
40 * parse_fetch_refspec() or parse_push_refspec().
43 struct refspec_item
*items
;
50 int refspec_item_init_fetch(struct refspec_item
*item
, const char *refspec
);
51 int refspec_item_init_push(struct refspec_item
*item
, const char *refspec
);
52 void refspec_item_clear(struct refspec_item
*item
);
53 void refspec_init_fetch(struct refspec
*rs
);
54 void refspec_init_push(struct refspec
*rs
);
55 void refspec_append(struct refspec
*rs
, const char *refspec
);
56 __attribute__((format (printf
,2,3)))
57 void refspec_appendf(struct refspec
*rs
, const char *fmt
, ...);
58 void refspec_appendn(struct refspec
*rs
, const char **refspecs
, int nr
);
59 void refspec_clear(struct refspec
*rs
);
61 int valid_fetch_refspec(const char *refspec
);
65 * Determine what <prefix> values to pass to the peer in ref-prefix lines
66 * (see linkgit:gitprotocol-v2[5]).
68 void refspec_ref_prefixes(const struct refspec
*rs
,
69 struct strvec
*ref_prefixes
);
71 int refname_matches_negative_refspec_item(const char *refname
, struct refspec
*rs
);
74 * Checks if a refname matches a globbing refspec pattern.
75 * If replacement is provided, computes the corresponding mapped refname.
76 * Returns 1 if refname matches pattern, 0 otherwise.
78 int match_refname_with_pattern(const char *pattern
, const char *refname
,
79 const char *replacement
, char **result
);
82 * Queries a refspec for a match and updates the query item.
83 * Returns 0 on success, -1 if no match is found or negative refspec matches.
85 int refspec_find_match(struct refspec
*rs
, struct refspec_item
*query
);
88 * Queries a refspec for all matches and appends results to the provided string
91 void refspec_find_all_matches(struct refspec
*rs
,
92 struct refspec_item
*query
,
93 struct string_list
*results
);
96 * Remove all entries in the input list which match any negative refspec in
99 struct ref
*apply_negative_refspecs(struct ref
*ref_map
, struct refspec
*rs
);
102 * Search for a refspec that matches the given name and return the
103 * corresponding destination (dst) if a match is found, NULL otherwise.
105 char *apply_refspecs(struct refspec
*rs
, const char *name
);
107 #endif /* REFSPEC_H */