git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] git config: do not create .git/ if it does not exist yet
@ 2016-02-24  7:47 Johannes Schindelin
  2016-02-24  8:26 ` Jeff King
  2016-02-24 12:48 ` [PATCH v2] git config: report when trying to modify a non-existing repo config Johannes Schindelin
  0 siblings, 2 replies; 16+ messages in thread
From: Johannes Schindelin @ 2016-02-24  7:47 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

It is a pilot error to call `git config section.key value` outside of
any Git worktree.

Let's report that error instead of creating the .git/ directory and
writing a fresh config into it.

This addresses https://github.com/git-for-windows/git/issues/643 and
https://groups.google.com/forum/#!topic/git-for-windows/fVRdnDIKVuw

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---

	I cannot think of a way how to test this: all of the regression
	tests run inside Git's own worktree, and we cannot even assume
	that /tmp/ is outside of a worktree (or that it exists).

 builtin/config.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/builtin/config.c b/builtin/config.c
index adc7727..78aab95 100644
--- a/builtin/config.c
+++ b/builtin/config.c
@@ -352,6 +352,9 @@ static int get_colorbool(const char *var, int print)
 
 static void check_write(void)
 {
+	if (!given_config_source.file && !startup_info->have_repository)
+		die("not in a git directory");
+
 	if (given_config_source.use_stdin)
 		die("writing to stdin is not supported");
 
-- 
2.7.2.windows.1.2.gbc859c8

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

end of thread, other threads:[~2016-02-25 15:55 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-02-24  7:47 [PATCH] git config: do not create .git/ if it does not exist yet Johannes Schindelin
2016-02-24  8:26 ` Jeff King
2016-02-24 10:14   ` John Keeping
2016-02-24 10:31     ` Jeff King
2016-02-24 11:31       ` Johannes Schindelin
2016-02-24 12:13         ` Johannes Schindelin
2016-02-24 12:34           ` Jeff King
2016-02-24 18:45           ` Junio C Hamano
2016-02-24 11:01   ` Duy Nguyen
2016-02-24 12:48 ` [PATCH v2] git config: report when trying to modify a non-existing repo config Johannes Schindelin
2016-02-24 12:59   ` Duy Nguyen
2016-02-24 13:26     ` Johannes Schindelin
2016-02-24 13:29       ` Duy Nguyen
2016-02-24 20:11   ` Junio C Hamano
2016-02-24 22:31     ` Junio C Hamano
2016-02-25 15:54       ` 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).