git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Minor documentation problems
@ 2006-11-02 10:40 Matthieu Moy
  2006-11-02 11:41 ` Petr Baudis
  2006-11-02 12:39 ` Minor documentation problems [RFC PATCH] Sean
  0 siblings, 2 replies; 9+ messages in thread
From: Matthieu Moy @ 2006-11-02 10:40 UTC (permalink / raw)
  To: git

Hi,

I'm giving a try to git/cogito after using other systems (particularly
GNU Arch and Bazaar).

I'm looking for a VCS which can suite me (willing to spend some time
learning it) and some collegues (NOT willing to spend more than a few
minutes learning a new tool. "patch" was already too complex, and
someone already requested me to send a full version instead of this
"weird thing that I don't have time to learn"). I'm also looking for a
system for my students, ranging from the somewhat experienced hacker
to the mathematician not caring about computers at all.

The git/cogito duo might do it, let's see.


I found minor problems with the doc, which deserve to be fixed:

* http://www.kernel.org/pub/software/scm/cogito/docs/cg-commit.1.html
  Mentions .git/config, but not ~/.gitconfig (which is indeed _the_
  place where I think most people want to set their name and email).

  Side note: it can be interesting to have a command to do this.
  For example, bzr has "bzr whoami 'me <myself@myisp.com>'", which
  avoids having to learn the config file syntax.

* RSS link on the wiki:
  The URL
  http://git.or.cz/gitwiki/RecentChanges?action=rss_rc&ddiffs=1&unique=1
  seems to be working as an RSS feed for changes, but it's not linked
  to by http://git.or.cz/gitwiki/RecentChanges. Usually, there's an
  RSS icon, and an HTML <link rel="alternate" ...> to help finding it.

Thanks,

-- 

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

* Re: Minor documentation problems
  2006-11-02 10:40 Minor documentation problems Matthieu Moy
@ 2006-11-02 11:41 ` Petr Baudis
  2006-11-02 13:20   ` Matthieu Moy
  2006-11-02 12:39 ` Minor documentation problems [RFC PATCH] Sean
  1 sibling, 1 reply; 9+ messages in thread
From: Petr Baudis @ 2006-11-02 11:41 UTC (permalink / raw)
  To: git; +Cc: jnareb

  Hi,

Dear diary, on Thu, Nov 02, 2006 at 11:40:23AM CET, I got a letter
where Matthieu Moy <Matthieu.Moy@imag.fr> said that...
> I found minor problems with the doc, which deserve to be fixed:
> 
> * http://www.kernel.org/pub/software/scm/cogito/docs/cg-commit.1.html
>   Mentions .git/config, but not ~/.gitconfig (which is indeed _the_
>   place where I think most people want to set their name and email).

  thanks for pointing this out, further releases will mention both.

>   Side note: it can be interesting to have a command to do this.
>   For example, bzr has "bzr whoami 'me <myself@myisp.com>'", which
>   avoids having to learn the config file syntax.

  Yes, you are certainly not the first to wish this, I'm seriously
thinking about introducing cg-admin-config for setting the most common
configuration variables.

  Moreover, I'm more and more thinking about removing the fallback on
guessing based on /etc/passwd and hostname. _Many_ people were and will
be burnt by it, and I think it's more sane to require the user to
confirm once what the valid credentials are (at _that_ point it's ok to
guess, but the user has to confirm it) than let them unconsciously do
200 commits with completely bogus author lines.

  What do the Git people think? Perhaps we could introduce GIT_NO_GUESS
environment variable which will prevent var.c from guessing?

> * RSS link on the wiki:
>   The URL
>   http://git.or.cz/gitwiki/RecentChanges?action=rss_rc&ddiffs=1&unique=1
>   seems to be working as an RSS feed for changes, but it's not linked
>   to by http://git.or.cz/gitwiki/RecentChanges. Usually, there's an
>   RSS icon, and an HTML <link rel="alternate" ...> to help finding it.

  Fixed, thanks.

-- 
				Petr "Pasky" Baudis
Stuff: http://pasky.or.cz/
#!/bin/perl -sp0777i<X+d*lMLa^*lN%0]dsXx++lMlN/dsM0<j]dsj
$/=unpack('H*',$_);$_=`echo 16dio\U$k"SK$/SM$n\EsN0p[lN*1

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

