Skip to content

Commit ad13637

Browse files
ao2gitster
authored andcommitted
config: move config_from_gitmodules to submodule-config.c
The .gitmodules file is not meant as a place to store arbitrary configuration to distribute with the repository. Move config_from_gitmodules() out of config.c and into submodule-config.c to make it even clearer that it is not a mechanism to retrieve arbitrary configuration from the .gitmodules file. Signed-off-by: Antonio Ospite <[email protected]> Acked-by: Brandon Williams <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent ed84343 commit ad13637

File tree

4 files changed

+28
-27
lines changed

4 files changed

+28
-27
lines changed

config.c

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2172,23 +2172,6 @@ int git_config_get_pathname(const char *key, const char **dest)
21722172
return repo_config_get_pathname(the_repository, key, dest);
21732173
}
21742174

2175-
/*
2176-
* Note: This function exists solely to maintain backward compatibility with
2177-
* 'fetch' and 'update_clone' storing configuration in '.gitmodules' and should
2178-
* NOT be used anywhere else.
2179-
*
2180-
* Runs the provided config function on the '.gitmodules' file found in the
2181-
* working directory.
2182-
*/
2183-
void config_from_gitmodules(config_fn_t fn, void *data)
2184-
{
2185-
if (the_repository->worktree) {
2186-
char *file = repo_worktree_path(the_repository, GITMODULES_FILE);
2187-
git_config_from_file(fn, file, data);
2188-
free(file);
2189-
}
2190-
}
2191-
21922175
int git_config_get_expiry(const char *key, const char **output)
21932176
{
21942177
int ret = git_config_get_string_const(key, output);

config.h

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -215,16 +215,6 @@ extern int repo_config_get_maybe_bool(struct repository *repo,
215215
extern int repo_config_get_pathname(struct repository *repo,
216216
const char *key, const char **dest);
217217

218-
/*
219-
* Note: This function exists solely to maintain backward compatibility with
220-
* 'fetch' and 'update_clone' storing configuration in '.gitmodules' and should
221-
* NOT be used anywhere else.
222-
*
223-
* Runs the provided config function on the '.gitmodules' file found in the
224-
* working directory.
225-
*/
226-
extern void config_from_gitmodules(config_fn_t fn, void *data);
227-
228218
extern int git_config_get_value(const char *key, const char **value);
229219
extern const struct string_list *git_config_get_value_multi(const char *key);
230220
extern void git_config_clear(void);

submodule-config.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -671,3 +671,20 @@ void submodule_free(struct repository *r)
671671
if (r->submodule_cache)
672672
submodule_cache_clear(r->submodule_cache);
673673
}
674+
675+
/*
676+
* Note: This function exists solely to maintain backward compatibility with
677+
* 'fetch' and 'update_clone' storing configuration in '.gitmodules' and should
678+
* NOT be used anywhere else.
679+
*
680+
* Runs the provided config function on the '.gitmodules' file found in the
681+
* working directory.
682+
*/
683+
void config_from_gitmodules(config_fn_t fn, void *data)
684+
{
685+
if (the_repository->worktree) {
686+
char *file = repo_worktree_path(the_repository, GITMODULES_FILE);
687+
git_config_from_file(fn, file, data);
688+
free(file);
689+
}
690+
}

submodule-config.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#define SUBMODULE_CONFIG_CACHE_H
33

44
#include "cache.h"
5+
#include "config.h"
56
#include "hashmap.h"
67
#include "submodule.h"
78
#include "strbuf.h"
@@ -55,4 +56,14 @@ void submodule_free(struct repository *r);
5556
*/
5657
int check_submodule_name(const char *name);
5758

59+
/*
60+
* Note: This function exists solely to maintain backward compatibility with
61+
* 'fetch' and 'update_clone' storing configuration in '.gitmodules' and should
62+
* NOT be used anywhere else.
63+
*
64+
* Runs the provided config function on the '.gitmodules' file found in the
65+
* working directory.
66+
*/
67+
extern void config_from_gitmodules(config_fn_t fn, void *data);
68+
5869
#endif /* SUBMODULE_CONFIG_H */

0 commit comments

Comments
 (0)