Skip to content

Commit 1870cc3

Browse files
pks-tgitster
authored andcommitted
config: pass repo to git_config_get_index_threads()
Refactor `git_config_get_index_threads()` to accept a `struct repository` such that we can get rid of the implicit dependency on `the_repository`. Rename the function accordingly. Signed-off-by: Patrick Steinhardt <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 2ea8536 commit 1870cc3

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

config.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2826,7 +2826,7 @@ int git_config_get_max_percent_split_change(void)
28262826
return -1; /* default value */
28272827
}
28282828

2829-
int git_config_get_index_threads(int *dest)
2829+
int repo_config_get_index_threads(struct repository *r, int *dest)
28302830
{
28312831
int is_bool, val;
28322832

@@ -2836,7 +2836,7 @@ int git_config_get_index_threads(int *dest)
28362836
return 0;
28372837
}
28382838

2839-
if (!git_config_get_bool_or_int("index.threads", &is_bool, &val)) {
2839+
if (!repo_config_get_bool_or_int(r, "index.threads", &is_bool, &val)) {
28402840
if (is_bool)
28412841
*dest = val ? 0 : 1;
28422842
else

config.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -710,7 +710,7 @@ int git_config_get_maybe_bool(const char *key, int *dest);
710710
*/
711711
int git_config_get_pathname(const char *key, char **dest);
712712

713-
int git_config_get_index_threads(int *dest);
713+
int repo_config_get_index_threads(struct repository *r, int *dest);
714714
int git_config_get_split_index(void);
715715
int git_config_get_max_percent_split_change(void);
716716

read-cache.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2267,7 +2267,7 @@ int do_read_index(struct index_state *istate, const char *path, int must_exist)
22672267

22682268
src_offset = sizeof(*hdr);
22692269

2270-
if (git_config_get_index_threads(&nr_threads))
2270+
if (repo_config_get_index_threads(the_repository, &nr_threads))
22712271
nr_threads = 1;
22722272

22732273
/* TODO: does creating more threads than cores help? */
@@ -2787,7 +2787,7 @@ static int record_eoie(void)
27872787
* used for threading is written by default if the user
27882788
* explicitly requested threaded index reads.
27892789
*/
2790-
return !git_config_get_index_threads(&val) && val != 1;
2790+
return !repo_config_get_index_threads(the_repository, &val) && val != 1;
27912791
}
27922792

27932793
static int record_ieot(void)
@@ -2802,7 +2802,7 @@ static int record_ieot(void)
28022802
* written by default if the user explicitly requested
28032803
* threaded index reads.
28042804
*/
2805-
return !git_config_get_index_threads(&val) && val != 1;
2805+
return !repo_config_get_index_threads(the_repository, &val) && val != 1;
28062806
}
28072807

28082808
enum write_extensions {
@@ -2875,7 +2875,7 @@ static int do_write_index(struct index_state *istate, struct tempfile *tempfile,
28752875

28762876
hashwrite(f, &hdr, sizeof(hdr));
28772877

2878-
if (!HAVE_THREADS || git_config_get_index_threads(&nr_threads))
2878+
if (!HAVE_THREADS || repo_config_get_index_threads(the_repository, &nr_threads))
28792879
nr_threads = 1;
28802880

28812881
if (nr_threads != 1 && record_ieot()) {

0 commit comments

Comments
 (0)