| 173 | } |
| 174 | |
| 175 | static int backend_for_worktree(struct reftable_backend **out, |
| 176 | struct reftable_ref_store *store, |
| 177 | const char *worktree_name) |
| 178 | { |
| 179 | struct strbuf worktree_dir = STRBUF_INIT; |
| 180 | int ret; |
| 181 | |
| 182 | *out = strmap_get(&store->worktree_backends, worktree_name); |
| 183 | if (*out) { |
| 184 | ret = 0; |
| 185 | goto out; |
| 186 | } |
| 187 | |
| 188 | strbuf_addf(&worktree_dir, "%s/worktrees/%s/reftable", |
| 189 | store->base.repo->commondir, worktree_name); |
| 190 | |
| 191 | CALLOC_ARRAY(*out, 1); |
| 192 | store->err = ret = reftable_backend_init(*out, worktree_dir.buf, |
| 193 | &store->write_options); |
| 194 | if (ret < 0) { |
| 195 | free(*out); |
| 196 | goto out; |
| 197 | } |
| 198 | |
| 199 | strmap_put(&store->worktree_backends, worktree_name, *out); |
| 200 | |
| 201 | out: |
| 202 | strbuf_release(&worktree_dir); |
| 203 | return ret; |
| 204 | } |
| 205 | |
| 206 | /* |
| 207 | * Some refs are global to the repository (refs/heads/{*}), while others are |
no test coverage detected