* note: this function should be able to detect shared symref even if * HEAD is temporarily detached (e.g. in the middle of rebase or * bisect). New commands that do similar things should update this * function as well. */
| 495 | * function as well. |
| 496 | */ |
| 497 | int is_shared_symref(const struct worktree *wt, const char *symref, |
| 498 | const char *target) |
| 499 | { |
| 500 | const char *symref_target; |
| 501 | struct ref_store *refs; |
| 502 | int flags; |
| 503 | |
| 504 | if (wt->is_bare) |
| 505 | return 0; |
| 506 | |
| 507 | if (wt->is_detached && !strcmp(symref, "HEAD")) { |
| 508 | if (is_worktree_being_rebased(wt, target)) |
| 509 | return 1; |
| 510 | if (is_worktree_being_bisected(wt, target)) |
| 511 | return 1; |
| 512 | } |
| 513 | |
| 514 | refs = get_worktree_ref_store(wt); |
| 515 | symref_target = refs_resolve_ref_unsafe(refs, symref, 0, |
| 516 | NULL, &flags); |
| 517 | if ((flags & REF_ISSYMREF) && |
| 518 | symref_target && !strcmp(symref_target, target)) |
| 519 | return 1; |
| 520 | |
| 521 | return 0; |
| 522 | } |
| 523 | |
| 524 | const struct worktree *find_shared_symref(struct worktree **worktrees, |
| 525 | const char *symref, |
no test coverage detected