<feed xmlns='http://www.w3.org/2005/Atom'>
<title>git/worktree.c, branch v2.16.2</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/git/git.git/
</subtitle>
<id>https://git.shady.money/git/atom?h=v2.16.2</id>
<link rel='self' href='https://git.shady.money/git/atom?h=v2.16.2'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/'/>
<updated>2017-11-06T05:24:27Z</updated>
<entry>
<title>Merge branch 'bc/object-id'</title>
<updated>2017-11-06T05:24:27Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2017-11-06T05:24:27Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=e7e456f5007f30997e48dec57a1fc09b6b0f071e'/>
<id>urn:sha1:e7e456f5007f30997e48dec57a1fc09b6b0f071e</id>
<content type='text'>
Conversion from uchar[20] to struct object_id continues.

* bc/object-id: (25 commits)
  refs/files-backend: convert static functions to object_id
  refs: convert read_raw_ref backends to struct object_id
  refs: convert peel_object to struct object_id
  refs: convert resolve_ref_unsafe to struct object_id
  worktree: convert struct worktree to object_id
  refs: convert resolve_gitlink_ref to struct object_id
  Convert remaining callers of resolve_gitlink_ref to object_id
  sha1_file: convert index_path and index_fd to struct object_id
  refs: convert reflog_expire parameter to struct object_id
  refs: convert read_ref_at to struct object_id
  refs: convert peel_ref to struct object_id
  builtin/pack-objects: convert to struct object_id
  pack-bitmap: convert traverse_bitmap_commit_list to object_id
  refs: convert dwim_log to struct object_id
  builtin/reflog: convert remaining unsigned char uses to object_id
  refs: convert dwim_ref and expand_ref to struct object_id
  refs: convert read_ref and read_ref_full to object_id
  refs: convert resolve_refdup and refs_resolve_refdup to struct object_id
  Convert check_connected to use struct object_id
  refs: update ref transactions to use struct object_id
  ...
</content>
</entry>
<entry>
<title>worktree: handle broken symrefs in find_shared_symref()</title>
<updated>2017-10-21T12:30:07Z</updated>
<author>
<name>Jeff King</name>
<email>peff@peff.net</email>
</author>
<published>2017-10-19T17:49:36Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=dbd2b55cb7b06e94096b8c18852a94732e3f76a8'/>
<id>urn:sha1:dbd2b55cb7b06e94096b8c18852a94732e3f76a8</id>
<content type='text'>
The refs_resolve_ref_unsafe() function may return NULL even
with a REF_ISSYMREF flag if a symref points to a broken ref.
As a result, it's possible for find_shared_symref() to
segfault when it passes NULL to strcmp().

This is hard to trigger for most code paths. We typically
pass HEAD to the function as the symref to resolve, and
programs like "git branch" will bail much earlier if HEAD
isn't valid.

I did manage to trigger it through one very obscure
sequence:

  # You have multiple notes refs which conflict.
  git notes add -m base
  git notes --ref refs/notes/foo add -m foo

  # There's left-over cruft in NOTES_MERGE_REF that
  # makes it a broken symref (in this case we point
  # to a syntactically invalid ref).
  echo "ref: refs/heads/master.lock" &gt;.git/NOTES_MERGE_REF

  # You try to merge the notes. We read the broken value in
  # order to complain that another notes-merge is
  # in-progress, but we segfault in find_shared_symref().
  git notes merge refs/notes/foo

This is obviously silly and almost certainly impossible to
trigger accidentally, but it does show that the bug is
triggerable from at least one code path. In addition, it
would trigger if we saw a transient filesystem error when
resolving the pointed-to ref.

We can fix this by treating NULL the same as a non-matching
symref. Arguably we'd prefer to know if a symref points to
"refs/heads/foo", but "refs/heads/foo" is broken. But
refs_resolve_ref_unsafe() isn't capable of giving us that
information, so this is the best we can do.

