Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/git/blob/master/refspec.h # git [Ported from github.com/git/git] Sync with Git 2.56.1 Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `master` Branches Tags History `git / refspec.h` 119 lines ยท 3806 bytes Raw Blame History 1 #ifndef REFSPEC_H 2 #define REFSPEC_H 3 4 struct git_hash_algo; 5 struct string_list; 6 struct strvec; 7 8 #define TAG_REFSPEC "refs/tags/*:refs/tags/*" 9 10 /** 11 * A struct refspec_item holds the parsed interpretation of a refspec. If it 12 * will force updates (starts with a '+'), force is true. If it is a pattern 13 * (sides end with '*') pattern is true. If it is a negative refspec, (starts 14 * with '^'), negative is true. src and dest are the two sides (including '*' 15 * characters if present); if there is only one side, it is src, and dst is 16 * NULL; if sides exist but are empty (i.e., the refspec either starts or ends 17 * with ':'), the corresponding side is "". 18 * 19 * remote_find_tracking(), given a remote and a struct refspec_item with either src 20 * or dst filled out, will fill out the other such that the result is in the 21 * "fetch" specification for the remote (note that this evaluates patterns and 22 * returns a single result). 23 */ 24 struct refspec_item { 25 unsigned force : 1; 26 unsigned pattern : 1; 27 unsigned matching : 1; 28 unsigned exact_sha1 : 1; 29 unsigned negative : 1; 30 31 char *src; 32 char *dst; 33 34 char *raw; 35 }; 36 37 int refspec_item_init_fetch(struct refspec_item *item, const char *refspec, 38 const struct git_hash_algo *algo); 39 int refspec_item_init_push(struct refspec_item *item, const char *refspec, 40 const struct git_hash_algo *algo); 41 void refspec_item_clear(struct refspec_item *item); 42 43 /** 44 * An array of strings can be parsed into a struct refspec using 45 * parse_fetch_refspec() or parse_push_refspec(). 46 */ 47 struct refspec { 48 struct refspec_item *items; 49 int alloc; 50 int nr; 51 52 const struct git_hash_algo *hash_algo; 53 unsigned fetch : 1; 54 }; 55 56 #define REFSPEC_INIT_FETCH(algo) { \ 57 .fetch = 1, \ 58 .hash_algo = (algo), \ 59 } 60 #define REFSPEC_INIT_PUSH(algo) { \ 61 .fetch = 0, \ 62 .hash_algo = (algo), \ 63 } 64 65 void refspec_init_fetch(struct refspec *rs, const struct git_hash_algo *hash_algo); 66 void refspec_init_push(struct refspec *rs, const struct git_hash_algo *hash_algo); 67 void refspec_clear(struct refspec *rs); 68 69 void refspec_append(struct refspec *rs, const char *refspec); 70 __attribute__((format (printf,2,3))) 71 void refspec_appendf(struct refspec *rs, const char *fmt, ...); 72 void refspec_appendn(struct refspec *rs, const char **refspecs, int nr); 73 74 int valid_fetch_refspec(const char *refspec, const struct git_hash_algo *algo); 75 76 /* 77 * Determine what values to pass to the peer in ref-prefix lines 78 * (see linkgit:gitprotocol-v2[5]). 79 */ 80 void refspec_ref_prefixes(const struct refspec *rs, 81 struct strvec *ref_prefixes); 82 83 int refname_matches_negative_refspec_item(const char *refname, struct refspec *rs); 84 85 /* 86 * Checks if a refname matches a globbing refspec pattern. 87 * If replacement is provided, computes the corresponding mapped refname. 88 * Returns 1 if refname matches pattern, 0 otherwise. 89 */ 90 int match_refname_with_pattern(const char *pattern, const char *refname, 91 const char *replacement, char **result); 92 93 /* 94 * Queries a refspec for a match and updates the query item. 95 * Returns 0 on success, -1 if no match is found or negative refspec matches. 96 */ 97 int refspec_find_match(struct refspec *rs, struct refspec_item *query); 98 99 /* 100 * Queries a refspec for all matches and appends results to the provided string 101 * list. 102 */ 103 void refspec_find_all_matches(struct refspec *rs, 104 struct refspec_item *query, 105 struct string_list *results); 106 107 /* 108 * Remove all entries in the input list which match any negative refspec in 109 * the refspec list. 110 */ 111 struct ref *apply_negative_refspecs(struct ref *ref_map, struct refspec *rs); 112 113 /* 114 * Search for a refspec that matches the given name and return the 115 * corresponding destination (dst) if a match is found, NULL otherwise. 116 */ 117 char *apply_refspecs(struct refspec *rs, const char *name); 118 119 #endif /* REFSPEC_H */