<feed xmlns='http://www.w3.org/2005/Atom'>
<title>git/setup.h, 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-16T17:48:14Z</updated>
<entry>
<title>Merge branch 'ty/setup-error-tightening'</title>
<updated>2026-03-16T17:48:14Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2026-03-16T17:48:14Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=c563b12ce7aa6bf8130385c80c001b2340026ff5'/>
<id>urn:sha1:c563b12ce7aa6bf8130385c80c001b2340026ff5</id>
<content type='text'>
While discovering a ".git" directory, the code treats any stat()
failure as a sign that a filesystem entity .git does not exist
there, and ignores ".git" that is not a "gitdir" file or a
directory.  The code has been tightened to notice and report
filesystem corruption better.

* ty/setup-error-tightening:
  setup: improve error diagnosis for invalid .git files
</content>
</entry>
<entry>
<title>Merge branch 'kn/ref-location'</title>
<updated>2026-03-04T18:52:59Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2026-03-04T18:52:58Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=1d0a2acb78f157d39937a088548e561b27722e8d'/>
<id>urn:sha1:1d0a2acb78f157d39937a088548e561b27722e8d</id>
<content type='text'>
Allow the directory in which reference backends store their data to
be specified.

* kn/ref-location:
  refs: add GIT_REFERENCE_BACKEND to specify reference backend
  refs: allow reference location in refstorage config
  refs: receive and use the reference storage payload
  refs: move out stub modification to generic layer
  refs: extract out `refs_create_refdir_stubs()`
  setup: don't modify repo in `create_reference_database()`
</content>
</entry>
<entry>
<title>setup: improve error diagnosis for invalid .git files</title>
<updated>2026-03-04T17:23:48Z</updated>
<author>
<name>Tian Yuchen</name>
<email>a3205153416@gmail.com</email>
</author>
<published>2026-03-04T14:15:26Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=1dd27bfbfdc0f3b2071ecb8b505476f4caa56a13'/>
<id>urn:sha1:1dd27bfbfdc0f3b2071ecb8b505476f4caa56a13</id>
<content type='text'>
'read_gitfile_gently()' treats any non-regular file as
'READ_GITFILE_ERR_NOT_A_FILE' and fails to discern between 'ENOENT'
and other stat failures. This flawed error reporting is noted by two
'NEEDSWORK' comments.

Address these comments by introducing two new error codes:
'READ_GITFILE_ERR_MISSING'(which groups the "file missing" scenarios
together) and 'READ_GITFILE_ERR_IS_A_DIR':

1. Update 'read_gitfile_error_die()' to treat 'IS_A_DIR', 'MISSING',
'NOT_A_FILE' and 'STAT_FAILED' as non-fatal no-ops. This accommodates
intentional non-repo scenarios (e.g., GIT_DIR=/dev/null).

2. Explicitly catch 'NOT_A_FILE' and 'STAT_FAILED' during
discovery and call 'die()' if 'die_on_error' is set.

3. Unconditionally pass '&amp;error_code' to 'read_gitfile_gently()'.

4. Only invoke 'is_git_directory()' when we explicitly receive
   'READ_GITFILE_ERR_IS_A_DIR', avoiding redundant checks.

Additionally, audit external callers of 'read_gitfile_gently()' in
'submodule.c' and 'worktree.c' to accommodate the refined error codes.

Signed-off-by: Tian Yuchen &lt;a3205153416@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>refs: allow reference location in refstorage config</title>
<updated>2026-02-25T17:38:41Z</updated>
<author>
<name>Karthik Nayak</name>
<email>karthik.188@gmail.com</email>
</author>
<published>2026-02-25T09:40:45Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=01dc84594ee365ee7086fccc7f590ab527730531'/>
<id>urn:sha1:01dc84594ee365ee7086fccc7f590ab527730531</id>
<content type='text'>
The 'extensions.refStorage' config is used to specify the reference
backend for a given repository. Both the 'files' and 'reftable' backends
utilize the $GIT_DIR as the reference folder by default in
`get_main_ref_store()`.

Since the reference backends are pluggable, this means that they could
work with out-of-tree reference directories too. Extend the 'refStorage'
config to also support taking an URI input, where users can specify the
reference backend and the location.

