config: add options parameter to git_config_from_mem
The underlying config parser knows how to handle a config_options struct, but git_config_from_mem() always passes NULL. Let's allow our callers to specify the options struct. We could add a "_with_options" variant, but since there are only a handful of callers, let's just update them to pass NULL. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Jeff King committed
Jun 28, 2018 at 18:05 UTC
4574f1aace4ca53ac0fc63a545383dab1a71fec9
4 files changed
+14
-8
config.c
+7
-4
@@ -1569,8 +1569,10 @@ int git_config_from_file(config_fn_t fn, const char *filename, void *data)
1569
return git_config_from_file_with_options(fn, filename, data, NULL);
1570
}
1571
1572
-int git_config_from_mem(config_fn_t fn, const enum config_origin_type origin_type,
1573
- const char *name, const char *buf, size_t len, void *data)
1572
+int git_config_from_mem(config_fn_t fn,
1573
+ const enum config_origin_type origin_type,
1574
+ const char *name, const char *buf, size_t len,
1575
+ void *data, const struct config_options *opts)
1576
{
1577
struct config_source top;
1578
@@ -1585,7 +1587,7 @@ int git_config_from_mem(config_fn_t fn, const enum config_origin_type origin_typ
1587
top.do_ungetc = config_buf_ungetc;
1588
top.do_ftell = config_buf_ftell;
1589
1588
- return do_config_from(&top, fn, data, NULL);
1590
+ return do_config_from(&top, fn, data, opts);
1591
}
1592
1593
int git_config_from_blob_oid(config_fn_t fn,
@@ -1606,7 +1608,8 @@ int git_config_from_blob_oid(config_fn_t fn,
1608
return error("reference '%s' does not point to a blob", name);
1609
}
1610
1609
- ret = git_config_from_mem(fn, CONFIG_ORIGIN_BLOB, name, buf, size, data);
1611
+ ret = git_config_from_mem(fn, CONFIG_ORIGIN_BLOB, name, buf, size,
1612
+ data, NULL);
1613
free(buf);
1614
1615
return ret;
config.h
+5
-2
@@ -68,8 +68,11 @@ extern int git_config_from_file(config_fn_t fn, const char *, void *);
68
extern int git_config_from_file_with_options(config_fn_t fn, const char *,
69
void *,
70
const struct config_options *);
71
-extern int git_config_from_mem(config_fn_t fn, const enum config_origin_type,
72
- const char *name, const char *buf, size_t len, void *data);
71
+extern int git_config_from_mem(config_fn_t fn,
72
+ const enum config_origin_type,
73
+ const char *name,
74
+ const char *buf, size_t len,
75
+ void *data, const struct config_options *opts);
76
extern int git_config_from_blob_oid(config_fn_t fn, const char *name,
77
const struct object_id *oid, void *data);
78
extern void git_config_push_parameter(const char *text);
fsck.c
+1
-1
@@ -1012,7 +1012,7 @@ static int fsck_blob(struct blob *blob, const char *buf,
1012
data.options = options;
1013
data.ret = 0;
1014
if (git_config_from_mem(fsck_gitmodules_fn, CONFIG_ORIGIN_BLOB,
1015
- ".gitmodules", buf, size, &data))
1015
+ ".gitmodules", buf, size, &data, NULL))
1016
data.ret |= report(options, &blob->object,
1017
FSCK_MSG_GITMODULES_PARSE,
1018
"could not parse gitmodules blob");
submodule-config.c
+1
-1
@@ -561,7 +561,7 @@ static const struct submodule *config_from(struct submodule_cache *cache,
561
parameter.gitmodules_oid = &oid;
562
parameter.overwrite = 0;
563
git_config_from_mem(parse_config, CONFIG_ORIGIN_SUBMODULE_BLOB, rev.buf,
564
- config, config_size, ¶meter);
564
+ config, config_size, ¶meter, NULL);
565
strbuf_release(&rev);
566
free(config);
567