<feed xmlns='http://www.w3.org/2005/Atom'>
<title>git/builtin/worktree.c, branch v2.20.2</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/git/git.git/
</subtitle>
<id>https://git.shady.money/git/atom?h=v2.20.2</id>
<link rel='self' href='https://git.shady.money/git/atom?h=v2.20.2'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/'/>
<updated>2018-10-31T02:41:47Z</updated>
<entry>
<title>worktree: rename is_worktree_locked to worktree_lock_reason</title>
<updated>2018-10-31T02:41:47Z</updated>
<author>
<name>Nickolai Belakovski</name>
<email>nbelakovski@gmail.com</email>
</author>
<published>2018-10-30T06:24:09Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=d236f12bdeb478bbaabf056bc611c34cf9218ca8'/>
<id>urn:sha1:d236f12bdeb478bbaabf056bc611c34cf9218ca8</id>
<content type='text'>
A function prefixed with 'is_' would be expected to return a boolean,
however this function returns a string.

Signed-off-by: Nickolai Belakovski &lt;nbelakovski@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>worktree: delete .git/worktrees if empty after 'remove'</title>
<updated>2018-08-30T16:28:02Z</updated>
<author>
<name>Eric Sunshine</name>
<email>sunshine@sunshineco.com</email>
</author>
<published>2018-08-28T21:20:26Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=3a5404333c6c8b5897e78c9dcb711d623035791b'/>
<id>urn:sha1:3a5404333c6c8b5897e78c9dcb711d623035791b</id>
<content type='text'>
For cleanliness, "git worktree prune" deletes the .git/worktrees
directory if it is empty after pruning is complete.

For consistency, make "git worktree remove &lt;path&gt;" likewise delete
.git/worktrees if it is empty after the removal.

Signed-off-by: Eric Sunshine &lt;sunshine@sunshineco.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>worktree: teach 'remove' to override lock when --force given twice</title>
<updated>2018-08-30T16:28:02Z</updated>
<author>
<name>Eric Sunshine</name>
<email>sunshine@sunshineco.com</email>
</author>
<published>2018-08-28T21:20:25Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=f4143101cbb26d189f63f2d29875f4acc07b2730'/>
<id>urn:sha1:f4143101cbb26d189f63f2d29875f4acc07b2730</id>
<content type='text'>
For consistency with "add -f -f" and "move -f -f" which override
the lock on a worktree, allow "remove -f -f" to do so, as well, as a
convenience.

Signed-off-by: Eric Sunshine &lt;sunshine@sunshineco.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>worktree: teach 'move' to override lock when --force given twice</title>
<updated>2018-08-30T16:28:02Z</updated>
<author>
<name>Eric Sunshine</name>
<email>sunshine@sunshineco.com</email>
</author>
<published>2018-08-28T21:20:24Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=68a6b3a1bd45eb1814a0c1cedfe347692c3f2ff7'/>
<id>urn:sha1:68a6b3a1bd45eb1814a0c1cedfe347692c3f2ff7</id>
<content type='text'>
For consistency with "add -f -f", which allows a missing but locked
worktree path to be re-used, allow "move -f -f" to override a lock,
as well, as a convenience.

Signed-off-by: Eric Sunshine &lt;sunshine@sunshineco.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>worktree: teach 'add' to respect --force for registered but missing path</title>
<updated>2018-08-30T16:28:02Z</updated>
<author>
<name>Eric Sunshine</name>
<email>sunshine@sunshineco.com</email>
</author>
<published>2018-08-28T21:20:23Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=e19831c94f91fd410fe001c0372b9c88b40d335b'/>
<id>urn:sha1:e19831c94f91fd410fe001c0372b9c88b40d335b</id>
<content type='text'>
For safety, "git worktree add &lt;path&gt;" will refuse to add a new
worktree at &lt;path&gt; if &lt;path&gt; is already associated with a worktree
entry, even if &lt;path&gt; is missing (for instance, has been deleted or
resides on non-mounted removable media or network share). The typical
way to re-create a worktree at &lt;path&gt; in such a situation is either to
prune all "broken" entries ("git worktree prune") or to selectively
remove the worktree entry manually ("git worktree remove &lt;path&gt;").

However, neither of these approaches ("prune" nor "remove") is
especially convenient, and they may be unsuitable for scripting when a
tool merely wants to re-use a worktree if it exists or create it from
scratch if it doesn't (much as a tool might use "mkdir -p" to re-use
or create a directory).

Therefore, teach 'add' to respect --force as a convenient way to
re-use a path already associated with a worktree entry if the path is
non-existent. For a locked worktree, require --force to be specified
twice.

Signed-off-by: Eric Sunshine &lt;sunshine@sunshineco.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>worktree: disallow adding same path multiple times</title>
<updated>2018-08-30T16:28:02Z</updated>
<author>
<name>Eric Sunshine</name>
<email>sunshine@sunshineco.com</email>
</author>
<published>2018-08-28T21:20:22Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=cb56f55c16c128e18449c9417dc045f787c1b663'/>
<id>urn:sha1:cb56f55c16c128e18449c9417dc045f787c1b663</id>
<content type='text'>
A given path should only ever be associated with a single registered
worktree. This invariant is enforced by refusing to create a new
worktree at a given path if that path already exists. For example:

    $ git worktree add -q --detach foo
    $ git worktree add -q --detach foo
    fatal: 'foo' already exists

