<feed xmlns='http://www.w3.org/2005/Atom'>
<title>git/worktree.h, branch v2.41.2</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/git/git.git/
</subtitle>
<id>https://git.shady.money/git/atom?h=v2.41.2</id>
<link rel='self' href='https://git.shady.money/git/atom?h=v2.41.2'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/'/>
<updated>2023-03-19T22:03:11Z</updated>
<entry>
<title>Merge branch 'rj/avoid-switching-to-already-used-branch'</title>
<updated>2023-03-19T22:03:11Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2023-03-19T22:03:11Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=96a806f87a379fbc54b5cdb889518e9540d954c9'/>
<id>urn:sha1:96a806f87a379fbc54b5cdb889518e9540d954c9</id>
<content type='text'>
A few subcommands have been taught to stop users from working on a
branch that is being used in another worktree linked to the same
repository.

* rj/avoid-switching-to-already-used-branch:
  switch: reject if the branch is already checked out elsewhere (test)
  rebase: refuse to switch to a branch already checked out elsewhere (test)
  branch: fix die_if_checked_out() when ignore_current_worktree
  worktree: introduce is_shared_symref()
</content>
</entry>
<entry>
<title>worktree: introduce is_shared_symref()</title>
<updated>2023-02-25T21:05:23Z</updated>
<author>
<name>Rubén Justo</name>
<email>rjusto@gmail.com</email>
</author>
<published>2023-02-25T14:21:51Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=662078caacd450f93faa72e0e7d8580c42621415'/>
<id>urn:sha1:662078caacd450f93faa72e0e7d8580c42621415</id>
<content type='text'>
Add a new function, is_shared_symref(), which contains the heart of
find_shared_symref().  Refactor find_shared_symref() to use the new
function is_shared_symref().

Soon, we will use is_shared_symref() to search for symref beyond
the first worktree that matches.

Signed-off-by: Rubén Justo &lt;rjusto@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>object.h: stop depending on cache.h; make cache.h depend on object.h</title>
<updated>2023-02-24T01:25:29Z</updated>
<author>
<name>Elijah Newren</name>
<email>newren@gmail.com</email>
</author>
<published>2023-02-24T00:09:30Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=a64215b6cd5e67939187475c5b248dc5d13e3d60'/>
<id>urn:sha1:a64215b6cd5e67939187475c5b248dc5d13e3d60</id>
<content type='text'>
Things should be able to depend on object.h without pulling in all of
cache.h.  Move an enum to allow this.

Note that a couple files previously depended on things brought in
through cache.h indirectly (revision.h -&gt; commit.h -&gt; object.h -&gt;
cache.h).  As such, this change requires making existing dependencies
more explicit in half a dozen files.  The inclusion of strbuf.h in
some headers if of particular note: these headers directly embedded a
strbuf in some new structs, meaning they should have been including
strbuf.h all along but were indirectly getting the necessary
definitions.

Signed-off-by: Elijah Newren &lt;newren@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>refs: unify parse_worktree_ref() and ref_type()</title>
<updated>2022-09-19T18:11:11Z</updated>
<author>
<name>Han-Wen Nienhuys</name>
<email>hanwen@google.com</email>
</author>
<published>2022-09-19T16:34:50Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=71e5473493612f74244e2fa7a257a868df98be53'/>
<id>urn:sha1:71e5473493612f74244e2fa7a257a868df98be53</id>
<content type='text'>
The logic to handle worktree refs (worktrees/NAME/REF and
main-worktree/REF) existed in two places:

* ref_type() in refs.c

* parse_worktree_ref() in worktree.c

Collapse this logic together in one function parse_worktree_ref():
this avoids having to cross-check the result of parse_worktree_ref()
and ref_type().

Introduce enum ref_worktree_type, which is slightly different from
enum ref_type. The latter is a misleading name (one would think that
'ref_type' would have the symref option).

Instead, enum ref_worktree_type only makes explicit how a refname
relates to a worktree. From this point of view, HEAD and
refs/bisect/abc are the same: they specify the current worktree
implicitly.

