<feed xmlns='http://www.w3.org/2005/Atom'>
<title>git/builtin/worktree.c, branch v2.18.2</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/git/git.git/
</subtitle>
<id>https://git.shady.money/git/atom?h=v2.18.2</id>
<link rel='self' href='https://git.shady.money/git/atom?h=v2.18.2'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/'/>
<updated>2018-05-23T05:38:18Z</updated>
<entry>
<title>Merge branch 'tg/worktree-add-existing-branch'</title>
<updated>2018-05-23T05:38:18Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2018-05-23T05:38:18Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=10174da9f1643eb939d93d479547494baf77377b'/>
<id>urn:sha1:10174da9f1643eb939d93d479547494baf77377b</id>
<content type='text'>
"git worktree add" learned to check out an existing branch.

* tg/worktree-add-existing-branch:
  worktree: teach "add" to check out existing branches
  worktree: factor out dwim_branch function
  worktree: improve message when creating a new worktree
  worktree: remove extra members from struct add_opts
</content>
</entry>
<entry>
<title>Merge branch 'sb/worktree-remove-opt-force'</title>
<updated>2018-05-08T06:59:24Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2018-05-08T06:59:24Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=90186fa0579e4dcdde08a2d823d9b269578d5a70'/>
<id>urn:sha1:90186fa0579e4dcdde08a2d823d9b269578d5a70</id>
<content type='text'>
"git worktree remove" learned that "-f" is a shorthand for
"--force" option, just like for "git worktree add".

* sb/worktree-remove-opt-force:
  worktree: accept -f as short for --force for removal
</content>
</entry>
<entry>
<title>worktree: teach "add" to check out existing branches</title>
<updated>2018-04-30T00:06:34Z</updated>
<author>
<name>Thomas Gummerer</name>
<email>t.gummerer@gmail.com</email>
</author>
<published>2018-04-24T21:56:35Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=f60a7b763fe070161b332d3878f81a7f09ab6e44'/>
<id>urn:sha1:f60a7b763fe070161b332d3878f81a7f09ab6e44</id>
<content type='text'>
Currently 'git worktree add &lt;path&gt;' creates a new branch named after the
basename of the path by default.  If a branch with that name already
exists, the command refuses to do anything, unless the '--force' option
is given.

However we can do a little better than that, and check the branch out if
it is not checked out anywhere else.  This will help users who just want
to check an existing branch out into a new worktree, and save a few
keystrokes.

As the current behaviour is to simply 'die()' when a branch with the name
of the basename of the path already exists, there are no backwards
compatibility worries here.

We will still 'die()' if the branch is checked out in another worktree,
unless the --force flag is passed.

Helped-by: Eric Sunshine &lt;sunshine@sunshineco.com&gt;
Signed-off-by: Thomas Gummerer &lt;t.gummerer@gmail.com&gt;
Reviewed-by: Eric Sunshine &lt;sunshine@sunshineco.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>worktree: factor out dwim_branch function</title>
<updated>2018-04-30T00:06:34Z</updated>
<author>
<name>Thomas Gummerer</name>
<email>t.gummerer@gmail.com</email>
</author>
<published>2018-04-24T21:56:34Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=6427f87186e53d9d4319d43e4efbe46bb93b7440'/>
<id>urn:sha1:6427f87186e53d9d4319d43e4efbe46bb93b7440</id>
<content type='text'>
Factor out a dwim_branch function, which takes care of the dwim'ery in
'git worktree add &lt;path&gt;'.  It's not too much code currently, but we're
adding a new kind of dwim in a subsequent patch, at which point it makes
more sense to have it as a separate function.

Factor it out now to reduce the patch noise in the next patch.

