Skip to content

Commit 0574499

Browse files
ao2gitster
authored andcommitted
submodule-config: add helper to get 'update-clone' config from .gitmodules
Add a helper function to make it clearer that retrieving 'update-clone' configuration from the .gitmodules file is a special case supported solely for backward compatibility purposes. This change removes one direct use of 'config_from_gitmodules' for options not strictly related to submodules: "submodule.fetchjobs" does not describe a property of a submodule, but a behavior of other commands when dealing with submodules, so it does not really belong to the .gitmodules file. This is in the effort to communicate better that .gitmodules is not to be used as a mechanism to store arbitrary configuration in the repository that any command can retrieve. Signed-off-by: Antonio Ospite <[email protected]> Acked-by: Brandon Williams <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 71a6953 commit 0574499

File tree

3 files changed

+19
-4
lines changed

3 files changed

+19
-4
lines changed

builtin/submodule--helper.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1706,8 +1706,8 @@ static int update_clone_task_finished(int result,
17061706
return 0;
17071707
}
17081708

1709-
static int gitmodules_update_clone_config(const char *var, const char *value,
1710-
void *cb)
1709+
static int git_update_clone_config(const char *var, const char *value,
1710+
void *cb)
17111711
{
17121712
int *max_jobs = cb;
17131713
if (!strcmp(var, "submodule.fetchjobs"))
@@ -1757,8 +1757,8 @@ static int update_clone(int argc, const char **argv, const char *prefix)
17571757
};
17581758
suc.prefix = prefix;
17591759

1760-
config_from_gitmodules(gitmodules_update_clone_config, &max_jobs);
1761-
git_config(gitmodules_update_clone_config, &max_jobs);
1760+
update_clone_config_from_gitmodules(&max_jobs);
1761+
git_config(git_update_clone_config, &max_jobs);
17621762

17631763
argc = parse_options(argc, argv, prefix, module_update_clone_options,
17641764
git_submodule_helper_usage, 0);

submodule-config.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -716,3 +716,17 @@ void fetch_config_from_gitmodules(int *max_children, int *recurse_submodules)
716716
};
717717
config_from_gitmodules(gitmodules_fetch_config, &config);
718718
}
719+
720+
static int gitmodules_update_clone_config(const char *var, const char *value,
721+
void *cb)
722+
{
723+
int *max_jobs = cb;
724+
if (!strcmp(var, "submodule.fetchjobs"))
725+
*max_jobs = parse_submodule_fetchjobs(var, value);
726+
return 0;
727+
}
728+
729+
void update_clone_config_from_gitmodules(int *max_jobs)
730+
{
731+
config_from_gitmodules(gitmodules_update_clone_config, &max_jobs);
732+
}

submodule-config.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,5 +67,6 @@ int check_submodule_name(const char *name);
6767
extern void config_from_gitmodules(config_fn_t fn, void *data);
6868

6969
extern void fetch_config_from_gitmodules(int *max_children, int *recurse_submodules);
70+
extern void update_clone_config_from_gitmodules(int *max_jobs);
7071

7172
#endif /* SUBMODULE_CONFIG_H */

0 commit comments

Comments
 (0)