mirror of
https://github.com/git/git.git
synced 2026-01-11 21:33:13 +09:00
Merge branch 'ob/core-attributesfile-in-repository' into seen
The core.attributesfile is intended to be set per repository, but were kept track of by a single global variable in-core, which has been corrected by moving it to per-repository data structure. Comments? * ob/core-attributesfile-in-repository: environment: move "core.attributesFile" into repo-setting
This commit is contained in:
commit
42e8b0210e
19
attr.c
19
attr.c
@ -879,14 +879,6 @@ const char *git_attr_system_file(void)
|
||||
return system_wide;
|
||||
}
|
||||
|
||||
const char *git_attr_global_file(void)
|
||||
{
|
||||
if (!git_attributes_file)
|
||||
git_attributes_file = xdg_config_home("attributes");
|
||||
|
||||
return git_attributes_file;
|
||||
}
|
||||
|
||||
int git_attr_system_is_enabled(void)
|
||||
{
|
||||
return !git_env_bool("GIT_ATTR_NOSYSTEM", 0);
|
||||
@ -912,6 +904,8 @@ static void bootstrap_attr_stack(struct index_state *istate,
|
||||
{
|
||||
struct attr_stack *e;
|
||||
unsigned flags = READ_ATTR_MACRO_OK;
|
||||
const char *attributes_file_path;
|
||||
struct repository *repo;
|
||||
|
||||
if (*stack)
|
||||
return;
|
||||
@ -927,8 +921,13 @@ static void bootstrap_attr_stack(struct index_state *istate,
|
||||
}
|
||||
|
||||
/* home directory */
|
||||
if (git_attr_global_file()) {
|
||||
e = read_attr_from_file(git_attr_global_file(), flags);
|
||||
if (istate && istate->repo)
|
||||
repo = istate->repo;
|
||||
else
|
||||
repo = the_repository;
|
||||
attributes_file_path = repo_settings_get_attributesfile_path(repo);
|
||||
if (attributes_file_path) {
|
||||
e = read_attr_from_file(attributes_file_path, flags);
|
||||
push_stack(stack, e, NULL, 0);
|
||||
}
|
||||
|
||||
|
||||
3
attr.h
3
attr.h
@ -232,9 +232,6 @@ void attr_start(void);
|
||||
/* Return the system gitattributes file. */
|
||||
const char *git_attr_system_file(void);
|
||||
|
||||
/* Return the global gitattributes file, if any. */
|
||||
const char *git_attr_global_file(void);
|
||||
|
||||
/* Return whether the system gitattributes file is enabled and should be used. */
|
||||
int git_attr_system_is_enabled(void);
|
||||
|
||||
|
||||
@ -72,7 +72,7 @@ static char *git_attr_val_system(int ident_flag UNUSED)
|
||||
|
||||
static char *git_attr_val_global(int ident_flag UNUSED)
|
||||
{
|
||||
char *file = xstrdup_or_null(git_attr_global_file());
|
||||
char *file = xstrdup_or_null(repo_settings_get_attributesfile_path(the_repository));
|
||||
if (file) {
|
||||
normalize_path_copy(file, file);
|
||||
return file;
|
||||
|
||||
@ -53,7 +53,6 @@ char *git_commit_encoding;
|
||||
char *git_log_output_encoding;
|
||||
char *apply_default_whitespace;
|
||||
char *apply_default_ignorewhitespace;
|
||||
char *git_attributes_file;
|
||||
int zlib_compression_level = Z_BEST_SPEED;
|
||||
int pack_compression_level = Z_DEFAULT_COMPRESSION;
|
||||
int fsync_object_files = -1;
|
||||
@ -339,11 +338,6 @@ int git_default_core_config(const char *var, const char *value,
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!strcmp(var, "core.attributesfile")) {
|
||||
FREE_AND_NULL(git_attributes_file);
|
||||
return git_config_pathname(&git_attributes_file, var, value);
|
||||
}
|
||||
|
||||
if (!strcmp(var, "core.bare")) {
|
||||
is_bare_repository_cfg = git_config_bool(var, value);
|
||||
return 0;
|
||||
|
||||
@ -155,7 +155,6 @@ extern int assume_unchanged;
|
||||
extern int warn_on_object_refname_ambiguity;
|
||||
extern char *apply_default_whitespace;
|
||||
extern char *apply_default_ignorewhitespace;
|
||||
extern char *git_attributes_file;
|
||||
extern int zlib_compression_level;
|
||||
extern int pack_compression_level;
|
||||
extern unsigned long pack_size_limit_cfg;
|
||||
|
||||
@ -5,6 +5,7 @@
|
||||
#include "midx.h"
|
||||
#include "pack-objects.h"
|
||||
#include "setup.h"
|
||||
#include "path.h"
|
||||
|
||||
static void repo_cfg_bool(struct repository *r, const char *key, int *dest,
|
||||
int def)
|
||||
@ -161,6 +162,7 @@ void repo_settings_clear(struct repository *r)
|
||||
struct repo_settings empty = REPO_SETTINGS_INIT;
|
||||
FREE_AND_NULL(r->settings.fsmonitor);
|
||||
FREE_AND_NULL(r->settings.hooks_path);
|
||||
FREE_AND_NULL(r->settings.attributes_file_path);
|
||||
r->settings = empty;
|
||||
}
|
||||
|
||||
@ -233,3 +235,11 @@ void repo_settings_reset_shared_repository(struct repository *repo)
|
||||
{
|
||||
repo->settings.shared_repository_initialized = 0;
|
||||
}
|
||||
const char *repo_settings_get_attributesfile_path(struct repository *repo)
|
||||
{
|
||||
if (!repo->settings.attributes_file_path) {
|
||||
if (repo_config_get_pathname(repo, "core.attributesfile", &repo->settings.attributes_file_path))
|
||||
repo->settings.attributes_file_path = xdg_config_home("attributes");
|
||||
}
|
||||
return repo->settings.attributes_file_path;
|
||||
}
|
||||
|
||||
@ -70,6 +70,7 @@ struct repo_settings {
|
||||
int max_allowed_tree_depth;
|
||||
|
||||
char *hooks_path;
|
||||
char *attributes_file_path;
|
||||
};
|
||||
#define REPO_SETTINGS_INIT { \
|
||||
.shared_repository = -1, \
|
||||
@ -102,4 +103,11 @@ int repo_settings_get_shared_repository(struct repository *repo);
|
||||
void repo_settings_set_shared_repository(struct repository *repo, int value);
|
||||
void repo_settings_reset_shared_repository(struct repository *repo);
|
||||
|
||||
/*
|
||||
* Read the value for "core.attributesfile".
|
||||
* Defaults to xdg_config_home("attributes") if the core.attributesfile
|
||||
* which is set via repo config isn't available.
|
||||
*/
|
||||
const char *repo_settings_get_attributesfile_path(struct repository *repo);
|
||||
|
||||
#endif /* REPO_SETTINGS_H */
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user