Signed-off-by: Thomas Gummerer &lt;t.gummerer@gmail.com&gt;
Reviewed-by: Eric Sunshine &lt;sunshine@sunshineco.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>worktree: improve message when creating a new worktree</title>
<updated>2018-04-30T00:06:34Z</updated>
<author>
<name>Thomas Gummerer</name>
<email>t.gummerer@gmail.com</email>
</author>
<published>2018-04-24T21:56:33Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=2c27002a0aaab03ab850244c66d116109e7d2b83'/>
<id>urn:sha1:2c27002a0aaab03ab850244c66d116109e7d2b83</id>
<content type='text'>
Currently 'git worktree add' produces output like the following:

    Preparing ../foo (identifier foo)
    HEAD is now at 26da330922 &lt;title&gt;

The '../foo' is the path where the worktree is created, which the user
has just given on the command line.  The identifier is an internal
implementation detail, which is not particularly relevant for the user
and indeed isn't mentioned explicitly anywhere in the man page.

Instead of this message, print a message that gives the user a bit more
detail of what exactly 'git worktree' is doing.  There are various dwim
modes which perform some magic under the hood, which should be
helpful to users.  Just from the output of the command it is not always
visible to users what exactly has happened.

Help the users a bit more by modifying the "Preparing ..." message and
adding some additional information of what 'git worktree add' did under
the hood, while not displaying the identifier anymore.

Currently there are several different cases:

  - 'git worktree add -b ...' or 'git worktree add &lt;path&gt;', both of
    which create a new branch, either through the user explicitly
    requesting it, or through 'git worktree add' implicitly creating
    it.  This will end up with the following output:

      Preparing worktree (new branch '&lt;branch&gt;')
      HEAD is now at 26da330922 &lt;title&gt;

  - 'git worktree add -B ...', which may either create a new branch if
    the branch with the given name does not exist yet, or resets an
    existing branch to the current HEAD, or the commit-ish given.
    Depending on which action is taken, we'll end up with the following
    output:

      Preparing worktree (resetting branch '&lt;branch&gt;'; was at caa68db14)
      HEAD is now at 26da330922 &lt;title&gt;

    or:

      Preparing worktree (new branch '&lt;branch&gt;')
      HEAD is now at 26da330922 &lt;title&gt;

  - 'git worktree add --detach' or 'git worktree add &lt;path&gt;
    &lt;commit-ish&gt;', both of which create a new worktree with a detached
    HEAD, for which we will print the following output:

      Preparing worktree (detached HEAD 26da330922)
      HEAD is now at 26da330922 &lt;title&gt;

  - 'git worktree add &lt;path&gt; &lt;local-branch&gt;', which checks out the
    branch and prints the following output:

      Preparing worktree (checking out '&lt;local-branch&gt;')
      HEAD is now at 47007d5 &lt;title&gt;

Additionally currently the "Preparing ..." line is printed to stderr,
while the "HEAD is now at ..." line is printed to stdout by 'git reset
--hard', which is used internally by 'git worktree add'.  Fix this
inconsistency by printing the "Preparing ..." message to stdout as
well.  As "Preparing ..." is not an error, stdout also seems like the
more appropriate output stream.

Helped-by: Eric Sunshine &lt;sunshine@sunshineco.com&gt;
Signed-off-by: Thomas Gummerer &lt;t.gummerer@gmail.com&gt;
Reviewed-by: Eric Sunshine &lt;sunshine@sunshineco.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>worktree: remove extra members from struct add_opts</title>
<updated>2018-04-30T00:06:34Z</updated>
<author>
<name>Thomas Gummerer</name>
<email>t.gummerer@gmail.com</email>
</author>
<published>2018-04-24T21:56:32Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=d861d34a6ed0d04cef99ad2bdf3fdd3b23cee63a'/>
<id>urn:sha1:d861d34a6ed0d04cef99ad2bdf3fdd3b23cee63a</id>
<content type='text'>
There are two members of 'struct add_opts', which are only used inside
the 'add()' function, but being part of 'struct add_opts' they are
needlessly also passed to the 'add_worktree' function.

Make them local to the 'add()' function to make it clearer where they
are used.

