Add git-config-set, a simple helper for scripts to set config variables
[git/git.git] / config-set.c
CommitLineData
1b1e59c5
JS
1#include "cache.h"
2
3static const char git_config_set_usage[] =
4"git-config-set name [value [value_regex]] | --unset name [value_regex]";
5
6int main(int argc, const char **argv)
7{
8 setup_git_directory();
9 switch (argc) {
10 case 2:
11 return git_config_set(argv[1], NULL);
12 case 3:
13 if (!strcmp(argv[1], "--unset"))
14 return git_config_set(argv[2], NULL);
15 else
16 return git_config_set(argv[1], argv[2]);
17 case 4:
18 if (!strcmp(argv[1], "--unset"))
19 return git_config_set_multivar(argv[2], NULL, argv[3]);
20 else
21 return git_config_set_multivar(argv[1], argv[2], argv[3]);
22 default:
23 usage(git_config_set_usage);
24 }
25 return 0;
26}