Skip to contentSkip to conversation

Wish: make commiter email address configurable per-repo

PATCH In review Stephen Kelly 6 participants 19 messages Jun 15, 2016 Documentation

lore
Share & tools
lore
#0 lore raw

Hi,

In KDE the committer email address is used to be able to use keywords in commit messages to automatically close bugs.

If my email address that I use for committing is not the same as that configured in the bugzilla, the automated bug closing does not work.

So for some git repos in KDE which I work on on work time, I'd like to set a different committer address. I can't just set GIT_COMMITTER_EMAIL or whatever in my bashrc, because in other repos I want to use a different committer email, and don't want it set globally for all git repos I work on.

This doesn't seem to be configurable in git config. Can that be changed?

All the best,

Steve.

#1 lore raw
Quoted 6 lines · Stephen Kelly

So for some git repos in KDE which I work on on work time, I'd like to set a different committer address. I can't just set GIT_COMMITTER_EMAIL or whatever in my bashrc, because in other repos I want to use a different committer email, and don't want it set globally for all git repos I work on.

This doesn't seem to be configurable in git config. Can that be changed?

See user.email in git-config(1). Most people set it globally, as in

  git config --global user.email "[email protected]"

but there's nothing stopping you from doing

git config user.email "[email protected]"

to set it on a per-repo level. (Or just edit .git/config, of course.)

Signature · 2 lines
Thomas Rast
trast@{inf,student}.ethz.ch
#2 lore raw
Quoted 11 lines · Thomas Rast
Quoted 7 lines · Stephen Kelly

So for some git repos in KDE which I work on on work time, I'd like to set a different committer address. I can't just set GIT_COMMITTER_EMAIL or whatever in my bashrc, because in other repos I want to use a different committer email, and don't want it set globally for all git repos I work on.

This doesn't seem to be configurable in git config. Can that be changed?

See user.email in git-config(1). Most people set it globally, as in

Quoted 8 lines
  git config --global user.email "[email protected]"

but there's nothing stopping you from doing

git config user.email "[email protected]"

to set it on a per-repo level. (Or just edit .git/config, of course.)

Doesn't this set both the author and the committer?

#3 lore raw
Quoted 5 lines · Stephen Kelly
Quoted 4 lines · Thomas Rast

See user.email in git-config(1). Most people set it globally, as in

  git config --global user.email "[email protected]"
Quoted 7 lines
Quoted 5 lines

but there's nothing stopping you from doing

git config user.email "[email protected]"

to set it on a per-repo level. (Or just edit .git/config, of course.)

Doesn't this set both the author and the committer?

Stephen Kelly wrote earlier:

Quoted 2 lines

If my email address that I use for committing is not the same as that configured in the bugzilla, the automated bug closing does not work.

Oh, I see. Yes, it does.

Probably if KDE has this use-case then that means we need to implement it as a feature on size alone, but I briefly looked into the code and it requires a bit more restructuring than I'm willing to do over coffee.

I think as a stop-gap measure you'll have to use an alias such as

  ci = commit --author="your usual <author>"

