diff options
author | Edward Thomson <ethomson@microsoft.com> | 2013-07-11 17:09:15 -0500 |
---|---|---|
committer | Edward Thomson <ethomson@microsoft.com> | 2013-07-11 17:17:53 -0500 |
commit | 0a1c8f55b35ebd35a7d267099257634483268ffd (patch) | |
tree | 35f35ddc8347354c0a8ffa526b38b824da07b1dc | |
parent | f2de67d589e4fde3378f531c782cbe176cb65f36 (diff) | |
download | libgit2-0a1c8f55b35ebd35a7d267099257634483268ffd.tar.gz |
preload configuration paths
-rw-r--r-- | src/fileops.c | 14 | ||||
-rw-r--r-- | src/fileops.h | 7 | ||||
-rw-r--r-- | src/global.c | 9 |
3 files changed, 25 insertions, 5 deletions
diff --git a/src/fileops.c b/src/fileops.c index 1f58fa5cd..db53d4fce 100644 --- a/src/fileops.c +++ b/src/fileops.c @@ -627,6 +627,20 @@ static git_futils_dirs_guess_cb git_futils__dir_guess[GIT_FUTILS_DIR__MAX] = { git_futils_guess_xdg_dirs, }; +int git_futils_dirs_global_init(void) +{ + git_futils_dir_t i; + git_buf *path; + int error = 0; + + for (i = 0; i < GIT_FUTILS_DIR__MAX; i++) { + if ((error = git_futils_dirs_get(&path, i)) < 0) + break; + } + + return error; +} + static int git_futils_check_selector(git_futils_dir_t which) { if (which < GIT_FUTILS_DIR__MAX) diff --git a/src/fileops.h b/src/fileops.h index f4e059c83..d23ebaffb 100644 --- a/src/fileops.h +++ b/src/fileops.h @@ -310,6 +310,13 @@ typedef enum { } git_futils_dir_t; /** + * Configures global data for configuration file search paths. + * + * @return 0 on success, <0 on failure + */ +extern int git_futils_dirs_global_init(void); + +/** * Get the search path for global/system/xdg files * * @param out pointer to git_buf containing search path diff --git a/src/global.c b/src/global.c index 2d40ca2fc..a06d0c81f 100644 --- a/src/global.c +++ b/src/global.c @@ -65,10 +65,8 @@ int git_threads_init(void) return -1; /* Initialize any other subsystems that have global state */ - if ((error = git_hash_global_init()) >= 0) - _tls_init = 1; - - if (error == 0) + if ((error = git_hash_global_init()) >= 0 && + (error = git_futils_dirs_global_init()) >= 0) _tls_init = 1; GIT_MEMORY_BARRIER; @@ -127,7 +125,8 @@ int git_threads_init(void) pthread_key_create(&_tls_key, &cb__free_status); /* Initialize any other subsystems that have global state */ - if ((error = git_hash_global_init()) >= 0) + if ((error = git_hash_global_init()) >= 0 && + (error = git_futils_dirs_global_init()) >= 0) _tls_init = 1; GIT_MEMORY_BARRIER; |