Skip to content

Commit 6f5ca70

Browse files
sambostockgitster
authored andcommitted
worktree: clarify that --expire only affects missing worktrees
The --expire option for "git worktree list" and "git worktree prune" only affects worktrees whose working directory path no longer exists. The help text did not make this clear, and the documentation inconsistently used "unused" for prune but "missing" for list. Update the help text and documentation to consistently describe these as "missing worktrees", and use "prune" instead of "expire" when describing the effect on missing worktrees since the terminology is clearer. While at it, expand the description of the "prune" subcommand itself to better explain what it does and when to use it, as suggested by Junio. Helped-by: Eric Sunshine <sunshine@sunshineco.com> Helped-by: Junio C Hamano <gitster@pobox.com> Signed-off-by: Sam Bostock <sam@sambostock.ca> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 9a2fb14 commit 6f5ca70

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

Documentation/git-worktree.adoc

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,13 @@ with linked worktrees if you move the main worktree manually.)
131131

132132
`prune`::
133133

134-
Prune worktree information in `$GIT_DIR/worktrees`.
134+
Remove worktree information in `$GIT_DIR/worktrees` for worktrees
135+
whose working trees are missing. Useful after manually removing
136+
a working tree that is no longer needed (but use "git worktree
137+
remove" next time you want to do so). Also, if you _moved_ a
138+
working tree elsewhere causing the worktree information to become
139+
dangling, see "git worktree repair" to reconnect the worktree to
140+
the new working tree location.
135141

136142
`remove`::
137143

@@ -271,7 +277,7 @@ mismatch, even if the links are correct.
271277
With `list`, output additional information about worktrees (see below).
272278

273279
`--expire <time>`::
274-
With `prune`, only expire unused worktrees older than _<time>_.
280+
With `prune`, only prune missing worktrees if older than _<time>_.
275281
+
276282
With `list`, annotate missing worktrees as prunable if they are older than
277283
_<time>_.

builtin/worktree.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ static int prune(int ac, const char **av, const char *prefix,
252252
OPT__DRY_RUN(&show_only, N_("do not remove, show only")),
253253
OPT__VERBOSE(&verbose, N_("report pruned working trees")),
254254
OPT_EXPIRY_DATE(0, "expire", &expire,
255-
N_("expire working trees older than <time>")),
255+
N_("prune missing working trees older than <time>")),
256256
OPT_END()
257257
};
258258

@@ -1063,7 +1063,7 @@ static int list(int ac, const char **av, const char *prefix,
10631063
OPT_BOOL(0, "porcelain", &porcelain, N_("machine-readable output")),
10641064
OPT__VERBOSE(&verbose, N_("show extended annotations and reasons, if available")),
10651065
OPT_EXPIRY_DATE(0, "expire", &expire,
1066-
N_("add 'prunable' annotation to worktrees older than <time>")),
1066+
N_("add 'prunable' annotation to missing worktrees older than <time>")),
10671067
OPT_SET_INT('z', NULL, &line_terminator,
10681068
N_("terminate records with a NUL character"), '\0'),
10691069
OPT_END()

0 commit comments

Comments
 (0)