<feed xmlns='http://www.w3.org/2005/Atom'>
<title>git/refs, branch v2.23.2</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/git/git.git/
</subtitle>
<id>https://git.shady.money/git/atom?h=v2.23.2</id>
<link rel='self' href='https://git.shady.money/git/atom?h=v2.23.2'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/'/>
<updated>2019-08-07T19:25:35Z</updated>
<entry>
<title>dir-iterator: release strbuf after use</title>
<updated>2019-08-07T19:25:35Z</updated>
<author>
<name>René Scharfe</name>
<email>l.s.r@web.de</email>
</author>
<published>2019-08-07T11:15:14Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=9b7b0295f9521262b50143e580f4eb27b7bb83a7'/>
<id>urn:sha1:9b7b0295f9521262b50143e580f4eb27b7bb83a7</id>
<content type='text'>
Signed-off-by: René Scharfe &lt;l.s.r@web.de&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>dir-iterator: add flags parameter to dir_iterator_begin</title>
<updated>2019-07-11T20:52:15Z</updated>
<author>
<name>Matheus Tavares</name>
<email>matheus.bernardino@usp.br</email>
</author>
<published>2019-07-10T23:59:00Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=fa1da7d2eef0fedf0e5942028513912bf2bb64ed'/>
<id>urn:sha1:fa1da7d2eef0fedf0e5942028513912bf2bb64ed</id>
<content type='text'>
Add the possibility of giving flags to dir_iterator_begin to initialize
a dir-iterator with special options.

Currently possible flags are:
- DIR_ITERATOR_PEDANTIC, which makes dir_iterator_advance abort
immediately in the case of an error, instead of keep looking for the
next valid entry;
- DIR_ITERATOR_FOLLOW_SYMLINKS, which makes the iterator follow
symlinks and include linked directories' contents in the iteration.

These new flags will be used in a subsequent patch.

Also add tests for the flags' usage and adjust refs/files-backend.c to
the new dir_iterator_begin signature.

Signed-off-by: Matheus Tavares &lt;matheus.bernardino@usp.br&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>dir-iterator: refactor state machine model</title>
<updated>2019-07-11T20:52:15Z</updated>
<author>
<name>Matheus Tavares</name>
<email>matheus.bernardino@usp.br</email>
</author>
<published>2019-07-10T23:58:59Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=3012397e0327f5e4dfd1d1183a792268429744ae'/>
<id>urn:sha1:3012397e0327f5e4dfd1d1183a792268429744ae</id>
<content type='text'>
dir_iterator_advance() is a large function with two nested loops. Let's
improve its readability factoring out three functions and simplifying
its mechanics. The refactored model will no longer depend on
level.initialized and level.dir_state to keep track of the iteration
state and will perform on a single loop.

Also, dir_iterator_begin() currently does not check if the given string
represents a valid directory path. Since the refactored model will have
to stat() the given path at initialization, let's also check for this
kind of error and make dir_iterator_begin() return NULL, on failures,
with errno appropriately set. And add tests for this new behavior.

Improve documentation at dir-iteration.h and code comments at
dir-iterator.c to reflect the changes and eliminate possible
ambiguities.

Finally, adjust refs/files-backend.c to check for now possible
dir_iterator_begin() failures.

Original-patch-by: Daniel Ferreira &lt;bnmvco@gmail.com&gt;
Signed-off-by: Matheus Tavares &lt;matheus.bernardino@usp.br&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>Merge branch 'jk/refs-double-abort'</title>
<updated>2019-04-16T10:28:11Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2019-04-16T10:28:11Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=2e08c892a7037ce2c7dfe30134eb54a2825bf0be'/>
<id>urn:sha1:2e08c892a7037ce2c7dfe30134eb54a2825bf0be</id>
<content type='text'>
A corner case bug in the refs API has been corrected.

* jk/refs-double-abort:
  refs/files-backend: don't look at an aborted transaction
  refs/files-backend: handle packed transaction prepare failure
</content>
</entry>
<entry>
<title>Merge branch 'nd/rewritten-ref-is-per-worktree'</title>
<updated>2019-04-09T17:14:23Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2019-04-09T17:14:23Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=917f2cd1c2396c694ae956a1a26d9c92bf50b847'/>
<id>urn:sha1:917f2cd1c2396c694ae956a1a26d9c92bf50b847</id>
<content type='text'>
"git rebase" uses the refs/rewritten/ hierarchy to store its
intermediate states, which inherently makes the hierarchy per
worktree, but it didn't quite work well.

* nd/rewritten-ref-is-per-worktree:
  Make sure refs/rewritten/ is per-worktree
  files-backend.c: reduce duplication in add_per_worktree_entries_to_dir()
  files-backend.c: factor out per-worktree code in loose_fill_ref_dir()
</content>
</entry>
<entry>
<title>refs/files-backend: don't look at an aborted transaction</title>
<updated>2019-03-22T06:52:54Z</updated>
<author>
<name>Jeff King</name>
<email>peff@peff.net</email>
</author>
<published>2019-03-21T09:28:54Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=d3322eb28b142a893fbc03142724bb54e95990a6'/>
<id>urn:sha1:d3322eb28b142a893fbc03142724bb54e95990a6</id>
<content type='text'>
When deleting refs, we hold packed-refs.lock and prepare a packed
transaction to drop the refs from the packed-refs file. If it turns out
that we don't need to rewrite the packed refs (e.g., because none of the
deletions were present in the file), then we abort the transaction.

