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

Function is_shared_symref

worktree.c:497–522  ·  view source on GitHub ↗

* 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. */

Source from the content-addressed store, hash-verified

495 * function as well.
496 */
497int 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
524const struct worktree *find_shared_symref(struct worktree **worktrees,
525 const char *symref,

Callers 2

find_shared_symrefFunction · 0.85
die_if_checked_outFunction · 0.85

Calls 4

get_worktree_ref_storeFunction · 0.85
refs_resolve_ref_unsafeFunction · 0.85

Tested by

no test coverage detected