* Attempt to resolve and set the provided 'gitdir' for repository 'repo'. * Return 0 upon success and a non-zero value upon failure. */
| 222 | * Return 0 upon success and a non-zero value upon failure. |
| 223 | */ |
| 224 | static int repo_init_gitdir(struct repository *repo, const char *gitdir) |
| 225 | { |
| 226 | int ret = 0; |
| 227 | int error = 0; |
| 228 | char *abspath = NULL; |
| 229 | const char *resolved_gitdir; |
| 230 | struct set_gitdir_args args = { NULL }; |
| 231 | |
| 232 | abspath = real_pathdup(gitdir, 0); |
| 233 | if (!abspath) { |
| 234 | ret = -1; |
| 235 | goto out; |
| 236 | } |
| 237 | |
| 238 | /* 'gitdir' must reference the gitdir directly */ |
| 239 | resolved_gitdir = resolve_gitdir_gently(abspath, &error); |
| 240 | if (!resolved_gitdir) { |
| 241 | ret = -1; |
| 242 | goto out; |
| 243 | } |
| 244 | |
| 245 | repo_set_gitdir(repo, resolved_gitdir, &args); |
| 246 | |
| 247 | out: |
| 248 | free(abspath); |
| 249 | return ret; |
| 250 | } |
| 251 | |
| 252 | void repo_set_worktree(struct repository *repo, const char *path) |
| 253 | { |
no test coverage detected