Skip to content

Commit d236f12

Browse files
nbelakovskigitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent e21cc07 commit d236f12

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

builtin/worktree.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ static void validate_worktree_add(const char *path, const struct add_opts *opts)
245245
if (!wt)
246246
goto done;
247247

248-
locked = !!is_worktree_locked(wt);
248+
locked = !!worktree_lock_reason(wt);
249249
if ((!locked && opts->force) || (locked && opts->force > 1)) {
250250
if (delete_git_dir(wt->id))
251251
die(_("unable to re-add worktree '%s'"), path);
@@ -682,7 +682,7 @@ static int lock_worktree(int ac, const char **av, const char *prefix)
682682
if (is_main_worktree(wt))
683683
die(_("The main working tree cannot be locked or unlocked"));
684684

685-
old_reason = is_worktree_locked(wt);
685+
old_reason = worktree_lock_reason(wt);
686686
if (old_reason) {
687687
if (*old_reason)
688688
die(_("'%s' is already locked, reason: %s"),
@@ -714,7 +714,7 @@ static int unlock_worktree(int ac, const char **av, const char *prefix)
714714
die(_("'%s' is not a working tree"), av[0]);
715715
if (is_main_worktree(wt))
716716
die(_("The main working tree cannot be locked or unlocked"));
717-
if (!is_worktree_locked(wt))
717+
if (!worktree_lock_reason(wt))
718718
die(_("'%s' is not locked"), av[0]);
719719
ret = unlink_or_warn(git_common_path("worktrees/%s/locked", wt->id));
720720
free_worktrees(worktrees);
@@ -787,7 +787,7 @@ static int move_worktree(int ac, const char **av, const char *prefix)
787787
validate_no_submodules(wt);
788788

789789
if (force < 2)
790-
reason = is_worktree_locked(wt);
790+
reason = worktree_lock_reason(wt);
791791
if (reason) {
792792
if (*reason)
793793
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)
900900
if (is_main_worktree(wt))
901901
die(_("'%s' is a main working tree"), av[0]);
902902
if (force < 2)
903-
reason = is_worktree_locked(wt);
903+
reason = worktree_lock_reason(wt);
904904
if (reason) {
905905
if (*reason)
906906
die(_("cannot remove a locked working tree, lock reason: %s\nuse 'remove -f -f' to override or unlock first"),

worktree.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ int is_main_worktree(const struct worktree *wt)
235235
return !wt->id;
236236
}
237237

238-
const char *is_worktree_locked(struct worktree *wt)
238+
const char *worktree_lock_reason(struct worktree *wt)
239239
{
240240
assert(!is_main_worktree(wt));
241241

worktree.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ struct worktree {
1010
char *path;
1111
char *id;
1212
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 */
1414
struct object_id head_oid;
1515
int is_detached;
1616
int is_bare;
@@ -60,7 +60,7 @@ extern int is_main_worktree(const struct worktree *wt);
6060
* Return the reason string if the given worktree is locked or NULL
6161
* otherwise.
6262
*/
63-
extern const char *is_worktree_locked(struct worktree *wt);
63+
extern const char *worktree_lock_reason(struct worktree *wt);
6464

6565
#define WT_VALIDATE_WORKTREE_MISSING_OK (1 << 0)
6666

0 commit comments

Comments
 (0)