aboutsummaryrefslogtreecommitdiff
path: root/t/helper
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2016-07-06 13:38:11 -0700
committerJunio C Hamano <gitster@pobox.com>2016-07-06 13:38:11 -0700
commit1e4bf907890e094f1c1c8c5086387e7d5fdb0655 (patch)
tree50bf586083db40ec2dc4213110381f73e6d6c9dd /t/helper
parent7a738b40f67fc44c2a2c1abcffe474241af3d30e (diff)
parent20b20a22f8f7c1420e259c97ef790cb93091f475 (diff)
downloadgit-1e4bf907890e094f1c1c8c5086387e7d5fdb0655.tar.gz
git-1e4bf907890e094f1c1c8c5086387e7d5fdb0655.tar.xz
Merge branch 'jk/upload-pack-hook'
"upload-pack" allows a custom "git pack-objects" replacement when responding to "fetch/clone" via the uploadpack.packObjectsHook. * jk/upload-pack-hook: upload-pack: provide a hook for running pack-objects t1308: do not get fooled by symbolic links to the source tree config: add a notion of "scope" config: return configset value for current_config_ functions config: set up config_source for command-line config git_config_parse_parameter: refactor cleanup code git_config_with_options: drop "found" counting
Diffstat (limited to 't/helper')
-rw-r--r--t/helper/test-config.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/t/helper/test-config.c b/t/helper/test-config.c
index 6a7755221..509aeef40 100644
--- a/t/helper/test-config.c
+++ b/t/helper/test-config.c
@@ -25,6 +25,9 @@
* ascending order of priority from a config_set
* constructed from files entered as arguments.
*
+ * iterate -> iterate over all values using git_config(), and print some
+ * data for each
+ *
* Examples:
*
* To print the value with highest priority for key "foo.bAr Baz.rock":
@@ -32,6 +35,36 @@
*
*/
+static const char *scope_name(enum config_scope scope)
+{
+ switch (scope) {
+ case CONFIG_SCOPE_SYSTEM:
+ return "system";
+ case CONFIG_SCOPE_GLOBAL:
+ return "global";
+ case CONFIG_SCOPE_REPO:
+ return "repo";
+ case CONFIG_SCOPE_CMDLINE:
+ return "cmdline";
+ default:
+ return "unknown";
+ }
+}
+static int iterate_cb(const char *var, const char *value, void *data)
+{
+ static int nr;
+
+ if (nr++)
+ putchar('\n');
+
+ printf("key=%s\n", var);
+ printf("value=%s\n", value ? value : "(null)");
+ printf("origin=%s\n", current_config_origin_type());
+ printf("name=%s\n", current_config_name());
+ printf("scope=%s\n", scope_name(current_config_scope()));
+
+ return 0;
+}
int main(int argc, char **argv)
{
@@ -134,6 +167,9 @@ int main(int argc, char **argv)
printf("Value not found for \"%s\"\n", argv[2]);
goto exit1;
}
+ } else if (!strcmp(argv[1], "iterate")) {
+ git_config(iterate_cb, NULL);
+ goto exit0;
}
die("%s: Please check the syntax and the function name", argv[0]);