]> Kevux Git Server - rit/commit
setup: don't modify repo in `create_reference_database()`
authorKarthik Nayak <karthik.188@gmail.com>
Wed, 25 Feb 2026 09:40:41 +0000 (10:40 +0100)
committerJunio C Hamano <gitster@pobox.com>
Wed, 25 Feb 2026 17:27:11 +0000 (09:27 -0800)
commit2c69ff481938a10660c2078cf83235db26773254
tree3d168d1367099369e5ee3f1417a698d9c352332d
parent67ad42147a7acc2af6074753ebd03d904476118f
setup: don't modify repo in `create_reference_database()`

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 <karthik.188@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/clone.c
setup.c
setup.h