git@vger.kernel.org list mirror (unofficial, one of many)
 help / color / mirror / code / Atom feed
* man page for "git-worktree" is a bit confusing WRT "prune"
@ 2017-11-13 14:48 Robert P. J. Day
  2017-11-13 17:39 ` Eric Sunshine
  0 siblings, 1 reply; 5+ messages in thread
From: Robert P. J. Day @ 2017-11-13 14:48 UTC (permalink / raw)
  To: Git Mailing list


  once more, into the man pages ... "git worktree" seems like a fairly
simple command, but there is some confusion about the function of

  $ git worktree prune

the normal meaning of "prune" (certainly with git commands) is to
actually delete some content, and the initial impression of this
command is that it will delete an actual worktree. however, further
reading reveals:

" ... or you can run git worktree prune in the main or any linked
working tree to clean up any stale administrative files."

  ah, so one learns that the subcommand "prune" does *not* do any
actual pruning as people would *normally* understand it, it simply
deletes the administrative information about an already-deleted
worktree, do i read that correctly?

  that's emphasized further down in the actual definition of "prune":

    prune
        Prune working tree information in $GIT_DIR/worktrees.

but perhaps that explanation could be extended to say it only works on
already-deleted trees, since that's certainly not clear from that
single sentence.

  finally, the prune "--expire" option is truly confusing:

    --expire <time>
        With prune, only expire unused working trees older than <time>.

suddenly, we encounter the verb "expire", which means ... what? how
does "expiring" a worktree differ from "pruning" a worktree? and what
makes a worktree "unused"? the normal meaning of "unused" is that you
haven't, you know, *used* it lately. in this context, though, does it
mean deleted? and if it means deleted, what does it mean for it to be
older than some time if it's already gone?

  thoughts?

rday

-- 

========================================================================
Robert P. J. Day                                 Ottawa, Ontario, CANADA
                        http://crashcourse.ca

Twitter:                                       http://twitter.com/rpjday
LinkedIn:                               http://ca.linkedin.com/in/rpjday
========================================================================

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: man page for "git-worktree" is a bit confusing WRT "prune"
  2017-11-13 14:48 man page for "git-worktree" is a bit confusing WRT "prune" Robert P. J. Day
@ 2017-11-13 17:39 ` Eric Sunshine
  2017-11-13 21:06   ` Robert P. J. Day
  0 siblings, 1 reply; 5+ messages in thread
From: Eric Sunshine @ 2017-11-13 17:39 UTC (permalink / raw)
  To: Robert P. J. Day; +Cc: Git Mailing list

On Mon, Nov 13, 2017 at 9:48 AM, Robert P. J. Day <rpjday@crashcourse.ca> wrote:
>   once more, into the man pages ... "git worktree" seems like a fairly
> simple command, but there is some confusion about the function of
>
>   $ git worktree prune
>
> the normal meaning of "prune" (certainly with git commands) is to
> actually delete some content, and the initial impression of this
> command is that it will delete an actual worktree. however, further
> reading reveals:
>
> " ... or you can run git worktree prune in the main or any linked
> working tree to clean up any stale administrative files."
>
>   ah, so one learns that the subcommand "prune" does *not* do any
> actual pruning as people would *normally* understand it, it simply
> deletes the administrative information about an already-deleted
> worktree, do i read that correctly?

Yes. This usage is consistent with "git remote prune" which removes
administrative information about local branches which have already
been deleted on the remote side.

>   that's emphasized further down in the actual definition of "prune":
>
>     prune
>         Prune working tree information in $GIT_DIR/worktrees.
>
> but perhaps that explanation could be extended to say it only works on
> already-deleted trees, since that's certainly not clear from that
> single sentence.

As originally implemented, git-worktree would detect deleted or
relocated worktrees and prune or update the administrative information
automatically. So, "prune" was more a behind-the-scenes implementation
detail rather than an important user-facing command. However, the
implementation and semantics of that automatic behavior were not quite
robust and ended up leaving things in a slightly corrupted state (if I
recall correctly), though the corruption was easily corrected by hand.
As a consequence, the automatic behavior was retired while the general
implementation of git-worktree "cooked", with the idea that it could
be revisited later, with the result that "prune" became more
user-facing than originally intended.

The above description could be extended with more information. An
alternative would be to point the reader at the "DETAILS" section as
is done already for "prune" in "DISCUSSION".

>   finally, the prune "--expire" option is truly confusing:
>
>     --expire <time>
>         With prune, only expire unused working trees older than <time>.
>
> suddenly, we encounter the verb "expire", which means ... what? how
> does "expiring" a worktree differ from "pruning" a worktree? and what
> makes a worktree "unused"? the normal meaning of "unused" is that you
> haven't, you know, *used* it lately. in this context, though, does it
> mean deleted? and if it means deleted, what does it mean for it to be
> older than some time if it's already gone?
>
>   thoughts?

This dates back to the original behavior of automatically pruning
administrative information for deleted worktrees. As discussed
elsewhere in the document, a worktree may be placed on some removable
device (USB drive, memory stick, etc.) or network share which isn't
always mounted. The "expire time" provides such
not-necessarily-mounted worktrees a grace period before being pruned
automatically. You wouldn't want your worktree administrative
information erased automatically when invoking some git-worktree
command -- say "git worktree list" -- simply because you forgot to
plug your memory stick back into the computer; the grace period
protects against this sort of lossage. As with "prune", originally,
the grace period was more a behind-the-scenes detail than a
user-facing feature. Nevertheless, it's still useful; you might forget
to plug in your memory stick before invoking "git worktree prune"
manually.

The term "unused" is unfortunate. A better description would likely be welcome.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: man page for "git-worktree" is a bit confusing WRT "prune"
  2017-11-13 17:39 ` Eric Sunshine
