From patchwork Thu Nov 20 16:22:20 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom de Vries X-Patchwork-Id: 412775 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id BE6311400B7 for ; Fri, 21 Nov 2014 03:22:56 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:cc:subject:references :in-reply-to:content-type; q=dns; s=default; b=uYXL50Vt4DuEEyNpX lUi07ydHibxXqD8XM66MMzi2/UGxZfs+HWJpyUyVyVY5OR96Q/MSZy13pDageg5g zmoQzq9qwTLxUQyhtdLeCkwBp+BN0a5CL/6Aw3iCrTruKcLOwBd3o2gOPTDbIcQG fxuKiA51wxQm9GhzFikaYml7IY= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:cc:subject:references :in-reply-to:content-type; s=default; bh=hI11Qdy3Whu9wiEUAEZd5bh JNSM=; b=t+nPn3tRVCzpZDkYHzancDVM2EtK3aJl+NidYENgiEaGC0NNADY34NN sPlaXEyQWCzI6JjUBQ7ZP35IfyvUQ/oiviVjs1/rcnhsxNbilOvclreU1QSirrhL vrqCunzuwkpsFVDoSRDH4nQaNUGEJl2VO46AvM3sMTo1HrppPW40= Received: (qmail 7427 invoked by alias); 20 Nov 2014 16:22:30 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 7363 invoked by uid 89); 20 Nov 2014 16:22:30 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 X-HELO: relay1.mentorg.com Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 20 Nov 2014 16:22:28 +0000 Received: from nat-ies.mentorg.com ([192.94.31.2] helo=SVR-IES-FEM-01.mgc.mentorg.com) by relay1.mentorg.com with esmtp id 1XrUUx-0007MQ-AQ from Tom_deVries@mentor.com ; Thu, 20 Nov 2014 08:22:23 -0800 Received: from [127.0.0.1] (137.202.0.76) by SVR-IES-FEM-01.mgc.mentorg.com (137.202.0.104) with Microsoft SMTP Server id 14.3.181.6; Thu, 20 Nov 2014 16:22:21 +0000 Message-ID: <546E153C.2000907@mentor.com> Date: Thu, 20 Nov 2014 17:22:20 +0100 From: Tom de Vries User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.2.0 MIME-Version: 1.0 To: Diego Novillo CC: Peter Bergner , gcc-patches Subject: Re: [PATCH 1/2] teach mklog to get name / email from git config when available References: <1398737468-6981-1-git-send-email-tsaunders@mozilla.com> <1398737468-6981-2-git-send-email-tsaunders@mozilla.com> In-Reply-To: On 09-05-14 16:47, Diego Novillo wrote: > I would probably use git config directly here. It would work with both > git and svn checkouts (if you have a global .git configuration). But > testing for .git is fine with me as well. > > I like Peter's idea of having a ~/.mklog file to override. This would > work for both svn and git checkouts. > Diego, this patch implements both: - it uses the ~/.mklog file proposed by Peter - in absence of a ~/.mklog file, it uses git config, also when not in a git repository OK? Thanks, - Tom 2014-11-20 Tom de Vries Peter Bergner * mklog: Handle .mklog. Use git setting independent of presence .git directory. --- contrib/mklog | 56 +++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 35 insertions(+), 21 deletions(-) diff --git a/contrib/mklog b/contrib/mklog index 840f6f8..abbf0af 100755 --- a/contrib/mklog +++ b/contrib/mklog @@ -29,32 +29,46 @@ use File::Temp; use File::Copy qw(cp mv); -# Change these settings to reflect your profile. -$username = $ENV{'USER'}; -$name = `finger $username | grep -o 'Name: .*'`; -@n = split(/: /, $name); -$name = $n[1]; chop($name); -$addr = $username . "\@my.domain.org"; $date = `date +%Y-%m-%d`; chop ($date); +$dot_mklog_format_msg = + "The .mklog format is:\n" + . "NAME = ...\n" + . "EMAIL = ...\n"; + +# Create a .mklog to reflect your profile, if necessary. +my $conf = "$ENV{HOME}/.mklog"; +if (-f "$conf") { + open (CONF, "$conf") + or die "Could not open file '$conf' for reading: $!\n"; + while () { + if (m/^\s*NAME\s*=\s*(.*)\s*$/) { + $name = $1; + } elsif (m/^\s*EMAIL\s*=\s*(.*)\s*$/) { + $addr = $1; + } + } + if (!($name && $addr)) { + die "Could not read .mklog settings.\n" + . $dot_mklog_format_msg; + } +} else { + $name = `git config user.name`; + chomp($name); + $addr = `git config user.email`; + chomp($addr); + + if (!($name && $addr)) { + die "Could not read git user.name and user.email settings.\n" + . "Please add missing git settings, or create a .mklog file in" + . " $ENV{HOME}.\n" + . $dot_mklog_format_msg; + } +} + $gcc_root = $0; $gcc_root =~ s/[^\\\/]+$/../; -# if this is a git tree then take name and email from the git configuration -if (-d "$gcc_root/.git") { - $gitname = `git config user.name`; - chomp($gitname); - if ($gitname) { - $name = $gitname; - } - - $gitaddr = `git config user.email`; - chomp($gitaddr); - if ($gitaddr) { - $addr = $gitaddr; - } -} - #----------------------------------------------------------------------------- # Program starts here. You should not need to edit anything below this # line. -- 1.9.1