| 255 | } |
| 256 | |
| 257 | void refspec_ref_prefixes(const struct refspec *rs, |
| 258 | struct strvec *ref_prefixes) |
| 259 | { |
| 260 | int i; |
| 261 | for (i = 0; i < rs->nr; i++) { |
| 262 | const struct refspec_item *item = &rs->items[i]; |
| 263 | const char *prefix = NULL; |
| 264 | |
| 265 | if (item->negative) |
| 266 | continue; |
| 267 | |
| 268 | if (rs->fetch) { |
| 269 | if (item->exact_sha1) |
| 270 | continue; |
| 271 | prefix = item->src; |
| 272 | } else { |
| 273 | /* |
| 274 | * Pushes can have an explicit destination like |
| 275 | * "foo:bar", or can implicitly use the src for both |
| 276 | * ("foo" is the same as "foo:foo"). |
| 277 | */ |
| 278 | if (item->dst) |
| 279 | prefix = item->dst; |
| 280 | else if (item->src && !item->exact_sha1) |
| 281 | prefix = item->src; |
| 282 | } |
| 283 | |
| 284 | if (!prefix) |
| 285 | continue; |
| 286 | |
| 287 | if (item->pattern) { |
| 288 | const char *glob = strchr(prefix, '*'); |
| 289 | strvec_pushf(ref_prefixes, "%.*s", |
| 290 | (int)(glob - prefix), |
| 291 | prefix); |
| 292 | } else { |
| 293 | expand_ref_prefix(ref_prefixes, prefix); |
| 294 | } |
| 295 | } |
| 296 | } |
| 297 | |
| 298 | int match_refname_with_pattern(const char *pattern, const char *refname, |
| 299 | const char *replacement, char **result) |
no test coverage detected