config: add `git_die_config()` to the config-set API
[gitweb.git] / setup.c
diff --git a/setup.c b/setup.c
index 613e3b3c13b3f09bce07c54dc440d03c0b5beb0c..793369da36fa92bddc63c12e722d44bba99dab17 100644 (file)
--- a/setup.c
+++ b/setup.c
@@ -29,7 +29,7 @@ static int abspath_part_inside_repo(char *path)
                return -1;
        wtlen = strlen(work_tree);
        len = strlen(path);
-       off = 0;
+       off = offset_1st_component(path);
 
        /* check if work tree is already the prefix */
        if (wtlen <= len && !strncmp(path, work_tree, wtlen)) {
@@ -45,7 +45,7 @@ static int abspath_part_inside_repo(char *path)
                off = wtlen;
        }
        path0 = path;
-       path += offset_1st_component(path) + off;
+       path += off;
 
        /* check each '/'-terminated level */
        while (*path) {
@@ -624,6 +624,15 @@ static const char *setup_git_directory_gently_1(int *nongit_ok)
        dev_t current_device = 0;
        int one_filesystem = 1;
 
+       /*
+        * We may have read an incomplete configuration before
+        * setting-up the git directory. If so, clear the cache so
+        * that the next queries to the configuration reload complete
+        * configuration (including the per-repo config file that we
+        * ignored previously).
+        */
+       git_config_clear();
+
        /*
         * Let's assume that we are in a git repository.
         * If it turns out later that we are somewhere else, the value will be