MCPcopy Create free account
hub / github.com/git/git / refs_compute_filesystem_location

Function refs_compute_filesystem_location

refs.c:3554–3589  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3552}
3553
3554void refs_compute_filesystem_location(const char *gitdir, const char *payload,
3555 bool *is_worktree, struct strbuf *refdir,
3556 struct strbuf *ref_common_dir)
3557{
3558 struct strbuf sb = STRBUF_INIT;
3559
3560 *is_worktree = get_common_dir_noenv(ref_common_dir, gitdir);
3561
3562 if (!payload) {
3563 /*
3564 * We can use the 'gitdir' as the 'refdir' without appending the
3565 * worktree path, as the 'gitdir' here is already the worktree
3566 * path and is different from 'commondir' denoted by 'ref_common_dir'.
3567 */
3568 strbuf_addstr(refdir, gitdir);
3569 return;
3570 }
3571
3572 if (!is_absolute_path(payload)) {
3573 strbuf_addf(&sb, "%s/%s", ref_common_dir->buf, payload);
3574 strbuf_realpath(ref_common_dir, sb.buf, 1);
3575 } else {
3576 strbuf_realpath(ref_common_dir, payload, 1);
3577 }
3578
3579 strbuf_addbuf(refdir, ref_common_dir);
3580
3581 if (*is_worktree) {
3582 const char *wt_id = strrchr(gitdir, '/');
3583 if (!wt_id)
3584 BUG("worktree path does not contain slash");
3585 strbuf_addf(refdir, "/worktrees/%s", wt_id + 1);
3586 }
3587
3588 strbuf_release(&sb);
3589}

Callers 2

reftable_be_initFunction · 0.85
files_ref_store_initFunction · 0.85

Calls 7

get_common_dir_noenvFunction · 0.85
strbuf_addstrFunction · 0.85
is_absolute_pathFunction · 0.85
strbuf_addfFunction · 0.85
strbuf_realpathFunction · 0.85
strbuf_addbufFunction · 0.85
strbuf_releaseFunction · 0.85

Tested by

no test coverage detected