<feed xmlns='http://www.w3.org/2005/Atom'>
<title>git/refs.h, branch v2.51.2</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/git/git.git/
</subtitle>
<id>https://git.shady.money/git/atom?h=v2.51.2</id>
<link rel='self' href='https://git.shady.money/git/atom?h=v2.51.2'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/'/>
<updated>2025-10-15T17:29:31Z</updated>
<entry>
<title>Merge branch 'kn/refs-files-case-insensitive' into maint-2.51</title>
<updated>2025-10-15T17:29:31Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2025-10-15T17:29:31Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=ff8ef0f9f350330d7a8572a0220f921c42ab33ca'/>
<id>urn:sha1:ff8ef0f9f350330d7a8572a0220f921c42ab33ca</id>
<content type='text'>
Deal more gracefully with directory / file conflicts when the files
backend is used for ref storage, by failing only the ones that are
involved in the conflict while allowing others.

* kn/refs-files-case-insensitive:
  refs/files: handle D/F conflicts during locking
  refs/files: handle F/D conflicts in case-insensitive FS
  refs/files: use correct error type when lock exists
  refs/files: catch conflicts on case-insensitive file-systems
</content>
</entry>
<entry>
<title>Merge branch 'ps/reflog-migrate-fixes' into maint-2.51</title>
<updated>2025-10-15T17:29:28Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2025-10-15T17:29:27Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=e04c0aded3ce7dc02feab55770a98e5ec1aa65fb'/>
<id>urn:sha1:e04c0aded3ce7dc02feab55770a98e5ec1aa65fb</id>
<content type='text'>
"git refs migrate" to migrate the reflog entries from a refs
backend to another had a handful of bugs squashed.

* ps/reflog-migrate-fixes:
  refs: fix invalid old object IDs when migrating reflogs
  refs: stop unsetting REF_HAVE_OLD for log-only updates
  refs/files: detect race when generating reflog entry for HEAD
  refs: fix identity for migrated reflogs
  ident: fix type of string length parameter
  builtin/reflog: implement subcommand to write new entries
  refs: export `ref_transaction_update_reflog()`
  builtin/reflog: improve grouping of subcommands
  Documentation/git-reflog: convert to use synopsis type
</content>
</entry>
<entry>
<title>refs/files: catch conflicts on case-insensitive file-systems</title>
<updated>2025-09-17T16:19:07Z</updated>
<author>
<name>Karthik Nayak</name>
<email>karthik.188@gmail.com</email>
</author>
<published>2025-09-17T15:25:11Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=3c07063231557201d61ff4d41cee171bda63d1c6'/>
<id>urn:sha1:3c07063231557201d61ff4d41cee171bda63d1c6</id>
<content type='text'>
During the 'prepare' phase of a reference transaction in the files
backend, we create the lock files for references to be created. When
using batched updates on case-insensitive filesystems, the entire
batched updates would be aborted if there are conflicting names such as:

  refs/heads/Foo
  refs/heads/foo

This affects all commands which were migrated to use batched updates in
Git 2.51, including 'git-fetch(1)' and 'git-receive-pack(1)'. Before
that, reference updates would be applied serially with one transaction
used per update. When users fetched multiple references on
case-insensitive systems, subsequent references would simply overwrite
any earlier references. So when fetching:

  refs/heads/foo: 5f34ec0bfeac225b1c854340257a65b106f70ea6
  refs/heads/Foo: ec3053b0977e83d9b67fc32c4527a117953994f3
  refs/heads/sample: 2eefd1150e06d8fca1ddfa684dec016f36bf4e56

The user would simply end up with:

  refs/heads/foo: ec3053b0977e83d9b67fc32c4527a117953994f3
  refs/heads/sample: 2eefd1150e06d8fca1ddfa684dec016f36bf4e56

This is buggy behavior since the user is never informed about the
overrides performed and missing references. Nevertheless, the user is
left with a working repository with a subset of the references. Since
Git 2.51, in such situations fetches would simply fail without updating
any references. Which is also buggy behavior and worse off since the
user is left without any references.

The error is triggered in `lock_raw_ref()` where the files backend
attempts to create a lock file. When a lock file already exists the
function returns a 'REF_TRANSACTION_ERROR_GENERIC'. When this happens,
the entire batched updates, not individual operation, is aborted as if
it were in a transaction.