Signed-off-by: Jeff King &lt;peff@peff.net&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>refs: convert resolve_ref_unsafe to struct object_id</title>
<updated>2017-10-16T02:05:51Z</updated>
<author>
<name>brian m. carlson</name>
<email>sandals@crustytoothpaste.net</email>
</author>
<published>2017-10-15T22:07:09Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=49e61479be913f67e66bb3fdf8de9475c41b58bd'/>
<id>urn:sha1:49e61479be913f67e66bb3fdf8de9475c41b58bd</id>
<content type='text'>
Convert resolve_ref_unsafe to take a pointer to struct object_id by
converting one remaining caller to use struct object_id, removing the
temporary NULL pointer check in expand_ref, converting the declaration
and definition, and applying the following semantic patch:

@@
expression E1, E2, E3, E4;
@@
- resolve_ref_unsafe(E1, E2, E3.hash, E4)
+ resolve_ref_unsafe(E1, E2, &amp;E3, E4)

@@
expression E1, E2, E3, E4;
@@
- resolve_ref_unsafe(E1, E2, E3-&gt;hash, E4)
+ resolve_ref_unsafe(E1, E2, E3, E4)

Signed-off-by: brian m. carlson &lt;sandals@crustytoothpaste.net&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>worktree: convert struct worktree to object_id</title>
<updated>2017-10-16T02:05:51Z</updated>
<author>
<name>brian m. carlson</name>
<email>sandals@crustytoothpaste.net</email>
</author>
<published>2017-10-15T22:07:08Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=0f05154c7064f82f122b845e0fe49a487d3a8d6e'/>
<id>urn:sha1:0f05154c7064f82f122b845e0fe49a487d3a8d6e</id>
<content type='text'>
Convert the head_sha1 member to be head_oid instead.  This is required
to convert resolve_ref_unsafe.

Signed-off-by: brian m. carlson &lt;sandals@crustytoothpaste.net&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>refs: pass NULL to refs_resolve_ref_unsafe() if hash is not needed</title>
<updated>2017-09-24T01:18:18Z</updated>
<author>
<name>René Scharfe</name>
<email>l.s.r@web.de</email>
</author>
<published>2017-09-23T09:44:57Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=e691b027b60034ed3362fc4d6065b6be85bf234b'/>
<id>urn:sha1:e691b027b60034ed3362fc4d6065b6be85bf234b</id>
<content type='text'>
This allows us to get rid of two write-only variables, one of them
being a SHA1 buffer.

Signed-off-by: Rene Scharfe &lt;l.s.r@web.de&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>Merge branch 'nd/prune-in-worktree'</title>
<updated>2017-09-19T01:47:53Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2017-09-19T01:47:53Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=8a044c7f1d56cef657be342e40de0795d688e882'/>
<id>urn:sha1:8a044c7f1d56cef657be342e40de0795d688e882</id>
<content type='text'>
"git gc" and friends when multiple worktrees are used off of a
single repository did not consider the index and per-worktree refs
of other worktrees as the root for reachability traversal, making
objects that are in use only in other worktrees to be subject to
garbage collection.

* nd/prune-in-worktree:
  refs.c: reindent get_submodule_ref_store()
  refs.c: remove fallback-to-main-store code get_submodule_ref_store()
  rev-list: expose and document --single-worktree
  revision.c: --reflog add HEAD reflog from all worktrees
  files-backend: make reflog iterator go through per-worktree reflog
  revision.c: --all adds HEAD from all worktrees
  refs: remove dead for_each_*_submodule()
  refs.c: move for_each_remote_ref_submodule() to submodule.c
  revision.c: use refs_for_each*() instead of for_each_*_submodule()
  refs: add refs_head_ref()
  refs: move submodule slash stripping code to get_submodule_ref_store
  refs.c: refactor get_submodule_ref_store(), share common free block
  revision.c: --indexed-objects add objects from all worktrees
  revision.c: refactor add_index_objects_to_pending()
  refs.c: use is_dir_sep() in resolve_gitlink_ref()
  revision.h: new flag in struct rev_info wrt. worktree-related refs
</content>
</entry>
<entry>
<title>Merge branch 'nd/worktree-kill-parse-ref'</title>
<updated>2017-09-10T08:08:24Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2017-09-10T08:08:23Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=79553b94f966f3cec6156a68001650ca26a584c4'/>
<id>urn:sha1:79553b94f966f3cec6156a68001650ca26a584c4</id>
<content type='text'>
"git branch -M a b" while on a branch that is completely unrelated
to either branch a or branch b misbehaved when multiple worktree
was in use.  This has been fixed.

