* Do we have HEAD in the output, and also the branch it points at? * If so, find that decoration entry for that current branch. */
| 292 | * If so, find that decoration entry for that current branch. |
| 293 | */ |
| 294 | static const struct name_decoration *current_pointed_by_HEAD(const struct name_decoration *decoration) |
| 295 | { |
| 296 | const struct name_decoration *list, *head = NULL; |
| 297 | const char *branch_name = NULL; |
| 298 | int rru_flags; |
| 299 | |
| 300 | /* First find HEAD */ |
| 301 | for (list = decoration; list; list = list->next) |
| 302 | if (list->type == DECORATION_REF_HEAD) { |
| 303 | head = list; |
| 304 | break; |
| 305 | } |
| 306 | if (!head) |
| 307 | return NULL; |
| 308 | |
| 309 | /* Now resolve and find the matching current branch */ |
| 310 | branch_name = refs_resolve_ref_unsafe(get_main_ref_store(the_repository), |
| 311 | "HEAD", 0, NULL, &rru_flags); |
| 312 | if (!branch_name || !(rru_flags & REF_ISSYMREF)) |
| 313 | return NULL; |
| 314 | |
| 315 | if (!starts_with(branch_name, "refs/")) |
| 316 | return NULL; |
| 317 | |
| 318 | /* OK, do we have that ref in the list? */ |
| 319 | for (list = decoration; list; list = list->next) |
| 320 | if ((list->type == DECORATION_REF_LOCAL) && |
| 321 | !strcmp(branch_name, list->name)) { |
| 322 | return list; |
| 323 | } |
| 324 | |
| 325 | return NULL; |
| 326 | } |
| 327 | |
| 328 | static void show_name(struct strbuf *sb, const struct name_decoration *decoration) |
| 329 | { |
no test coverage detected