However, the check can be fooled, and the invariant broken, if the
path is missing. Continuing the example:

    $ rm -fr foo
    $ git worktree add -q --detach foo
    $ git worktree list
    ...      eadebfe [master]
    .../foo  eadebfe (detached HEAD)
    .../foo  eadebfe (detached HEAD)

This "corruption" leads to the unfortunate situation in which the
worktree can not be removed:

    $ git worktree remove foo
    fatal: validation failed, cannot remove working tree: '.../foo'
    does not point back to '.git/worktrees/foo'

Nor can the bogus entry be pruned:

    $ git worktree prune -v
    $ git worktree list
    ...      eadebfe [master]
    .../foo  eadebfe (detached HEAD)
    .../foo  eadebfe (detached HEAD)

without first deleting the worktree directory manually:

    $ rm -fr foo
    $ git worktree prune -v
    Removing .../foo: gitdir file points to non-existent location
    Removing .../foo1: gitdir file points to non-existent location
    $ git worktree list
    ...  eadebfe [master]

or by manually deleting the worktree entry in .git/worktrees.

To address this problem, upgrade "git worktree add" validation to
allow worktree creation only if the given path is not already
associated with an existing worktree (even if the path itself is
non-existent), thus preventing such bogus worktree entries from being
created in the first place.

Reported-by: Jeff King &lt;peff@peff.net&gt;
Signed-off-by: Eric Sunshine &lt;sunshine@sunshineco.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>worktree: prepare for more checks of whether path can become worktree</title>
<updated>2018-08-30T16:28:02Z</updated>
<author>
<name>Eric Sunshine</name>
<email>sunshine@sunshineco.com</email>
</author>
<published>2018-08-28T21:20:21Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=45059e6468ab5710748c8827d5bf1f4c7c69d6d1'/>
<id>urn:sha1:45059e6468ab5710748c8827d5bf1f4c7c69d6d1</id>
<content type='text'>
Certain conditions must be met for a path to be a valid candidate as the
location of a new worktree; for instance, the path must not exist or
must be an empty directory. Although the number of conditions is small,
new conditions will soon be added so factor out the existing checks into
a separate function to avoid further bloating add_worktree().

Signed-off-by: Eric Sunshine &lt;sunshine@sunshineco.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>worktree: generalize delete_git_dir() to reduce code duplication</title>
<updated>2018-08-30T16:28:02Z</updated>
<author>
<name>Eric Sunshine</name>
<email>sunshine@sunshineco.com</email>
</author>
<published>2018-08-28T21:20:20Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=602aaed03f7f82323d88703d6fa2263a13c37907'/>
<id>urn:sha1:602aaed03f7f82323d88703d6fa2263a13c37907</id>
<content type='text'>
prune_worktrees() and delete_git_dir() both remove worktree
administrative entries from .git/worktrees, and their implementations
are nearly identical. The only difference is that prune_worktrees() is
also capable of removing a bogus non-worktree-related file from
.git/worktrees.

Simplify by extending delete_git_dir() to handle the little bit of
extra functionality needed by prune_worktrees(), and drop the
effectively duplicate code from the latter.

Signed-off-by: Eric Sunshine &lt;sunshine@sunshineco.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>worktree: move delete_git_dir() earlier in file for upcoming new callers</title>
<updated>2018-08-30T16:28:02Z</updated>
<author>
<name>Eric Sunshine</name>
<email>sunshine@sunshineco.com</email>
</author>
<published>2018-08-28T21:20:19Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=e5353bef550d91655b3f8fb443a26c0ba209153f'/>
<id>urn:sha1:e5353bef550d91655b3f8fb443a26c0ba209153f</id>
<content type='text'>
This is a pure code movement to avoid having to forward-declare the
function when new callers are subsequently added.

Signed-off-by: Eric Sunshine &lt;sunshine@sunshineco.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>worktree: add --quiet option</title>
<updated>2018-08-17T22:18:01Z</updated>
<author>
<name>Elia Pinto</name>
<email>gitter.spiros@gmail.com</email>
</author>
<published>2018-08-15T20:56:30Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=371979c21745a8be34a556e663d71e3a984ff4ce'/>
<id>urn:sha1:371979c21745a8be34a556e663d71e3a984ff4ce</id>
<content type='text'>
Add the '--quiet' option to git worktree, as for the other git
commands. 'add' is the only command affected by it since all other
commands, except 'list', are currently silent by default.

[jc: appiled trivial fix-up to keep the tests from touching outside
the scratch area]

Helped-by: Martin Ågren &lt;martin.agren@gmail.com&gt;
Helped-by: Duy Nguyen &lt;pclouds@gmail.com&gt;
Helped-by: Eric Sunshine &lt;sunshine@sunshineco.com&gt;
Signed-off-by: Elia Pinto &lt;gitter.spiros@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
</feed>
