forked from gitster/git
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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>
- Loading branch information
Showing
3 changed files
with
29 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} |