along with a local setting for user.email to force them to be different. (Note that this will re-set the author when saying 'git ci --amend' on other people's commits!)

Signature · 2 lines
Thomas Rast
trast@{inf,student}.ethz.ch
#4 lore raw
Quoted 26 lines · Thomas Rast
Quoted 5 lines · Stephen Kelly
Quoted 4 lines · Thomas Rast

See user.email in git-config(1). Most people set it globally, as in

  git config --global user.email "[email protected]"
Quoted 7 lines
Quoted 5 lines

but there's nothing stopping you from doing

git config user.email "[email protected]"

to set it on a per-repo level. (Or just edit .git/config, of course.)

Doesn't this set both the author and the committer?

Oh, I see. Yes, it does.

Stephen Kelly wrote earlier:

Quoted 2 lines

If my email address that I use for committing is not the same as that configured in the bugzilla, the automated bug closing does not work.

Probably if KDE has this use-case then that means we need to implement it as a feature on size alone, but I briefly looked into the code and it requires a bit more restructuring than I'm willing to do over coffee.

Quoted 8 lines

I think as a stop-gap measure you'll have to use an alias such as

  ci = commit --author="your usual <author>"

along with a local setting for user.email to force them to be different. (Note that this will re-set the author when saying 'git ci --amend' on other people's commits!)

Thanks for looking into it!

I'll consider the alias you suggest. Git command aliases can be configured per repo, right?

Is there a bug tracker used for git so that this issue doesn't get lost?

All the best,

Steve.

#5 lore raw
Quoted 37 lines · Stephen Kelly
Quoted 26 lines · Thomas Rast
Quoted 5 lines · Stephen Kelly
Quoted 4 lines · Thomas Rast

See user.email in git-config(1).  Most people set it globally, as in

  git config --global user.email "[email protected]"

Quoted 7 lines
Quoted 5 lines

but there's nothing stopping you from doing

  git config user.email "[email protected]"

to set it on a per-repo level.  (Or just edit .git/config, of course.)

Doesn't this set both the author and the committer?

Oh, I see.  Yes, it does.

Stephen Kelly wrote earlier:

Quoted 2 lines

If my email address that I use for committing is not the same as that configured in the bugzilla, the automated bug closing does not work.

Probably if KDE has this use-case then that means we need to implement it as a feature on size alone, but I briefly looked into the code and it requires a bit more restructuring than I'm willing to do over coffee.

Quoted 8 lines

I think as a stop-gap measure you'll have to use an alias such as

  ci = commit --author="your usual <author>"

along with a local setting for user.email to force them to be different.  (Note that this will re-set the author when saying 'git ci --amend' on other people's commits!)

Quoted 5 lines

Thanks for looking into it!

I'll consider the alias you suggest. Git command aliases can be configured per repo, right?

Yes, aliases are normal configuration variables, and can be set per repo.

Quoted 2 lines

Is there a bug tracker used for git so that this issue doesn't get lost?

No, just this mailing list.

#7 lore raw

PATCH 1/1 Introduce new configuation option to override committer information

In reply to Stephen Kelly

Currently, there is no way to set committer information on a per-repository basis. The 'user.name' and 'user.email' configuration options set both author and committer information. To solve this, introduce 'user.committername' and 'user.committeremail' configuration options to override committer name and email respectively.

---
 Documentation/config.txt |   29 +++++++++++++++++++++++------
 builtin/blame.c          |    2 +-
 builtin/commit.c         |    4 ++--
 cache.h                  |    4 +++-
 config.c                 |   15 +++++++++++++++
 environment.c            |    2 ++
 ident.c                  |   18 ++++++++++++------
 7 files changed, 58 insertions(+), 16 deletions(-)
Documentation/config.txt +23 -6
index 6a6c0b5..5405a4c 100644
@@ -1842,14 +1842,31 @@ url.<base>.pushInsteadOf::
 	setting for that remote.
 
 user.email::
-	Your email address to be recorded in any newly created commits.
-	Can be overridden by the 'GIT_AUTHOR_EMAIL', 'GIT_COMMITTER_EMAIL', and
-	'EMAIL' environment variables.  See linkgit:git-commit-tree[1].
+	The email address to be recorded in any newly created commits.
+	Sets both author and committer email.  To override only
+	committer email, use 'user.committeremail'.  Can be overridden
+	by the 'GIT_AUTHOR_EMAIL', 'GIT_COMMITTER_EMAIL', and 'EMAIL'
+	environment variables.  See linkgit:git-commit-tree[1].
 
 user.name::
-	Your full name to be recorded in any newly created commits.
-	Can be overridden by the 'GIT_AUTHOR_NAME' and 'GIT_COMMITTER_NAME'
-	environment variables.  See linkgit:git-commit-tree[1].
+	The full name to be recorded in any newly created commits.
+	Sets both author and committer name.  To override only
+	committer name, use 'user.committername'.  Can be overridden
+	by the 'GIT_AUTHOR_NAME' and 'GIT_COMMITTER_NAME' environment
+	variables.  See linkgit:git-commit-tree[1].
+
+user.committeremail::
+	The email address of the committer to use while recording
+	newly created commits.  Used to override committer email
+	specified in 'user.email'.  Can be overridden by the
+	'GIT_COMMITTER_EMAIL', and 'EMAIL' environment variables.  See
+	linkgit:git-commit-tree[1].
+
+user.committername::
+	The full name of the committer to use while recording newly
+	created commits.  Used to override committer name specified in
+	'user.name'.  Can be overridden by the 'GIT_COMMITTER_NAME'
+	environment variable.  See linkgit:git-commit-tree[1].
 
 user.signingkey::
 	If linkgit:git-tag[1] is not selecting the key you want it to
builtin/blame.c +1 -1
index f5fccc1..1f47130 100644
@@ -2146,7 +2146,7 @@ static struct commit *fake_working_tree_commit(struct diff_options *opt,
 	cache_tree_invalidate_path(active_cache_tree, path);
 
 	commit->buffer = xmalloc(400);
-	ident = fmt_ident("Not Committed Yet", "not.committed.yet", NULL, 0);
+	ident = fmt_ident("Not Committed Yet", "not.committed.yet", NULL, 0, 0);
 	snprintf(commit->buffer, 400,
 		"tree 0000000000000000000000000000000000000000\n"
 		"parent %s\n"
builtin/commit.c +2 -2
index 4fd1a16..a449a13 100644
@@ -1352,8 +1352,8 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
 	}
 
 	if (commit_tree(sb.buf, active_cache_tree->sha1, parents, commit_sha1,
-			fmt_ident(author_name, author_email, author_date,
-				IDENT_ERROR_ON_NO_NAME))) {
+				fmt_ident(author_name, author_email, author_date,
+				0, IDENT_ERROR_ON_NO_NAME))) {
 		rollback_index_files();
 		die("failed to write commit object");
 	}
cache.h +3 -1
index 33decd9..91740c0 100644
@@ -833,7 +833,7 @@ enum date_mode parse_date_format(const char *format);
 #define IDENT_NO_DATE	       4
 extern const char *git_author_info(int);
 extern const char *git_committer_info(int);
-extern const char *fmt_ident(const char *name, const char *email, const char *date_str, int);
+extern const char *fmt_ident(const char *name, const char *email, const char *date_str, int, int);
 extern const char *fmt_name(const char *name, const char *email);
 extern const char *git_editor(void);
 extern const char *git_pager(int stdout_is_tty);
@@ -1008,6 +1008,8 @@ extern const char *config_exclusive_filename;
 #define MAX_GITNAME (1000)
 extern char git_default_email[MAX_GITNAME];
 extern char git_default_name[MAX_GITNAME];
+extern char git_default_committeremail[MAX_GITNAME];
+extern char git_default_committername[MAX_GITNAME];
 #define IDENT_NAME_GIVEN 01
 #define IDENT_MAIL_GIVEN 02
 #define IDENT_ALL_GIVEN (IDENT_NAME_GIVEN|IDENT_MAIL_GIVEN)
config.c +15 -0
index c63d683..ba130dc 100644
@@ -665,6 +665,21 @@ static int git_default_user_config(const char *var, const char *value)
 		return 0;
 	}
 
+	if (!strcmp(var, "user.committername")) {
+		if (!value)
+			return config_error_nonbool(var);
+		strlcpy(git_default_committername, value,
+			sizeof(git_default_committername));
+		return 0;
+	}
+
+	if (!strcmp(var, "user.committeremail")) {
+		if (!value)
+			return config_error_nonbool(var);
+		strlcpy(git_default_committeremail, value,
+			sizeof(git_default_committeremail));
+		return 0;
+	}
 	/* Add other config variables here and to Documentation/config.txt. */
 	return 0;
 }
environment.c +2 -0
index de5581f..1277764 100644
@@ -11,6 +11,8 @@
 
 char git_default_email[MAX_GITNAME];
 char git_default_name[MAX_GITNAME];
+char git_default_committeremail[MAX_GITNAME];
+char git_default_committername[MAX_GITNAME];
 int user_ident_explicitly_given;
 int trust_executable_bit = 1;
 int trust_ctime = 1;
ident.c +12 -6
index 9e24388..b3dcaaa 100644
@@ -183,7 +183,7 @@ static const char *env_hint =
 "\n";
 
 const char *fmt_ident(const char *name, const char *email,
-		      const char *date_str, int flag)
+		const char *date_str, int committer_info, int flag)
 {
 	static char buffer[1000];
 	char date[50];
@@ -193,9 +193,15 @@ const char *fmt_ident(const char *name, const char *email,
 	int name_addr_only = (flag & IDENT_NO_DATE);
 
 	setup_ident();
-	if (!name)
+	if (committer_info) {
+		if (!name)
+			name = git_default_committername;
+		if (!email)
+			email = git_default_committeremail;
+	}
+	if (!name || !*name)
 		name = git_default_name;
-	if (!email)
+	if (!email || !*email)
 		email = git_default_email;
 
 	if (!*name) {
@@ -237,7 +243,7 @@ const char *fmt_ident(const char *name, const char *email,
 
 const char *fmt_name(const char *name, const char *email)
 {
-	return fmt_ident(name, email, NULL, IDENT_ERROR_ON_NO_NAME | IDENT_NO_DATE);
+	return fmt_ident(name, email, NULL, 0, IDENT_ERROR_ON_NO_NAME | IDENT_NO_DATE);
 }
 
 const char *git_author_info(int flag)
@@ -245,7 +251,7 @@ const char *git_author_info(int flag)
 	return fmt_ident(getenv("GIT_AUTHOR_NAME"),
 			 getenv("GIT_AUTHOR_EMAIL"),
 			 getenv("GIT_AUTHOR_DATE"),
-			 flag);
+			 0, flag);
 }
 
 const char *git_committer_info(int flag)
@@ -257,7 +263,7 @@ const char *git_committer_info(int flag)
 	return fmt_ident(getenv("GIT_COMMITTER_NAME"),
 			 getenv("GIT_COMMITTER_EMAIL"),
 			 getenv("GIT_COMMITTER_DATE"),
-			 flag);
+			 1, flag);
 }
 
 int user_ident_sufficiently_given(void)
