aboutsummaryrefslogtreecommitdiff
path: root/builtin-config.c
Commit message (Collapse)AuthorAge
* Merge branch 'jh/maint-config-file-prefix'Junio C Hamano2010-01-27
|\ | | | | | | | | * jh/maint-config-file-prefix: builtin-config: Fix crash when using "-f <relative path>" from non-root dir
| * builtin-config: Fix crash when using "-f <relative path>" from non-root dirJohan Herland2010-01-26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When your current directory is not at the root of the working tree, and you use the "-f" option with a relative path, the current code tries to read from a wrong file, since argv[2] is now beyond the end of the rearranged argument list. This patch replaces the incorrect argv[2] with the variable holding the given config file name. The bug was introduced by d64ec16 (git config: reorganize to use parseopt). [jc: added test] Signed-off-by: Johan Herland <johan@herland.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | builtin-config: add --path option doing ~ and ~user expansion.Matthieu Moy2009-12-31
| | | | | | | | | | | | | | | | | | | | 395de250 (Expand ~ and ~user in core.excludesfile, commit.template) introduced a C function git_config_pathname, doing ~/ and ~user/ expansion. This patch makes the feature available to scripts with 'git config --get --path'. Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | Convert existing die(..., strerror(errno)) to die_errno()Thomas Rast2009-06-27
| | | | | | | | | | | | | | | | | | | | | | Change calls to die(..., strerror(errno)) to use the new die_errno(). In the process, also make slight style adjustments: at least state _something_ about the function that failed (instead of just printing the pathname), and put paths in single quotes. Signed-off-by: Thomas Rast <trast@student.ethz.ch> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | parse-opts: prepare for OPT_FILENAMEStephen Boyd2009-05-25
|/ | | | | | | | | | To give OPT_FILENAME the prefix, we pass the prefix to parse_options() which passes the prefix to parse_options_start() which sets the prefix member of parse_opts_ctx accordingly. If there isn't a prefix in the calling context, passing NULL will suffice. Signed-off-by: Stephen Boyd <bebarino@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* git config: error when editing a repo config and not being in oneFelipe Contreras2009-04-29
| | | | | | | | | | Let's throw an error on this specific case. If the user specifies the config file, he must know what he is doing. Teemu Likonen pointed this out. Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* config: test for --replace-all with one argument and fix documentation.Carlos Rica2009-03-17
| | | | | | | | | Option --replace-all only allows at least two arguments, so documentation was needing to be updated accordingly. A test showing that the command fails with only one parameter is also provided. Signed-off-by: Carlos Rica <jasampler@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* config: set help text for --bool-or-intJeff King2009-03-07
| | | | | | | | | | | | The conversion to parse_opt left this as NULL; on glibc systems, the usage message prints --bool-or-int (null) and on other ones, segfaults. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* git config: don't allow --get-color* and variable typeFelipe Contreras2009-02-21
| | | | | | | | | | | Doing so would be incoherent since --get-color would pick a color slot and ignore the variable type option (e.g. --bool), and the type would require a variable name. Suggested by Junio C Hamano. Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* git config: don't allow extra arguments for -e or -l.Felipe Contreras2009-02-21
| | | | | | | As suggested by Johannes Schindelin. Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* git config: don't allow multiple variable typesFelipe Contreras2009-02-21
| | | | | | | | Only --bool, --int, or --bool-or-int can be used, but not any combination of them. Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* git config: don't allow multiple config file locationsFelipe Contreras2009-02-21
| | | | | | | | Either --global, --system, or --file can be used, but not any combination. Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* git config: reorganize to use parseoptFelipe Contreras2009-02-21
| | | | | | | | This patch has benefited from comments by Johannes Schindelin and Junio C Hamano. Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* git config: reorganize get_color*Felipe Contreras2009-02-21
| | | | | | | | | | In preparation for parseopt. Also remove some unecessary comments since the usage is described in the documentation. Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* git config: trivial rename in preparation for parseoptFelipe Contreras2009-02-21
| | | | | | | | | | | | | | | | | | Essentially this replaces 'file' with 'prefix' in the cases where the variable is used as a prefix, which is consistent with other git commands. When using the --list option general errors where not properly reported, only errors related with the 'file'. Now they are reported, and 'file' is irrelevant. That reduces the rest of 'file' usage to nothing, therefore now only 'prefix' remains. Suggested by Johannes Schindelin. Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* git config: trivial cleanup for editor actionJohannes Schindelin2009-02-21
| | | | | Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* git config: codestyle cleanupsFelipe Contreras2009-02-21
| | | | | Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* config: Add new option to open an editor.Felipe Contreras2009-02-08
| | | | | | | | | The idea was originated by discussion about usability of manually editing the config file in 'special needs' systems such as Windows. Now the user can forget a bit about where the config files actually are. Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* Use git_pathdup instead of xstrdup(git_path(...))Alex Riesen2008-10-30
| | | | Signed-off-by: Junio C Hamano <gitster@pobox.com>
* Make non-static functions, that may be static, staticStephan Beyer2008-07-23
| | | | | Signed-off-by: Stephan Beyer <s-beyer@gmx.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* Make usage strings dash-lessStephan Beyer2008-07-13
| | | | | | | | | | | | | | | When you misuse a git command, you are shown the usage string. But this is currently shown in the dashed form. So if you just copy what you see, it will not work, when the dashed form is no longer supported. This patch makes git commands show the dash-less version. For shell scripts that do not specify OPTIONS_SPEC, git-sh-setup.sh generates a dash-less usage string now. Signed-off-by: Stephan Beyer <s-beyer@gmx.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* Only use GIT_CONFIG in "git config", not other programsDaniel Barkalow2008-07-01
| | | | | | | | | | | | | | | | | For everything other than using "git config" to read or write a git-style config file that isn't the current repo's config file, GIT_CONFIG was actively detrimental. Rather than argue over which programs are important enough to have work anyway, just fix all of them at the root. Also removes GIT_LOCAL_CONFIG, which would only be useful for programs that do want to use global git-specific config, but not the repo's own git-specific config, and want to use some other, presumably git-specific config. Despite being documented, I can't find any sign that it was ever used. Signed-off-by: Daniel Barkalow <barkalow@iabervon.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* Provide git_config with a callback-data parameterJohannes Schindelin2008-05-14
| | | | | | | | | | | | git_config() only had a function parameter, but no callback data parameter. This assumes that all callback functions only modify global variables. With this patch, every callback gets a void * parameter, and it is hoped that this will help the libification effort. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* Merge branch 'mk/color'Junio C Hamano2008-04-19
|\ | | | | | | | | * mk/color: Use color.ui variable in scripts too
| * Use color.ui variable in scripts tooMatthias Kestenholz2008-04-10
| | | | | | | | | | Signed-off-by: Matthias Kestenholz <mk@spinlock.ch> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | Fix git_config_bool_or_intJunio C Hamano2008-04-13
|/ | | | | | | | The earlier one botched the return value logic between config_bool and config_bool_and_int. The former should normalize between 0 and 1 while the latter should give back full range of integer values. Signed-off-by: Junio C Hamano <gitster@pobox.com>
* Always set *nongit_ok in setup_git_directory_gently()SZEDER Gábor2008-03-26
| | | | | | | | | | | | setup_git_directory_gently() only modified the value of its *nongit_ok argument if we were not in a git repository. Now it will always set it to 0 when we are inside a repository. Also remove now unnecessary initializations in the callers of this function. Signed-off-by: SZEDER Gábor <szeder@ira.uka.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* Merge branch 'jk/noetcconfig'Junio C Hamano2008-02-16
|\ | | | | | | | | | | | | | | | | | | * jk/noetcconfig: fix config reading in tests allow suppressing of global and system config Conflicts: cache.h
| * allow suppressing of global and system configJeff King2008-02-06
| | | | | | | | | | | | | | | | | | | | | | The GIT_CONFIG_NOGLOBAL and GIT_CONFIG_NOSYSTEM environment variables are magic undocumented switches that can be used to ensure a totally clean environment. This is necessary for running reliable tests, since those config files may contain settings that change the outcome of tests. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | builtin-config.c: guard config parser from value=NULLJunio C Hamano2008-02-11
|/ | | | | | color configuration variables expect a string value. Signed-off-by: Junio C Hamano <gitster@pobox.com>
* config --get-colorbool: diff.color is a deprecated synonym to color.diffJunio C Hamano2007-12-05
| | | | | | | | The applications can ask for color.diff but the configuration of old timer users can still instruct it to use color with diff.color this way. Signed-off-by: Junio C Hamano <gitster@pobox.com>
* git config --get-colorboolJunio C Hamano2007-12-05
| | | | | | | | | | | | | | | | | | | | | | This adds an option to help scripts find out color settings from the configuration file. git config --get-colorbool color.diff inspects color.diff variable, and exits with status 0 (i.e. success) if color is to be used. It exits with status 1 otherwise. If a script wants "true"/"false" answer to the standard output of the command, it can pass an additional boolean parameter to its command line, telling if its standard output is a terminal, like this: git config --get-colorbool color.diff true When called like this, the command outputs "true" to its standard output if color is to be used (i.e. "color.diff" says "always", "auto", or "true"), and "false" otherwise. Signed-off-by: Junio C Hamano <gitster@pobox.com>
* git config: Don't rely on regexec() returning 1 on non-matchBjörn Steinbrink2007-12-05
| | | | | | | | | | | | Some systems don't return 1 from regexec() when the pattern does not match (notably HP-UX which returns 20). Bug identified by Dscho and H.Merijn Brand. Signed-off-by: Björn Steinbrink <B.Steinbrink@gmx.de> Tested-by: H.Merijn Brand <h.m.brand@xs4all.nl> Cc: Johannes Schindelin <Johannes.Schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* git-config --get-color: get configured colorJunio C Hamano2007-11-28
| | | | | | | This new option allows scripts to grab color setting from the user configuration, translated to ANSI color escape sequence. Signed-off-by: Junio C Hamano <gitster@pobox.com>
* Introduce git_etc_gitconfig() that encapsulates access of ETC_GITCONFIG.Johannes Sixt2007-11-14
| | | | | | | | | | | | | | | In a subsequent patch the path to the system-wide config file will be computed. This is a preparation for that change. It turns all accesses of ETC_GITCONFIG into function calls. There is no change in behavior. As a consequence, config.c is the only file that needs the definition of ETC_GITCONFIG. Hence, -DETC_GITCONFIG is removed from the CFLAGS and a special build rule for config.c is introduced. As a side-effect, changing the defintion of ETC_GITCONFIG (e.g. in config.mak) does not trigger a complete rebuild anymore. Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* git-config: print error message if the config file cannot be readGerrit Pape2007-10-18
| | | | | | | | | | | Instead of simply exiting with 255, print an error message including the reason why a config file specified through --file cannot be opened or read. The problem was noticed by Joey Hess, reported through http://bugs.debian.org/445208 Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
* git-config: handle --file option with relative pathname properlyGerrit Pape2007-10-15
| | | | | | | | | | | | | | | When calling git-config not from the top level directory of a repository, it changes directory before trying to open the config file specified through the --file option, which then fails if the config file was specified by a relative pathname. This patch adjusts the pathname to the config file if applicable. The problem was noticed by Joey Hess, reported through http://bugs.debian.org/445208 Signed-off-by: Gerrit Pape <pape@smarden.org> Signed-off-by: Lars Hjemli <hjemli@gmail.com> Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
* git-config: don't silently ignore options after --listFrank Lichtenheld2007-10-15
| | | | | | | | | Error out if someone gives options after --list since that is not a valid syntax. Signed-off-by: Frank Lichtenheld <frank@lichtenheld.de> Signed-off-by: Lars Hjemli <hjemli@gmail.com> Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
* Add an option to specify a file to config builtinAlex Riesen2007-07-31
| | | | | | | | | There are (really!) systems where using environment variables is very cumbersome (yes, Windows, it has problems unsetting them). Besides this form is shorter. Signed-off-by: Alex Riesen <raa.lkml@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* getenv/setenv: use constants if availableMatthias Lederhofer2007-07-02
| | | | | | | | | | There were places using "GIT_DIR" instead of GIT_DIR_ENVIRONMENT and "GIT_CONFIG" instead of CONFIG_ENVIRONMENT. This makes it easier to find all places touching an environment variable using git grep or similar tools. Signed-off-by: Matthias Lederhofer <matled@gmx.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* config: add support for --bool and --int while setting valuesFrank Lichtenheld2007-06-26
| | | | | Signed-off-by: Frank Lichtenheld <frank@lichtenheld.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* config: Add --null/-z option for null-delimted outputFrank Lichtenheld2007-06-26
| | | | | | | | | Use \n as delimiter between key and value and \0 as delimiter after each key/value pair. This should be easily parsable output. Signed-off-by: Frank Lichtenheld <frank@lichtenheld.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* config: Change output of --get-regexp for valueless keysFrank Lichtenheld2007-06-26
| | | | | | | | | Print no space after the name of a key without value. Otherwise keys without values are printed exactly the same as keys with empty values. Signed-off-by: Frank Lichtenheld <frank@lichtenheld.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* Update git-config documentationAndrew Ruder2007-04-18
| | | | | | | | Documentation/git-config.txt: Added documentation for --system Documentation/builtin-config.c: Added --system to the short usage Signed-off-by: Andrew Ruder <andy@aeruder.net> Signed-off-by: Junio C Hamano <junkio@cox.net>
* git-config: document --rename-section, provide --remove-sectionPaolo Bonzini2007-03-03
| | | | | | | | | This patch documents the previously undocumented option --rename-section and adds a new option to zap an entire section. Signed-off-by: Paolo Bonzini <bonzini@gnu.org> Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de> Signed-off-by: Junio C Hamano <junkio@cox.net>
* config: read system-wide defaults from /etc/gitconfigJohannes Schindelin2007-02-19
| | | | | | | | The settings in /etc/gitconfig can be overridden in ~/.gitconfig, which in turn can be overridden in .git/config. Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de> Signed-off-by: Junio C Hamano <junkio@cox.net>
* [PATCH] Rename git-repo-config to git-config.Tom Prince2007-01-28
Signed-off-by: Tom Prince <tom.prince@ualberta.net> Signed-off-by: Junio C Hamano <junkio@cox.net>