Add the required changes to obtain and propagate this value to the
individual backends. Add the necessary documentation and tests.

Traditionally, for linked worktrees, references were stored in the
'$GIT_DIR/worktrees/&lt;wt_id&gt;' path. But when using an alternate reference
storage path, it doesn't make sense to store the main worktree
references in the new path, and the linked worktree references in the
$GIT_DIR. So, let's store linked worktree references in
'$ALTERNATE_REFERENCE_DIR/worktrees/&lt;wt_id&gt;'. To do this, create the
necessary files and folders while also adding stubs in the $GIT_DIR path
to ensure that it is still considered a Git directory.

Ideally, we would want to pass in a `struct worktree *` to individual
backends, instead of passing the `gitdir`. This allows them to handle
worktree specific logic. Currently, that is not possible since the
worktree code is:

  - Tied to using the global `the_repository` variable.

  - Is not setup before the reference database during initialization of
    the repository.

Add a TODO in 'refs.c' to ensure we can eventually make that change.

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>setup: don't modify repo in `create_reference_database()`</title>
<updated>2026-02-25T17:27:11Z</updated>
<author>
<name>Karthik Nayak</name>
<email>karthik.188@gmail.com</email>
</author>
<published>2026-02-25T09:40:41Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=2c69ff481938a10660c2078cf83235db26773254'/>
<id>urn:sha1:2c69ff481938a10660c2078cf83235db26773254</id>
<content type='text'>
The `create_reference_database()` function is used to create the
reference database during initialization of a repository. The function
calls `repo_set_ref_storage_format()` to set the repositories reference
format. This is an unexpected side-effect of the function. More so
because the function is only called in two locations:

  1. During git-init(1) where the value is propagated from the `struct
     repository_format repo_fmt` value.

  2. During git-clone(1) where the value is propagated from the
     `the_repository` value.

The former is valid, however the flow already calls
`repo_set_ref_storage_format()`, so this effort is simply duplicated.
The latter sets the existing value in `the_repository` back to itself.
While this is okay for now, introduction of more fields in
`repo_set_ref_storage_format()` would cause issues, especially
dynamically allocated strings, where we would free/allocate the same
string back into `the_repostiory`.

To avoid all this confusion, clean up the function to no longer take in
and set the repo's reference storage format.

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>Merge branch 'ar/submodule-gitdir-tweak'</title>
<updated>2026-02-05T23:41:58Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2026-02-05T23:41:58Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=c3a5261dc0e726b5d8ee6309afcad9d431a4b50c'/>
<id>urn:sha1:c3a5261dc0e726b5d8ee6309afcad9d431a4b50c</id>
<content type='text'>
Avoid local submodule repository directory paths overlapping with
each other by encoding submodule names before using them as path
components.

* ar/submodule-gitdir-tweak:
  submodule: detect conflicts with existing gitdir configs
  submodule: hash the submodule name for the gitdir path
  submodule: fix case-folding gitdir filesystem collisions
  submodule--helper: fix filesystem collisions by encoding gitdir paths
  builtin/credential-store: move is_rfc3986_unreserved to url.[ch]
  submodule--helper: add gitdir migration command
  submodule: allow runtime enabling extensions.submodulePathConfig
  submodule: introduce extensions.submodulePathConfig
  builtin/submodule--helper: add gitdir command
  submodule: always validate gitdirs inside submodule_name_to_gitdir
  submodule--helper: use submodule_name_to_gitdir in add_submodule
</content>
</entry>
<entry>
<title>submodule: introduce extensions.submodulePathConfig</title>
<updated>2026-01-12T19:56:55Z</updated>
<author>
<name>Adrian Ratiu</name>
<email>adrian.ratiu@collabora.com</email>
</author>
<published>2026-01-12T18:46:25Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=4173df5187c8ba8bc2cc1a215f25b284d70631da'/>
<id>urn:sha1:4173df5187c8ba8bc2cc1a215f25b284d70631da</id>
<content type='text'>
The idea of this extension is to abstract away the submodule gitdir
path implementation: everyone is expected to use the config and not
worry about how the path is computed internally, either in git or
other implementations.

With this extension enabled, the submodule.&lt;name&gt;.gitdir repo config
becomes the single source of truth for all submodule gitdir paths.

