worktree: rename is_worktree_locked to worktree_lock_reason
A function prefixed with 'is_' would be expected to return a boolean, however this function returns a string. Signed-off-by: Nickolai Belakovski <nbelakovski@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Nickolai Belakovski committed
Oct 29, 2018 at 23:24 UTC
d236f12bdeb478bbaabf056bc611c34cf9218ca8
3 files changed
+8
-8
builtin/worktree.c
+5
-5
@@ -245,7 +245,7 @@ static void validate_worktree_add(const char *path, const struct add_opts *opts)
245
if (!wt)
246
goto done;
247
248
- locked = !!is_worktree_locked(wt);
248
+ locked = !!worktree_lock_reason(wt);
249
if ((!locked && opts->force) || (locked && opts->force > 1)) {
250
if (delete_git_dir(wt->id))
251
die(_("unable to re-add worktree '%s'"), path);
@@ -682,7 +682,7 @@ static int lock_worktree(int ac, const char **av, const char *prefix)
682
if (is_main_worktree(wt))
683
die(_("The main working tree cannot be locked or unlocked"));
684
685
- old_reason = is_worktree_locked(wt);
685
+ old_reason = worktree_lock_reason(wt);
686
if (old_reason) {
687
if (*old_reason)
688
die(_("'%s' is already locked, reason: %s"),
@@ -714,7 +714,7 @@ static int unlock_worktree(int ac, const char **av, const char *prefix)
714
die(_("'%s' is not a working tree"), av[0]);
715
if (is_main_worktree(wt))
716
die(_("The main working tree cannot be locked or unlocked"));
717
- if (!is_worktree_locked(wt))
717
+ if (!worktree_lock_reason(wt))
718
die(_("'%s' is not locked"), av[0]);
719
ret = unlink_or_warn(git_common_path("worktrees/%s/locked", wt->id));
720
free_worktrees(worktrees);
@@ -787,7 +787,7 @@ static int move_worktree(int ac, const char **av, const char *prefix)
787
validate_no_submodules(wt);
788
789
if (force < 2)
790
- reason = is_worktree_locked(wt);
790
+ reason = worktree_lock_reason(wt);
791
if (reason) {
792
if (*reason)
793
die(_("cannot move a locked working tree, lock reason: %s\nuse 'move -f -f' to override or unlock first"),
@@ -900,7 +900,7 @@ static int remove_worktree(int ac, const char **av, const char *prefix)
900
if (is_main_worktree(wt))
901
die(_("'%s' is a main working tree"), av[0]);
902
if (force < 2)
903
- reason = is_worktree_locked(wt);
903
+ reason = worktree_lock_reason(wt);
904
if (reason) {
905
if (*reason)
906
die(_("cannot remove a locked working tree, lock reason: %s\nuse 'remove -f -f' to override or unlock first"),
worktree.c
+1
-1
@@ -235,7 +235,7 @@ int is_main_worktree(const struct worktree *wt)
235
return !wt->id;
236
}
237
238
-const char *is_worktree_locked(struct worktree *wt)
238
+const char *worktree_lock_reason(struct worktree *wt)
239
{
240
assert(!is_main_worktree(wt));
241
worktree.h
+2
-2
@@ -10,7 +10,7 @@ struct worktree {
10
char *path;
11
char *id;
12
char *head_ref; /* NULL if HEAD is broken or detached */
13
- char *lock_reason; /* private - use is_worktree_locked */
13
+ char *lock_reason; /* private - use worktree_lock_reason */
14
struct object_id head_oid;
15
int is_detached;
16
int is_bare;
@@ -60,7 +60,7 @@ extern int is_main_worktree(const struct worktree *wt);
60
* Return the reason string if the given worktree is locked or NULL
61
* otherwise.
62
*/
63
-extern const char *is_worktree_locked(struct worktree *wt);
63
+extern const char *worktree_lock_reason(struct worktree *wt);
64
65
#define WT_VALIDATE_WORKTREE_MISSING_OK (1 << 0)
66