diff options
author | Russell Belfer <rb@github.com> | 2013-03-16 03:39:00 +0400 |
---|---|---|
committer | Russell Belfer <rb@github.com> | 2013-03-16 03:39:00 +0400 |
commit | 5540d9477ed143707435324e785336d254b12e47 (patch) | |
tree | 4ffaba1990a82cc51ee5169d7d2913ecceef4df2 /src/attrcache.h | |
parent | a5f6138407efb6d8866fe8de5aac13454aefcd82 (diff) |
Implement global/system file search paths
The goal of this work is to expose the search logic for "global",
"system", and "xdg" files through the git_libgit2_opts() interface.
Behind the scenes, I changed the logic for finding files to have a
notion of a git_strarray that represents a search path and to store
a separate search path for each of the three tiers of config file.
For each tier, I implemented a function to initialize it to default
values (generally based on environment variables), and then general
interfaces to get it, set it, reset it, and prepend new directories
to it.
Next, I exposed these interfaces through the git_libgit2_opts
interface, reusing the GIT_CONFIG_LEVEL_SYSTEM, etc., constants
for the user to control which search path they were modifying.
There are alternative designs for the opts interface / argument
ordering, so I'm putting this phase out for discussion.
Additionally, I ended up doing a little bit of clean up regarding
attr.h and attr_file.h, adding a new attrcache.h so the other two
files wouldn't have to be included in so many places.
Diffstat (limited to 'src/attrcache.h')
-rw-r--r-- | src/attrcache.h | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/attrcache.h b/src/attrcache.h new file mode 100644 index 000000000..12cec4bfb --- /dev/null +++ b/src/attrcache.h @@ -0,0 +1,24 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_attrcache_h__ +#define INCLUDE_attrcache_h__ + +#include "pool.h" +#include "strmap.h" + +typedef struct { + int initialized; + git_pool pool; + git_strmap *files; /* hash path to git_attr_file of rules */ + git_strmap *macros; /* hash name to vector<git_attr_assignment> */ + const char *cfg_attr_file; /* cached value of core.attributesfile */ + const char *cfg_excl_file; /* cached value of core.excludesfile */ +} git_attr_cache; + +extern int git_attr_cache__init(git_repository *repo); + +#endif |