From: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
To: git@vger.kernel.org
Cc: "Eric Sunshine" <sunshine@sunshineco.com>,
"Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
Subject: [PATCH 3/3] worktree prune: improve prune logic when worktree is moved
Date: Sat, 3 Mar 2018 10:39:18 +0700 [thread overview]
Message-ID: <20180303033918.15751-4-pclouds@gmail.com> (raw)
In-Reply-To: <20180303033918.15751-1-pclouds@gmail.com>
Worktree manual move support is actually gone in 618244e160 (worktree:
stop supporting moving worktrees manually - 2016-01-22). Before that,
this gitdir could be updated often when the worktree is accessed. That
keeps the worktree from being pruned by this logic.
"git worktree move" is coming so we don't really need this, but since
it's easy to do, perhaps we could keep supporting manual worktree move a
bit longer. Notice that when a worktree is active, the "index" file
should be updated pretty often in common case. The logic is updated to
check for index mtime to see if the worktree is alive.
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
builtin/worktree.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/builtin/worktree.c b/builtin/worktree.c
index 60440c4106..4d4404e97f 100644
--- a/builtin/worktree.c
+++ b/builtin/worktree.c
@@ -101,6 +101,9 @@ static int prune_worktree(const char *id, struct strbuf *reason)
if (!file_exists(path)) {
free(path);
if (st.st_mtime <= expire) {
+ if (!stat(git_path("worktrees/%s/index", id), &st) &&
+ st.st_mtime > expire)
+ return 0;
strbuf_addf(reason, _("Removing worktrees/%s: gitdir file points to non-existent location"), id);
return 1;
} else {
--
2.16.1.435.g8f24da2e1a
next prev parent reply other threads:[~2018-03-03 3:39 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-03 3:39 [PATCH 0/3] git worktree prune improvements Nguyễn Thái Ngọc Duy
2018-03-03 3:39 ` [PATCH 1/3] gc.txt: more details about what gc does Nguyễn Thái Ngọc Duy
2018-03-03 9:14 ` Eric Sunshine
2018-03-03 3:39 ` [PATCH 2/3] worktree: delete dead code Nguyễn Thái Ngọc Duy
2018-03-03 3:39 ` Nguyễn Thái Ngọc Duy [this message]
2018-03-03 9:30 ` [PATCH 3/3] worktree prune: improve prune logic when worktree is moved Eric Sunshine
2018-03-03 14:21 ` [PATCH 0/3] git worktree prune improvements Randall S. Becker
2018-03-05 12:16 ` Duy Nguyen
2018-03-15 16:44 ` [PATCH v2 " Nguyễn Thái Ngọc Duy
2018-03-15 16:44 ` [PATCH v2 1/3] gc.txt: more details about what gc does Nguyễn Thái Ngọc Duy
2018-03-15 16:44 ` [PATCH v2 2/3] worktree: delete dead code Nguyễn Thái Ngọc Duy
2018-03-18 22:51 ` Eric Sunshine
2018-03-15 16:44 ` [PATCH v2 3/3] worktree prune: improve prune logic when worktree is moved Nguyễn Thái Ngọc Duy
2018-03-18 22:59 ` Eric Sunshine
2018-03-18 23:02 ` [PATCH v2 0/3] git worktree prune improvements 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=20180303033918.15751-4-pclouds@gmail.com \
--to=pclouds@gmail.com \
--cc=git@vger.kernel.org \
--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;
as well as URLs for NNTP newsgroup(s).