Skip to content

Commit

Permalink
config: move config_from_gitmodules to submodule-config.c
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
ao2 authored and gitster committed Jun 26, 2018
1 parent ed84343 commit ad13637
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 27 deletions.
17 changes: 0 additions & 17 deletions config.c
Original file line number Diff line number Diff line change
Expand Up @@ -2172,23 +2172,6 @@ int git_config_get_pathname(const char *key, const char **dest)
return repo_config_get_pathname(the_repository, key, dest);
}

/*
* Note: This function exists solely to maintain backward compatibility with
* 'fetch' and 'update_clone' storing configuration in '.gitmodules' and should
* NOT be used anywhere else.
*
* Runs the provided config function on the '.gitmodules' file found in the
* working directory.
*/
void config_from_gitmodules(config_fn_t fn, void *data)
{
if (the_repository->worktree) {
char *file = repo_worktree_path(the_repository, GITMODULES_FILE);
git_config_from_file(fn, file, data);
free(file);
}
}

int git_config_get_expiry(const char *key, const char **output)
{
int ret = git_config_get_string_const(key, output);
Expand Down
10 changes: 0 additions & 10 deletions config.h
Original file line number Diff line number Diff line change
Expand Up @@ -215,16 +215,6 @@ extern int repo_config_get_maybe_bool(struct repository *repo,
extern int repo_config_get_pathname(struct repository *repo,
const char *key, const char **dest);

/*
* Note: This function exists solely to maintain backward compatibility with
* 'fetch' and 'update_clone' storing configuration in '.gitmodules' and should
* NOT be used anywhere else.
*
* Runs the provided config function on the '.gitmodules' file found in the
* working directory.
*/
extern void config_from_gitmodules(config_fn_t fn, void *data);

extern int git_config_get_value(const char *key, const char **value);
extern const struct string_list *git_config_get_value_multi(const char *key);
extern void git_config_clear(void);
Expand Down
17 changes: 17 additions & 0 deletions submodule-config.c
Original file line number Diff line number Diff line change
Expand Up @@ -671,3 +671,20 @@ void submodule_free(struct repository *r)
if (r->submodule_cache)
submodule_cache_clear(r->submodule_cache);
}

/*
* Note: This function exists solely to maintain backward compatibility with
* 'fetch' and 'update_clone' storing configuration in '.gitmodules' and should
* NOT be used anywhere else.
*
* Runs the provided config function on the '.gitmodules' file found in the
* working directory.
*/
void config_from_gitmodules(config_fn_t fn, void *data)
{
if (the_repository->worktree) {
char *file = repo_worktree_path(the_repository, GITMODULES_FILE);
git_config_from_file(fn, file, data);
free(file);
}
}
11 changes: 11 additions & 0 deletions submodule-config.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#define SUBMODULE_CONFIG_CACHE_H

#include "cache.h"
#include "config.h"
#include "hashmap.h"
#include "submodule.h"
#include "strbuf.h"
Expand Down Expand Up @@ -55,4 +56,14 @@ void submodule_free(struct repository *r);
*/
int check_submodule_name(const char *name);

/*
* Note: This function exists solely to maintain backward compatibility with
* 'fetch' and 'update_clone' storing configuration in '.gitmodules' and should
* NOT be used anywhere else.
*
* Runs the provided config function on the '.gitmodules' file found in the
* working directory.
*/
extern void config_from_gitmodules(config_fn_t fn, void *data);

#endif /* SUBMODULE_CONFIG_H */

0 comments on commit ad13637

Please sign in to comment.