From ca1b6e54095a7e28d468a832f143025feae6cd4f Mon Sep 17 00:00:00 2001 From: Russell Belfer Date: Tue, 31 Jul 2012 17:02:54 -0700 Subject: Add template dir and set gid to repo init This extends git_repository_init_ext further with support for initializing the repository from an external template directory and with support for the "create shared" type flags that make a set GID repository directory. This also adds tests for much of the new functionality to the existing `repo/init.c` test suite. Also, this adds a bunch of new utility functions including a very general purpose `git_futils_mkdir` (with the ability to make paths and to chmod the paths post-creation) and a file tree copying function `git_futils_cp_r`. Also, this includes some new path functions that were useful to keep the code simple. --- src/config.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'src/config.c') diff --git a/src/config.c b/src/config.c index 44cfe760c..3ca49714c 100644 --- a/src/config.c +++ b/src/config.c @@ -515,3 +515,28 @@ int git_config_open_global(git_config **out) return error; } +int git_config_open_outside_repo(git_config **out) +{ + int error; + git_config *cfg = NULL; + git_buf buf = GIT_BUF_INIT; + + error = git_config_new(&cfg); + + if (!error && !git_config_find_global_r(&buf)) + error = git_config_add_file_ondisk(cfg, buf.ptr, 2); + + if (!error && !git_config_find_system_r(&buf)) + error = git_config_add_file_ondisk(cfg, buf.ptr, 1); + + git_buf_free(&buf); + + if (error && cfg) { + git_config_free(cfg); + cfg = NULL; + } + + *out = cfg; + + return error; +} -- cgit v1.2.1 From 85bd17462662905dfdf9247b262480280a616ad4 Mon Sep 17 00:00:00 2001 From: Russell Belfer Date: Wed, 22 Aug 2012 16:03:35 -0700 Subject: Some cleanup suggested during review This cleans up a number of items suggested during code review with @vmg, including: * renaming "outside repo" config API to `git_config_open_default` * killing the `git_config_open_global` API * removing the `git_` prefix from the static functions in fileops * removing some unnecessary functionality from the "cp" command --- src/config.c | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) (limited to 'src/config.c') diff --git a/src/config.c b/src/config.c index 3ca49714c..277daaafe 100644 --- a/src/config.c +++ b/src/config.c @@ -501,21 +501,7 @@ int git_config_find_system(char *system_config_path, size_t length) return 0; } -int git_config_open_global(git_config **out) -{ - int error; - git_buf path = GIT_BUF_INIT; - - if ((error = git_config_find_global_r(&path)) < 0) - return error; - - error = git_config_open_ondisk(out, git_buf_cstr(&path)); - git_buf_free(&path); - - return error; -} - -int git_config_open_outside_repo(git_config **out) +int git_config_open_default(git_config **out) { int error; git_config *cfg = NULL; -- cgit v1.2.1