diff options
| author | Ben Straub <bs@github.com> | 2012-11-20 16:02:25 -0800 |
|---|---|---|
| committer | Ben Straub <bs@github.com> | 2012-11-27 13:18:28 -0800 |
| commit | 54b2a37ac7715c74e5b06b76eb2b631987d7b6f8 (patch) | |
| tree | e2f7441735a506de16b411a3c181a76f264c2bab /src | |
| parent | eecc80502975df5ef3aa9027d1b8b929cd6181bd (diff) | |
| download | libgit2-54b2a37ac7715c74e5b06b76eb2b631987d7b6f8.tar.gz | |
Clean up config.h
Diffstat (limited to 'src')
| -rw-r--r-- | src/config.c | 74 | ||||
| -rw-r--r-- | src/config.h | 2 | ||||
| -rw-r--r-- | src/config_file.c | 24 | ||||
| -rw-r--r-- | src/config_file.h | 14 | ||||
| -rw-r--r-- | src/remote.c | 4 | ||||
| -rw-r--r-- | src/repository.c | 4 | ||||
| -rw-r--r-- | src/submodule.c | 16 | ||||
| -rw-r--r-- | src/vector.h | 2 | ||||
| -rw-r--r-- | src/win32/posix_w32.c | 2 |
9 files changed, 71 insertions, 71 deletions
diff --git a/src/config.c b/src/config.c index fc9ea65fe..5ee0d39ff 100644 --- a/src/config.c +++ b/src/config.c @@ -19,13 +19,13 @@ typedef struct { git_refcount rc; - git_config_file *file; + git_config_backend *file; unsigned int level; } file_internal; static void file_internal_free(file_internal *internal) { - git_config_file *file; + git_config_backend *file; file = internal->file; file->free(file); @@ -87,7 +87,7 @@ int git_config_add_file_ondisk( unsigned int level, int force) { - git_config_file *file = NULL; + git_config_backend *file = NULL; int res; assert(cfg && path); @@ -100,7 +100,7 @@ int git_config_add_file_ondisk( if (git_config_file__ondisk(&file, path) < 0) return -1; - if ((res = git_config_add_file(cfg, file, level, force)) < 0) { + if ((res = git_config_add_backend(cfg, file, level, force)) < 0) { /* * free manually; the file is not owned by the config * instance yet and will not be freed on cleanup @@ -132,7 +132,7 @@ int git_config_open_ondisk(git_config **out, const char *path) static int find_internal_file_by_level( file_internal **internal_out, - git_config *cfg, + const git_config *cfg, int level) { int pos = -1; @@ -224,7 +224,7 @@ static int git_config__add_internal( int git_config_open_level( git_config **cfg_out, - git_config *cfg_parent, + const git_config *cfg_parent, unsigned int level) { git_config *cfg; @@ -247,9 +247,9 @@ int git_config_open_level( return 0; } -int git_config_add_file( +int git_config_add_backend( git_config *cfg, - git_config_file *file, + git_config_backend *file, unsigned int level, int force) { @@ -284,7 +284,7 @@ int git_config_refresh(git_config *cfg) for (i = 0; i < cfg->files.length && !error; ++i) { file_internal *internal = git_vector_get(&cfg->files, i); - git_config_file *file = internal->file; + git_config_backend *file = internal->file; error = file->refresh(file); } @@ -296,34 +296,34 @@ int git_config_refresh(git_config *cfg) */ int git_config_foreach( - git_config *cfg, int (*fn)(const git_config_entry *, void *), void *data) + const git_config *cfg, git_config_foreach_cb cb, void *payload) { - return git_config_foreach_match(cfg, NULL, fn, data); + return git_config_foreach_match(cfg, NULL, cb, payload); } int git_config_foreach_match( - git_config *cfg, + const git_config *cfg, const char *regexp, - int (*fn)(const git_config_entry *, void *), - void *data) + git_config_foreach_cb cb, + void *payload) { int ret = 0; unsigned int i; file_internal *internal; - git_config_file *file; + git_config_backend *file; for (i = 0; i < cfg->files.length && ret == 0; ++i) { internal = git_vector_get(&cfg->files, i); file = internal->file; - ret = file->foreach(file, regexp, fn, data); + ret = file->foreach(file, regexp, cb, payload); } return ret; } -int git_config_delete(git_config *cfg, const char *name) +int git_config_delete_entry(git_config *cfg, const char *name) { - git_config_file *file; + git_config_backend *file; file_internal *internal; internal = git_vector_get(&cfg->files, 0); @@ -355,7 +355,7 @@ int git_config_set_bool(git_config *cfg, const char *name, int value) int git_config_set_string(git_config *cfg, const char *name, const char *value) { - git_config_file *file; + git_config_backend *file; file_internal *internal; internal = git_vector_get(&cfg->files, 0); @@ -369,9 +369,9 @@ int git_config_set_string(git_config *cfg, const char *name, const char *value) ***********/ int git_config_get_mapped( int *out, - git_config *cfg, + const git_config *cfg, const char *name, - git_cvar_map *maps, + const git_cvar_map *maps, size_t map_n) { const char *value; @@ -383,7 +383,7 @@ int git_config_get_mapped( return git_config_lookup_map_value(out, maps, map_n, value); } -int git_config_get_int64(int64_t *out, git_config *cfg, const char *name) +int git_config_get_int64(int64_t *out, const git_config *cfg, const char *name) { const char *value; int ret; @@ -394,7 +394,7 @@ int git_config_get_int64(int64_t *out, git_config *cfg, const char *name) return git_config_parse_int64(out, value); } -int git_config_get_int32(int32_t *out, git_config *cfg, const char *name) +int git_config_get_int32(int32_t *out, const git_config *cfg, const char *name) { const char *value; int ret; @@ -405,7 +405,7 @@ int git_config_get_int32(int32_t *out, git_config *cfg, const char *name) return git_config_parse_int32(out, value); } -static int get_string_at_file(const char **out, git_config_file *file, const char *name) +static int get_string_at_file(const char **out, const git_config_backend *file, const char *name) { const git_config_entry *entry; int res; @@ -417,7 +417,7 @@ static int get_string_at_file(const char **out, git_config_file *file, const cha return res; } -static int get_string(const char **out, git_config *cfg, const char *name) +static int get_string(const char **out, const git_config *cfg, const char *name) { file_internal *internal; unsigned int i; @@ -434,7 +434,7 @@ static int get_string(const char **out, git_config *cfg, const char *name) return GIT_ENOTFOUND; } -int git_config_get_bool(int *out, git_config *cfg, const char *name) +int git_config_get_bool(int *out, const git_config *cfg, const char *name) { const char *value = NULL; int ret; @@ -445,7 +445,7 @@ int git_config_get_bool(int *out, git_config *cfg, const char *name) return git_config_parse_bool(out, value); } -int git_config_get_string(const char **out, git_config *cfg, const char *name) +int git_config_get_string(const char **out, const git_config *cfg, const char *name) { int ret; const char *str = NULL; @@ -457,7 +457,7 @@ int git_config_get_string(const char **out, git_config *cfg, const char *name) return 0; } -int git_config_get_entry(const git_config_entry **out, git_config *cfg, const char *name) +int git_config_get_entry(const git_config_entry **out, const git_config *cfg, const char *name) { file_internal *internal; unsigned int i; @@ -467,7 +467,7 @@ int git_config_get_entry(const git_config_entry **out, git_config *cfg, const ch *out = NULL; git_vector_foreach(&cfg->files, i, internal) { - git_config_file *file = internal->file; + git_config_backend *file = internal->file; int ret = file->get(file, name, out); if (ret != GIT_ENOTFOUND) return ret; @@ -476,11 +476,11 @@ int git_config_get_entry(const git_config_entry **out, git_config *cfg, const ch return GIT_ENOTFOUND; } -int git_config_get_multivar(git_config *cfg, const char *name, const char *regexp, - int (*fn)(const git_config_entry *entry, void *data), void *data) +int git_config_get_multivar(const git_config *cfg, const char *name, const char *regexp, + git_config_foreach_cb cb, void *payload) { file_internal *internal; - git_config_file *file; + git_config_backend *file; int ret = GIT_ENOTFOUND; size_t i; @@ -493,7 +493,7 @@ int git_config_get_multivar(git_config *cfg, const char *name, const char *regex for (i = cfg->files.length; i > 0; --i) { internal = git_vector_get(&cfg->files, i - 1); file = internal->file; - ret = file->get_multivar(file, name, regexp, fn, data); + ret = file->get_multivar(file, name, regexp, cb, payload); if (ret < 0 && ret != GIT_ENOTFOUND) return ret; } @@ -503,7 +503,7 @@ int git_config_get_multivar(git_config *cfg, const char *name, const char *regex int git_config_set_multivar(git_config *cfg, const char *name, const char *regexp, const char *value) { - git_config_file *file; + git_config_backend *file; file_internal *internal; internal = git_vector_get(&cfg->files, 0); @@ -634,7 +634,7 @@ int git_config_open_default(git_config **out) ***********/ int git_config_lookup_map_value( int *out, - git_cvar_map *maps, + const git_cvar_map *maps, size_t map_n, const char *value) { @@ -644,7 +644,7 @@ int git_config_lookup_map_value( goto fail_parse; for (i = 0; i < map_n; ++i) { - git_cvar_map *m = maps + i; + const git_cvar_map *m = maps + i; switch (m->cvar_type) { case GIT_CVAR_FALSE: @@ -790,7 +790,7 @@ static int rename_config_entries_cb( return error; } - return git_config_delete(data->config, entry->name); + return git_config_delete_entry(data->config, entry->name); } int git_config_rename_section( diff --git a/src/config.h b/src/config.h index c7595ee79..ac8da6ff2 100644 --- a/src/config.h +++ b/src/config.h @@ -43,6 +43,6 @@ extern int git_config_rename_section( * @param out the new backend * @param path where the config file is located */ -extern int git_config_file__ondisk(struct git_config_file **out, const char *path); +extern int git_config_file__ondisk(struct git_config_backend **out, const char *path); #endif diff --git a/src/config_file.c b/src/config_file.c index 1209c53df..7cc812aa4 100644 --- a/src/config_file.c +++ b/src/config_file.c @@ -64,7 +64,7 @@ typedef struct cvar_t { (iter) = (tmp)) typedef struct { - git_config_file parent; + git_config_backend parent; git_strmap *values; @@ -149,7 +149,7 @@ static void free_vars(git_strmap *values) git_strmap_free(values); } -static int config_open(git_config_file *cfg, unsigned int level) +static int config_open(git_config_backend *cfg, unsigned int level) { int res; diskfile_backend *b = (diskfile_backend *)cfg; @@ -176,7 +176,7 @@ static int config_open(git_config_file *cfg, unsigned int level) return res; } -static int config_refresh(git_config_file *cfg) +static int config_refresh(git_config_backend *cfg) { int res, updated = 0; diskfile_backend *b = (diskfile_backend *)cfg; @@ -203,7 +203,7 @@ static int config_refresh(git_config_file *cfg) return res; } -static void backend_free(git_config_file *_backend) +static void backend_free(git_config_backend *_backend) { diskfile_backend *backend = (diskfile_backend *)_backend; @@ -216,7 +216,7 @@ static void backend_free(git_config_file *_backend) } static int file_foreach( - git_config_file *backend, + git_config_backend *backend, const char *regexp, int (*fn)(const git_config_entry *, void *), void *data) @@ -262,7 +262,7 @@ cleanup: return result; } -static int config_set(git_config_file *cfg, const char *name, const char *value) +static int config_set(git_config_backend *cfg, const char *name, const char *value) { cvar_t *var = NULL, *old_var; diskfile_backend *b = (diskfile_backend *)cfg; @@ -346,7 +346,7 @@ static int config_set(git_config_file *cfg, const char *name, const char *value) /* * Internal function that actually gets the value in string form */ -static int config_get(git_config_file *cfg, const char *name, const git_config_entry **out) +static int config_get(const git_config_backend *cfg, const char *name, const git_config_entry **out) { diskfile_backend *b = (diskfile_backend *)cfg; char *key; @@ -368,7 +368,7 @@ static int config_get(git_config_file *cfg, const char *name, const git_config_e } static int config_get_multivar( - git_config_file *cfg, + git_config_backend *cfg, const char *name, const char *regex_str, int (*fn)(const git_config_entry *, void *), @@ -431,7 +431,7 @@ static int config_get_multivar( } static int config_set_multivar( - git_config_file *cfg, const char *name, const char *regexp, const char *value) + git_config_backend *cfg, const char *name, const char *regexp, const char *value) { int replaced = 0; cvar_t *var, *newvar; @@ -506,7 +506,7 @@ static int config_set_multivar( return result; } -static int config_delete(git_config_file *cfg, const char *name) +static int config_delete(git_config_backend *cfg, const char *name) { cvar_t *var; diskfile_backend *b = (diskfile_backend *)cfg; @@ -540,7 +540,7 @@ static int config_delete(git_config_file *cfg, const char *name) return result; } -int git_config_file__ondisk(git_config_file **out, const char *path) +int git_config_file__ondisk(git_config_backend **out, const char *path) { diskfile_backend *backend; @@ -562,7 +562,7 @@ int git_config_file__ondisk(git_config_file **out, const char *path) backend->parent.refresh = config_refresh; backend->parent.free = backend_free; - *out = (git_config_file *)backend; + *out = (git_config_backend *)backend; return 0; } diff --git a/src/config_file.h b/src/config_file.h index b500dd64f..a9671b68d 100644 --- a/src/config_file.h +++ b/src/config_file.h @@ -9,36 +9,36 @@ #include "git2/config.h" -GIT_INLINE(int) git_config_file_open(git_config_file *cfg, unsigned int level) +GIT_INLINE(int) git_config_file_open(git_config_backend *cfg, unsigned int level) { return cfg->open(cfg, level); } -GIT_INLINE(void) git_config_file_free(git_config_file *cfg) +GIT_INLINE(void) git_config_file_free(git_config_backend *cfg) { cfg->free(cfg); } GIT_INLINE(int) git_config_file_get_string( - const git_config_entry **out, git_config_file *cfg, const char *name) + const git_config_entry **out, git_config_backend *cfg, const char *name) { return cfg->get(cfg, name, out); } GIT_INLINE(int) git_config_file_set_string( - git_config_file *cfg, const char *name, const char *value) + git_config_backend *cfg, const char *name, const char *value) { return cfg->set(cfg, name, value); } GIT_INLINE(int) git_config_file_delete( - git_config_file *cfg, const char *name) + git_config_backend *cfg, const char *name) { return cfg->del(cfg, name); } GIT_INLINE(int) git_config_file_foreach( - git_config_file *cfg, + git_config_backend *cfg, int (*fn)(const git_config_entry *entry, void *data), void *data) { @@ -46,7 +46,7 @@ GIT_INLINE(int) git_config_file_foreach( } GIT_INLINE(int) git_config_file_foreach_match( - git_config_file *cfg, + git_config_backend *cfg, const char *regexp, int (*fn)(const git_config_entry *entry, void *data), void *data) diff --git a/src/remote.c b/src/remote.c index 063e5186a..5035588a3 100644 --- a/src/remote.c +++ b/src/remote.c @@ -303,7 +303,7 @@ int git_remote_save(const git_remote *remote) return -1; } } else { - int error = git_config_delete(config, git_buf_cstr(&buf)); + int error = git_config_delete_entry(config, git_buf_cstr(&buf)); if (error == GIT_ENOTFOUND) { error = 0; giterr_clear(); @@ -356,7 +356,7 @@ int git_remote_save(const git_remote *remote) if (git_config_set_string(config, git_buf_cstr(&buf), "--no-tags") < 0) goto on_error; } else if (tagopt) { - if (git_config_delete(config, git_buf_cstr(&buf)) < 0) + if (git_config_delete_entry(config, git_buf_cstr(&buf)) < 0) goto on_error; } diff --git a/src/repository.c b/src/repository.c index 1642f4570..efbb3a348 100644 --- a/src/repository.c +++ b/src/repository.c @@ -824,7 +824,7 @@ static int repo_init_config( SET_REPO_CONFIG(string, "core.worktree", work_dir); } else if ((opts->flags & GIT_REPOSITORY_INIT__IS_REINIT) != 0) { - if (git_config_delete(config, "core.worktree") < 0) + if (git_config_delete_entry(config, "core.worktree") < 0) giterr_clear(); } } else { @@ -1356,7 +1356,7 @@ int git_repository_set_workdir( /* passthrough error means gitlink is unnecessary */ if (error == GIT_PASSTHROUGH) - error = git_config_delete(config, "core.worktree"); + error = git_config_delete_entry(config, "core.worktree"); else if (!error) error = git_config_set_string(config, "core.worktree", path.ptr); diff --git a/src/submodule.c b/src/submodule.c index 6093ff960..994ce316a 100644 --- a/src/submodule.c +++ b/src/submodule.c @@ -66,7 +66,7 @@ __KHASH_IMPL( str_hash_no_trailing_slash, str_equal_no_trailing_slash); static int load_submodule_config(git_repository *repo, bool force); -static git_config_file *open_gitmodules(git_repository *, bool, const git_oid *); +static git_config_backend *open_gitmodules(git_repository *, bool, const git_oid *); static int lookup_head_remote(git_buf *url, git_repository *repo); static int submodule_get(git_submodule **, git_repository *, const char *, const char *); static void submodule_release(git_submodule *sm, int decr); @@ -201,7 +201,7 @@ int git_submodule_add_setup( int use_gitlink) { int error = 0; - git_config_file *mods = NULL; + git_config_backend *mods = NULL; git_submodule *sm; git_buf name = GIT_BUF_INIT, real_url = GIT_BUF_INIT; git_repository_init_options initopt; @@ -412,7 +412,7 @@ cleanup: int git_submodule_save(git_submodule *submodule) { int error = 0; - git_config_file *mods; + git_config_backend *mods; git_buf key = GIT_BUF_INIT; assert(submodule); @@ -717,7 +717,7 @@ int git_submodule_reload(git_submodule *submodule) git_index *index; int pos, error; git_tree *head; - git_config_file *mods; + git_config_backend *mods; assert(submodule); @@ -1187,14 +1187,14 @@ static int load_submodule_config_from_head( return error; } -static git_config_file *open_gitmodules( +static git_config_backend *open_gitmodules( git_repository *repo, bool okay_to_create, const git_oid *gitmodules_oid) { const char *workdir = git_repository_workdir(repo); git_buf path = GIT_BUF_INIT; - git_config_file *mods = NULL; + git_config_backend *mods = NULL; if (workdir != NULL) { if (git_buf_joinpath(&path, workdir, GIT_MODULES_FILE) != 0) @@ -1230,7 +1230,7 @@ static int load_submodule_config(git_repository *repo, bool force) int error; git_oid gitmodules_oid; git_buf path = GIT_BUF_INIT; - git_config_file *mods = NULL; + git_config_backend *mods = NULL; if (repo->submodules && !force) return 0; @@ -1378,7 +1378,7 @@ static int submodule_update_config( goto cleanup; if (!value) - error = git_config_delete(config, key.ptr); + error = git_config_delete_entry(config, key.ptr); else error = git_config_set_string(config, key.ptr, value); diff --git a/src/vector.h b/src/vector.h index 6d820b8fc..46129f17b 100644 --- a/src/vector.h +++ b/src/vector.h @@ -55,7 +55,7 @@ GIT_INLINE(int) git_vector_bsearch2( return git_vector_bsearch3(NULL, v, cmp, key); } -GIT_INLINE(void *) git_vector_get(git_vector *v, size_t position) +GIT_INLINE(void *) git_vector_get(const git_vector *v, size_t position) { return (position < v->length) ? v->contents[position] : NULL; } diff --git a/src/win32/posix_w32.c b/src/win32/posix_w32.c index 0efcaf597..e301290dc 100644 --- a/src/win32/posix_w32.c +++ b/src/win32/posix_w32.c @@ -537,7 +537,7 @@ int p_inet_pton(int af, const char* src, void* dst) return -1; } - if (WSAStringToAddress(src, af, NULL, (struct sockaddr *) &sa, &srcsize) != 0) + if (WSAStringToAddress((LPSTR)src, af, NULL, (struct sockaddr *) &sa, &srcsize) != 0) { errno = WSAGetLastError(); return -1; |
