From: Junio C Hamano Date: Tue, 8 May 2018 06:59:24 +0000 (+0900) Subject: Merge branch 'sb/worktree-remove-opt-force' X-Git-Tag: v2.18.0-rc0~91 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/90186fa0579e4dcdde08a2d823d9b269578d5a70?ds=sidebyside;hp=-c Merge branch 'sb/worktree-remove-opt-force' "git worktree remove" learned that "-f" is a shorthand for "--force" option, just like for "git worktree add". * sb/worktree-remove-opt-force: worktree: accept -f as short for --force for removal --- 90186fa0579e4dcdde08a2d823d9b269578d5a70 diff --combined Documentation/git-worktree.txt index 2755ca90e3,99b713c849..9920d9c06e --- a/Documentation/git-worktree.txt +++ b/Documentation/git-worktree.txt @@@ -14,7 -14,7 +14,7 @@@ SYNOPSI 'git worktree lock' [--reason ] 'git worktree move' 'git worktree prune' [-n] [-v] [--expire ] - 'git worktree remove' [--force] + 'git worktree remove' [-f] 'git worktree unlock' DESCRIPTION @@@ -27,12 -27,11 +27,12 @@@ out more than one branch at a time. Wi tree is associated with the repository. This new working tree is called a "linked working tree" as opposed to the "main working tree" prepared by "git init" or "git clone". A repository has one main working tree (if it's not a -bare repository) and zero or more linked working trees. +bare repository) and zero or more linked working trees. When you are done +with a linked working tree, remove it with `git worktree remove`. -When you are done with a linked working tree you can simply delete it. -The working tree's administrative files in the repository (see -"DETAILS" below) will eventually be removed automatically (see +If a working tree is deleted without using `git worktree remove`, then +its associated administrative files, which reside in the repository +(see "DETAILS" below), will eventually be removed automatically (see `gc.worktreePruneExpire` in linkgit:git-config[1]), or you can run `git worktree prune` in the main or any linked working tree to clean up any stale administrative files. @@@ -107,7 -106,7 +107,7 @@@ OPTION By default, `add` refuses to create a new working tree when `` is a branch name and is already checked out by another working tree and `remove` refuses to remove an unclean - working tree. This option overrides that safeguard. + working tree. This option overrides these safeguards. -b :: -B :: @@@ -233,7 -232,7 +233,7 @@@ The worktree list command has two outpu details on a single line with columns. For example: ------------ -S git worktree list +$ git worktree list /path/to/bare-source (bare) /path/to/linked-worktree abcd1234 [master] /path/to/other-linked-worktree 1234abc (detached HEAD) @@@ -248,7 -247,7 +248,7 @@@ if the value is true. An empty line in example: ------------ -S git worktree list --porcelain +$ git worktree list --porcelain worktree /path/to/bare-source bare @@@ -279,7 -278,8 +279,7 @@@ $ pushd ../tem # ... hack hack hack ... $ git commit -a -m 'emergency fix for boss' $ popd -$ rm -rf ../temp -$ git worktree prune +$ git worktree remove ../temp ------------ BUGS diff --combined builtin/worktree.c index 40a438ed6c,dba460f813..30647b30c5 --- a/builtin/worktree.c +++ b/builtin/worktree.c @@@ -101,9 -101,16 +101,9 @@@ static int prune_worktree(const char *i } path[len] = '\0'; if (!file_exists(path)) { - struct stat st_link; free(path); - /* - * the repo is moved manually and has not been - * accessed since? - */ - if (!stat(git_path("worktrees/%s/link", id), &st_link) && - st_link.st_nlink > 1) - return 0; - if (st.st_mtime <= expire) { + if (stat(git_path("worktrees/%s/index", id), &st) || + st.st_mtime <= expire) { strbuf_addf(reason, _("Removing worktrees/%s: gitdir file points to non-existent location"), id); return 1; } else { @@@ -495,7 -502,7 +495,7 @@@ static void show_worktree(struct worktr strbuf_addstr(&sb, "(bare)"); else { strbuf_addf(&sb, "%-*s ", abbrev_len, - find_unique_abbrev(wt->head_oid.hash, DEFAULT_ABBREV)); + find_unique_abbrev(&wt->head_oid, DEFAULT_ABBREV)); if (wt->is_detached) strbuf_addstr(&sb, "(detached HEAD)"); else if (wt->head_ref) { @@@ -520,7 -527,7 +520,7 @@@ static void measure_widths(struct workt if (path_len > *maxlen) *maxlen = path_len; - sha1_len = strlen(find_unique_abbrev(wt[i]->head_oid.hash, *abbrev)); + sha1_len = strlen(find_unique_abbrev(&wt[i]->head_oid, *abbrev)); if (sha1_len > *abbrev) *abbrev = sha1_len; } @@@ -783,8 -790,9 +783,9 @@@ static int remove_worktree(int ac, cons { int force = 0; struct option options[] = { - OPT_BOOL(0, "force", &force, - N_("force removing even if the worktree is dirty")), + OPT__FORCE(&force, + N_("force removing even if the worktree is dirty"), + PARSE_OPT_NOCOMPLETE), OPT_END() }; struct worktree **worktrees, *wt;