* Re: Minor documentation problems [RFC PATCH]
  2006-11-02 10:40 Minor documentation problems Matthieu Moy
  2006-11-02 11:41 ` Petr Baudis
@ 2006-11-02 12:39 ` Sean
  2006-11-02 13:29   ` Matthieu Moy
  2006-11-02 13:54   ` Johannes Schindelin
  1 sibling, 2 replies; 9+ messages in thread
From: Sean @ 2006-11-02 12:39 UTC (permalink / raw)
  To: Matthieu Moy; +Cc: git

On Thu, 02 Nov 2006 11:40:23 +0100
Matthieu Moy <Matthieu.Moy@imag.fr> wrote:

> * http://www.kernel.org/pub/software/scm/cogito/docs/cg-commit.1.html
>   Mentions .git/config, but not ~/.gitconfig (which is indeed _the_
>   place where I think most people want to set their name and email).
> 
>   Side note: it can be interesting to have a command to do this.
>   For example, bzr has "bzr whoami 'me <myself@myisp.com>'", which
>   avoids having to learn the config file syntax.

This is the git version :

$ git repo-config user.email "myself@myisp.com"
$ git repo-config user.name "me"

Unfortunately repo-config doesn't update ~/.gitconfig only
the .git/config file.

The patch below adds a --global option to allow:

$ git repo-config --global user.email "myself@myisp.com"
$ git repo-config --global user.name "me"

Although the syntax is a bit depressing, it would seem to
be the path of least resistance.

The patch below always updates ~/.gitconfig but perhaps it
should respect GIT_CONFIG and/or GIT_CONFIG_LOCAL
environment variables.

Sean

diff --git a/builtin-repo-config.c b/builtin-repo-config.c
index f60cee1..8c2b58a 100644
--- a/builtin-repo-config.c
+++ b/builtin-repo-config.c
@@ -127,9 +127,20 @@ free_strings:
 	return ret;
 }
 
