Skip to content

Commit 503af77

Browse files
authored
Merge pull request libgit2#4769 from tiennou/fix/worktree-unlock
worktree: unlock should return 1 when the worktree isn't locked
2 parents 0036993 + 59c2e70 commit 503af77

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/worktree.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ int git_worktree_unlock(git_worktree *wt)
426426
assert(wt);
427427

428428
if (!git_worktree_is_locked(NULL, wt))
429-
return 0;
429+
return 1;
430430

431431
if (git_buf_joinpath(&path, wt->gitdir_path, "locked") < 0)
432432
return -1;

tests/worktree/worktree.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,7 @@ void test_worktree_worktree__unlock_unlocked_worktree(void)
477477

478478
cl_git_pass(git_worktree_lookup(&wt, fixture.repo, "testrepo-worktree"));
479479
cl_assert(!git_worktree_is_locked(NULL, wt));
480-
cl_assert(git_worktree_unlock(wt) == 0);
480+
cl_assert_equal_i(1, git_worktree_unlock(wt));
481481
cl_assert(!wt->locked);
482482

483483
git_worktree_free(wt);
@@ -490,7 +490,7 @@ void test_worktree_worktree__unlock_locked_worktree(void)
490490
cl_git_pass(git_worktree_lookup(&wt, fixture.repo, "testrepo-worktree"));
491491
cl_git_pass(git_worktree_lock(wt, NULL));
492492
cl_assert(git_worktree_is_locked(NULL, wt));
493-
cl_git_pass(git_worktree_unlock(wt));
493+
cl_assert_equal_i(0, git_worktree_unlock(wt));
494494
cl_assert(!wt->locked);
495495

496496
git_worktree_free(wt);

0 commit comments

Comments
 (0)