1
0
mirror of https://github.com/git/git.git synced 2024-10-21 22:18:12 +02:00

Merge branch 'nb/worktree-api-doc'

Code readability fix.

* nb/worktree-api-doc:
  worktree: rename is_worktree_locked to worktree_lock_reason
  worktree: update documentation for lock_reason and lock_reason_valid
This commit is contained in:
Junio C Hamano 2018-11-13 22:37:21 +09:00
commit 504bdc5994
3 changed files with 9 additions and 9 deletions

@ -245,7 +245,7 @@ static void validate_worktree_add(const char *path, const struct add_opts *opts)
if (!wt)
goto done;
locked = !!is_worktree_locked(wt);
locked = !!worktree_lock_reason(wt);
if ((!locked && opts->force) || (locked && opts->force > 1)) {
if (delete_git_dir(wt->id))
die(_("unable to re-add worktree '%s'"), path);
@ -682,7 +682,7 @@ static int lock_worktree(int ac, const char **av, const char *prefix)
if (is_main_worktree(wt))
die(_("The main working tree cannot be locked or unlocked"));
old_reason = is_worktree_locked(wt);
old_reason = worktree_lock_reason(wt);
if (old_reason) {
if (*old_reason)
die(_("'%s' is already locked, reason: %s"),
@ -714,7 +714,7 @@ static int unlock_worktree(int ac, const char **av, const char *prefix)
die(_("'%s' is not a working tree"), av[0]);
if (is_main_worktree(wt))
die(_("The main working tree cannot be locked or unlocked"));
if (!is_worktree_locked(wt))
if (!worktree_lock_reason(wt))
die(_("'%s' is not locked"), av[0]);
ret = unlink_or_warn(git_common_path("worktrees/%s/locked", wt->id));
free_worktrees(worktrees);
@ -787,7 +787,7 @@ static int move_worktree(int ac, const char **av, const char *prefix)
validate_no_submodules(wt);
if (force < 2)
reason = is_worktree_locked(wt);
reason = worktree_lock_reason(wt);
if (reason) {
if (*reason)
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)
if (is_main_worktree(wt))
die(_("'%s' is a main working tree"), av[0]);
if (force < 2)
reason = is_worktree_locked(wt);
reason = worktree_lock_reason(wt);
if (reason) {
if (*reason)
die(_("cannot remove a locked working tree, lock reason: %s\nuse 'remove -f -f' to override or unlock first"),

@ -235,7 +235,7 @@ int is_main_worktree(const struct worktree *wt)
return !wt->id;
}
const char *is_worktree_locked(struct worktree *wt)
const char *worktree_lock_reason(struct worktree *wt)
{
assert(!is_main_worktree(wt));

@ -10,12 +10,12 @@ struct worktree {
char *path;
char *id;
char *head_ref; /* NULL if HEAD is broken or detached */
char *lock_reason; /* internal use */
char *lock_reason; /* private - use worktree_lock_reason */
struct object_id head_oid;
int is_detached;
int is_bare;
int is_current;
int lock_reason_valid;
int lock_reason_valid; /* private */
};
/* Functions for acting on the information about worktrees. */
@ -60,7 +60,7 @@ extern int is_main_worktree(const struct worktree *wt);
* Return the reason string if the given worktree is locked or NULL
* otherwise.
*/
extern const char *is_worktree_locked(struct worktree *wt);
extern const char *worktree_lock_reason(struct worktree *wt);
#define WT_VALIDATE_WORKTREE_MISSING_OK (1 << 0)