+static int set_config(int global, const char* key, const char* value,
+		const char* value_regex, int multi_replace)
+{
+	if (global)
+		return git_global_config_set_multivar(key, value,
+				value_regex, multi_replace);
+	else
+		return git_config_set_multivar(key, value,
+				value_regex, multi_replace);
+}
+
 int cmd_repo_config(int argc, const char **argv, const char *prefix)
 {
-	int nongit = 0;
+	int nongit = 0, global = 0;
 	setup_git_directory_gently(&nongit);
 
 	while (1 < argc) {
@@ -139,6 +150,8 @@ int cmd_repo_config(int argc, const char
 			type = T_BOOL;
 		else if (!strcmp(argv[1], "--list") || !strcmp(argv[1], "-l"))
 			return git_config(show_all_config);
+		else if (!strcmp(argv[1], "--global"))
+			global = 1;
 		else
 			break;
 		argc--;
@@ -150,9 +163,9 @@ int cmd_repo_config(int argc, const char
 		return get_value(argv[1], NULL);
 	case 3:
 		if (!strcmp(argv[1], "--unset"))
-			return git_config_set(argv[2], NULL);
+			return set_config(global, argv[2], NULL, NULL, 0);
 		else if (!strcmp(argv[1], "--unset-all"))
-			return git_config_set_multivar(argv[2], NULL, NULL, 1);
+			return set_config(global, argv[2], NULL, NULL, 1);
 		else if (!strcmp(argv[1], "--get"))
 			return get_value(argv[2], NULL);
 		else if (!strcmp(argv[1], "--get-all")) {
@@ -165,12 +178,12 @@ int cmd_repo_config(int argc, const char
 			return get_value(argv[2], NULL);
 		} else
 
-			return git_config_set(argv[1], argv[2]);
+			return set_config(global, argv[1], argv[2], NULL, 0);
 	case 4:
 		if (!strcmp(argv[1], "--unset"))
-			return git_config_set_multivar(argv[2], NULL, argv[3], 0);
+			return set_config(global, argv[2], NULL, argv[3], 0);
 		else if (!strcmp(argv[1], "--unset-all"))
-			return git_config_set_multivar(argv[2], NULL, argv[3], 1);
+			return set_config(global, argv[2], NULL, argv[3], 1);
 		else if (!strcmp(argv[1], "--get"))
 			return get_value(argv[2], argv[3]);
 		else if (!strcmp(argv[1], "--get-all")) {
@@ -183,13 +196,13 @@ int cmd_repo_config(int argc, const char
 			return get_value(argv[2], argv[3]);
 		} else if (!strcmp(argv[1], "--replace-all"))
 
-			return git_config_set_multivar(argv[2], argv[3], NULL, 1);
+			return set_config(global, argv[2], argv[3], NULL, 1);
 		else
 
-			return git_config_set_multivar(argv[1], argv[2], argv[3], 0);
+			return set_config(global, argv[1], argv[2], argv[3], 0);
 	case 5:
 		if (!strcmp(argv[1], "--replace-all"))
-			return git_config_set_multivar(argv[2], argv[3], argv[4], 1);
+			return set_config(global, argv[2], argv[3], argv[4], 1);
 	case 1:
 	default:
 		usage(git_config_set_usage);
diff --git a/cache.h b/cache.h
index d0a1657..5f7c599 100644
--- a/cache.h
+++ b/cache.h
@@ -402,6 +402,8 @@ extern int git_config_int(const char *,
 extern int git_config_bool(const char *, const char *);
 extern int git_config_set(const char *, const char *);
 extern int git_config_set_multivar(const char *, const char *, const char *, int);
+extern int git_global_config_set(const char*, const char*);
+extern int git_global_config_set_multivar(const char*, const char*, const char*, int);
 extern int check_repository_format_version(const char *var, const char *value);
 
 #define MAX_GITNAME (1000)
diff --git a/config.c b/config.c
index e8f0caf..0393b65 100644
--- a/config.c
+++ b/config.c
@@ -529,22 +529,16 @@ int git_config_set(const char* key, cons
  * - the config file is removed and the lock file rename()d to it.
  *
  */
-int git_config_set_multivar(const char* key, const char* value,
+int git_config_file_set_multivar(char* config_filename,
+	const char* key, const char* value,
 	const char* value_regex, int multi_replace)
 {
 	int i, dot;
 	int fd = -1, in_fd;
 	int ret;
-	char* config_filename;
 	char* lock_file;
 	const char* last_dot = strrchr(key, '.');
 
-	config_filename = getenv("GIT_CONFIG");
-	if (!config_filename) {
-		config_filename = getenv("GIT_CONFIG_LOCAL");
-		if (!config_filename)
-			config_filename  = git_path("config");
-	}
 	config_filename = xstrdup(config_filename);
 	lock_file = xstrdup(mkpath("%s.lock", config_filename));
 
@@ -742,3 +736,36 @@ out_free:
 }
 
 
+int git_config_set_multivar(const char* key, const char* value,
+	const char* value_regex, int multi_replace)
+{
+	char* config_filename;
+	config_filename = getenv("GIT_CONFIG");
+	if (!config_filename) {
+		config_filename = getenv("GIT_CONFIG_LOCAL");
+		if (!config_filename)
+			config_filename  = git_path("config");
+	}
+	return git_config_file_set_multivar(config_filename, key, value,
+				value_regex, multi_replace);
+}
+
+int git_global_config_set_multivar(const char* key, const char* value,
+	const char* value_regex, int multi_replace)
+{
+	int ret = -1;
+	const char *home = getenv("HOME");
+	if (home) {
+		char * global = xstrdup(mkpath("%s/.gitconfig", home));
+		ret = git_config_file_set_multivar(global, key, value,
+				value_regex, multi_replace);
+		free(global);
+	}
+	return ret;
+}
+
+int git_global_config_set(const char* key, const char* value)
+{
+	return git_global_config_set_multivar(key, value, NULL, 0);
+}

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

* Re: Minor documentation problems
  2006-11-02 11:41 ` Petr Baudis
@ 2006-11-02 13:20   ` Matthieu Moy
  0 siblings, 0 replies; 9+ messages in thread
From: Matthieu Moy @ 2006-11-02 13:20 UTC (permalink / raw)
  To: git

Petr Baudis <pasky@suse.cz> writes:

>   Moreover, I'm more and more thinking about removing the fallback on
> guessing based on /etc/passwd and hostname. _Many_ people were and will
> be burnt by it, and I think it's more sane to require the user to
> confirm once what the valid credentials are (at _that_ point it's ok to
> guess, but the user has to confirm it) than let them unconsciously do
> 200 commits with completely bogus author lines.

IIRC, Darcs will prompt interactively the first time and remember it.
The problem of interactive prompt is that it can break scripts (which
are not always ran from an interactive prompt), so it's probably OK to
do this in cogito, but less so in git.

One nice thing with guess-and-don't-ask is that people who don't care
don't have to bother about this. I mean, some people have been
satisfied with CVS storing the username of the guy doing the access
which is often wrong for years, so ... it's probably OK to use an
incorrect guess for a private project with, say, <5 contributors.

-- 

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

* Re: Minor documentation problems [RFC PATCH]
  2006-11-02 12:39 ` Minor documentation problems [RFC PATCH] Sean
@ 2006-11-02 13:29   ` Matthieu Moy
  2006-11-02 13:54   ` Johannes Schindelin
  1 sibling, 0 replies; 9+ messages in thread
From: Matthieu Moy @ 2006-11-02 13:29 UTC (permalink / raw)
  To: git

Sean <seanlkml@sympatico.ca> writes:

> This is the git version :
>
> $ git repo-config user.email "myself@myisp.com"
> $ git repo-config user.name "me"

Great!

But this should be mentionned in
http://www.kernel.org/pub/software/scm/git/docs/git-commit-tree.html
too.

Perhaps, "As an alternative to editing the .git/config or ~/.gitconfig
manually, you can use git-repo-config".

BTW,
http://www.kernel.org/pub/software/scm/git/docs/git-commit-tree.html
also fails to mention ~/.gitconfig.

-- 

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

* Re: Minor documentation problems [RFC PATCH]
  2006-11-02 12:39 ` Minor documentation problems [RFC PATCH] Sean
  2006-11-02 13:29   ` Matthieu Moy
@ 2006-11-02 13:54   ` Johannes Schindelin
  2006-11-02 14:30     ` Sean
  1 sibling, 1 reply; 9+ messages in thread
From: Johannes Schindelin @ 2006-11-02 13:54 UTC (permalink / raw)
  To: Sean; +Cc: git

Hi,

On Thu, 2 Nov 2006, Sean wrote:

> The patch below always updates ~/.gitconfig but perhaps it
> should respect GIT_CONFIG and/or GIT_CONFIG_LOCAL
> environment variables.

Your patch would be loads shorter and easier to read if you'd just 
override the GIT_CONFIG environment variable (like --git-dir sets 
GIT_DIR).

Ciao,
Dscho

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

* Re: Minor documentation problems [RFC PATCH]
  2006-11-02 13:54   ` Johannes Schindelin
@ 2006-11-02 14:30     ` Sean
  2006-11-02 14:51       ` Johannes Schindelin
  0 siblings, 1 reply; 9+ messages in thread
From: Sean @ 2006-11-02 14:30 UTC (permalink / raw)
  To: Johannes Schindelin; +Cc: git

On Thu, 2 Nov 2006 14:54:24 +0100 (CET)
Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:

> Your patch would be loads shorter and easier to read if you'd just 
> override the GIT_CONFIG environment variable (like --git-dir sets 
> GIT_DIR).
> 

Indeed. Thanks...  How 'bout this:

diff --git a/builtin-repo-config.c b/builtin-repo-config.c
index f60cee1..dcdae81 100644
--- a/builtin-repo-config.c
+++ b/builtin-repo-config.c
@@ -139,7 +139,16 @@ int cmd_repo_config(int argc, const char
 			type = T_BOOL;
 		else if (!strcmp(argv[1], "--list") || !strcmp(argv[1], "-l"))
 			return git_config(show_all_config);
-		else
+		else if (!strcmp(argv[1], "--global")) {
+			char *home = getenv("HOME");
+			if (home) {
+				char *user_config = xstrdup(mkpath("%s/.gitconfig", home));
+				setenv("GIT_CONFIG", user_config, 1);
+				free(user_config);
+			} else {
+				return -1;
+			}
+		} else
 			break;
 		argc--;
 		argv++;

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

* Re: Minor documentation problems [RFC PATCH]
  2006-11-02 14:30     ` Sean
@ 2006-11-02 14:51       ` Johannes Schindelin
  2006-11-02 15:44         ` [PATCH] Add --global option to git-repo-config Sean
  0 siblings, 1 reply; 9+ messages in thread
From: Johannes Schindelin @ 2006-11-02 14:51 UTC (permalink / raw)
  To: Sean; +Cc: git

Hi,

On Thu, 2 Nov 2006, Sean wrote:

> -		else
> +		else if (!strcmp(argv[1], "--global")) {
> +			char *home = getenv("HOME");
> +			if (home) {
> +				char *user_config = xstrdup(mkpath("%s/.gitconfig", home));
> +				setenv("GIT_CONFIG", user_config, 1);
> +				free(user_config);
> +			} else {
> +				return -1;

Micronit: might be useful to tell the user that she's homeless.

Else: ACK.

Ciao,
Dscho

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

* [PATCH] Add --global option to git-repo-config.
  2006-11-02 14:51       ` Johannes Schindelin
@ 2006-11-02 15:44         ` Sean
  0 siblings, 0 replies; 9+ messages in thread
From: Sean @ 2006-11-02 15:44 UTC (permalink / raw)
  To: Johannes Schindelin; +Cc: git


Allow user to set variables in global ~/.gitconfig file
using command line.

Signed-off-by: Sean Estabrooks <seanlkml@sympatico.ca>
---
 Documentation/git-repo-config.txt |   31 ++++++++++++++++++-------------
 builtin-repo-config.c             |   13 +++++++++++--
 2 files changed, 29 insertions(+), 15 deletions(-)

diff --git a/Documentation/git-repo-config.txt b/Documentation/git-repo-config.txt
index 8a1ab61..8199615 100644
--- a/Documentation/git-repo-config.txt
+++ b/Documentation/git-repo-config.txt
@@ -3,19 +3,19 @@ git-repo-config(1)
 
 NAME
 ----
-git-repo-config - Get and set options in .git/config
+git-repo-config - Get and set repository or global options.
 
 
 SYNOPSIS
 --------
 [verse]
-'git-repo-config' [type] name [value [value_regex]]
-'git-repo-config' [type] --replace-all name [value [value_regex]]
-'git-repo-config' [type] --get name [value_regex]
-'git-repo-config' [type] --get-all name [value_regex]
-'git-repo-config' [type] --unset name [value_regex]
-'git-repo-config' [type] --unset-all name [value_regex]
-'git-repo-config' -l | --list
+'git-repo-config' [--global] [type] name [value [value_regex]]
+'git-repo-config' [--global] [type] --replace-all name [value [value_regex]]
+'git-repo-config' [--global] [type] --get name [value_regex]
+'git-repo-config' [--global] [type] --get-all name [value_regex]
+'git-repo-config' [--global] [type] --unset name [value_regex]
+'git-repo-config' [--global] [type] --unset-all name [value_regex]
+'git-repo-config' [--global] -l | --list
 
 DESCRIPTION
 -----------
@@ -41,8 +41,9 @@ This command will fail if:
 . Can not write to .git/config,
 . no section was provided,
 . the section or key is invalid,
-. you try to unset an option which does not exist, or
-. you try to unset/set an option for which multiple lines match.
+. you try to unset an option which does not exist,
+. you try to unset/set an option for which multiple lines match, or
+. you use --global option without $HOME being properly set.
 
 
 OPTIONS
@@ -64,14 +65,17 @@ OPTIONS
 --get-regexp::
 	Like --get-all, but interprets the name as a regular expression.
 
+--global::
+	Use global ~/.gitconfig file rather than the repository .git/config.
+
 --unset::
-	Remove the line matching the key from .git/config.
+	Remove the line matching the key from config file.
 
 --unset-all::
-	Remove all matching lines from .git/config.
+	Remove all matching lines from config file.
 
 -l, --list::
-	List all variables set in .git/config.
+	List all variables set in config file.
 
 
 ENVIRONMENT
@@ -79,6 +83,7 @@ ENVIRONMENT
 
 GIT_CONFIG::
 	Take the configuration from the given file instead of .git/config.
+	Using the "--global" option forces this to ~/.gitconfig.
 
 GIT_CONFIG_LOCAL::
 	Currently the same as $GIT_CONFIG; when Git will support global
diff --git a/builtin-repo-config.c b/builtin-repo-config.c
index f60cee1..7b6e572 100644
--- a/builtin-repo-config.c
+++ b/builtin-repo-config.c
@@ -3,7 +3,7 @@
 #include <regex.h>
 
 static const char git_config_set_usage[] =
-"git-repo-config [ --bool | --int ] [--get | --get-all | --get-regexp | --replace-all | --unset | --unset-all] name [value [value_regex]] | --list";
+"git-repo-config [ --global ] [ --bool | --int ] [--get | --get-all | --get-regexp | --replace-all | --unset | --unset-all] name [value [value_regex]] | --list";
 
 static char *key;
 static regex_t *key_regexp;
@@ -139,7 +139,16 @@ int cmd_repo_config(int argc, const char
 			type = T_BOOL;
 		else if (!strcmp(argv[1], "--list") || !strcmp(argv[1], "-l"))
 			return git_config(show_all_config);
-		else
+		else if (!strcmp(argv[1], "--global")) {
+			char *home = getenv("HOME");
+			if (home) {
+				char *user_config = xstrdup(mkpath("%s/.gitconfig", home));
+				setenv("GIT_CONFIG", user_config, 1);
+				free(user_config);
+			} else {
+				die("$HOME not set");
+			}
+		} else
 			break;
 		argc--;
 		argv++;
-- 
1.4.3.3.g869c

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

end of thread, other threads:[~2006-11-02 15:44 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-11-02 10:40 Minor documentation problems Matthieu Moy
2006-11-02 11:41 ` Petr Baudis
2006-11-02 13:20   ` Matthieu Moy
2006-11-02 12:39 ` Minor documentation problems [RFC PATCH] Sean
2006-11-02 13:29   ` Matthieu Moy
2006-11-02 13:54   ` Johannes Schindelin
2006-11-02 14:30     ` Sean
2006-11-02 14:51       ` Johannes Schindelin
2006-11-02 15:44         ` [PATCH] Add --global option to git-repo-config Sean

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).