git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Jeff King <peff@peff.net>
To: git@vger.kernel.org
Subject: worktree duplicates, was: [PATCH] SubmittingPatches: mention doc-diff
Date: Tue, 21 Aug 2018 15:35:56 -0400	[thread overview]
Message-ID: <20180821193556.GA859@sigill.intra.peff.net> (raw)
In-Reply-To: <20180821192321.GA720@sigill.intra.peff.net>

On Tue, Aug 21, 2018 at 03:23:21PM -0400, Jeff King wrote:

> We already advise people to make sure their documentation
> formats correctly. Let's point them at the doc-diff script,
> which can help with that.
> 
> Let's also put a brief note in the script about its purpose,
> since that otherwise can only be found in the original
> commit message. Along with the existing -h/usage text,
> that's hopefully enough for developers to make use of it.
> 
> Signed-off-by: Jeff King <peff@peff.net>
> ---
> Just a finishing touch on the jk/diff-rendered-docs topic.

I noticed one other oddity with this script, but I actually think the
fix lies elsewhere.

The script does basically this to set up the temporary tree:

  test -d $tmp || git worktree add $tmp ...

The script never cleans up the worktree (since its results can often be
reused between runs), but you may do so with "rm" or "git clean". That
creates an interesting situation if the script is run again before
"worktree prune" runs. We identify the directory as a "new" worktree,
and add it to the list. So you may end up with several copies:

  $ git worktree list
  /home/peff/compile/git                                      eee785d2e0 [jk/doc-diff]
  /home/peff/compile/git/.git/tmp-ci                          290f16acda (detached HEAD)
  /home/peff/compile/git/Documentation/tmp-doc-diff/worktree  cc6237c051 (detached HEAD)
  /home/peff/compile/git/Documentation/tmp-doc-diff/worktree  e55de40950 (detached HEAD)
  /home/peff/compile/git/Documentation/tmp-doc-diff/worktree  e55de40950 (detached HEAD)

If I then run "git worktree prune", those duplicates don't go away
(because the directory is still there; it just corresponds to only the
final entry). If I delete the tmp-doc-diff directory and then run "git
worktree prune", they do all go away.

So I'm not sure:

  1. Should the script be doing something else to indicate that the
     worktree may be reused? I tried "git worktree remove", but it's
     unhappy that the directory doesn't exist. Should it quietly handle
     ignore that and remove any leftover cruft in $GIT_DIR/worktrees?

  2. Should "git worktree add" be more clever about realizing that an
     existing entry in $GIT_DIR/worktrees points to this directory? That
     would be fine for my use, but I wonder if there's some potential
     for loss (e.g., you blew away the work tree but until you do a
     "worktree prune", the refs are still there, objects reachable,
     etc).

  3. Should "git worktree prune" be more clever about dropping
     duplicates? I think it should be easy to identify them: they are
     entries in $GIT_DIR/worktrees for which:

       - the directory in $entry/gitdir does exist, but

       - $(cat $entry/gitdir)/.git does not point back to $entry

I could see any of them being plausible fixes, but people who have given
worktrees a lot of thought may have stronger opinions.

-Peff

  reply	other threads:[~2018-08-21 19:35 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-21 19:23 [PATCH] SubmittingPatches: mention doc-diff Jeff King
2018-08-21 19:35 ` Jeff King [this message]
2018-08-21 20:22   ` worktree duplicates, was: " Eric Sunshine
2018-08-21 20:43     ` Jeff King
2018-08-23 18:19       ` Eric Sunshine
2018-08-24 14:46         ` Duy Nguyen
2018-08-24 22:55           ` Eric Sunshine
2018-08-24 23:25             ` Jeff King
2018-08-27  9:55               ` Eric Sunshine
2018-08-27 19:40                 ` Jeff King
2018-08-21 19:38 ` Derrick Stolee

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=20180821193556.GA859@sigill.intra.peff.net \
    --to=peff@peff.net \
    --cc=git@vger.kernel.org \
    /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).