summaryrefslogtreecommitdiff
path: root/config.c
diff options
context:
space:
mode:
Diffstat (limited to 'config.c')
-rw-r--r--config.c23
1 files changed, 21 insertions, 2 deletions
diff --git a/config.c b/config.c
index e54d99d..34a139c 100644
--- a/config.c
+++ b/config.c
@@ -214,6 +214,7 @@ static int include_by_gitdir(const struct config_options *opts,
struct strbuf pattern = STRBUF_INIT;
int ret = 0, prefix;
const char *git_dir;
+ int already_tried_absolute = 0;
if (opts->git_dir)
git_dir = opts->git_dir;
@@ -226,6 +227,7 @@ static int include_by_gitdir(const struct config_options *opts,
strbuf_add(&pattern, cond, cond_len);
prefix = prepare_include_condition_pattern(&pattern);
+again:
if (prefix < 0)
goto done;
@@ -245,6 +247,20 @@ static int include_by_gitdir(const struct config_options *opts,
ret = !wildmatch(pattern.buf + prefix, text.buf + prefix,
icase ? WM_CASEFOLD : 0, NULL);
+ if (!ret && !already_tried_absolute) {
+ /*
+ * We've tried e.g. matching gitdir:~/work, but if
+ * ~/work is a symlink to /mnt/storage/work
+ * strbuf_realpath() will expand it, so the rule won't
+ * match. Let's match against a
+ * strbuf_add_absolute_path() version of the path,
+ * which'll do the right thing
+ */
+ strbuf_reset(&text);
+ strbuf_add_absolute_path(&text, git_dir);
+ already_tried_absolute = 1;
+ goto again;
+ }
done:
strbuf_release(&pattern);
strbuf_release(&text);
@@ -1965,7 +1981,7 @@ int git_config_get_expiry(const char *key, const char **output)
if (ret)
return ret;
if (strcmp(*output, "now")) {
- unsigned long now = approxidate("now");
+ timestamp_t now = approxidate("now");
if (approxidate(*output) >= now)
git_die_config(key, _("Invalid %s: '%s'"), key, *output);
}
@@ -2621,7 +2637,7 @@ int git_config_rename_section_in_file(const char *config_filename,
struct lock_file *lock;
int out_fd;
char buf[1024];
- FILE *config_file;
+ FILE *config_file = NULL;
struct stat st;
if (new_name && !section_name_is_ok(new_name)) {
@@ -2706,11 +2722,14 @@ int git_config_rename_section_in_file(const char *config_filename,
}
}
fclose(config_file);
+ config_file = NULL;
commit_and_out:
if (commit_lock_file(lock) < 0)
ret = error_errno("could not write config file %s",
config_filename);
out:
+ if (config_file)
+ fclose(config_file);
rollback_lock_file(lock);
out_no_rollback:
free(filename_buf);