From: "Sam Bostock via GitGitGadget" <gitgitgadget@gmail.com>
To: git@vger.kernel.org
Cc: Eric Sunshine <sunshine@sunshineco.com>,
Sam Bostock <sam.bostock@shopify.com>,
Sam Bostock <sam.bostock@shopify.com>
Subject: [PATCH v3] worktree: clarify that --expire only affects missing worktrees
Date: Wed, 28 Jan 2026 05:39:45 +0000 [thread overview]
Message-ID: <pull.2135.v3.git.git.1769578785381.gitgitgadget@gmail.com> (raw)
In-Reply-To: <pull.2135.v2.git.git.1766168169.gitgitgadget@gmail.com>
From: Sam Bostock <sam.bostock@shopify.com>
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>
---
worktree: clarify --expire applies to missing worktrees
Changes from v2:
* Squash into a single commit
* Expand the prune subcommand description per Junio's suggestion
Changes from v1:
* Use "prune" instead of "expire" in help text
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-2135%2Fsambostock%2Fexpire-missing-worktrees-v3
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-2135/sambostock/expire-missing-worktrees-v3
Pull-Request: https://github.com/git/git/pull/2135
Range-diff vs v2:
1: ddd4191ecb ! 1: a4483d9a20 worktree: clarify --expire applies to missing worktrees
@@ Metadata
Author: Sam Bostock <sam.bostock@shopify.com>
## Commit message ##
- worktree: clarify --expire applies to missing worktrees
+ worktree: clarify that --expire only affects missing worktrees
- The `--expire` option for `git worktree list` and `git worktree prune`
+ 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.
- This updates the help text and documentation to consistently describe
- these as "missing worktrees".
+ 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>
## Documentation/git-worktree.adoc ##
+@@ Documentation/git-worktree.adoc: with linked worktrees if you move the main worktree manually.)
+
+ `prune`::
+
+-Prune worktree information in `$GIT_DIR/worktrees`.
++Remove worktree information in `$GIT_DIR/worktrees` for worktrees
++whose working trees are missing. Useful after manually removing
++a working tree that is no longer needed (but use "git worktree
++remove" next time you want to do so). Also, if you _moved_ a
++working tree elsewhere causing the worktree information to become
++dangling, see "git worktree repair" to reconnect the worktree to
++the new working tree location.
+
+ `remove`::
+
@@ Documentation/git-worktree.adoc: mismatch, even if the links are correct.
With `list`, output additional information about worktrees (see below).
`--expire <time>`::
- With `prune`, only expire unused worktrees older than _<time>_.
-+ With `prune`, only expire missing worktrees older than _<time>_.
++ With `prune`, only prune missing worktrees if older than _<time>_.
+
With `list`, annotate missing worktrees as prunable if they are older than
_<time>_.
@@ builtin/worktree.c: static int prune(int ac, const char **av, const char *prefix
OPT__VERBOSE(&verbose, N_("report pruned working trees")),
OPT_EXPIRY_DATE(0, "expire", &expire,
- N_("expire working trees older than <time>")),
-+ N_("expire missing working trees older than <time>")),
++ N_("prune missing working trees older than <time>")),
OPT_END()
};
2: ff4732b72a < -: ---------- worktree: use 'prune' instead of 'expire' in help text
Documentation/git-worktree.adoc | 10 ++++++++--
builtin/worktree.c | 4 ++--
2 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/Documentation/git-worktree.adoc b/Documentation/git-worktree.adoc
index f272f79783..22ef37ec02 100644
--- a/Documentation/git-worktree.adoc
+++ b/Documentation/git-worktree.adoc
@@ -131,7 +131,13 @@ with linked worktrees if you move the main worktree manually.)
`prune`::
-Prune worktree information in `$GIT_DIR/worktrees`.
+Remove worktree information in `$GIT_DIR/worktrees` for worktrees
+whose working trees are missing. Useful after manually removing
+a working tree that is no longer needed (but use "git worktree
+remove" next time you want to do so). Also, if you _moved_ a
+working tree elsewhere causing the worktree information to become
+dangling, see "git worktree repair" to reconnect the worktree to
+the new working tree location.
`remove`::
@@ -271,7 +277,7 @@ mismatch, even if the links are correct.
With `list`, output additional information about worktrees (see below).
`--expire <time>`::
- With `prune`, only expire unused worktrees older than _<time>_.
+ With `prune`, only prune missing worktrees if older than _<time>_.
+
With `list`, annotate missing worktrees as prunable if they are older than
_<time>_.
diff --git a/builtin/worktree.c b/builtin/worktree.c
index fbdaf2eb2e..3d6547c23b 100644
--- a/builtin/worktree.c
+++ b/builtin/worktree.c
@@ -252,7 +252,7 @@ static int prune(int ac, const char **av, const char *prefix,
OPT__DRY_RUN(&show_only, N_("do not remove, show only")),
OPT__VERBOSE(&verbose, N_("report pruned working trees")),
OPT_EXPIRY_DATE(0, "expire", &expire,
- N_("expire working trees older than <time>")),
+ N_("prune missing working trees older than <time>")),
OPT_END()
};
@@ -1070,7 +1070,7 @@ static int list(int ac, const char **av, const char *prefix,
OPT_BOOL(0, "porcelain", &porcelain, N_("machine-readable output")),
OPT__VERBOSE(&verbose, N_("show extended annotations and reasons, if available")),
OPT_EXPIRY_DATE(0, "expire", &expire,
- N_("add 'prunable' annotation to worktrees older than <time>")),
+ N_("add 'prunable' annotation to missing worktrees older than <time>")),
OPT_SET_INT('z', NULL, &line_terminator,
N_("terminate records with a NUL character"), '\0'),
OPT_END()
base-commit: c4a0c8845e2426375ad257b6c221a3a7d92ecfda
--
gitgitgadget
next prev parent reply other threads:[~2026-01-28 5:39 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-19 15:00 [PATCH] worktree: clarify --expire applies to missing worktrees Sam Bostock via GitGitGadget
2025-12-19 15:11 ` Eric Sunshine
2025-12-20 5:44 ` Junio C Hamano
2025-12-20 7:14 ` Eric Sunshine
2025-12-20 7:31 ` Junio C Hamano
2025-12-20 8:23 ` Eric Sunshine
2025-12-19 18:16 ` [PATCH v2 0/2] " Sam Bostock via GitGitGadget
2025-12-19 18:16 ` [PATCH v2 1/2] " Sam Bostock via GitGitGadget
2025-12-20 6:07 ` Junio C Hamano
2025-12-19 18:16 ` [PATCH v2 2/2] worktree: use 'prune' instead of 'expire' in help text Sam Bostock via GitGitGadget
2025-12-20 6:11 ` Junio C Hamano
2026-01-21 19:55 ` [PATCH v2 0/2] worktree: clarify --expire applies to missing worktrees Junio C Hamano
2026-01-28 5:39 ` Sam Bostock via GitGitGadget [this message]
2026-01-30 0:29 ` [PATCH v3] worktree: clarify that --expire only affects " Eric Sunshine
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=pull.2135.v3.git.git.1769578785381.gitgitgadget@gmail.com \
--to=gitgitgadget@gmail.com \
--cc=git@vger.kernel.org \
--cc=sam.bostock@shopify.com \
--cc=sunshine@sunshineco.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox