Andrew's git
/
gitweb.git
/ diff
summary
|
log
|
commit
| diff |
tree
commit
grep
author
committer
pickaxe
?
re
add line number and file name info to `config_set`
author
Tanay Abhra
<tanayabh@gmail.com>
Thu, 7 Aug 2014 11:59:14 +0000
(
04:59
-0700)
committer
Junio C Hamano
<gitster@pobox.com>
Thu, 7 Aug 2014 18:38:50 +0000
(11:38 -0700)
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 <tanayabh@gmail.com>
Reviewed-by: Matthieu Moy <Matthieu.Moy@imag.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
cache.h
patch
|
blob
|
history
config.c
patch
|
blob
|
history
raw
|
patch
|
inline
| side by side (parent:
b3b3f60
)
diff --git
a/cache.h
b/cache.h
index 7292aefa2e3cc4649825364b1b61b38c89f1a4a7..0b1bdfd896dccddcc1cdc167f300f607767da77c 100644
(file)
--- a/
cache.h
+++ b/
cache.h
@@
-1383,6
+1383,11
@@
extern int git_config_get_bool_or_int(const char *key, int *is_bool, int *dest);
extern int git_config_get_maybe_bool(const char *key, int *dest);
extern int git_config_get_pathname(const char *key, const char **dest);
extern int git_config_get_maybe_bool(const char *key, int *dest);
extern int git_config_get_pathname(const char *key, const char **dest);
+struct key_value_info {
+ const char *filename;
+ int linenr;
+};
+
extern int committer_ident_sufficiently_given(void);
extern int author_ident_sufficiently_given(void);
extern int committer_ident_sufficiently_given(void);
extern int author_ident_sufficiently_given(void);
diff --git
a/config.c
b/config.c
index 22fef4050bb5d411ea991f5a84644b9308f2f836..1ac85edce4900d0ac3e5a93f56dfe0555bca22e4 100644
(file)
--- a/
config.c
+++ b/
config.c
@@
-1262,6
+1262,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;
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
e = configset_find_element(cs, key);
/*
* Since the keys are being fed by git_config*() callback mechanism, they
@@
-1274,7
+1277,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_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 = NULL;
+ kv_info->linenr = -1;
+ }
+ si->util = kv_info;
return 0;
}
return 0;
}
@@
-1301,7
+1313,7
@@
void git_configset_clear(struct config_set *cs)
hashmap_iter_init(&cs->config_hash, &iter);
while ((entry = hashmap_iter_next(&iter))) {
free(entry->key);
hashmap_iter_init(&cs->config_hash, &iter);
while ((entry = hashmap_iter_next(&iter))) {
free(entry->key);
- string_list_clear(&entry->value_list,
0
);
+ string_list_clear(&entry->value_list,
1
);
}
hashmap_free(&cs->config_hash, 1);
cs->hash_initialized = 0;
}
hashmap_free(&cs->config_hash, 1);
cs->hash_initialized = 0;