@ 2017-11-13 21:06   ` Robert P. J. Day
  2017-11-14  3:26     ` Eric Sunshine
  0 siblings, 1 reply; 5+ messages in thread
From: Robert P. J. Day @ 2017-11-13 21:06 UTC (permalink / raw)
  To: Eric Sunshine; +Cc: Git Mailing list

On Mon, 13 Nov 2017, Eric Sunshine wrote:

> On Mon, Nov 13, 2017 at 9:48 AM, Robert P. J. Day <rpjday@crashcourse.ca> wrote:

... snip ...

> >   finally, the prune "--expire" option is truly confusing:
> >
> >     --expire <time>
> >         With prune, only expire unused working trees older than <time>.
> >
> > suddenly, we encounter the verb "expire", which means ... what?
> > how does "expiring" a worktree differ from "pruning" a worktree?
> > and what makes a worktree "unused"? the normal meaning of "unused"
> > is that you haven't, you know, *used* it lately. in this context,
> > though, does it mean deleted? and if it means deleted, what does
> > it mean for it to be older than some time if it's already gone?
>
> This dates back to the original behavior of automatically pruning
> administrative information for deleted worktrees. As discussed
> elsewhere in the document, a worktree may be placed on some
> removable device (USB drive, memory stick, etc.) or network share
> which isn't always mounted. The "expire time" provides such
> not-necessarily-mounted worktrees a grace period before being pruned
> automatically.

  how is this "expire time" measured? relative to what? i've looked
under .git/worktrees/<wtname>, and i see a bunch of files defining
that worktree, but it's not clear how a worktree stores the relevant
time to be used for the determination of when a worktree "expires".

  oh, and is it fair to assume that if a worktree is temporaily
missing, and is subsequently restored, the expire time counter is
reset? otherwise, it would get kind of weird.

rday

-- 

========================================================================
Robert P. J. Day                                 Ottawa, Ontario, CANADA
                        http://crashcourse.ca

