This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH 1/2] teach mklog to get name / email from git config when available
- From: Peter Bergner <bergner at vnet dot ibm dot com>
- To: segher at kernel dot crashing dot org
- Cc: tsaunders at mozilla dot com, gcc-patches at gcc dot gnu dot org, dnovillo at google dot com, Trevor Saunders <tbsaunde at mozilla dot com>
- Date: Tue, 29 Apr 2014 14:16:36 -0500
- Subject: Re: [PATCH 1/2] teach mklog to get name / email from git config when available
- Authentication-results: sourceware.org; auth=none
- References: <1398737468-6981-1-git-send-email-tsaunders at mozilla dot com> <1398737468-6981-2-git-send-email-tsaunders at mozilla dot com> <20140429153900 dot GA3930 at gate dot crashing dot org>
On Tue, 2014-04-29 at 10:39 -0500, segher@kernel.crashing.org wrote:
> > +# if this is a git tree then take name and email from the git configuration
> > +if (-d .git) {
> > + $gitname = `git config user.name`;
> > + chomp($gitname);
> > + if ($gitname) {
> > + $name = $gitname;
> > + }
> > +
> > + $gitaddr = `git config user.email`;
> > + chomp($gitaddr);
> > + if ($gitaddr) {
> > + $addr = $gitaddr;
> > + }
> > +}
>
> "-d .git" is, erm, not so great.
>
> How about something like
>
> sub get_git_config {
> my $res = `git config --get @_`;
> return undef if $?;
> chomp $res;
> return $res;
> }
I've always used a hacked up version that reads a ~/.mklog config
file for the name and email address to use. Ala:
[bergner@otta ~]$ cat ~/.mklog
NAME = Peter Bergner
EMAIL = bergner@vnet.ibm.com
my $conf = "$ENV{HOME}/.mklog";
if (-f "$conf")
{
open (CONF, "$conf")
or die "Could not open file '$conf' for reading: $!\n";
while (<CONF>)
{
if (m/^\s*NAME\s*=\s*(.*)\s*$/)
{
$name = $1;
}
elsif (m/^\s*EMAIL\s*=\s*(.*)\s*$/)
{
$addr = $1;
}
}
}
Peter