Change this to return 'REF_TRANSACTION_ERROR_CASE_CONFLICT' instead to
aid the batched update mechanism to simply reject such errors. The
change only affects batched updates since batched updates will reject
individual updates with non-generic errors. So specifically this would
only affect:

    1. git fetch
    2. git receive-pack
    3. git update-ref --batch-updates

This bubbles the error type up to `files_transaction_prepare()` which
tries to lock each reference update. So if the locking fails, we check
if the rejection type can be ignored, which is done by calling
`ref_transaction_maybe_set_rejected()`.

As the error type is now 'REF_TRANSACTION_ERROR_CASE_CONFLICT',
the specific reference update would simply be rejected, while other
updates in the transaction would continue to be applied. This allows
partial application of references in case-insensitive filesystems when
fetching colliding references.

While the earlier implementation allowed the last reference to be
applied overriding the initial references, this change would allow the
first reference to be applied while rejecting consequent collisions.
This should be an okay compromise since with the files backend, there is
no scenario possible where we would retain all colliding references.

Let's also be more proactive and notify users on case-insensitive
filesystems about such problems by providing a brief about the issue
while also recommending using the reftable backend, which doesn't have
the same issue.

Reported-by: Joe Drew &lt;joe.drew@indexexchange.com&gt;
Helped-by: Patrick Steinhardt &lt;ps@pks.im&gt;
Signed-off-by: Karthik Nayak &lt;karthik.188@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>refs: fix invalid old object IDs when migrating reflogs</title>
<updated>2025-08-06T14:36:31Z</updated>
<author>
<name>Patrick Steinhardt</name>
<email>ps@pks.im</email>
</author>
<published>2025-08-06T05:54:20Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=465eff81de44763832e96fbe609ec269f1c23ade'/>
<id>urn:sha1:465eff81de44763832e96fbe609ec269f1c23ade</id>
<content type='text'>
When migrating reflog entries between different storage formats we end
up with invalid old object IDs for the migrated entries: instead of
writing the old object ID of the to-be-migrated entry, we end up with
the all-zeroes object ID.

The root cause of this issue is that we don't know to use the old object
ID provided by the caller. Instead, we manually resolve the old object
ID by resolving the current value of its matching reference. But as that
reference does not yet exist in the target ref storage we always end up
resolving it to all-zeroes.

This issue got unnoticed as there is no user-facing command that would
even show the old object ID. While `git log -g` knows to show the new
object ID, we don't have any formatting directive to show the old object
ID.

Fix the bug by introducing a new flag `REF_LOG_USE_PROVIDED_OIDS`. If
set, backends are instructed to use the old and new object IDs provided
by the caller, without doing any manual resolving. Set this flag in
`ref_transaction_update_reflog()`.

Amend our tests in t1460-refs-migrate to use our test tool to read
reflog entries. This test tool prints out both old and new object ID of
each reflog entry, which fixes the test gap. Furthermore it also prints
the full identity used to write the reflog, which provides test coverage
for the previous commit in this patch series that fixed the identity for
migrated reflogs.

Signed-off-by: Patrick Steinhardt &lt;ps@pks.im&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>refs: export `ref_transaction_update_reflog()`</title>
<updated>2025-08-06T14:36:29Z</updated>
<author>
<name>Patrick Steinhardt</name>
<email>ps@pks.im</email>
</author>
<published>2025-08-06T05:54:14Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=1ffd2d41599e2b506f20430914e3bc53a0e05f3a'/>
<id>urn:sha1:1ffd2d41599e2b506f20430914e3bc53a0e05f3a</id>
<content type='text'>
In a subsequent commit we'll add another user that wants to write reflog
entries. This requires them to call `ref_transaction_update_reflog()`,
but that function is local to "refs.c".

Export the function to prepare for the change. While at it, drop the
`flags` field, as all callers are for now expected to use the same flags
anyway.

Signed-off-by: Patrick Steinhardt &lt;ps@pks.im&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>Merge branch 'kn/for-each-ref-skip'</title>
<updated>2025-08-04T01:44:26Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2025-08-04T01:44:26Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=8d9f536a5106231a3ed24e392eeb28b7b304fe5e'/>
<id>urn:sha1:8d9f536a5106231a3ed24e392eeb28b7b304fe5e</id>
<content type='text'>
"git for-each-ref" learns "--start-after" option to help
applications that want to page its output.

* kn/for-each-ref-skip:
  ref-cache: set prefix_state when seeking
  for-each-ref: introduce a '--start-after' option
  ref-filter: remove unnecessary else clause
  refs: selectively set prefix in the seek functions
  ref-cache: remove unused function 'find_ref_entry()'
  refs: expose `ref_iterator` via 'refs.h'
