Add git-config-set, a simple helper for scripts to set config variables
This is meant for the end user, who cannot be expected to edit .git/config by hand. Example: git-config-set core.filemode true will set filemode in the section [core] to true, git-config-set --unset core.filemode will remove the entry (failing if it is not there), and git-config-set --unset diff.twohead ^recar will remove the unique entry whose value matches the regex "^recar" (failing if there is no unique such entry). It is just a light wrapper around git_config_set() and git_config_set_multivar(). Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <junkio@cox.net>
Johannes Schindelin committed
Nov 17, 2005 at 22:44 UTC
1b1e59c5084ac8b0af0aa443bb1713179d400211
3 files changed
+29
-1
.gitignore
+1
@@ -17,6 +17,7 @@ git-clone
17
git-clone-pack
18
git-commit
19
git-commit-tree
20
+git-config-set
21
git-convert-objects
22
git-count-objects
23
git-cvsexportcommit
Makefile
+2
-1
@@ -125,7 +125,8 @@ PROGRAMS = \
125
git-unpack-objects$X git-update-index$X git-update-server-info$X \
126
git-upload-pack$X git-verify-pack$X git-write-tree$X \
127
git-update-ref$X git-symbolic-ref$X git-check-ref-format$X \
128
- git-name-rev$X git-pack-redundant$X git-var$X $(SIMPLE_PROGRAMS)
128
+ git-name-rev$X git-pack-redundant$X git-config-set$X git-var$X \
129
+ $(SIMPLE_PROGRAMS)
130
131
# Backward compatibility -- to be removed after 1.0
132
PROGRAMS += git-ssh-pull$X git-ssh-push$X
config-set.c
new
+26
@@ -0,0 +1,26 @@
1
+#include "cache.h"
2
+
3
+static const char git_config_set_usage[] =
4
+"git-config-set name [value [value_regex]] | --unset name [value_regex]";
5
+
6
+int 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
+}