Skip to content

Commit 4574f1a

Browse files
peffgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 6358320 commit 4574f1a

File tree

4 files changed

+14
-8
lines changed

4 files changed

+14
-8
lines changed

config.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1569,8 +1569,10 @@ int git_config_from_file(config_fn_t fn, const char *filename, void *data)
15691569
return git_config_from_file_with_options(fn, filename, data, NULL);
15701570
}
15711571

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)
15741576
{
15751577
struct config_source top;
15761578

@@ -1585,7 +1587,7 @@ int git_config_from_mem(config_fn_t fn, const enum config_origin_type origin_typ
15851587
top.do_ungetc = config_buf_ungetc;
15861588
top.do_ftell = config_buf_ftell;
15871589

1588-
return do_config_from(&top, fn, data, NULL);
1590+
return do_config_from(&top, fn, data, opts);
15891591
}
15901592

15911593
int git_config_from_blob_oid(config_fn_t fn,
@@ -1606,7 +1608,8 @@ int git_config_from_blob_oid(config_fn_t fn,
16061608
return error("reference '%s' does not point to a blob", name);
16071609
}
16081610

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);
16101613
free(buf);
16111614

16121615
return ret;

config.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,11 @@ extern int git_config_from_file(config_fn_t fn, const char *, void *);
6868
extern int git_config_from_file_with_options(config_fn_t fn, const char *,
6969
void *,
7070
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);
7376
extern int git_config_from_blob_oid(config_fn_t fn, const char *name,
7477
const struct object_id *oid, void *data);
7578
extern void git_config_push_parameter(const char *text);

fsck.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1012,7 +1012,7 @@ static int fsck_blob(struct blob *blob, const char *buf,
10121012
data.options = options;
10131013
data.ret = 0;
10141014
if (git_config_from_mem(fsck_gitmodules_fn, CONFIG_ORIGIN_BLOB,
1015-
".gitmodules", buf, size, &data))
1015+
".gitmodules", buf, size, &data, NULL))
10161016
data.ret |= report(options, &blob->object,
10171017
FSCK_MSG_GITMODULES_PARSE,
10181018
"could not parse gitmodules blob");

submodule-config.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -561,7 +561,7 @@ static const struct submodule *config_from(struct submodule_cache *cache,
561561
parameter.gitmodules_oid = &oid;
562562
parameter.overwrite = 0;
563563
git_config_from_mem(parse_config, CONFIG_ORIGIN_SUBMODULE_BLOB, rev.buf,
564-
config, config_size, &parameter);
564+
config, config_size, &parameter, NULL);
565565
strbuf_release(&rev);
566566
free(config);
567567

0 commit comments

Comments
 (0)