The submodule.&lt;name&gt;.gitdir config is added automatically for all new
submodules when this extension is enabled.

Git will throw an error if the extension is enabled and a config is
missing, advising users how to migrate. Migration is manual for now.

E.g. to add a missing config entry for an existing "foo" module:
git config submodule.foo.gitdir .git/modules/foo

Suggested-by: Junio C Hamano &lt;gitster@pobox.com&gt;
Suggested-by: Phillip Wood &lt;phillip.wood123@gmail.com&gt;
Suggested-by: Patrick Steinhardt &lt;ps@pks.im&gt;
Signed-off-by: Adrian Ratiu &lt;adrian.ratiu@collabora.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>setup: convert `set_git_dir()` to have file scope</title>
<updated>2025-11-20T01:41:03Z</updated>
<author>
<name>Patrick Steinhardt</name>
<email>ps@pks.im</email>
</author>
<published>2025-11-19T07:50:50Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=7c188a9e45405ff911b81a5dd9029f4e91fb338e'/>
<id>urn:sha1:7c188a9e45405ff911b81a5dd9029f4e91fb338e</id>
<content type='text'>
We don't have any external callers of `set_git_dir()` anymore now that
`enter_repo()` has been moved into "setup.c". Remove the declaration and
mark the function as static.

Note that this change requires us to move the implementation around so
that we can avoid adding any new forward declarations.

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>path: move `enter_repo()` into "setup.c"</title>
<updated>2025-11-20T01:41:03Z</updated>
<author>
<name>Patrick Steinhardt</name>
<email>ps@pks.im</email>
</author>
<published>2025-11-19T07:50:49Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=831e02340b9de46c9ea0a1bbce3894f390f5a45e'/>
<id>urn:sha1:831e02340b9de46c9ea0a1bbce3894f390f5a45e</id>
<content type='text'>
The function `enter_repo()` is used to enter a repository at a given
path. As such it sits way closer to setting up a repository than it does
with handling paths, but regardless of that it's located in "path.c"
instead of in "setup.c".

Move the function into "setup.c".

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>setup: use the default algorithm to initialize repo format</title>
<updated>2025-07-01T21:58:24Z</updated>
<author>
<name>brian m. carlson</name>
<email>sandals@crustytoothpaste.net</email>
</author>
<published>2025-07-01T21:22:31Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=d6e616cee741fc3f67fd3b7c328175b932d0aaa5'/>
<id>urn:sha1:d6e616cee741fc3f67fd3b7c328175b932d0aaa5</id>
<content type='text'>
When we define a new repository format with REPOSITORY_FORMAT_INIT, we
always use GIT_HASH_SHA1, and this value ends up getting used as the
default value to initialize a repository if none of the command line,
environment, or config tell us to do otherwise.

Because we might not always want to use SHA-1 as the default, let's
instead specify the default hash algorithm constant so that we will use
whatever the specified default is.

However, we also need to continue to read older repositories.  If we're
in a v0 repository or extensions.objectformat is not set, then we must
continue to default to the original hash algorithm: SHA-1.  If an
algorithm is set explicitly, however, it will override the hash_algo
member of the repository_format struct and we'll get the right value.

Similarly, if the repository was initialized before Git 0.99.3, then it
may lack a core.repositoryformatversion key, and some repositories lack
a config file altogether.  In both cases, format-&gt;version is -1 and we
need to assume that SHA-1 is in use.

Because clear_repository_format reinitializes the struct
repository_format and therefore sets the hash_algo member to the default
(which could in the future not be SHA-1), we need to reset this member
explicitly.  We know, however, that at the point we call
read_repository_format, we are actually reading an existing repository
and not initializing a new one or operating outside of a repository, so
we are not changing the default behavior back to SHA-1 if the default
algorithm is different.

It is potentially questionable that we ignore all repository
configuration if there is a config file but it doesn't have
core.repositoryformatversion set, in which case we reset all of the
configuration to the default.  However, it is unclear what the right
thing to do instead with such an old repository is and a simple git init
will add the missing entry, so for now, we simply honor what the
existing code does and reset the value to the default, simply adding our
initialization to SHA-1.

Signed-off-by: brian m. carlson &lt;sandals@crustytoothpaste.net&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
</feed>