Signature · 1 line
1.7.2.2.409.gdbb11.dirty
#8 lore raw

Re: [PATCH] Introduce new configuation option to override committer information

Quoted 8 lines · Ramkumar Ramachandra

Currently, there is no way to set committer information on a per-repository basis. The 'user.name' and 'user.email' configuration options set both author and committer information. To solve this, introduce 'user.committername' and 'user.committeremail' configuration options to override committer name and email respectively.

<snip>

Thanks for working on this. I wanted to try it out, but it no longer applies cleanly since 4c28e4ada03f5440251545cf91e0d81bce9b010d and after trivial merging, I can't build.

Can you update the patch?

Thanks,

Steve.

#9 lore raw

PATCH v2 1/1 Introduce new configuation option to override committer information

Currently, there is no way to set committer information on a per-repository basis. The 'user.name' and 'user.email' configuration options set both author and committer information. To solve this, introduce 'user.committername' and 'user.committeremail' configuration options to override committer name and email respectively.

---
Differences since v1: just rebased. Applies cleanly to master now.
Stephen: Please do not cull CC.

 Documentation/config.txt |   29 +++++++++++++++++++++++------
 builtin/blame.c          |    2 +-
 builtin/commit.c         |    2 +-
 cache.h                  |    4 +++-
 config.c                 |   15 +++++++++++++++
 environment.c            |    2 ++
 ident.c                  |   18 ++++++++++++------
 7 files changed, 57 insertions(+), 15 deletions(-)
