Thread (1 message) 1 message, 1 author, 2016-06-15

Re: [RFC PATCH 1/3] config --global --edit: create a template file if needed

From: Junio C Hamano <hidden>
Date: 2016-06-15 23:02:02

Matthieu Moy [off-list ref] writes:
When the user has no ~/.gitconfig file, git config --global --edit used
to launch an editor on an nonexistant file name.

Instead, create a file with a default content before launching the
editor. The template contains only commented-out entries, to save a few
keystrokes for the user. If the values are guessed properly, the user
will only have to uncomment the entries.

Advanced users teaching newbies can create a minimalistic configuration
faster for newbies. Beginners reading a tutorial advising to run "git
config --global --edit" as a first step will be slightly more guided for
their first contact with Git.

Signed-off-by: Matthieu Moy <redacted>
---
Probably a good idea; I do not think of any possible interactions we
have to worry about with the configuration file init-db creates with
possible templating.

Do we use "user-wide" as a phrase to refer to these?  It sounds
somewhat funny to call anything specific to $frotz "$frotz-wide", at
least to me.

Surely, /etc/gitconfig is called "site-wide".  But .git/config is
per-project (or project-specific), and I would always have thought
that ~/.gitconfig was "per-user".
quoted hunk
 builtin/config.c | 30 +++++++++++++++++++++++++++---
 cache.h          |  1 +
 ident.c          |  2 +-
 3 files changed, 29 insertions(+), 4 deletions(-)
diff --git a/builtin/config.c b/builtin/config.c
index fcd8474..3821697 100644
--- a/builtin/config.c
+++ b/builtin/config.c
@@ -445,6 +445,20 @@ static int get_urlmatch(const char *var, const char *url)
 	return 0;
 }
 
+static char *default_user_config()
static char *default_user_config(void)
+{
+	struct strbuf buf = STRBUF_INIT;
+	strbuf_addf(&buf,
+		    _("# This is Git's user-wide configuration file.\n"
+		      "[core]\n"
+		      "# Please, adapt and uncomment the following lines:\n"
tangent: is it a French tradition to always have comma after please?
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help