If that abort succeeds, then the transaction struct will have been
freed, and we set our local pointer to NULL so we don't look at it
again.

However, if it fails, then the struct will _still_ have been freed
(because ref_transaction_abort() always frees). But we don't clean up
the pointer, and will jump to our cleanup code, which will try to abort
it again, causing a use-after-free.

It's actually impossible for this to trigger in practice, since
packed_transaction_abort() will never return anything but success. But
let's fix it anyway, since that's more than we should assume about the
packed-refs code (after all, we are already bothering to check for an
error result which cannot be triggered).

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/files-backend: handle packed transaction prepare failure</title>
<updated>2019-03-22T06:52:49Z</updated>
<author>
<name>Jeff King</name>
<email>peff@peff.net</email>
</author>
<published>2019-03-21T09:28:44Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=249e8dc73ea54aa09d828cf83f5a5de6bf5702f9'/>
<id>urn:sha1:249e8dc73ea54aa09d828cf83f5a5de6bf5702f9</id>
<content type='text'>
In files_transaction_prepare(), if we have to delete some refs, we use a
subordinate packed_transaction to do so. It's rare for that
sub-transaction's prepare step to fail, since we hold the packed-refs
lock. But if it does, we trigger a BUG() due to these steps:

  - we've attached the packed transaction to the files transaction as
    backend_data-&gt;packed_transaction

  - when the prepare step fails, the packed transaction cleans itself
    up, putting itself into the CLOSED state

  - the error value from preparing the packed transaction lets us know
    in files_transaction_prepare() that we should also clean up and
    return an error. We call files_transaction_cleanup(), which tries to
    abort backend_data-&gt;packed_transaction. Since it's already CLOSED,
    that triggers an assertion in ref_transaction_abort().

We can fix that by disconnecting the packed transaction from the outer
files transaction, and then free-ing (not aborting!) it ourselves.

A few other options/alternatives I considered:

  - we could just make it a noop to abort a CLOSED transaction. But that
    seems less safe, since clearly this code expects (and enforces) a
    particular set of state transitions.

  - we could have files_transaction_cleanup() selectively call abort()
    vs free() based on the state of the on the packed transaction.
    That's basically a more restricted version of the above, but also
    potentially unsafe.

  - instead of disconnecting backend_data-&gt;packed_transaction on error,
    we could wait to install it until we successfully prepare. That
    might make the flow a little simpler, but it introduces a hassle.
    Earlier parts of files_transaction_prepare() that encounter an error
    will jump to the cleanup label, and expect that cleaning up the
    outer transaction will clean up the packed transaction, too. We'd
    have to adjust those sites to clean up the packed transaction.

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>Make sure refs/rewritten/ is per-worktree</title>
<updated>2019-03-08T02:57:47Z</updated>
<author>
<name>Nguyễn Thái Ngọc Duy</name>
<email>pclouds@gmail.com</email>
</author>
<published>2019-03-07T12:29:17Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=b9317d55a37f93c47d48f12a7b3e45a71434d0e7'/>
<id>urn:sha1:b9317d55a37f93c47d48f12a7b3e45a71434d0e7</id>
<content type='text'>
a9be29c981 (sequencer: make refs generated by the `label` command
worktree-local, 2018-04-25) adds refs/rewritten/ as per-worktree
reference space. Unfortunately (my bad) there are a couple places that
need update to make sure it's really per-worktree.

 - add_per_worktree_entries_to_dir() is updated to make sure ref listing
   look at per-worktree refs/rewritten/ instead of per-repo one [1]

 - common_list[] is updated so that git_path() returns the correct
   location. This includes "rev-parse --git-path".

This mess is created by me. I started trying to fix it with the
introduction of refs/worktree, where all refs will be per-worktree
without special treatments. Unfortunate refs/rewritten came before
refs/worktree so this is all we can do.

This also fixes logs/refs/worktree not being per-worktree.

[1] note that ref listing still works sometimes. For example, if you
    have .git/worktrees/foo/refs/rewritten/bar AND the directory
    .git/worktrees/refs/rewritten, refs/rewritten/bar will show up.
    add_per_worktree_entries_to_dir() is only needed when the directory
    .git/worktrees/refs/rewritten is missing.

Reported-by: Phillip Wood &lt;phillip.wood123@gmail.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>files-backend.c: reduce duplication in add_per_worktree_entries_to_dir()</title>
<updated>2019-03-08T02:57:47Z</updated>
<author>
<name>Nguyễn Thái Ngọc Duy</name>
<email>pclouds@gmail.com</email>
</author>
<published>2019-03-07T12:29:16Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=90d31ff5d470286a8480311384429ebee8bbc939'/>
<id>urn:sha1:90d31ff5d470286a8480311384429ebee8bbc939</id>
<content type='text'>
This function is duplicated to handle refs/bisect/ and refs/worktree/
and a third prefix is coming. Time to clean up.

This also fixes incorrect "refs/worktrees/" length in this code. The
correct length is 14 not 11. The test in the next patch will also cover
this.

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>files-backend.c: factor out per-worktree code in loose_fill_ref_dir()</title>
<updated>2019-03-08T02:57:47Z</updated>
<author>
<name>Nguyễn Thái Ngọc Duy</name>
<email>pclouds@gmail.com</email>
</author>
<published>2019-03-07T12:29:15Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=09e65645e3b092e4d93bb8513b14474c68df23d8'/>
<id>urn:sha1:09e65645e3b092e4d93bb8513b14474c68df23d8</id>
<content type='text'>
This is the first step for further cleaning up and extending this
function.

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>
