From patchwork Thu Nov 20 21:51:06 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: 412886 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 8F1A514010F for ; Fri, 21 Nov 2014 08:51:27 +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=l1xozZtUhzfAfSrmC JGBB5PmtxCuuzGwNJTIR7yJdqAoQs1epgZFEGgrKZCw/P5Otjwk5qJBHONlKUivs fB9rWo+VBWImXCydTcVeslUf1f+MjYBJaPbVmKTlJVa8I9oS4iO9Y0Dm4m9z/sK1 wtzmO0qvKOCvs9X//zzy1y4QMU= 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=7HcFdMotITtTKUpVOVmvw0q +iqE=; b=YD47ndBUXYav1gKb7MUZfQI9p1uSMC9mG2I3F/oVdY1cbYTOG+3Zoci Zbt9LC2IOd9lBywxPVRGvm2+qF/9ymLdHDG3GmElTFuMF+UMfV2Yj1TboZ68mVGT PWRCjyEEQiujll+0SQIB4jXjQxiHgOszKBtsCch0Ti3yHHSZbm4c= Received: (qmail 1682 invoked by alias); 20 Nov 2014 21:51:20 -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 1665 invoked by uid 89); 20 Nov 2014 21:51:19 -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 21:51:18 +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 1XrZd9-00072u-ET from Tom_deVries@mentor.com ; Thu, 20 Nov 2014 13:51:11 -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 21:51:09 +0000 Message-ID: <546E624A.8020408@mentor.com> Date: Thu, 20 Nov 2014 22:51:06 +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: Segher Boessenkool , 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> <546E153C.2000907@mentor.com> <20141120164316.GA32581@gate.crashing.org> In-Reply-To: <20141120164316.GA32581@gate.crashing.org> On 20-11-14 17:43, Segher Boessenkool wrote: > On Thu, Nov 20, 2014 at 05:22:20PM +0100, Tom de Vries wrote: >> +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*$/) { > > The final \s* never matches anything since the .* gobbles up everything. > Use .*? if you really want to get rid of the trailing whitespace. > Thanks for spotting that, patch updated. OK for trunk? Thanks, - Tom > > Segher > 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..f7974a7 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