Twitter:                                       http://twitter.com/rpjday
LinkedIn:                               http://ca.linkedin.com/in/rpjday
========================================================================

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: man page for "git-worktree" is a bit confusing WRT "prune"
  2017-11-13 21:06   ` Robert P. J. Day
@ 2017-11-14  3:26     ` Eric Sunshine
  2017-11-14  8:47       ` Robert P. J. Day
  0 siblings, 1 reply; 5+ messages in thread
From: Eric Sunshine @ 2017-11-14  3:26 UTC (permalink / raw)
  To: Robert P. J. Day; +Cc: Git Mailing list, Nguyễn Thái Ngọc Duy

[+cc:Duy]

On Mon, Nov 13, 2017 at 4:06 PM, Robert P. J. Day <rpjday@crashcourse.ca> wrote:
> On Mon, 13 Nov 2017, Eric Sunshine wrote:
>> On Mon, Nov 13, 2017 at 9:48 AM, Robert P. J. Day <rpjday@crashcourse.ca> wrote:
>> >   finally, the prune "--expire" option is truly confusing:
>> >
>> >     --expire <time>
>> >         With prune, only expire unused working trees older than <time>.
>> >
>> > suddenly, we encounter the verb "expire", which means ... what?
>> > how does "expiring" a worktree differ from "pruning" a worktree?
>> > and what makes a worktree "unused"? the normal meaning of "unused"
>> > is that you haven't, you know, *used* it lately. in this context,
>> > though, does it mean deleted? and if it means deleted, what does
>> > it mean for it to be older than some time if it's already gone?
>>
>> This dates back to the original behavior of automatically pruning
>> administrative information for deleted worktrees. As discussed
>> elsewhere in the document, a worktree may be placed on some
>> removable device (USB drive, memory stick, etc.) or network share
>> which isn't always mounted. The "expire time" provides such
>> not-necessarily-mounted worktrees a grace period before being pruned
>> automatically.
>
>   how is this "expire time" measured? relative to what? i've looked
> under .git/worktrees/<wtname>, and i see a bunch of files defining
> that worktree, but it's not clear how a worktree stores the relevant
> time to be used for the determination of when a worktree "expires".

According to Documentation/gitrepository-layout.txt:

    worktrees/<id>/gitdir::
        A text file containing the absolute path back to the .git file
        that points to here. This is used to check if the linked
        repository has been manually removed and there is no need to
        keep this directory any more. The mtime of this file should be
        updated every time the linked repository is accessed.

So, the expire time is relative to the mtime of the 'gitdir' file for
that worktree. Presumably (according to the documentation excerpt),
mtime of  'gitdir' is supposed to be updated each time the linked
repository is accessed, however, I haven't found the code which does
that (and it's been too long since I dealt which this code to remember
where/if it is being done); in practice, I don't actually see the
timestamp on 'gitdir' being updated, so that may be a bug/problem.

>   oh, and is it fair to assume that if a worktree is temporaily
> missing, and is subsequently restored, the expire time counter is
> reset? otherwise, it would get kind of weird.

If we believe the documentation, then, as long as you've invoked some
Git command recently enough in the restored worktree, it should be
safe from pruning.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: man page for "git-worktree" is a bit confusing WRT "prune"
  2017-11-14  3:26     ` Eric Sunshine
@ 2017-11-14  8:47       ` Robert P. J. Day
  0 siblings, 0 replies; 5+ messages in thread
From: Robert P. J. Day @ 2017-11-14  8:47 UTC (permalink / raw)
  To: Eric Sunshine; +Cc: Git Mailing list, Nguyễn Thái Ngọc Duy

On Mon, 13 Nov 2017, Eric Sunshine wrote:

> On Mon, Nov 13, 2017 at 4:06 PM, Robert P. J. Day <rpjday@crashcourse.ca> wrote:

... snip ...

> >   how is this "expire time" measured? relative to what? i've
> > looked under .git/worktrees/<wtname>, and i see a bunch of files
> > defining that worktree, but it's not clear how a worktree stores
> > the relevant time to be used for the determination of when a
> > worktree "expires".
>
> According to Documentation/gitrepository-layout.txt:
>
>     worktrees/<id>/gitdir::
>         A text file containing the absolute path back to the .git file
>         that points to here. This is used to check if the linked
>         repository has been manually removed and there is no need to
>         keep this directory any more. The mtime of this file should be
>         updated every time the linked repository is accessed.
>
> So, the expire time is relative to the mtime of the 'gitdir' file for
> that worktree...

  yup, that clears it up, thanks.

rday

-- 

========================================================================
Robert P. J. Day                                 Ottawa, Ontario, CANADA
                        http://crashcourse.ca

Twitter:                                       http://twitter.com/rpjday
LinkedIn:                               http://ca.linkedin.com/in/rpjday
========================================================================

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2017-11-14  8:47 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-13 14:48 man page for "git-worktree" is a bit confusing WRT "prune" Robert P. J. Day
2017-11-13 17:39 ` Eric Sunshine
2017-11-13 21:06   ` Robert P. J. Day
2017-11-14  3:26     ` Eric Sunshine
2017-11-14  8:47       ` Robert P. J. Day

git@vger.kernel.org list mirror (unofficial, one of many)

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://public-inbox.org/git
	git clone --mirror http://ou63pmih66umazou.onion/git
	git clone --mirror http://czquwvybam4bgbro.onion/git
	git clone --mirror http://hjrcffqmbrq6wope.onion/git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V1 git git/ https://public-inbox.org/git \
		git@vger.kernel.org
	public-inbox-index git

Example config snippet for mirrors.
Newsgroups are available over NNTP:
	nntp://news.public-inbox.org/inbox.comp.version-control.git
	nntp://ou63pmih66umazou.onion/inbox.comp.version-control.git
	nntp://czquwvybam4bgbro.onion/inbox.comp.version-control.git
	nntp://hjrcffqmbrq6wope.onion/inbox.comp.version-control.git
	nntp://news.gmane.io/gmane.comp.version-control.git
 note: .onion URLs require Tor: https://www.torproject.org/

code repositories for project(s) associated with this inbox:

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

AGPL code for this site: git clone https://public-inbox.org/public-inbox.git