summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/checkout.c23
-rw-r--r--src/ignore.c38
-rw-r--r--src/ignore.h2
-rw-r--r--src/index.c17
4 files changed, 27 insertions, 53 deletions
diff --git a/src/checkout.c b/src/checkout.c
index 62a73d6d0..e29fccd05 100644
--- a/src/checkout.c
+++ b/src/checkout.c
@@ -1119,7 +1119,6 @@ static int checkout_data_init(
git_checkout_opts *proposed)
{
int error = 0;
- git_config *cfg;
git_repository *repo = git_iterator_owner(target);
memset(data, 0, sizeof(*data));
@@ -1132,9 +1131,6 @@ static int checkout_data_init(
if ((error = git_repository__ensure_not_bare(repo, "checkout")) < 0)
return error;
- if ((error = git_repository_config__weakptr(&cfg, repo)) < 0)
- return error;
-
data->repo = repo;
GITERR_CHECK_VERSION(
@@ -1147,7 +1143,10 @@ static int checkout_data_init(
/* refresh config and index content unless NO_REFRESH is given */
if ((data->opts.checkout_strategy & GIT_CHECKOUT_NO_REFRESH) == 0) {
- if ((error = git_config_refresh(cfg)) < 0)
+ git_config *cfg;
+
+ if ((error = git_repository_config__weakptr(&cfg, repo)) < 0 ||
+ (error = git_config_refresh(cfg)) < 0)
goto cleanup;
/* if we are checking out the index, don't reload,
@@ -1184,19 +1183,13 @@ static int checkout_data_init(
data->pfx = git_pathspec_prefix(&data->opts.paths);
- error = git_config_get_bool(&data->can_symlink, cfg, "core.symlinks");
- if (error < 0) {
- if (error != GIT_ENOTFOUND)
- goto cleanup;
-
- /* If "core.symlinks" is not found anywhere, default to true. */
- data->can_symlink = true;
- giterr_clear();
- error = 0;
- }
+ if ((error = git_repository__cvar(
+ &data->can_symlink, repo, GIT_CVAR_SYMLINKS)) < 0)
+ goto cleanup;
if (!data->opts.baseline) {
data->opts_free_baseline = true;
+
error = checkout_lookup_head_tree(&data->opts.baseline, repo);
if (error == GIT_EORPHANEDHEAD) {
diff --git a/src/ignore.c b/src/ignore.c
index 17779522c..e150b9585 100644
--- a/src/ignore.c
+++ b/src/ignore.c
@@ -15,24 +15,14 @@ static int parse_ignore_file(
git_attr_fnmatch *match = NULL;
const char *scan = NULL;
char *context = NULL;
- bool ignore_case = false;
- git_config *cfg = NULL;
- int val;
-
- /* Prefer to have the caller pass in a git_ignores as the parsedata object.
- * If they did not, then we can (much more slowly) find the value of
- * ignore_case by using the repository object. */
- if (parsedata != NULL) {
- ignore_case = ((git_ignores *)parsedata)->ignore_case;
- } else {
- if ((error = git_repository_config(&cfg, repo)) < 0)
- return error;
-
- if (git_config_get_bool(&val, cfg, "core.ignorecase") == 0)
- ignore_case = (val != 0);
+ int ignore_case = false;
- git_config_free(cfg);
- }
+ /* Prefer to have the caller pass in a git_ignores as the parsedata
+ * object. If they did not, then look up the value of ignore_case */
+ if (parsedata != NULL)
+ ignore_case = ((git_ignores *)parsedata)->ignore_case;
+ else if (git_repository__cvar(&ignore_case, repo, GIT_CVAR_IGNORECASE) < 0)
+ return error;
if (ignores->key && git__suffixcmp(ignores->key, "/" GIT_IGNORE_FILE) == 0) {
context = ignores->key + 2;
@@ -109,8 +99,6 @@ int git_ignore__for_path(
{
int error = 0;
const char *workdir = git_repository_workdir(repo);
- git_config *cfg = NULL;
- int val;
assert(ignores);
@@ -118,17 +106,11 @@ int git_ignore__for_path(
git_buf_init(&ignores->dir, 0);
ignores->ign_internal = NULL;
- /* Set the ignore_case flag appropriately */
- if ((error = git_repository_config(&cfg, repo)) < 0)
+ /* Read the ignore_case flag */
+ if ((error = git_repository__cvar(
+ &ignores->ignore_case, repo, GIT_CVAR_IGNORECASE)) < 0)
goto cleanup;
- if (git_config_get_bool(&val, cfg, "core.ignorecase") == 0)
- ignores->ignore_case = (val != 0);
- else
- ignores->ignore_case = 0;
-
- git_config_free(cfg);
-
if ((error = git_vector_init(&ignores->ign_path, 8, NULL)) < 0 ||
(error = git_vector_init(&ignores->ign_global, 2, NULL)) < 0 ||
(error = git_attr_cache__init(repo)) < 0)
diff --git a/src/ignore.h b/src/ignore.h
index 5af8e8e7d..e00e4a8c8 100644
--- a/src/ignore.h
+++ b/src/ignore.h
@@ -28,7 +28,7 @@ typedef struct {
git_attr_file *ign_internal;
git_vector ign_path;
git_vector ign_global;
- unsigned int ignore_case:1;
+ int ignore_case;
} git_ignores;
extern int git_ignore__for_path(git_repository *repo, const char *path, git_ignores *ign);
diff --git a/src/index.c b/src/index.c
index 2afd28158..d8ca78e52 100644
--- a/src/index.c
+++ b/src/index.c
@@ -330,7 +330,7 @@ void git_index_clear(git_index *index)
git_vector_clear(&index->entries);
git_index_reuc_clear(index);
-
+
git_futils_filestamp_set(&index->stamp, NULL);
git_tree_cache_free(index->tree);
@@ -352,19 +352,18 @@ int git_index_set_caps(git_index *index, unsigned int caps)
old_ignore_case = index->ignore_case;
if (caps == GIT_INDEXCAP_FROM_OWNER) {
- git_config *cfg;
+ git_repository *repo = INDEX_OWNER(index);
int val;
- if (INDEX_OWNER(index) == NULL ||
- git_repository_config__weakptr(&cfg, INDEX_OWNER(index)) < 0)
- return create_index_error(-1,
- "Cannot get repository config to set index caps");
+ if (!repo)
+ return create_index_error(
+ -1, "Cannot access repository to set index caps");
- if (git_config_get_bool(&val, cfg, "core.ignorecase") == 0)
+ if (!git_repository__cvar(&val, repo, GIT_CVAR_IGNORECASE))
index->ignore_case = (val != 0);
- if (git_config_get_bool(&val, cfg, "core.filemode") == 0)
+ if (!git_repository__cvar(&val, repo, GIT_CVAR_FILEMODE))
index->distrust_filemode = (val == 0);
- if (git_config_get_bool(&val, cfg, "core.symlinks") == 0)
+ if (!git_repository__cvar(&val, repo, GIT_CVAR_SYMLINKS))
index->no_symlinks = (val == 0);
}
else {