<feed xmlns='http://www.w3.org/2005/Atom'>
<title>git/builtin/refs.c, branch jch</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/git/git.git/
</subtitle>
<id>https://git.shady.money/git/atom?h=jch</id>
<link rel='self' href='https://git.shady.money/git/atom?h=jch'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/'/>
<updated>2026-03-23T15:33:10Z</updated>
<entry>
<title>fsck: store repository in fsck options</title>
<updated>2026-03-23T15:33:10Z</updated>
<author>
<name>Patrick Steinhardt</name>
<email>ps@pks.im</email>
</author>
<published>2026-03-23T15:02:54Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=374985390871cb67c02b1608b693480e89567b9a'/>
<id>urn:sha1:374985390871cb67c02b1608b693480e89567b9a</id>
<content type='text'>
The fsck subsystem relies on `the_repository` quite a bit. While we
could of course explicitly pass a repository down the callchain, we
already have a `struct fsck_options` that we pass to almost all
functions.

Extend the options to also store the repository to make it readily
available.

Suggested-by: Junio C Hamano &lt;gitster@pobox.com&gt;
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>fsck: initialize fsck options via a function</title>
<updated>2026-03-23T15:33:10Z</updated>
<author>
<name>Patrick Steinhardt</name>
<email>ps@pks.im</email>
</author>
<published>2026-03-23T15:02:53Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=f22360902621e0807a1c0a77476e3e4d323c708d'/>
<id>urn:sha1:f22360902621e0807a1c0a77476e3e4d323c708d</id>
<content type='text'>
We initialize the `struct fsck_options` via a set of macros, often in
global scope. In the next commit though we're about to introduce a new
repository field to the options that must be initialized, and naturally
we don't have a repo other than `the_repository` available in this
scope.

Refactor the code to instead intrdouce a new `fsck_options_init()`
function that initializes the options for us and move initialization
into function scope.

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 'ms/refs-optimize'</title>
<updated>2025-10-02T19:26:12Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2025-10-02T19:26:12Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=db0babf9b2f807e6913b3591d04cb752b8219e9d'/>
<id>urn:sha1:db0babf9b2f807e6913b3591d04cb752b8219e9d</id>
<content type='text'>
"git refs optimize" is added for not very well explained reason
despite it does the same thing as "git pack-refs"...

* ms/refs-optimize:
  t: add test for git refs optimize subcommand
  t0601: refactor tests to be shareable
  builtin/refs: add optimize subcommand
  doc: pack-refs: factor out common options
  builtin/pack-refs: factor out core logic into a shared library
  builtin/pack-refs: convert to use the generic refs_optimize() API
  reftable-backend: implement 'optimize' action
  files-backend: implement 'optimize' action
  refs: add a generic 'optimize' API
</content>
</entry>
<entry>
<title>builtin/refs: add optimize subcommand</title>
<updated>2025-09-19T17:02:56Z</updated>
<author>
<name>Meet Soni</name>
<email>meetsoni3017@gmail.com</email>
</author>
<published>2025-09-19T08:26:45Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=ecc70a48a5ea5e568b1cbdd111f7ddba62dbe4d6'/>
<id>urn:sha1:ecc70a48a5ea5e568b1cbdd111f7ddba62dbe4d6</id>
<content type='text'>
As part of the ongoing effort to consolidate reference handling,
introduce a new `optimize` subcommand. This command provides the same
functionality and exit-code behavior as `git pack-refs`, serving as its
modern replacement.

Implement `cmd_refs_optimize` by having it call the `pack_refs_core()`
helper function. This helper was factored out of the original
`cmd_pack_refs` in a preceding commit, allowing both commands to share
the same core logic as independent peers.

Add documentation for the new command. The man page leverages the shared
options file, created in a previous commit, by using the AsciiDoc
`include::` macro to ensure consistency with git-pack-refs(1).

Mentored-by: Patrick Steinhardt &lt;ps@pks.im&gt;
Mentored-by: shejialuo &lt;shejialuo@gmail.com&gt;
Signed-off-by: Meet Soni &lt;meetsoni3017@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>builtin/refs: add 'exists' subcommand</title>
<updated>2025-09-02T16:58:35Z</updated>
<author>
<name>Meet Soni</name>
<email>meetsoni3017@gmail.com</email>
</author>
<published>2025-08-26T06:41:07Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=0f0a8a11c00295ed30b02cc721b0994900c6a3d3'/>
<id>urn:sha1:0f0a8a11c00295ed30b02cc721b0994900c6a3d3</id>
<content type='text'>
As part of the ongoing effort to consolidate reference handling,
introduce a new `exists` subcommand. This command provides the same
functionality and exit-code behavior as `git show-ref --exists`, serving
as its modern replacement.

The logic for `show-ref --exists` is minimal. Rather than creating a
shared helper function which would be overkill for ~20 lines of code,
its implementation is intentionally duplicated here. This contrasts with
`git refs list`, where sharing the larger implementation of
`for-each-ref` was necessary.

Documentation for the new subcommand is also added to the `git-refs(1)`
man page.

Mentored-by: Patrick Steinhardt &lt;ps@pks.im&gt;
Mentored-by: shejialuo &lt;shejialuo@gmail.com&gt;
Signed-off-by: Meet Soni &lt;meetsoni3017@gmail.com&gt;
Acked-by: Patrick Steinhardt &lt;ps@pks.im&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>builtin/refs: add list subcommand</title>
<updated>2025-08-05T16:11:54Z</updated>
<author>
<name>Meet Soni</name>
<email>meetsoni3017@gmail.com</email>
</author>
<published>2025-08-05T09:27:56Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=eecccfe98bb023a79f3c2b8bc415b6d656d0d381'/>
<id>urn:sha1:eecccfe98bb023a79f3c2b8bc415b6d656d0d381</id>
<content type='text'>
Git's reference management is distributed across multiple commands. As
part of an ongoing effort to consolidate and modernize reference
handling, introduce a `list` subcommand under the `git refs` umbrella as
a replacement for `git for-each-ref`.