The files-backend must avoid packing refs/bisect/* and friends into
packed-refs, so expose is_per_worktree_ref() separately.

Signed-off-by: Han-Wen Nienhuys &lt;hanwen@google.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>worktree: create init_worktree_config()</title>
<updated>2022-02-08T17:49:20Z</updated>
<author>
<name>Derrick Stolee</name>
<email>dstolee@microsoft.com</email>
</author>
<published>2022-02-07T21:32:59Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=615a84ad788b26260c5b053ace2d5720ea5f05c5'/>
<id>urn:sha1:615a84ad788b26260c5b053ace2d5720ea5f05c5</id>
<content type='text'>
Upgrading a repository to use extensions.worktreeConfig is non-trivial.
There are several steps involved, including moving some config settings
from the common config file to the main worktree's config.worktree file.
The previous change updated the documentation with all of these details.

Commands such as 'git sparse-checkout set' upgrade the repository to use
extensions.worktreeConfig without following these steps, causing some
user pain in some special cases.

Create a helper method, init_worktree_config(), that will be used in a
later change to fix this behavior within 'git sparse-checkout set'. The
method is carefully documented in worktree.h.

Note that we do _not_ upgrade the repository format version to 1 during
this process. The worktree config extension must be considered by Git
and third-party tools even if core.repositoryFormatVersion is 0 for
historical reasons documented in 11664196ac ("Revert
"check_repository_format_gently(): refuse extensions for old
repositories"", 2020-07-15). This is a special case for this extension,
and newer extensions (such as extensions.objectFormat) still need to
upgrade the repository format version.

Signed-off-by: Derrick Stolee &lt;dstolee@microsoft.com&gt;
Reviewed-by: Elijah Newren &lt;newren@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>worktree: simplify find_shared_symref() memory ownership model</title>
<updated>2021-12-02T06:18:25Z</updated>
<author>
<name>Anders Kaseorg</name>
<email>andersk@mit.edu</email>
</author>
<published>2021-12-01T22:15:43Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=c8dd491fa5b57ecfd9ef33ae5291eb2a9402cd59'/>
<id>urn:sha1:c8dd491fa5b57ecfd9ef33ae5291eb2a9402cd59</id>
<content type='text'>
Storing the worktrees list in a static variable meant that
find_shared_symref() had to rebuild the list on each call (which is
inefficient when the call site is in a loop), and also that each call
invalidated the pointer returned by the previous call (which is
confusing).

Instead, make it the caller’s responsibility to pass in the worktrees
list and manage its lifetime.

Signed-off-by: Anders Kaseorg &lt;andersk@mit.edu&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>worktree: teach worktree to lazy-load "prunable" reason</title>
<updated>2021-01-30T17:57:16Z</updated>
<author>
<name>Rafael Silva</name>
<email>rafaeloliveira.cs@gmail.com</email>
</author>
<published>2021-01-19T21:27:34Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=fc0c7d5e9e9e396afdd669019e7635773b1d1423'/>
<id>urn:sha1:fc0c7d5e9e9e396afdd669019e7635773b1d1423</id>
<content type='text'>
Add worktree_prune_reason() to allow a caller to discover whether a
worktree is prunable and the reason that it is, much like
worktree_lock_reason() indicates whether a worktree is locked and the
reason for the lock. As with worktree_lock_reason(), retrieve the
prunable reason lazily and cache it in the `worktree` structure.

Helped-by: Eric Sunshine &lt;sunshine@sunshineco.com&gt;
Signed-off-by: Rafael Silva &lt;rafaeloliveira.cs@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: libify should_prune_worktree()</title>
<updated>2021-01-30T17:57:08Z</updated>
<author>
<name>Rafael Silva</name>
<email>rafaeloliveira.cs@gmail.com</email>
</author>
<published>2021-01-19T21:27:33Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=a29a8b7574ab34026252691933f462eddc59146a'/>
<id>urn:sha1:a29a8b7574ab34026252691933f462eddc59146a</id>
<content type='text'>
As part of teaching "git worktree list" to annotate worktree that is a
candidate for pruning, let's move should_prune_worktree() from
builtin/worktree.c to worktree.c in order to make part of the worktree
public API.

should_prune_worktree() knows how to select the given worktree for
pruning based on an expiration date, however the expiration value is
stored in a static file-scope variable and it is not local to the
function. In order to move the function, teach should_prune_worktree()
to take the expiration date as an argument and document the new
parameter that is not immediately obvious.

Also, change the function comment to clearly state that the worktree's
path is returned in `wtpath` argument.

Helped-by: Eric Sunshine &lt;sunshine@sunshineco.com&gt;
Signed-off-by: Rafael Silva &lt;rafaeloliveira.cs@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>Merge branch 'ma/worktree-cleanups'</title>
<updated>2020-10-05T21:01:52Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2020-10-05T21:01:52Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=07601b5b360264a74f94d74640999ea19cf61517'/>
<id>urn:sha1:07601b5b360264a74f94d74640999ea19cf61517</id>
<content type='text'>
Code clean-up.

* ma/worktree-cleanups:
  worktree: use skip_prefix to parse target
  worktree: rename copy-pasted variable
  worktree: update renamed variable in comment
  worktree: inline `worktree_ref()` into its only caller
  wt-status: introduce wt_status_state_free_buffers()
  wt-status: print to s-&gt;fp, not stdout
  wt-status: replace sha1 mentions with oid
</content>
</entry>
<entry>
<title>worktree: inline `worktree_ref()` into its only caller</title>
<updated>2020-09-27T21:21:47Z</updated>
<author>
<name>Martin Ågren</name>
<email>martin.agren@gmail.com</email>
</author>
<published>2020-09-27T13:15:44Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=ef2d5547fa342197befd4be599438d7a7fa41e04'/>
<id>urn:sha1:ef2d5547fa342197befd4be599438d7a7fa41e04</id>
<content type='text'>
We have `strbuf_worktree_ref()`, which works on a strbuf, and a wrapper
for it, `worktree_ref()` which returns a string. We even make this
wrapper available through worktree.h. But it only has a single caller,
sitting right next to it in worktree.c.

Just inline the wrapper into its only caller. This means the caller can
quite naturally reuse a single strbuf. We currently achieve something
similar by having a static strbuf in the wrapper.

Signed-off-by: Martin Ågren &lt;martin.agren@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
</feed>
