From: Tom de Vries Date: Tue, 25 Nov 2014 16:45:13 +0000 (+0000) Subject: Use .mklog name and email settings, or git settings X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=fdb424cfea0d021be66d0e335ff7e72c504acbc5;p=gcc.git Use .mklog name and email settings, or git settings 2014-11-25 Tom de Vries Peter Bergner * mklog: Handle .mklog. Use git setting independent of presence .git directory. Co-Authored-By: Peter Bergner From-SVN: r218050 --- diff --git a/contrib/ChangeLog b/contrib/ChangeLog index 60257c48e07..77bad5a9cff 100644 --- a/contrib/ChangeLog +++ b/contrib/ChangeLog @@ -1,3 +1,9 @@ +2014-11-25 Tom de Vries + Peter Bergner + + * mklog: Handle .mklog. Use git setting independent of presence .git + directory. + 2014-11-14 Tom de Vries * mklog: Move reading of .diff file up and add comment. Copy diff_lines diff --git a/contrib/mklog b/contrib/mklog index 840f6f8c266..f7974a7bd15 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.