* Wish: make commiter email address configurable per-repo
@ 2011-01-07 13:16 Stephen Kelly
2011-01-07 13:20 ` Thomas Rast
2011-01-08 8:03 ` [PATCH] Introduce new configuation option to override committer information Ramkumar Ramachandra
0 siblings, 2 replies; 19+ messages in thread
From: Stephen Kelly @ 2011-01-07 13:16 UTC (permalink / raw)
To: git
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.
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Wish: make commiter email address configurable per-repo
2011-01-07 13:16 Wish: make commiter email address configurable per-repo Stephen Kelly
@ 2011-01-07 13:20 ` Thomas Rast
2011-01-07 13:23 ` Stephen Kelly
2011-01-08 8:03 ` [PATCH] Introduce new configuation option to override committer information Ramkumar Ramachandra
1 sibling, 1 reply; 19+ messages in thread
From: Thomas Rast @ 2011-01-07 13:20 UTC (permalink / raw)
To: Stephen Kelly; +Cc: git
Stephen Kelly wrote:
> 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 "author@example.com"
but there's nothing stopping you from doing
git config user.email "alias@example.com"
to set it on a per-repo level. (Or just edit .git/config, of course.)
--
Thomas Rast
trast@{inf,student}.ethz.ch
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Wish: make commiter email address configurable per-repo
2011-01-07 13:20 ` Thomas Rast
@ 2011-01-07 13:23 ` Stephen Kelly
2011-01-07 13:43 ` Thomas Rast
2011-01-20 18:44 ` Junio C Hamano
0 siblings, 2 replies; 19+ messages in thread
From: Stephen Kelly @ 2011-01-07 13:23 UTC (permalink / raw)
To: git
Thomas Rast wrote:
> Stephen Kelly wrote:
>> 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 "author@example.com"
>
> but there's nothing stopping you from doing
>
> git config user.email "alias@example.com"
>
> 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?
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Wish: make commiter email address configurable per-repo
2011-01-07 13:23 ` Stephen Kelly
@ 2011-01-07 13:43 ` Thomas Rast
2011-01-07 18:01 ` Stephen Kelly
2011-01-20 18:44 ` Junio C Hamano
1 sibling, 1 reply; 19+ messages in thread
From: Thomas Rast @ 2011-01-07 13:43 UTC (permalink / raw)
To: Stephen Kelly; +Cc: git
Stephen Kelly wrote:
> Thomas Rast wrote:
> > See user.email in git-config(1). Most people set it globally, as in
> >
> > git config --global user.email "author@example.com"
> >
> > but there's nothing stopping you from doing
> >
> > git config user.email "alias@example.com"
> >
> > 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:
> 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!)
--
Thomas Rast
trast@{inf,student}.ethz.ch
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Wish: make commiter email address configurable per-repo
2011-01-07 13:43 ` Thomas Rast
@ 2011-01-07 18:01 ` Stephen Kelly
2011-01-07 18:19 ` Erik Faye-Lund
0 siblings, 1 reply; 19+ messages in thread
From: Stephen Kelly @ 2011-01-07 18:01 UTC (permalink / raw)
To: git
Thomas Rast wrote:
> Stephen Kelly wrote:
>> Thomas Rast wrote:
>> > See user.email in git-config(1). Most people set it globally, as in
>> >
>> > git config --global user.email "author@example.com"
>> >
>> > but there's nothing stopping you from doing
>> >
>> > git config user.email "alias@example.com"
>> >
>> > 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:
>> 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.
>
> 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.
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Wish: make commiter email address configurable per-repo
2011-01-07 18:01 ` Stephen Kelly
@ 2011-01-07 18:19 ` Erik Faye-Lund
0 siblings, 0 replies; 19+ messages in thread
From: Erik Faye-Lund @ 2011-01-07 18:19 UTC (permalink / raw)
To: Stephen Kelly; +Cc: git
On Fri, Jan 7, 2011 at 7:01 PM, Stephen Kelly <steveire@gmail.com> wrote:
> Thomas Rast wrote:
>
>> Stephen Kelly wrote:
>>> Thomas Rast wrote:
>>> > See user.email in git-config(1). Most people set it globally, as in
>>> >
>>> > git config --global user.email "author@example.com"
>>> >
>>> > but there's nothing stopping you from doing
>>> >
>>> > git config user.email "alias@example.com"
>>> >
>>> > 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:
>>> 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.
>>
>> 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?
>
Yes, aliases are normal configuration variables, and can be set per repo.
> Is there a bug tracker used for git so that this issue doesn't get lost?
>
No, just this mailing list.
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH] Introduce new configuation option to override committer information
2011-01-07 13:16 Wish: make commiter email address configurable per-repo Stephen Kelly
2011-01-07 13:20 ` Thomas Rast
@ 2011-01-08 8:03 ` Ramkumar Ramachandra
2011-01-08 19:24 ` Stephen Kelly
1 sibling, 1 reply; 19+ messages in thread
From: Ramkumar Ramachandra @ 2011-01-08 8:03 UTC (permalink / raw)
To: Git Mailing List; +Cc: Stephen Kelly, Thomas Rast, Erik Faye-Lund
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.
Reported-by: Stephen Kelly <steveire@gmail.com>
Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
---
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(-)
diff --git a/Documentation/config.txt b/Documentation/config.txt
index 6a6c0b5..5405a4c 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -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
diff --git a/builtin/blame.c b/builtin/blame.c
index f5fccc1..1f47130 100644
--- a/builtin/blame.c
+++ b/builtin/blame.c
@@ -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"
diff --git a/builtin/commit.c b/builtin/commit.c
index 4fd1a16..a449a13 100644
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@ -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");
}
diff --git a/cache.h b/cache.h
index 33decd9..91740c0 100644
--- a/cache.h
+++ b/cache.h
@@ -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)
diff --git a/config.c b/config.c
index c63d683..ba130dc 100644
--- a/config.c
+++ b/config.c
@@ -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;
}
diff --git a/environment.c b/environment.c
index de5581f..1277764 100644
--- a/environment.c
+++ b/environment.c
@@ -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;
diff --git a/ident.c b/ident.c
index 9e24388..b3dcaaa 100644
--- a/ident.c
+++ b/ident.c
@@ -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)
--
1.7.2.2.409.gdbb11.dirty
^ permalink raw reply related [flat|nested] 19+ messages in thread
* Re: [PATCH] Introduce new configuation option to override committer information
2011-01-08 8:03 ` [PATCH] Introduce new configuation option to override committer information Ramkumar Ramachandra
@ 2011-01-08 19:24 ` Stephen Kelly
2011-01-09 10:29 ` [PATCH v2] " Ramkumar Ramachandra
0 siblings, 1 reply; 19+ messages in thread
From: Stephen Kelly @ 2011-01-08 19:24 UTC (permalink / raw)
To: git
Ramkumar Ramachandra wrote:
> 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.
>
> Reported-by: Stephen Kelly <steveire@gmail.com>
> Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.co
<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.
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH v2] Introduce new configuation option to override committer information
2011-01-08 19:24 ` Stephen Kelly
@ 2011-01-09 10:29 ` Ramkumar Ramachandra
2011-01-09 17:24 ` Jonathan Nieder
2011-01-20 11:16 ` Stephen Kelly
0 siblings, 2 replies; 19+ messages in thread
From: Ramkumar Ramachandra @ 2011-01-09 10:29 UTC (permalink / raw)
To: Git List; +Cc: Stephen Kelly, Thomas Rast, Erik Faye-Lund
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.
Reported-by: Stephen Kelly <steveire@gmail.com>
Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
---
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(-)
diff --git a/Documentation/config.txt b/Documentation/config.txt
index ff7c225..0b89cb6 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -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
diff --git a/builtin/blame.c b/builtin/blame.c
index aa30ec5..7fc4d56 100644
--- a/builtin/blame.c
+++ b/builtin/blame.c
@@ -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"
diff --git a/builtin/commit.c b/builtin/commit.c
index 22ba54f..4d0dcac 100644
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@ -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));
}
diff --git a/cache.h b/cache.h
index d83d68c..bf22df6 100644
--- a/cache.h
+++ b/cache.h
@@ -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)
diff --git a/config.c b/config.c
index 625e051..3032522 100644
--- a/config.c
+++ b/config.c
@@ -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;
}
diff --git a/environment.c b/environment.c
index 9564475..641d6ca 100644
--- a/environment.c
+++ b/environment.c
@@ -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;
diff --git a/ident.c b/ident.c
index 1c4adb0..1a616b7 100644
--- a/ident.c
+++ b/ident.c
@@ -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)
--
1.7.2.2.409.gdbb11.dirty
^ permalink raw reply related [flat|nested] 19+ messages in thread
* Re: [PATCH v2] Introduce new configuation option to override committer information
2011-01-09 10:29 ` [PATCH v2] " Ramkumar Ramachandra
@ 2011-01-09 17:24 ` Jonathan Nieder
2011-01-11 13:41 ` Stephen Kelly
2011-01-11 14:42 ` Thomas Rast
2011-01-20 11:16 ` Stephen Kelly
1 sibling, 2 replies; 19+ messages in thread
From: Jonathan Nieder @ 2011-01-09 17:24 UTC (permalink / raw)
To: Ramkumar Ramachandra; +Cc: Git List, Stephen Kelly, Thomas Rast, Erik Faye-Lund
Ramkumar Ramachandra wrote:
> 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:
> 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
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH v2] Introduce new configuation option to override committer information
2011-01-09 17:24 ` Jonathan Nieder
@ 2011-01-11 13:41 ` Stephen Kelly
2011-01-11 14:19 ` Ramkumar Ramachandra
2011-01-11 14:42 ` Thomas Rast
1 sibling, 1 reply; 19+ messages in thread
From: Stephen Kelly @ 2011-01-11 13:41 UTC (permalink / raw)
To: Jonathan Nieder
Cc: Ramkumar Ramachandra, Git List, Thomas Rast, Erik Faye-Lund
On Sun, Jan 9, 2011 at 6:24 PM, Jonathan Nieder <jrnieder@gmail.com> wrote:
> Ramkumar Ramachandra wrote:
>
>> 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.
>
> Stephen Kelly:
>
>> 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.
>
> Hopeful,
> Jonathan
>
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH v2] Introduce new configuation option to override committer information
2011-01-11 13:41 ` Stephen Kelly
@ 2011-01-11 14:19 ` Ramkumar Ramachandra
0 siblings, 0 replies; 19+ messages in thread
From: Ramkumar Ramachandra @ 2011-01-11 14:19 UTC (permalink / raw)
To: Stephen Kelly; +Cc: Jonathan Nieder, Git List, Thomas Rast, Erik Faye-Lund
Hi,
Stephen Kelly writes:
> On Sun, Jan 9, 2011 at 6:24 PM, Jonathan Nieder <jrnieder@gmail.com> wrote:
> > Ramkumar Ramachandra wrote:
> >
> >> 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.
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
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH v2] Introduce new configuation option to override committer information
2011-01-09 17:24 ` Jonathan Nieder
2011-01-11 13:41 ` Stephen Kelly
@ 2011-01-11 14:42 ` Thomas Rast
2011-01-20 19:00 ` Junio C Hamano
1 sibling, 1 reply; 19+ messages in thread
From: Thomas Rast @ 2011-01-11 14:42 UTC (permalink / raw)
To: Jonathan Nieder, Ramkumar Ramachandra
Cc: Git List, Stephen Kelly, Erik Faye-Lund
Jonathan Nieder wrote:
> Ramkumar Ramachandra wrote:
>
> > 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 author@example.com
git config --global user.committeremail committer@example.com
git config user.email user@example.com
Probably the user would expect this to result in a uniform
user@example.com 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.
--
Thomas Rast
trast@{inf,student}.ethz.ch
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH v2] Introduce new configuation option to override committer information
2011-01-09 10:29 ` [PATCH v2] " Ramkumar Ramachandra
2011-01-09 17:24 ` Jonathan Nieder
@ 2011-01-20 11:16 ` Stephen Kelly
2011-01-20 12:52 ` Thomas Rast
1 sibling, 1 reply; 19+ messages in thread
From: Stephen Kelly @ 2011-01-20 11:16 UTC (permalink / raw)
To: git
Ramkumar Ramachandra wrote:
> 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.
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH v2] Introduce new configuation option to override committer information
2011-01-20 11:16 ` Stephen Kelly
@ 2011-01-20 12:52 ` Thomas Rast
2011-01-20 15:24 ` Stephen Kelly
0 siblings, 1 reply; 19+ messages in thread
From: Thomas Rast @ 2011-01-20 12:52 UTC (permalink / raw)
To: Stephen Kelly; +Cc: git, Ramkumar Ramachandra, Erik Faye-Lund, Jonathan Nieder
Stephen Kelly wrote:
>
> 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
> > 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 <registered.email@example.com>
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/201101111542.15185.trast@student.ethz.ch
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.
--
Thomas Rast
trast@{inf,student}.ethz.ch
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH v2] Introduce new configuation option to override committer information
2011-01-20 12:52 ` Thomas Rast
@ 2011-01-20 15:24 ` Stephen Kelly
2011-01-20 19:19 ` Jonathan Nieder
0 siblings, 1 reply; 19+ messages in thread
From: Stephen Kelly @ 2011-01-20 15:24 UTC (permalink / raw)
To: Thomas Rast; +Cc: git, Ramkumar Ramachandra, Erik Faye-Lund, Jonathan Nieder
On Thu, Jan 20, 2011 at 1:52 PM, Thomas Rast <trast@student.ethz.ch> wrote:
> Stephen Kelly wrote:
>>
>> 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.
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 :)
>
> * Stating *why* this cannot be solved in any other way on the KDE
> end. So far you only said
>
> > > 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.
>
> My gut feeling is that a footer line in the commit along the lines
> of
>
> Bugzilla-Id: Registered Name <registered.email@example.com>
>
> 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.
>
> * Replying to e.g.
>
> http://mid.gmane.org/201101111542.15185.trast@student.ethz.ch
>
> 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.
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Wish: make commiter email address configurable per-repo
2011-01-07 13:23 ` Stephen Kelly
2011-01-07 13:43 ` Thomas Rast
@ 2011-01-20 18:44 ` Junio C Hamano
1 sibling, 0 replies; 19+ messages in thread
From: Junio C Hamano @ 2011-01-20 18:44 UTC (permalink / raw)
To: Stephen Kelly; +Cc: git
Stephen Kelly <steveire@gmail.com> writes:
> Thomas Rast wrote:
>
>> Stephen Kelly wrote:
>>> 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 "author@example.com"
>>
>> but there's nothing stopping you from doing
>>
>> git config user.email "alias@example.com"
>>
>> 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...?
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH v2] Introduce new configuation option to override committer information
2011-01-11 14:42 ` Thomas Rast
@ 2011-01-20 19:00 ` Junio C Hamano
0 siblings, 0 replies; 19+ messages in thread
From: Junio C Hamano @ 2011-01-20 19:00 UTC (permalink / raw)
To: Thomas Rast
Cc: Jonathan Nieder, Ramkumar Ramachandra, Git List, Stephen Kelly,
Erik Faye-Lund
Thomas Rast <trast@student.ethz.ch> writes:
> 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 author@example.com
> git config --global user.committeremail committer@example.com
> git config user.email user@example.com
>
> Probably the user would expect this to result in a uniform
> user@example.com 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.
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH v2] Introduce new configuation option to override committer information
2011-01-20 15:24 ` Stephen Kelly
@ 2011-01-20 19:19 ` Jonathan Nieder
0 siblings, 0 replies; 19+ messages in thread
From: Jonathan Nieder @ 2011-01-20 19:19 UTC (permalink / raw)
To: Stephen Kelly; +Cc: Thomas Rast, git, Ramkumar Ramachandra, Erik Faye-Lund
Stephen Kelly wrote:
> On Thu, Jan 20, 2011 at 1:52 PM, Thomas Rast <trast@student.ethz.ch> wrote:
>> My gut feeling is that a footer line in the commit along the lines
>> of
>>
>> Bugzilla-Id: Registered Name <registered.email@example.com>
>>
>> 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
^ permalink raw reply [flat|nested] 19+ messages in thread
end of thread, other threads:[~2011-01-20 19:21 UTC | newest]
Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-01-07 13:16 Wish: make commiter email address configurable per-repo Stephen Kelly
2011-01-07 13:20 ` Thomas Rast
2011-01-07 13:23 ` Stephen Kelly
2011-01-07 13:43 ` Thomas Rast
2011-01-07 18:01 ` Stephen Kelly
2011-01-07 18:19 ` Erik Faye-Lund
2011-01-20 18:44 ` Junio C Hamano
2011-01-08 8:03 ` [PATCH] Introduce new configuation option to override committer information Ramkumar Ramachandra
2011-01-08 19:24 ` Stephen Kelly
2011-01-09 10:29 ` [PATCH v2] " Ramkumar Ramachandra
2011-01-09 17:24 ` Jonathan Nieder
2011-01-11 13:41 ` Stephen Kelly
2011-01-11 14:19 ` Ramkumar Ramachandra
2011-01-11 14:42 ` Thomas Rast
2011-01-20 19:00 ` Junio C Hamano
2011-01-20 11:16 ` Stephen Kelly
2011-01-20 12:52 ` Thomas Rast
2011-01-20 15:24 ` Stephen Kelly
2011-01-20 19:19 ` Jonathan Nieder
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).