Documentation/config.txt +23 -6
index ff7c225..0b89cb6 100644
@@ -1866,14 +1866,31 @@ url.<base>.pushInsteadOf::
 	setting for that remote.
 
 user.email::
-	Your email address to be recorded in any newly created commits.
-	Can be overridden by the 'GIT_AUTHOR_EMAIL', 'GIT_COMMITTER_EMAIL', and
-	'EMAIL' environment variables.  See linkgit:git-commit-tree[1].
+	The email address to be recorded in any newly created commits.
+	Sets both author and committer email.  To override only
+	committer email, use 'user.committeremail'.  Can be overridden
+	by the 'GIT_AUTHOR_EMAIL', 'GIT_COMMITTER_EMAIL', and 'EMAIL'
+	environment variables.  See linkgit:git-commit-tree[1].
 
 user.name::
-	Your full name to be recorded in any newly created commits.
-	Can be overridden by the 'GIT_AUTHOR_NAME' and 'GIT_COMMITTER_NAME'
-	environment variables.  See linkgit:git-commit-tree[1].
+	The full name to be recorded in any newly created commits.
+	Sets both author and committer name.  To override only
+	committer name, use 'user.committername'.  Can be overridden
+	by the 'GIT_AUTHOR_NAME' and 'GIT_COMMITTER_NAME' environment
+	variables.  See linkgit:git-commit-tree[1].
+
+user.committeremail::
+	The email address of the committer to use while recording
+	newly created commits.  Used to override committer email
+	specified in 'user.email'.  Can be overridden by the
+	'GIT_COMMITTER_EMAIL', and 'EMAIL' environment variables.  See
+	linkgit:git-commit-tree[1].
+
+user.committername::
+	The full name of the committer to use while recording newly
+	created commits.  Used to override committer name specified in
+	'user.name'.  Can be overridden by the 'GIT_COMMITTER_NAME'
+	environment variable.  See linkgit:git-commit-tree[1].
 
 user.signingkey::
 	If linkgit:git-tag[1] is not selecting the key you want it to
