Re: git-update-ref (reflog) uses bogus author ident information

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Jakub Narebski <jnareb@xxxxxxxxx> wrote:
> git-log reports 
> 
>   commit 059111c9381ce1444d17c8fc35606b0aa417ca42
>   Author: Jakub Narebski <jnareb@xxxxxxxxx>
>   Date:   Sat Jul 8 18:52:35 2006 +0200
>   
>       configure.ac vertical whitespace usage cleanup
>  
> git-var -l shows:
> 
>  GIT_COMMITTER_IDENT=Jakub Narebski <jnareb@xxxxxxxxx> 1152564452 +0200
>  GIT_AUTHOR_IDENT=Jakub Narebski <jnareb@xxxxxxxxx> 1152564452 +0200
> 
> BUT in git/.git/logs/refs/heads/autoconf I have (broken into lines):
>   fe7b45a419ae62ed96148d98f6aba8710a6f6245
>   059111c9381ce1444d17c8fc35606b0aa417ca42 
>   Jakub Narebski <jnareb@xxxxxxxxxx> 1152377555 +0200   
>   commit: configure.ac vertical whitespace usage cleanu
> 
> where "roke.D-201" are results of "hostname -f" on my computer, and are
> suitable _only_ for my small private local network.
> 
> Bug or a feature?

This is definately a bug.  The reflog uses the same ident code
that commit-tree uses, with the idea that GIT_COMMITTER_IDENT would
drive the entry in the reflog, as you expected it to.

Looking in refs.c at log_ref_write its invoking setup_ident()
then git_committer_info(1).  git_committer_info should be using
the environment variables (GIT_COMMITTER_NAME, GIT_COMMITTER_EMAIL,
GIT_COMMITTER_DATE) with defaults back to the gecos values.  Based
on that it would seem that the user data in .git/config is being
ignored...  Hm.

So you must be expecting .git/config to be supplying your data but
its getting overrwritten by setup_ident() in log_ref_write.

Here's the bug fix.  Sorry about that one.  That bug has been in
there since the reflog code was first put into GIT.  :-)

-->--
Allow user.name and user.email to drive reflog entry.

Apparently calling setup_ident() after git_config causes the
user.name and user.email values read from the config file to be
replaced with the data obtained from the host.  This means that
users who have setup their email address in user.email will instead
be writing reflog entries with their hostname.

Moving setup_ident() to before git_config in update-ref resolves
this ordering problem.
---
 builtin-update-ref.c |    1 +
 refs.c               |    1 -
 2 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/builtin-update-ref.c b/builtin-update-ref.c
index 00333c7..83094ab 100644
--- a/builtin-update-ref.c
+++ b/builtin-update-ref.c
@@ -12,6 +12,7 @@ int cmd_update_ref(int argc, const char 
 	unsigned char sha1[20], oldsha1[20];
 	int i;
 
+	setup_ident();
 	setup_git_directory();
 	git_config(git_default_config);
 
diff --git a/refs.c b/refs.c
index 2d9c1dc..56db394 100644
--- a/refs.c
+++ b/refs.c
@@ -379,7 +379,6 @@ static int log_ref_write(struct ref_lock
 			lock->log_file, strerror(errno));
 	}
 
-	setup_ident();
 	committer = git_committer_info(1);
 	if (msg) {
 		maxlen = strlen(committer) + strlen(msg) + 2*40 + 5;
-- 
1.4.1.gc48f

-
: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]