Signed-off-by: Thomas Gummerer &lt;t.gummerer@gmail.com&gt;
Reviewed-by: Eric Sunshine &lt;sunshine@sunshineco.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>worktree: accept -f as short for --force for removal</title>
<updated>2018-04-18T00:19:05Z</updated>
<author>
<name>Stefan Beller</name>
<email>sbeller@google.com</email>
</author>
<published>2018-04-17T18:19:39Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=d228eea5146540b09376f90e2b805553cdc78590'/>
<id>urn:sha1:d228eea5146540b09376f90e2b805553cdc78590</id>
<content type='text'>
Many commands support a "--force" option, frequently abbreviated as
"-f", however, "git worktree remove"'s hand-rolled OPT_BOOL forgets
to recognize the short form, despite git-worktree.txt documenting
"-f" as supported. Replace OPT_BOOL with OPT__FORCE, which provides
"-f" for free, and makes 'remove' consistent with 'add' option
parsing (which also specifies the PARSE_OPT_NOCOMPLETE flag).

Helped-by: Eric Sunshine &lt;sunshine@sunshineco.com&gt;
Signed-off-by: Stefan Beller &lt;sbeller@google.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>Merge branch 'nd/worktree-prune'</title>
<updated>2018-04-09T23:25:45Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2018-04-09T23:25:45Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=ca923f72653f5bfc61933ee334ca5fe34d4fe5f0'/>
<id>urn:sha1:ca923f72653f5bfc61933ee334ca5fe34d4fe5f0</id>
<content type='text'>
The way "git worktree prune" worked internally has been simplified,
by assuming how "git worktree move" moves an existing worktree to a
different place.

* nd/worktree-prune:
  worktree prune: improve prune logic when worktree is moved
  worktree: delete dead code
  gc.txt: more details about what gc does
</content>
</entry>
<entry>
<title>Merge branch 'bc/object-id'</title>
<updated>2018-04-09T23:25:45Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2018-04-09T23:25:45Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=a5bbc29994b22ab0b57c4dc9568a261d32476e94'/>
<id>urn:sha1:a5bbc29994b22ab0b57c4dc9568a261d32476e94</id>
<content type='text'>
Conversion from uchar[20] to struct object_id continues.

* bc/object-id: (36 commits)
  convert: convert to struct object_id
  sha1_file: introduce a constant for max header length
  Convert lookup_replace_object to struct object_id
  sha1_file: convert read_sha1_file to struct object_id
  sha1_file: convert read_object_with_reference to object_id
  tree-walk: convert tree entry functions to object_id
  streaming: convert istream internals to struct object_id
  tree-walk: convert get_tree_entry_follow_symlinks internals to object_id
  builtin/notes: convert static functions to object_id
  builtin/fmt-merge-msg: convert remaining code to object_id
  sha1_file: convert sha1_object_info* to object_id
  Convert remaining callers of sha1_object_info_extended to object_id
  packfile: convert unpack_entry to struct object_id
  sha1_file: convert retry_bad_packed_offset to struct object_id
  sha1_file: convert assert_sha1_type to object_id
  builtin/mktree: convert to struct object_id
  streaming: convert open_istream to use struct object_id
  sha1_file: convert check_sha1_signature to struct object_id
  sha1_file: convert read_loose_object to use struct object_id
  builtin/index-pack: convert struct ref_delta_entry to object_id
  ...
</content>
</entry>
<entry>
<title>worktree prune: improve prune logic when worktree is moved</title>
<updated>2018-03-15T19:37:48Z</updated>
<author>
<name>Nguyễn Thái Ngọc Duy</name>
<email>pclouds@gmail.com</email>
</author>
<published>2018-03-15T16:44:12Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=327864aaf76d000ee5d7722b9b9611ed7a2708f5'/>
<id>urn:sha1:327864aaf76d000ee5d7722b9b9611ed7a2708f5</id>
<content type='text'>
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/&lt;tag&gt;/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" has come 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.

The old logic of checking gitdir's mtime is dropped because nobody
updates it anyway. The new corner case is, if the index file does not
exist, we immediately remove the stale worktree. But if the "index"
file does not exist, you may have a bigger problem.

Signed-off-by: Nguyễn Thái Ngọc Duy &lt;pclouds@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
</feed>
