diff options
| author | Russell Belfer <rb@github.com> | 2013-04-22 14:27:36 -0700 |
|---|---|---|
| committer | Russell Belfer <rb@github.com> | 2013-04-23 12:57:30 -0700 |
| commit | eac76c230c92594eaa528e50746119bd3c33ffbb (patch) | |
| tree | 0f03ff2ab3cb7c4d4c94106e108f3ba0e129afa8 /src/checkout.c | |
| parent | ab01cbd4ddd756c7beda3f483791cb5d4e211872 (diff) | |
| download | libgit2-eac76c230c92594eaa528e50746119bd3c33ffbb.tar.gz | |
Use config cache where possible
This converts many of the config lookups that are done around the
library to use the repository config cache. This was everything I
could find that wasn't part of diff (which requires a larger fix).
Diffstat (limited to 'src/checkout.c')
| -rw-r--r-- | src/checkout.c | 23 |
1 files changed, 8 insertions, 15 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) { |
