* Add git-config-set, a simple helper for scripts to set config variables
@ 2005-11-17 21:44 Johannes Schindelin
2005-11-17 22:57 ` Junio C Hamano
0 siblings, 1 reply; 3+ messages in thread
From: Johannes Schindelin @ 2005-11-17 21:44 UTC (permalink / raw)
To: git, junkio
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>
---
.gitignore | 1 +
Makefile | 3 ++-
config-set.c | 26 ++++++++++++++++++++++++++
3 files changed, 29 insertions(+), 1 deletions(-)
create mode 100644 config-set.c
applies-to: 8ff699dffc817e92fb2101f538f84c38d5ed0a0f
acf7869a158171bf4552d0b0da64b20d48e4bf27
diff --git a/.gitignore b/.gitignore
index 0dd7b9c..d17a8b5 100644
--- a/.gitignore
+++ b/.gitignore
@@ -17,6 +17,7 @@ git-clone
git-clone-pack
git-commit
git-commit-tree
+git-config-set
git-convert-objects
git-count-objects
git-cvsexportcommit
diff --git a/Makefile b/Makefile
index ebff990..8e84e28 100644
--- a/Makefile
+++ b/Makefile
@@ -125,7 +125,8 @@ PROGRAMS = \
git-unpack-objects$X git-update-index$X git-update-server-info$X \
git-upload-pack$X git-verify-pack$X git-write-tree$X \
git-update-ref$X git-symbolic-ref$X git-check-ref-format$X \
- git-name-rev$X git-pack-redundant$X git-var$X $(SIMPLE_PROGRAMS)
+ git-name-rev$X git-pack-redundant$X git-config-set$X git-var$X \
+ $(SIMPLE_PROGRAMS)
# Backward compatibility -- to be removed after 1.0
PROGRAMS += git-ssh-pull$X git-ssh-push$X
diff --git a/config-set.c b/config-set.c
new file mode 100644
index 0000000..1b1547b
--- /dev/null
+++ b/config-set.c
@@ -0,0 +1,26 @@
+#include "cache.h"
+
+static const char git_config_set_usage[] =
+"git-config-set name [value [value_regex]] | --unset name [value_regex]";
+
+int main(int argc, const char **argv)
+{
+ setup_git_directory();
+ switch (argc) {
+ case 2:
+ return git_config_set(argv[1], NULL);
+ case 3:
+ if (!strcmp(argv[1], "--unset"))
+ return git_config_set(argv[2], NULL);
+ else
+ return git_config_set(argv[1], argv[2]);
+ case 4:
+ if (!strcmp(argv[1], "--unset"))
+ return git_config_set_multivar(argv[2], NULL, argv[3]);
+ else
+ return git_config_set_multivar(argv[1], argv[2], argv[3]);
+ default:
+ usage(git_config_set_usage);
+ }
+ return 0;
+}
---
0.99.9.GIT
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: Add git-config-set, a simple helper for scripts to set config variables
2005-11-17 21:44 Add git-config-set, a simple helper for scripts to set config variables Johannes Schindelin
@ 2005-11-17 22:57 ` Junio C Hamano
2005-11-17 23:24 ` Johannes Schindelin
0 siblings, 1 reply; 3+ messages in thread
From: Junio C Hamano @ 2005-11-17 22:57 UTC (permalink / raw)
To: Johannes Schindelin; +Cc: git
Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
> 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's kinda funny that your users cannot edit a plain text file
with an editor, but know how to do regex ;-).
I think the true value of this is that Porcelain scripts can
muck with configuration files.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Add git-config-set, a simple helper for scripts to set config variables
2005-11-17 22:57 ` Junio C Hamano
@ 2005-11-17 23:24 ` Johannes Schindelin
0 siblings, 0 replies; 3+ messages in thread
From: Johannes Schindelin @ 2005-11-17 23:24 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git
Hi,
On Thu, 17 Nov 2005, Junio C Hamano wrote:
> It's kinda funny that your users cannot edit a plain text file
> with an editor, but know how to do regex ;-).
No, they can't. But they deem it a cool feature... FDM...
Ciao,
Dscho
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2005-11-17 23:25 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-11-17 21:44 Add git-config-set, a simple helper for scripts to set config variables Johannes Schindelin
2005-11-17 22:57 ` Junio C Hamano
2005-11-17 23:24 ` Johannes Schindelin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).