@@ -1595,7 +1595,7 @@ static int git_default_core_config(const char *var, const char *value,
return git_config_string(&askpass_program, var, value);
if (!strcmp(var, "core.excludesfile"))
- return git_config_pathname(&excludes_file, var, value);
+ return git_config_strbuf_pathname(&excludes_file, var, value);
if (!strcmp(var, "core.whitespace")) {
if (!value)
@@ -3386,10 +3386,15 @@ void setup_standard_excludes(struct dir_struct *dir)
dir->exclude_per_dir = ".gitignore";
/* core.excludesfile defaulting to $XDG_CONFIG_HOME/git/ignore */
- if (!excludes_file)
- excludes_file = xdg_config_home("ignore");
- if (excludes_file && !access_or_warn(excludes_file, R_OK, 0))
- add_patterns_from_file_1(dir, excludes_file,
+ if (!excludes_file.len) {
+ char *str = xdg_config_home("ignore");
+ if (str) {
+ strbuf_addstr(&excludes_file, str);
+ free(str);
+ }
+ }
+ if (excludes_file.len && !access_or_warn(excludes_file.buf, R_OK, 0))
+ add_patterns_from_file_1(dir, excludes_file.buf,
dir->untracked ? &dir->internal.ss_excludes_file : NULL);
/* per repository user preference */
@@ -60,7 +60,7 @@ size_t delta_base_cache_limit = 96 * 1024 * 1024;
unsigned long big_file_threshold = 512 * 1024 * 1024;
const char *editor_program;
const char *askpass_program;
-const char *excludes_file;
+struct strbuf excludes_file = STRBUF_INIT;
enum auto_crlf auto_crlf = AUTO_CRLF_FALSE;
enum eol core_eol = EOL_UNSET;
int global_conv_flags_eol = CONV_EOL_RNDTRP_WARN;
@@ -222,7 +222,7 @@ extern const char *git_log_output_encoding;
extern const char *editor_program;
extern const char *askpass_program;
-extern const char *excludes_file;
+extern struct strbuf excludes_file;
/*
* Should we print an ellipsis after an abbreviated SHA-1 value
Make excludes_file a strbuf, so that we don't have to worry about freeing it if it is set multiple times. Signed-off-by: Rubén Justo <rjusto@gmail.com> --- config.c | 2 +- dir.c | 13 +++++++++---- environment.c | 2 +- environment.h | 2 +- 4 files changed, 12 insertions(+), 7 deletions(-)