</content>
</entry>
<entry>
<title>Merge branch 'ph/fetch-prune-optim'</title>
<updated>2025-07-16T16:42:27Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2025-07-16T16:42:26Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=7b625c2a3511ac89acd14ae4bcbbc471bd50cdbb'/>
<id>urn:sha1:7b625c2a3511ac89acd14ae4bcbbc471bd50cdbb</id>
<content type='text'>
"git fetch --prune" used to be O(n^2) expensive when there are many
refs, which has been corrected.

* ph/fetch-prune-optim:
  clean up interface for refs_warn_dangling_symrefs
  refs: remove old refs_warn_dangling_symref
  fetch-prune: optimize dangling-ref reporting
</content>
</entry>
<entry>
<title>refs: selectively set prefix in the seek functions</title>
<updated>2025-07-15T18:54:20Z</updated>
<author>
<name>Karthik Nayak</name>
<email>karthik.188@gmail.com</email>
</author>
<published>2025-07-15T11:28:28Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=2b4648b9190b552e942d93363482bd617a510fc1'/>
<id>urn:sha1:2b4648b9190b552e942d93363482bd617a510fc1</id>
<content type='text'>
The ref iterator exposes a `ref_iterator_seek()` function. The name
suggests that this would seek the iterator to a specific reference in
some ways similar to how `fseek()` works for the filesystem.

However, the function actually sets the prefix for refs iteration. So
further iteration would only yield references which match the particular
prefix. This is a bit confusing.

Let's add a 'flags' field to the function, which when set with the
'REF_ITERATOR_SEEK_SET_PREFIX' flag, will set the prefix for the
iteration in-line with the existing behavior. Otherwise, the reference
backends will simply seek to the specified reference and clears any
previously set prefix. This allows users to start iteration from a
specific reference.

In the packed and reftable backend, since references are available in a
sorted list, the changes are simply setting the prefix if needed. The
changes on the files-backend are a little more involved, since the files
backend uses the 'ref-cache' mechanism. We move out the existing logic
within `cache_ref_iterator_seek()` to `cache_ref_iterator_set_prefix()`
which is called when the 'REF_ITERATOR_SEEK_SET_PREFIX' flag is set. We
then parse the provided seek string and set the required levels and
their indexes to ensure that seeking is possible.

Helped-by: Patrick Steinhardt &lt;ps@pks.im&gt;
Signed-off-by: Karthik Nayak &lt;karthik.188@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>refs: expose `ref_iterator` via 'refs.h'</title>
<updated>2025-07-15T18:54:19Z</updated>
<author>
<name>Karthik Nayak</name>
<email>karthik.188@gmail.com</email>
</author>
<published>2025-07-15T11:28:26Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=6bde5d43b769509141d7ebc0b2476bc2035bc673'/>
<id>urn:sha1:6bde5d43b769509141d7ebc0b2476bc2035bc673</id>
<content type='text'>
The `ref_iterator` is an internal structure to the 'refs/'
sub-directory, which allows iteration over refs. All reference iteration
is built on top of these iterators.

External clients of the 'refs' subsystem use the various
'refs_for_each...()' functions to iterate over refs. However since these
are wrapper functions, each combination of functionality requires a new
wrapper function. This is not feasible as the functions pile up with the
increase in requirements. Expose the internal reference iterator, so
advanced users can mix and match options as needed.

Signed-off-by: Karthik Nayak &lt;karthik.188@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>clean up interface for refs_warn_dangling_symrefs</title>
<updated>2025-07-02T01:42:25Z</updated>
<author>
<name>Phil Hord</name>
<email>phil.hord@gmail.com</email>
</author>
<published>2025-07-02T01:12:15Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=87d8d8c5d09b1ee52cdf472b53b370020a7cb41c'/>
<id>urn:sha1:87d8d8c5d09b1ee52cdf472b53b370020a7cb41c</id>
<content type='text'>
The refs_warn_dangling_symrefs interface is a bit fragile as it passes
in printf-formatting strings with expectations about the number of
arguments. This patch series made it worse by adding a 2nd positional
argument. But there are only two call sites, and they both use almost
identical display options.

Make this safer by moving the format strings into the function that uses
them to make it easier to see when the arguments don't match. Pass a
prefix string and a dry_run flag so the decision logic can be handled
where needed.

Signed-off-by: Phil Hord &lt;phil.hord@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
</feed>