* nd/worktree-kill-parse-ref:
  branch: fix branch renaming not updating HEADs correctly
</content>
</entry>
<entry>
<title>revision.c: --all adds HEAD from all worktrees</title>
<updated>2017-08-24T21:56:43Z</updated>
<author>
<name>Nguyễn Thái Ngọc Duy</name>
<email>pclouds@gmail.com</email>
</author>
<published>2017-08-23T12:36:59Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=d0c39a49ccb5dfe7feba4325c3374d99ab123c59'/>
<id>urn:sha1:d0c39a49ccb5dfe7feba4325c3374d99ab123c59</id>
<content type='text'>
Unless single_worktree is set, --all now adds HEAD from all worktrees.

Since reachable.c code does not use setup_revisions(), we need to call
other_head_refs_submodule() explicitly there to have the same effect on
"git prune", so that we won't accidentally delete objects needed by some
other HEADs.

A new FIXME is added because we would need something like

    int refs_other_head_refs(struct ref_store *, each_ref_fn, cb_data);

in addition to other_head_refs() to handle it, which might require

    int get_submodule_worktrees(const char *submodule, int flags);

It could be a separate topic to reduce the scope of this one.

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>
<entry>
<title>branch: fix branch renaming not updating HEADs correctly</title>
<updated>2017-08-24T21:15:18Z</updated>
<author>
<name>Nguyễn Thái Ngọc Duy</name>
<email>pclouds@gmail.com</email>
</author>
<published>2017-08-24T10:41:24Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=31824d180d4f975e6b130cd9a33a9a0baef3d7ca'/>
<id>urn:sha1:31824d180d4f975e6b130cd9a33a9a0baef3d7ca</id>
<content type='text'>
There are two bugs that sort of work together and cause
problems. Let's start with one in replace_each_worktree_head_symref.

Before fa099d2322 (worktree.c: kill parse_ref() in favor of
refs_resolve_ref_unsafe() - 2017-04-24), this code looks like this:

    if (strcmp(oldref, worktrees[i]-&gt;head_ref))
            continue;
    set_worktree_head_symref(...);

After fa099d2322, it is possible that head_ref can be NULL. However,
the updated code takes the wrong exit. In the error case (NULL
head_ref), we should "continue;" to the next worktree. The updated
code makes us _skip_ "continue;" and update HEAD anyway.

The NULL head_ref is triggered by the second bug in add_head_info (in
the same commit). With the flag RESOLVE_REF_READING, resolve_ref_unsafe()
will abort if it cannot resolve the target ref. For orphan checkouts,
HEAD always points to an unborned branch, resolving target ref will
always fail. Now we have NULL head_ref. Now we always update HEAD.

Correct the logic in replace_ function so that we don't accidentally
update HEAD on error. As it turns out, correcting the logic bug above
breaks branch renaming completely, thanks to the second bug.

"git branch -[Mm]" does two steps (on a normal checkout, no orphan!):

 - rename the branch on disk (e.g. refs/heads/abc to refs/heads/def)
 - update HEAD if it points to the branch being renamed.

At the second step, since the branch pointed to by HEAD (e.g. "abc") no
longer exists on disk, we run into a temporary orphan checkout situation
that has been just corrected to _not_ update HEAD. But we need to update
HEAD since it's not actually an orphan checkout. We need to update HEAD
to move out of that orphan state.

Correct add_head_info(), remove RESOLVE_REF_READING flag. With the flag
gone, we should always return good "head_ref" in orphan checkouts (either
temporary or permanent). With good head_ref, things start to work again.

Noticed-by: Nish Aravamudan &lt;nish.aravamudan@canonical.com&gt;
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>
<entry>
<title>path: convert strbuf_git_common_path to take a 'struct repository'</title>
<updated>2017-06-24T01:24:34Z</updated>
<author>
<name>Brandon Williams</name>
<email>bmwill@google.com</email>
</author>
<published>2017-06-22T18:43:37Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=b337172c834b854903fb523416b53fe354b6e2a5'/>
<id>urn:sha1:b337172c834b854903fb523416b53fe354b6e2a5</id>
<content type='text'>
Signed-off-by: Brandon Williams &lt;bmwill@google.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
</feed>
