diff options
| author | Patrick Steinhardt <ps@pks.im> | 2018-07-06 11:25:47 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-07-06 11:25:47 +0000 |
| commit | f2a1cece3d95334d963ceffe1cd70836ae96078e (patch) | |
| tree | da0de6c5a2be018ab4236d2f0b41946110e299bb /src | |
| parent | 8a00de0899dcb71dca147acf7d47d19d27f63ba4 (diff) | |
| parent | 1da6329fd7f862ac355178dc89c8b321f420fca6 (diff) | |
| download | libgit2-f2a1cece3d95334d963ceffe1cd70836ae96078e.tar.gz | |
Merge pull request #4686 from tiennou/fix/more-worktree-from-bare
Fix git_worktree_validate failing on bare repositories
Diffstat (limited to 'src')
| -rw-r--r-- | src/worktree.c | 22 |
1 files changed, 6 insertions, 16 deletions
diff --git a/src/worktree.c b/src/worktree.c index 591df1c34..610fd7ee3 100644 --- a/src/worktree.c +++ b/src/worktree.c @@ -234,40 +234,30 @@ void git_worktree_free(git_worktree *wt) int git_worktree_validate(const git_worktree *wt) { - git_buf buf = GIT_BUF_INIT; - int err = 0; - assert(wt); - git_buf_puts(&buf, wt->gitdir_path); - if (!is_worktree_dir(buf.ptr)) { + if (!is_worktree_dir(wt->gitdir_path)) { giterr_set(GITERR_WORKTREE, "Worktree gitdir ('%s') is not valid", wt->gitlink_path); - err = -1; - goto out; + return GIT_ERROR; } - if (!git_path_exists(wt->parent_path)) { + if (wt->parent_path && !git_path_exists(wt->parent_path)) { giterr_set(GITERR_WORKTREE, "Worktree parent directory ('%s') does not exist ", wt->parent_path); - err = -2; - goto out; + return GIT_ERROR; } if (!git_path_exists(wt->commondir_path)) { giterr_set(GITERR_WORKTREE, "Worktree common directory ('%s') does not exist ", wt->commondir_path); - err = -3; - goto out; + return GIT_ERROR; } -out: - git_buf_dispose(&buf); - - return err; + return 0; } int git_worktree_add_init_options(git_worktree_add_options *opts, |