Implement `cmd_refs_list` by having it call the `for_each_ref_core()`
helper function. This helper was factored out of the original
`cmd_for_each_ref` in a preceding commit, allowing both commands to
share the same core logic as independent peers.

Add documentation for the new command. The man page leverages the shared
options file, created in a previous commit, by using the AsciiDoc
`include::` macro to ensure consistency with git-for-each-ref(1).

Mentored-by: Patrick Steinhardt &lt;ps@pks.im&gt;
Mentored-by: shejialuo &lt;shejialuo@gmail.com&gt;
Mentored-by: Karthik Nayak &lt;karthik.188@gmail.com&gt;
Signed-off-by: Meet Soni &lt;meetsoni3017@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>config: drop `git_config()` wrapper</title>
<updated>2025-07-23T15:15:18Z</updated>
<author>
<name>Patrick Steinhardt</name>
<email>ps@pks.im</email>
</author>
<published>2025-07-23T14:08:22Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=9ce196e86b455fa2552812802c58f30c090c94af'/>
<id>urn:sha1:9ce196e86b455fa2552812802c58f30c090c94af</id>
<content type='text'>
In 036876a1067 (config: hide functions using `the_repository` by
default, 2024-08-13) we have moved around a bunch of functions in the
config subsystem that depend on `the_repository`. Those function have
been converted into mere wrappers around their equivalent function that
takes in a repository as parameter, and the intent was that we'll
eventually remove those wrappers to make the dependency on the global
repository variable explicit at the callsite.

Follow through with that intent and remove `git_config()`. All callsites
are adjusted so that they use `repo_config(the_repository, ...)`
instead. While some callsites might already have a repository available,
this mechanical conversion is the exact same as the current situation
and thus cannot cause any regression. Those sites should eventually be
cleaned up in a later patch series.

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 'sj/ref-consistency-checks-more'</title>
<updated>2025-03-26T07:26:10Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2025-03-26T07:26:09Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=de35b7b3ffb6e642b47f748eb38e31182377fb0a'/>
<id>urn:sha1:de35b7b3ffb6e642b47f748eb38e31182377fb0a</id>
<content type='text'>
"git fsck" becomes more careful when checking the refs.

* sj/ref-consistency-checks-more:
  builtin/fsck: add `git refs verify` child process
  packed-backend: check whether the "packed-refs" is sorted
  packed-backend: add "packed-refs" entry consistency check
  packed-backend: check whether the refname contains NUL characters
  packed-backend: add "packed-refs" header consistency check
  packed-backend: check if header starts with "# pack-refs with: "
  packed-backend: check whether the "packed-refs" is regular file
  builtin/refs: get worktrees without reading head information
  t0602: use subshell to ensure working directory unchanged
</content>
</entry>
<entry>
<title>refs: show --no-reflog in the help text</title>
<updated>2025-03-03T22:51:29Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2025-03-03T22:51:29Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=6dff5de1da7157de20310b10e5a0c09953dbb4bb'/>
<id>urn:sha1:6dff5de1da7157de20310b10e5a0c09953dbb4bb</id>
<content type='text'>
We forgot that we must keep the documentation and help text in sync.

Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>builtin/refs: get worktrees without reading head information</title>
<updated>2025-02-27T22:03:07Z</updated>
<author>
<name>shejialuo</name>
<email>shejialuo@gmail.com</email>
</author>
<published>2025-02-27T16:06:06Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=fdf3820b7ef69dcf887bd86565e2442f89edc7c0'/>
<id>urn:sha1:fdf3820b7ef69dcf887bd86565e2442f89edc7c0</id>
<content type='text'>
In "packed-backend.c", there are some functions such as "create_snapshot"
and "next_record" which would check the correctness of the content of
the "packed-ref" file. When anything is bad, the program will die.

It may seem that we have nothing relevant to above feature, because we
are going to read and parse the raw "packed-ref" file without creating
the snapshot and using the ref iterator to check the consistency.

However, when using "get_worktrees" in "builtin/refs", we would parse
the "HEAD" information. If the referent of the "HEAD" is inside the
"packed-ref", we will call "create_snapshot" function to parse the
"packed-ref" to get the information. No matter whether the entry of
"HEAD" in "packed-ref" is correct, "create_snapshot" would call
"verify_buffer_safe" to check whether there is a newline in the last
line of the file. If not, the program will die.

Although this behavior has no harm for the program, it will
short-circuit the program. When the users execute "git refs verify" or
"git fsck", we should avoid reading the head information, which may
execute the read operation in packed backend with stricter checks to die
the program. Instead, we should continue to check other parts of the
"packed-refs" file completely.

Fortunately, in 465a22b338 (worktree: skip reading HEAD when repairing
worktrees, 2023-12-29), we have introduced a function
"get_worktrees_internal" which allows us to get worktrees without
reading head information.

Create a new exposed function "get_worktrees_without_reading_head", then
replace the "get_worktrees" in "builtin/refs" with the new created
function.

Mentored-by: Patrick Steinhardt &lt;ps@pks.im&gt;
Mentored-by: Karthik Nayak &lt;karthik.188@gmail.com&gt;
Signed-off-by: shejialuo &lt;shejialuo@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
</feed>