builtin/blame.c +1 -1
index aa30ec5..7fc4d56 100644
@@ -2161,7 +2161,7 @@ static struct commit *fake_working_tree_commit(struct diff_options *opt,
 	cache_tree_invalidate_path(active_cache_tree, path);
 
 	commit->buffer = xmalloc(400);
-	ident = fmt_ident("Not Committed Yet", "not.committed.yet", NULL, 0);
+	ident = fmt_ident("Not Committed Yet", "not.committed.yet", NULL, 0, 0);
 	snprintf(commit->buffer, 400,
 		"tree 0000000000000000000000000000000000000000\n"
 		"parent %s\n"
builtin/commit.c +1 -1
index 22ba54f..4d0dcac 100644
@@ -505,7 +505,7 @@ static void determine_author_info(struct strbuf *author_ident)
 
 	if (force_date)
 		date = force_date;
-	strbuf_addstr(author_ident, fmt_ident(name, email, date,
+	strbuf_addstr(author_ident, fmt_ident(name, email, date, 0,
 					      IDENT_ERROR_ON_NO_NAME));
 }
 
cache.h +3 -1
index d83d68c..bf22df6 100644
@@ -834,7 +834,7 @@ enum date_mode parse_date_format(const char *format);
 #define IDENT_NO_DATE	       4
 extern const char *git_author_info(int);
 extern const char *git_committer_info(int);
-extern const char *fmt_ident(const char *name, const char *email, const char *date_str, int);
+extern const char *fmt_ident(const char *name, const char *email, const char *date_str, int, int);
 extern const char *fmt_name(const char *name, const char *email);
 extern const char *git_editor(void);
 extern const char *git_pager(int stdout_is_tty);
@@ -1013,6 +1013,8 @@ extern const char *config_exclusive_filename;
 #define MAX_GITNAME (1000)
 extern char git_default_email[MAX_GITNAME];
 extern char git_default_name[MAX_GITNAME];
+extern char git_default_committeremail[MAX_GITNAME];
+extern char git_default_committername[MAX_GITNAME];
 #define IDENT_NAME_GIVEN 01
 #define IDENT_MAIL_GIVEN 02
 #define IDENT_ALL_GIVEN (IDENT_NAME_GIVEN|IDENT_MAIL_GIVEN)
config.c +15 -0
index 625e051..3032522 100644
@@ -682,6 +682,21 @@ static int git_default_user_config(const char *var, const char *value)
 		return 0;
 	}
 
+	if (!strcmp(var, "user.committername")) {
+		if (!value)
+			return config_error_nonbool(var);
+		strlcpy(git_default_committername, value,
+			sizeof(git_default_committername));
+		return 0;
+	}
+
+	if (!strcmp(var, "user.committeremail")) {
+		if (!value)
+			return config_error_nonbool(var);
+		strlcpy(git_default_committeremail, value,
+			sizeof(git_default_committeremail));
+		return 0;
+	}
 	/* Add other config variables here and to Documentation/config.txt. */
 	return 0;
 }
environment.c +2 -0
index 9564475..641d6ca 100644
@@ -11,6 +11,8 @@
 
 char git_default_email[MAX_GITNAME];
 char git_default_name[MAX_GITNAME];
+char git_default_committeremail[MAX_GITNAME];
+char git_default_committername[MAX_GITNAME];
 int user_ident_explicitly_given;
 int trust_executable_bit = 1;
 int trust_ctime = 1;
ident.c +12 -6
index 1c4adb0..1a616b7 100644
@@ -183,7 +183,7 @@ static const char *env_hint =
 "\n";
 
 const char *fmt_ident(const char *name, const char *email,
-		      const char *date_str, int flag)
+		const char *date_str, int committer_info, int flag)
 {
 	static char buffer[1000];
 	char date[50];
@@ -193,9 +193,15 @@ const char *fmt_ident(const char *name, const char *email,
 	int name_addr_only = (flag & IDENT_NO_DATE);
 
 	setup_ident();
-	if (!name)
+	if (committer_info) {
+		if (!name)
+			name = git_default_committername;
+		if (!email)
+			email = git_default_committeremail;
+	}
+	if (!name || !*name)
 		name = git_default_name;
-	if (!email)
+	if (!email || !*email)
 		email = git_default_email;
 
 	if (!*name) {
@@ -239,7 +245,7 @@ const char *fmt_ident(const char *name, const char *email,
 
 const char *fmt_name(const char *name, const char *email)
 {
-	return fmt_ident(name, email, NULL, IDENT_ERROR_ON_NO_NAME | IDENT_NO_DATE);
+	return fmt_ident(name, email, NULL, 0, IDENT_ERROR_ON_NO_NAME | IDENT_NO_DATE);
 }
 
 const char *git_author_info(int flag)
@@ -247,7 +253,7 @@ const char *git_author_info(int flag)
 	return fmt_ident(getenv("GIT_AUTHOR_NAME"),
 			 getenv("GIT_AUTHOR_EMAIL"),
 			 getenv("GIT_AUTHOR_DATE"),
-			 flag);
+			 0, flag);
 }
 
 const char *git_committer_info(int flag)
@@ -259,7 +265,7 @@ const char *git_committer_info(int flag)
 	return fmt_ident(getenv("GIT_COMMITTER_NAME"),
 			 getenv("GIT_COMMITTER_EMAIL"),
 			 getenv("GIT_COMMITTER_DATE"),
-			 flag);
+			 1, flag);
 }
 
 int user_ident_sufficiently_given(void)
