Store file name and line number for each key-value pair in the cache
during parsing of the configuration files.

Signed-off-by: Tanay Abhra <tanay...@gmail.com>
---
 config.c | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/config.c b/config.c
index 06257d9..110f9a5 100644
--- a/config.c
+++ b/config.c
@@ -1232,6 +1232,11 @@ int git_config_with_options(config_fn_t fn, void *data,
        return ret;
 }
 
+struct key_value_info {
+       const char *filename;
+       int linenr;
+};
+
 int git_config(config_fn_t fn, void *data)
 {
        return git_config_with_options(fn, data, NULL, 1);
@@ -1262,6 +1267,9 @@ static struct config_set_element 
*configset_find_element(struct config_set *cs,
 static int configset_add_value(struct config_set *cs, const char *key, const 
char *value)
 {
        struct config_set_element *e;
+       struct string_list_item *si;
+       struct key_value_info *kv_info = xmalloc(sizeof(*kv_info));
+
        e = configset_find_element(cs, key);
        /*
         * Since the keys are being fed by git_config*() callback mechanism, 
they
@@ -1274,7 +1282,16 @@ static int configset_add_value(struct config_set *cs, 
const char *key, const cha
                string_list_init(&e->value_list, 1);
                hashmap_add(&cs->config_hash, e);
        }
-       string_list_append_nodup(&e->value_list, value ? xstrdup(value) : NULL);
+       si = string_list_append_nodup(&e->value_list, value ? xstrdup(value) : 
NULL);
+       if (cf) {
+               kv_info->filename = strintern(cf->name);
+               kv_info->linenr = cf->linenr;
+       } else {
+               /* for values read from `git_config_from_parameters()` */
+               kv_info->filename = strintern("parameter");
+               kv_info->linenr = 0;
+       }
+       si->util = kv_info;
 
        return 0;
 }
-- 
1.9.0.GIT

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to