Skip to content

repository: move fetch_if_missing into struct repository#11

Open
malon7782 wants to merge 1 commit into
masterfrom
fetch-if-missing
Open

repository: move fetch_if_missing into struct repository#11
malon7782 wants to merge 1 commit into
masterfrom
fetch-if-missing

Conversation

@malon7782

Copy link
Copy Markdown
Owner

The global variable 'fetch_if_missing' controls whether a missing object check should prompt a lazy fetch from a promisor remote. In order to continue the libification effort, Move it into 'struct repository' and initialize it to 1 by default to keep the previous behavior.

Subsystems that already pass around a repository pointer, are updated to read this flag directly from their respective 'repo' instances. Builtin commands are updated to modify
'the_repository->fetch_if_missing'. Where necessary, the 'USE_THE_REPOSITORY_VARIABLE' macro is defined to allow these commands to access 'the_repository'.

Additionally, update the partial clone documentation to reflect that this is now a per-repository flag.

Mentored-by: Christian Couder christian.couder@gmail.com
Mentored-by: Ayush Chandekar ayu.chandekar@gmail.com
Mentored-by: Olamide Caleb Bello belkid98@gmail.com

@malon7782

malon7782 commented Jul 11, 2026

Copy link
Copy Markdown
Owner Author

I'm very unconvinced about the changes in this patch, although they are so simple and might be correct formally.

The reason is that I am still trying to figure out the mechanism of partial clone and promise remote (that's why I haven't explained what fetch_if_missing does in detail );
moreover, this variable is obviously different from the previous static configurations. It is a state variable that will be read and written frequently during runtime. Based on this, the only conclusion I can draw is that it is not so bad to put it in struct repository

@malon7782

Copy link
Copy Markdown
Owner Author

I'm very unconvinced about the changes in this patch, although they are so simple and might be correct formally.

The reason is that I am still trying to figure out the mechanism of partial clone and promise remote; moreover, this variable is obviously different from the previous static configurations. It is a state variable that will be read and written frequently during runtime. Based on this, the only conclusion I can draw is that it is not so bad to put it in struct repository

In other words, repository seems to be the least bad place to go. Because repo_settings, repo_config_values, raw_object_store, index_state are not intuitively appropriate. If we are sure to add it to the struct repository, we need to demonstrate that fetch_if_missing is a kill switch that is critical enough.

Comment thread builtin/fsck.c Outdated
Comment thread builtin/index-pack.c Outdated
Comment thread builtin/prune.c Outdated
The global variable 'fetch_if_missing' controls whether a missing
object check should prompt a lazy fetch from a promisor remote.
In order to continue the libification effort, move it into
'struct repository' and initialize it to 1 by default to keep the
previous behavior.

Subsystems that already pass around a repository pointer, are
updated to read this flag directly from their respective 'repo'
instances. For the rest, we access 'the_repository'.

Note that in builtin/fsck.c and builtin/index-pack.c, when running
related commands with the '-h' parameter, the 'repo' pointer is not
passed in. To prevent null pointer dereferences, we defer
operations on the repo in until after parameter parsing is complete.

Additionally, update the partial clone documentation to reflect
that this is now a per-repository flag.

Mentored-by: Christian Couder <christian.couder@gmail.com>
Mentored-by: Ayush Chandekar <ayu.chandekar@gmail.com>
Mentored-by: Olamide Caleb Bello <belkid98@gmail.com>
Signed-off-by: Tian Yuchen <cat@malon.dev>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants