summaryrefslogtreecommitdiff
path: root/builtin-config.c
Commit message (Collapse)AuthorAgeFilesLines
* Move 'builtin-*' into a 'builtin/' subdirectoryLinus Torvalds2010-02-221-496/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This shrinks the top-level directory a bit, and makes it much more pleasant to use auto-completion on the thing. Instead of [torvalds@nehalem git]$ em buil<tab> Display all 180 possibilities? (y or n) [torvalds@nehalem git]$ em builtin-sh builtin-shortlog.c builtin-show-branch.c builtin-show-ref.c builtin-shortlog.o builtin-show-branch.o builtin-show-ref.o [torvalds@nehalem git]$ em builtin-shor<tab> builtin-shortlog.c builtin-shortlog.o [torvalds@nehalem git]$ em builtin-shortlog.c you get [torvalds@nehalem git]$ em buil<tab> [type] builtin/ builtin.h [torvalds@nehalem git]$ em builtin [auto-completes to] [torvalds@nehalem git]$ em builtin/sh<tab> [type] shortlog.c shortlog.o show-branch.c show-branch.o show-ref.c show-ref.o [torvalds@nehalem git]$ em builtin/sho [auto-completes to] [torvalds@nehalem git]$ em builtin/shor<tab> [type] shortlog.c shortlog.o [torvalds@nehalem git]$ em builtin/shortlog.c which doesn't seem all that different, but not having that annoying break in "Display all 180 possibilities?" is quite a relief. NOTE! If you do this in a clean tree (no object files etc), or using an editor that has auto-completion rules that ignores '*.o' files, you won't see that annoying 'Display all 180 possibilities?' message - it will just show the choices instead. I think bash has some cut-off around 100 choices or something. So the reason I see this is that I'm using an odd editory, and thus don't have the rules to cut down on auto-completion. But you can simulate that by using 'ls' instead, or something similar. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* Merge branch 'jh/maint-config-file-prefix'Junio C Hamano2010-01-271-1/+1
|\ | | | | | | | | * 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-261-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-311-1/+19
| | | | | | | | | | | | | | | | | | | | 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-271-2/+2
| | | | | | | | | | | | | | | | | | | | | | 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-251-1/+2
|/ | | | | | | | | | 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-291-0/+2
| | | | | | | | | | 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-171-1/+1
| | | | | | | | | 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-071-1/+1
| | | | | | | | | | | | 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-211-0/+5
| | | | | | | | | | | 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-211-0/+2
| | | | | | | 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-211-12/+20
| | | | | | | | 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-211-0/+5
| | | | | | | | 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-211-154/+195
| | | | | | | | 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-211-44/+18
| | | | | | | | | | 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-211-14/+18
| | | | | | | | | | | | | | | | | | 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-211-6/+3
| | | | | Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* git config: codestyle cleanupsFelipe Contreras2009-02-211-3/+3
| | | | | 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-081-1/+12
| | | | | | | | | 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-301-1/+1
| | | | Signed-off-by: Junio C Hamano <gitster@pobox.com>
* Make non-static functions, that may be static, staticStephan Beyer2008-07-231-1/+1
| | | | | 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-131-1/+1
| | | | | | | | | | | | | | | 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-011-8/+7
| | | | | | | | | | | | | | | | | 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-141-12/+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-191-1/+5
|\ | | | | | | | | * mk/color: Use color.ui variable in scripts too
| * Use color.ui variable in scripts tooMatthias Kestenholz2008-04-101-1/+5
| | | | | | | | | | 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-131-2/+20
|/ | | | | | | | 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-261-1/+1
| | | | | | | | | | | | 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-161-2/+3
|\ | | | | | | | | | | | | | | | | | | * 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-061-2/+3
| | | | | | | | | | | | | | | | | | | | | | 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-111-0/+2
|/ | | | | | 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-051-2/+16
| | | | | | | | 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-051-1/+40
| | | | | | | | | | | | | | | | | | | | | | 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-051-2/+1
| | | | | | | | | | | | 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-281-3/+52
| | | | | | | 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-141-2/+2
| | | | | | | | | | | | | | | 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-181-1/+4
| | | | | | | | | | | 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-151-2/+7
| | | | | | | | | | | | | | | 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-151-1/+4
| | | | | | | | | 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-311-1/+8
| | | | | | | | | 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-021-2/+2
| | | | | | | | | | 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-261-13/+42
| | | | | 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-261-5/+13
| | | | | | | | | 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-261-2/+6
| | | | | | | | | 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-181-1/+1
| | | | | | | | 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-031-1/+14
| | | | | | | | | 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-191-3/+12
| | | | | | | | 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-281-0/+220
Signed-off-by: Tom Prince <tom.prince@ualberta.net> Signed-off-by: Junio C Hamano <junkio@cox.net>