git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] git config: error when editing a repo config and not being in one

From
Felipe Contreras <felipe.contreras@gmail.com>
Date
Apr 29, 2009, 22:25 UTC
Message-ID
<1241043939-29013-1-git-send-email-felipe.contreras@gmail.com>

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>
---
 builtin-config.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/builtin-config.c b/builtin-config.c
index d8da72c..6e936e1 100644
--- a/builtin-config.c
+++ b/builtin-config.c
@@ -390,6 +390,8 @@ int cmd_config(int argc, const char **argv, const char *unused_prefix)
 	}
 	else if (actions == ACTION_EDIT) {
 		check_argc(argc, 0, 0);
+		if (!config_exclusive_filename && !is_inside_git_dir())
+			die("not in a git directory");
 		git_config(git_default_config, NULL);
 		launch_editor(config_exclusive_filename ?
 			      config_exclusive_filename : git_path("config"),
-- 
1.6.3.rc3.12.gb7937.dirty
Next: Johannes Schindelin
Message 1 of 8 in “git config: error when editing a repo config and not being in one”
  1. git config: error when editing a repo config and not being in oneFelipe Contreras, Apr 29, 2009
  2. Johannes SchindelinApr 29, 2009
  3. git config: error when editing a repo config and not being in oneFelipe Contreras, Apr 29, 2009
  4. Johannes SchindelinApr 30, 2009
  5. Felipe ContrerasApr 30, 2009
  6. Johannes SchindelinApr 30, 2009
  7. Junio C HamanoApr 29, 2009
  8. Junio C HamanoApr 29, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.