MCPcopy Index your code
hub / github.com/git/git / prefix_magic

Function prefix_magic

pathspec.c:114–146  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

112};
113
114static void prefix_magic(struct strbuf *sb, int prefixlen,
115 unsigned magic, const char *element)
116{
117 /* No magic was found in element, just add prefix magic */
118 if (!magic) {
119 strbuf_addf(sb, ":(prefix:%d)", prefixlen);
120 return;
121 }
122
123 /*
124 * At this point, we know that parse_element_magic() was able
125 * to extract some pathspec magic from element. So we know
126 * element is correctly formatted in either shorthand or
127 * longhand form
128 */
129 if (element[1] != '(') {
130 /* Process an element in shorthand form (e.g. ":!/<match>") */
131 strbuf_addstr(sb, ":(");
132 for (unsigned int i = 0; i < ARRAY_SIZE(pathspec_magic); i++) {
133 if ((magic & pathspec_magic[i].bit) &&
134 pathspec_magic[i].mnemonic) {
135 if (sb->buf[sb->len - 1] != '(')
136 strbuf_addch(sb, ',');
137 strbuf_addstr(sb, pathspec_magic[i].name);
138 }
139 }
140 } else {
141 /* For the longhand form, we copy everything up to the final ')' */
142 size_t len = strchr(element, ')') - element;
143 strbuf_add(sb, element, len);
144 }
145 strbuf_addf(sb, ",prefix:%d)", prefixlen);
146}
147
148static size_t strcspn_escaped(const char *s, const char *stop)
149{

Callers 1

init_pathspec_itemFunction · 0.85

Calls 4

strbuf_addfFunction · 0.85
strbuf_addstrFunction · 0.85
strbuf_addchFunction · 0.85
strbuf_addFunction · 0.85

Tested by

no test coverage detected