diff options
author | Etienne Samson <samson.etienne@gmail.com> | 2018-08-17 00:51:51 +0200 |
---|---|---|
committer | Patrick Steinhardt <ps@pks.im> | 2018-10-26 14:58:51 +0200 |
commit | ef7d7defd6fdd504f2c34f66080e31a440a0fdfd (patch) | |
tree | b950b098655fee5aef3e5537e47053befb6d6d67 | |
parent | a5a0347db2638939ea2f4073301ea91439814fe1 (diff) | |
download | libgit2-ef7d7defd6fdd504f2c34f66080e31a440a0fdfd.tar.gz |
worktree: unlock should return 1 when the worktree isn't locked
The documentation states that git_worktree_unlock returns 0 on success,
and 1 on success if the worktree wasn't locked. Turns out we were
returning 0 in any of those cases.
(cherry picked from commit 59c2e70eeee8b2bae79d05060599114a5f6d737a)
-rw-r--r-- | src/worktree.c | 2 | ||||
-rw-r--r-- | tests/worktree/worktree.c | 4 |
2 files changed, 3 insertions, 3 deletions
diff --git a/src/worktree.c b/src/worktree.c index 6ba1fce33..4acf61b8b 100644 --- a/src/worktree.c +++ b/src/worktree.c @@ -417,7 +417,7 @@ int git_worktree_unlock(git_worktree *wt) assert(wt); if (!git_worktree_is_locked(NULL, wt)) - return 0; + return 1; if (git_buf_joinpath(&path, wt->gitdir_path, "locked") < 0) return -1; diff --git a/tests/worktree/worktree.c b/tests/worktree/worktree.c index 8f6bd7c55..9026a7f83 100644 --- a/tests/worktree/worktree.c +++ b/tests/worktree/worktree.c @@ -455,7 +455,7 @@ void test_worktree_worktree__unlock_unlocked_worktree(void) cl_git_pass(git_worktree_lookup(&wt, fixture.repo, "testrepo-worktree")); cl_assert(!git_worktree_is_locked(NULL, wt)); - cl_assert(git_worktree_unlock(wt) == 0); + cl_assert_equal_i(1, git_worktree_unlock(wt)); cl_assert(!wt->locked); git_worktree_free(wt); @@ -468,7 +468,7 @@ void test_worktree_worktree__unlock_locked_worktree(void) cl_git_pass(git_worktree_lookup(&wt, fixture.repo, "testrepo-worktree")); cl_git_pass(git_worktree_lock(wt, NULL)); cl_assert(git_worktree_is_locked(NULL, wt)); - cl_git_pass(git_worktree_unlock(wt)); + cl_assert_equal_i(0, git_worktree_unlock(wt)); cl_assert(!wt->locked); git_worktree_free(wt); |