git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Eric Sunshine <sunshine@sunshineco.com>
To: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
Cc: Git List <git@vger.kernel.org>
Subject: Re: [PATCH 3/3] worktree prune: improve prune logic when worktree is moved
Date: Sat, 3 Mar 2018 04:30:01 -0500	[thread overview]
Message-ID: <CAPig+cQG8yEqunNUjoEAPY-W9+TtzWADhgjdL6udnyrG0YEOVg@mail.gmail.com> (raw)
In-Reply-To: <20180303033918.15751-4-pclouds@gmail.com>

On Fri, Mar 2, 2018 at 10:39 PM, Nguyễn Thái Ngọc Duy <pclouds@gmail.com> wrote:
> 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.

I had a bit of trouble digesting this paragraph. Possible rewrite:

    Automatic detection of worktree relocation by a user (via 'mv',
    for instance) was removed by 618244e160 (worktree: stop supporting
    moving worktrees manually - 2016-01-22). Prior to that,
    .git/worktrees/<tag>/gitdir was updated whenever the worktree was
    accessed in order to let the pruning logic know that the worktree
    was "active" even if it disappeared for a while (due to being
    located on removable media, for instance).

> "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.

Seems like a reasonable approximation of the pre-618244e160 way things worked.

> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
> ---
> diff --git 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) {

This st.st_mtime is that of 'gitdir'...

> +                       if (!stat(git_path("worktrees/%s/index", id), &st) &&
> +                           st.st_mtime > expire)

...and this st.st_mtime is of 'index'.

I wonder if it the 'gitdir' mtime check is really that useful anymore
considering that 'index' mtime will almost certainly be more recent.

> +                               return 0;
>                         strbuf_addf(reason, _("Removing worktrees/%s: gitdir file points to non-existent location"), id);
>                         return 1;

  reply	other threads:[~2018-03-03  9:30 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 ` [PATCH 3/3] worktree prune: improve prune logic when worktree is moved Nguyễn Thái Ngọc Duy
2018-03-03  9:30   ` Eric Sunshine [this message]
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

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAPig+cQG8yEqunNUjoEAPY-W9+TtzWADhgjdL6udnyrG0YEOVg@mail.gmail.com \
    --to=sunshine@sunshineco.com \
    --cc=git@vger.kernel.org \
    --cc=pclouds@gmail.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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).