Signature · 1 line
1.7.2.2.409.gdbb11.dirty
#10 lore raw

Re: [PATCH v2] Introduce new configuation option to override committer information

Quoted 4 lines · Ramkumar Ramachandra

The 'user.name' and 'user.email' configuration
options set both author and committer information. To solve this, introduce 'user.committername' and 'user.committeremail' configuration options to override committer name and email respectively.

Predictably, I don't like this idea at all. How would we explain this to a new user that is reading over gitconfig(5) for the first time? It makes the semantics of the committer and author name (that are mostly meant for giving credit and a contact address) much more murky.

Stephen Kelly:

Quoted 2 lines

In KDE the committer email address is used to be able to use keywords in commit messages to automatically close bugs.

Is it impossible to fix this on the KDE side? I would think a many-to-one mapping from committer identities to bugzilla account names could be a useful thing to have in any case.

Hopeful,
Jonathan

#11 lore raw

Re: [PATCH v2] Introduce new configuation option to override committer information

Quoted 11 lines · Jonathan Nieder
Quoted 4 lines · Ramkumar Ramachandra

The 'user.name' and 'user.email' configuration
options set both author and committer information. To solve this, introduce 'user.committername' and 'user.committeremail' configuration options to override committer name and email respectively.

Predictably, I don't like this idea at all. How would we explain this to a new user that is reading over gitconfig(5) for the first time? It makes the semantics of the committer and author name (that are mostly meant for giving credit and a contact address) much more murky.

Well, now that I'm rethinking it, the weird thing is that it does not override in the way that the user intuitively might expect.

Assume we also had user.authoremail for completeness, and you do

  git config --global user.authoremail [email protected]
  git config --global user.committeremail [email protected]
  git config user.email [email protected]

Probably the user would expect this to result in a uniform [email protected] identity for the current repo, but I don't think we can twist it that way with the current config infrastructure. The obvious option of having user.{author,committer}* override the more generic user.* would be contrary to that intuition.

Signature · 2 lines
Thomas Rast
trast@{inf,student}.ethz.ch
#13 lore raw

Re: [PATCH v2] Introduce new configuation option to override committer information

In reply to Jonathan Nieder
Quoted 11 lines · Jonathan Nieder
Quoted 4 lines · Ramkumar Ramachandra

The 'user.name' and 'user.email' configuration
options set both author and committer information. To solve this, introduce 'user.committername' and 'user.committeremail' configuration options to override committer name and email respectively.

Predictably, I don't like this idea at all.  How would we explain this to a new user that is reading over gitconfig(5) for the first time? It makes the semantics of the committer and author name (that are mostly meant for giving credit and a contact address) much more murky.

It's like the difference between who are you, and what is your log-in identity on remote service X.

Quoted 9 lines

Stephen Kelly:

Quoted 2 lines

In KDE the committer email address is used to be able to use keywords in commit messages to automatically close bugs.

Is it impossible to fix this on the KDE side?  I would think a many-to-one mapping from committer identities to bugzilla account names could be a useful thing to have in any case.

I asked that before coming here, and apparently that is not possible.

Thanks,

Steve.

Quoted 4 lines

Hopeful,
Jonathan

