Skip to content

Commit 1da6329

Browse files
committed
worktree: don't return "untyped" negative numbers as error codes
1 parent 292a6ec commit 1da6329

File tree

1 file changed

+4
-11
lines changed

1 file changed

+4
-11
lines changed

src/worktree.c

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -234,37 +234,30 @@ void git_worktree_free(git_worktree *wt)
234234

235235
int git_worktree_validate(const git_worktree *wt)
236236
{
237-
int err = 0;
238-
239237
assert(wt);
240238

241239
if (!is_worktree_dir(wt->gitdir_path)) {
242240
giterr_set(GITERR_WORKTREE,
243241
"Worktree gitdir ('%s') is not valid",
244242
wt->gitlink_path);
245-
err = -1;
246-
goto out;
243+
return GIT_ERROR;
247244
}
248245

249246
if (wt->parent_path && !git_path_exists(wt->parent_path)) {
250247
giterr_set(GITERR_WORKTREE,
251248
"Worktree parent directory ('%s') does not exist ",
252249
wt->parent_path);
253-
err = -2;
254-
goto out;
250+
return GIT_ERROR;
255251
}
256252

257253
if (!git_path_exists(wt->commondir_path)) {
258254
giterr_set(GITERR_WORKTREE,
259255
"Worktree common directory ('%s') does not exist ",
260256
wt->commondir_path);
261-
err = -3;
262-
goto out;
257+
return GIT_ERROR;
263258
}
264259

265-
out:
266-
267-
return err;
260+
return 0;
268261
}
269262

270263
int git_worktree_add_init_options(git_worktree_add_options *opts,

0 commit comments

Comments
 (0)