| 2432 | } |
| 2433 | |
| 2434 | struct ref_store *get_worktree_ref_store(const struct worktree *wt) |
| 2435 | { |
| 2436 | struct ref_store *refs; |
| 2437 | const char *id; |
| 2438 | |
| 2439 | if (wt->is_current) |
| 2440 | return get_main_ref_store(wt->repo); |
| 2441 | |
| 2442 | id = wt->id ? wt->id : "/"; |
| 2443 | refs = lookup_ref_store_map(&wt->repo->worktree_ref_stores, id); |
| 2444 | if (refs) |
| 2445 | return refs; |
| 2446 | |
| 2447 | if (wt->id) { |
| 2448 | struct strbuf common_path = STRBUF_INIT; |
| 2449 | repo_common_path_append(wt->repo, &common_path, |
| 2450 | "worktrees/%s", wt->id); |
| 2451 | refs = ref_store_init(wt->repo, wt->repo->ref_storage_format, |
| 2452 | common_path.buf, REF_STORE_ALL_CAPS); |
| 2453 | strbuf_release(&common_path); |
| 2454 | } else { |
| 2455 | refs = ref_store_init(wt->repo, wt->repo->ref_storage_format, |
| 2456 | wt->repo->commondir, REF_STORE_ALL_CAPS); |
| 2457 | } |
| 2458 | |
| 2459 | if (refs) |
| 2460 | register_ref_store_map(&wt->repo->worktree_ref_stores, |
| 2461 | "worktree", refs, id); |
| 2462 | |
| 2463 | return refs; |
| 2464 | } |
| 2465 | |
| 2466 | void base_ref_store_init(struct ref_store *refs, struct repository *repo, |
| 2467 | const char *path, const struct ref_storage_be *be) |