diff options
| author | Junio C Hamano <gitster@pobox.com> | 2023-04-06 13:38:29 -0700 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2023-04-06 13:38:29 -0700 |
| commit | 06e9e726d463b413d45703b31881de4ed99b3417 (patch) | |
| tree | a1cad3c86f333a19f1b4d4fc9123236ad122a1ef /t/helper | |
| parent | Merge branch 'sm/ssl-key-type-config' (diff) | |
| parent | config.c: rename "struct config_source cf" (diff) | |
| download | git-06e9e726d463b413d45703b31881de4ed99b3417.tar.gz git-06e9e726d463b413d45703b31881de4ed99b3417.zip | |
Merge branch 'gc/config-parsing-cleanup'
Config API clean-up to reduce its dependence on static variables
* gc/config-parsing-cleanup:
config.c: rename "struct config_source cf"
config: report cached filenames in die_bad_number()
config.c: remove current_parsing_scope
config.c: remove current_config_kvi
config.c: plumb the_reader through callbacks
config.c: create config_reader and the_reader
config.c: don't assign to "cf_global" directly
config.c: plumb config_source through static fns
Diffstat (limited to 't/helper')
| -rw-r--r-- | t/helper/test-config.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/t/helper/test-config.c b/t/helper/test-config.c index 6dc4c37444..c7d43afa64 100644 --- a/t/helper/test-config.c +++ b/t/helper/test-config.c @@ -32,6 +32,9 @@ * iterate -> iterate over all values using git_config(), and print some * data for each * + * git_config_int -> iterate over all values using git_config() and print the + * integer value for the entered key or die + * * Examples: * * To print the value with highest priority for key "foo.bAr Baz.rock": @@ -56,6 +59,17 @@ static int iterate_cb(const char *var, const char *value, void *data UNUSED) return 0; } +static int parse_int_cb(const char *var, const char *value, void *data) +{ + const char *key_to_match = data; + + if (!strcmp(key_to_match, var)) { + int parsed = git_config_int(value, value); + printf("%d\n", parsed); + } + return 0; +} + static int early_config_cb(const char *var, const char *value, void *vdata) { const char *key = vdata; @@ -196,6 +210,9 @@ int cmd__config(int argc, const char **argv) } else if (!strcmp(argv[1], "iterate")) { git_config(iterate_cb, NULL); goto exit0; + } else if (argc == 3 && !strcmp(argv[1], "git_config_int")) { + git_config(parse_int_cb, (void *) argv[2]); + goto exit0; } die("%s: Please check the syntax and the function name", argv[0]); |