#14 lore raw

Re: [PATCH v2] Introduce new configuation option to override committer information

Hi,

Quoted 8 lines · Stephen Kelly
Quoted 7 lines · Jonathan Nieder
Quoted 4 lines · Ramkumar Ramachandra

The 'user.name' and 'user.email' configuration
options set both author and committer information. To solve this, introduce 'user.committername' and 'user.committeremail' configuration options to override committer name and email respectively.

Quoted 7 lines
Quoted 4 lines

Predictably, I don't like this idea at all.  How would we explain this to a new user that is reading over gitconfig(5) for the first time? It makes the semantics of the committer and author name (that are mostly meant for giving credit and a contact address) much more murky.

It's like the difference between who are you, and what is your log-in identity on remote service X.

This feature should not be widely advertised- while it can confuse many new users, I think it's useful to have in some scenarios like this one.

-- Ram

#6 lore raw
In reply to Stephen Kelly
Quoted 15 lines · Stephen Kelly
Quoted 13 lines · Thomas Rast
Quoted 7 lines · Stephen Kelly

So for some git repos in KDE which I work on on work time, I'd like to set a different committer address. I can't just set GIT_COMMITTER_EMAIL or whatever in my bashrc, because in other repos I want to use a different committer email, and don't want it set globally for all git repos I work on.

This doesn't seem to be configurable in git config. Can that be changed?

See user.email in git-config(1). Most people set it globally, as in

  git config --global user.email "[email protected]"
Quoted 7 lines
Quoted 5 lines

but there's nothing stopping you from doing

git config user.email "[email protected]"

to set it on a per-repo level. (Or just edit .git/config, of course.)

Doesn't this set both the author and the committer?

And the reason why that is a bad thing is...?

#12 lore raw

Re: [PATCH v2] Introduce new configuation option to override committer information

In reply to Thomas Rast
Quoted 9 lines · Thomas Rast

Well, now that I'm rethinking it, the weird thing is that it does not override in the way that the user intuitively might expect.

Assume we also had user.authoremail for completeness, and you do

  git config --global user.authoremail [email protected]
  git config --global user.committeremail [email protected]
  git config user.email [email protected]
Quoted 5 lines

Probably the user would expect this to result in a uniform [email protected] identity for the current repo, but I don't think we can twist it that way with the current config infrastructure. The obvious option of having user.{author,committer}* override the more generic user.* would be contrary to that intuition.

The thing is that the "intuition" is not so cut-and-dried. "email" is indeed more generic than "authoremail", so it is intuitive for the latter to override the former. But "$HOME/.gitconfig" is fallback default for the repository specific .git/config so it also is intuitive for anything in the latter to override whatever is in the former. Now you have a conflicting "more specific authoremail in more generic $HOME/.gitconfig vs more generic email in more specific .git/config---which wins?" situation.

Is there a way to document the rule of precedence clearly? For this particular case, recommending against setting author/committer-email in the fallback default $HOME/.gitconfig in the Documentation/config.txt might be sufficient.

But I am still not convinced why two need to be custom-set differently when both need to name _you_. After all, Author and Committer are both identifiers taken from the same namespace to identify real people, so if you want to use one value for the committer to name _you_, I don't see a sane reason why you want a different name to name the same _you_ in the author field.

The specific use case in the thread talks about KDE workflow interpreting the committer identifier in a particular way as a reason for it to be set to a particular value, but does not clarify why the author has to be different from that particular value for the committer.

#15 lore raw

Re: [PATCH v2] Introduce new configuation option to override committer information

In reply to Ramkumar Ramachandra
Quoted 5 lines · Ramkumar Ramachandra

Currently, there is no way to set committer information on a per-repository basis. The 'user.name' and 'user.email' configuration options set both author and committer information. To solve this, introduce 'user.committername' and 'user.committeremail' configuration options to override committer name and email respectively.

Is this patch going to become part of git, or is it in already?

If not it will probably just get lost because there is no issue tracker.

Thanks,

Steve.

#16 lore raw

Re: [PATCH v2] Introduce new configuation option to override committer information

Quoted 4 lines · Stephen Kelly

Is this patch going to become part of git, or is it in already?

If not it will probably just get lost because there is no issue tracker.

Discussion stalled without an agreement that any patch proposed is "good", so if it ends here it will be dropped.

You could probably help getting closer to a solution by:

* Not dropping Cc's all the time. I saw this email just by chance.

