git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] git-config: handle --file option with relative pathname properly
@ 2007-10-09 12:49 Gerrit Pape
  2007-10-09 13:14 ` Johannes Schindelin
  2007-10-09 13:20 ` Johannes Sixt
  0 siblings, 2 replies; 5+ messages in thread
From: Gerrit Pape @ 2007-10-09 12:49 UTC (permalink / raw)
  To: Junio C Hamano, git

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>
---
 builtin-config.c |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/builtin-config.c b/builtin-config.c
index 0a605e0..c2708ba 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 *name = setup_git_directory_gently(&nongit);
 
 	while (1 < argc) {
 		if (!strcmp(argv[1], "--int"))
@@ -189,7 +189,11 @@ 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 (argv[2][0] == '/')
+				name = argv[2];
+			else
+				name = name ? prefix_filename(name, strlen(name), argv[2]) : argv[2];
+			setenv(CONFIG_ENVIRONMENT, name, 1);
 			argc--;
 			argv++;
 		}
-- 
1.5.3.4

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2007-10-12 12:09 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-10-09 12:49 [PATCH] git-config: handle --file option with relative pathname properly Gerrit Pape
2007-10-09 13:14 ` Johannes Schindelin
2007-10-09 13:20 ` Johannes Sixt
2007-10-12 11:32   ` [PATCH amend] " Gerrit Pape
2007-10-12 12:08     ` 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).