aboutsummaryrefslogtreecommitdiff
path: root/builtin-config.c
diff options
context:
space:
mode:
authorGerrit Pape <pape@smarden.org>2007-10-12 11:32:51 +0000
committerShawn O. Pearce <spearce@spearce.org>2007-10-15 21:07:38 -0400
commit1ae14a6b52f8f0506780cd361933f717163ae19b (patch)
tree6ef7947d657b4b0299a9ef0e40a48636f65a8f7b /builtin-config.c
parent60fcc2e6ce255da1baa92905c10456981d260fa0 (diff)
downloadgit-1ae14a6b52f8f0506780cd361933f717163ae19b.tar.gz
git-1ae14a6b52f8f0506780cd361933f717163ae19b.tar.xz
git-config: handle --file option with relative pathname properly
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>
Diffstat (limited to 'builtin-config.c')
-rw-r--r--builtin-config.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/builtin-config.c b/builtin-config.c
index cb7e9e939..d98b6c2c4 100644
--- a/builtin-config.c
+++ b/builtin-config.c
@@ -165,7 +165,7 @@ int cmd_config(int argc, const char **argv, const char *prefix)
{
int nongit = 0;
char* value;
- setup_git_directory_gently(&nongit);
+ const char *file = setup_git_directory_gently(&nongit);
while (1 < argc) {
if (!strcmp(argv[1], "--int"))
@@ -192,7 +192,12 @@ int cmd_config(int argc, const char **argv, const char *prefix)
else if (!strcmp(argv[1], "--file") || !strcmp(argv[1], "-f")) {
if (argc < 3)
usage(git_config_set_usage);
- setenv(CONFIG_ENVIRONMENT, argv[2], 1);
+ if (!is_absolute_path(argv[2]) && file)
+ file = prefix_filename(file, strlen(file),
+ argv[2]);
+ else
+ file = argv[2];
+ setenv(CONFIG_ENVIRONMENT, file, 1);
argc--;
argv++;
}