* Stating *why* this cannot be solved in any other way on the KDE end. So far you only said

Quoted 5 lines
Quoted 3 lines

Is it impossible to fix this on the KDE side? I would think a many-to-one mapping from committer identities to bugzilla account names could be a useful thing to have in any case.

I asked that before coming here, and apparently that is not possible.

My gut feeling is that a footer line in the commit along the lines of

Bugzilla-Id: Registered Name <[email protected]>

would work. I suspect others have a similar feeling. A good case why this is not a feasible solution for (presumably) border cases like you would help get rid of it.

* Replying to e.g.

    http://mid.gmane.org/[email protected]

with (ideally better) ideas of what the semantics should be. My assessment is that it either conflicts with user expectations or with established git-config mechanisms of how the various files override each other.

Signature · 2 lines
Thomas Rast
trast@{inf,student}.ethz.ch
#17 lore raw

Re: [PATCH v2] Introduce new configuation option to override committer information

Quoted 4 lines · Thomas Rast
Quoted 3 lines · Stephen Kelly

Is this patch going to become part of git, or is it in already?

Quoted 8 lines
Quoted 1 line

If not it will probably just get lost because there is no issue tracker.

Discussion stalled without an agreement that any patch proposed is "good", so if it ends here it will be dropped.

You could probably help getting closer to a solution by:

* Not dropping Cc's all the time. I saw this email just by chance.

Sorry. I've never used a mailing list where you have to keep everyone in the CC. I use KNode for reading and writing to mailing lists. I don't see why you can get involved in a thread from the initial mail presumably because you read the title and decide it's interesting and then miss the replies even though they have the same title.

How does it work in this case:

Title - Stephen
* Re: Title - Alice
* * Re Title - Bob
* Re Title - Charlie

If you reply to Bob, do you also add Charlie to the CC? Do you search through everyone in long threads and make sure they're all CC'd?

I'm just trying to understand the mindset/process that everyone else on this list seems to use.

FWIW there's no need to CC me on replies. I'll see it anyway :)

Quoted 9 lines

* Stating *why* this cannot be solved in any other way on the KDE end. So far you only said

Quoted 5 lines
Quoted 3 lines

Is it impossible to fix this on the KDE side? I would think a many-to-one mapping from committer identities to bugzilla account names could be a useful thing to have in any case.

I asked that before coming here, and apparently that is not possible.

I filed a bug with the KDE sysadmins asking if there was a way of configuring multiple email addresses in bugzilla. I didn't think of adding some custom keywords to the template as you suggest below.

Quoted 9 lines

My gut feeling is that a footer line in the commit along the lines of

Bugzilla-Id: Registered Name <[email protected]>

would work. I suspect others have a similar feeling. A good case why this is not a feasible solution for (presumably) border cases like you would help get rid of it.

Yes, my case is a border case. This solution seems to duplicate the committer email address in concept. It also requires more work for the KDE sysadmins.

I think the better solution is to maintain a patched version of git externally. Silly as that sounds.

Quoted 9 lines

* Replying to e.g.

   http://mid.gmane.org/[email protected]

with (ideally better) ideas of what the semantics should be. My assessment is that it either conflicts with user expectations or with established git-config mechanisms of how the various files override each other.

Yes, I see what you mean in you example. If git config doesn't have any cases like this already then there's no prior art and two ways forward. I don't want to bikeshed it, so if you want just pick a solution and run with it. Otherwise I'll just continue using my patched version and drop the issue here.

Thanks,

Steve.

#18 lore raw

Re: [PATCH v2] Introduce new configuation option to override committer information

Quoted 7 lines · Stephen Kelly
Quoted 5 lines · Thomas Rast

My gut feeling is that a footer line in the commit along the lines of

Bugzilla-Id: Registered Name <[email protected]>

Quoted 7 lines
Quoted 3 lines

would work. I suspect others have a similar feeling. A good case why this is not a feasible solution for (presumably) border cases like you would help get rid of it.

Yes, my case is a border case. This solution seems to duplicate the committer email address in concept. It also requires more work for the KDE sysadmins.

Okay, this stirred my particular combination of lazy person and busybody. I volunteer to work on modifying the commit-reading/bug-closing script to take a Bugzilla-Id line into account when present if the KDE sysadmins are willing to accept such a modification. Another possibility would be a table (for example a plain text file) mapping git identities to bugzilla identities. Could you put me in touch with them?

Thanks for your work to improve tools. I do appreciate it.

Jonathan