[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: svn commit: rev 2390 - trunk/tools/hook-scripts

From: Branko Čibej <brane_at_xbc.nu>
Date: 2002-07-02 11:45:55 CEST

blair@tigris.org wrote:

>Author: blair
>Date: Tue, 02 Jul 2002 01:14:53 -0500
>New Revision: 2390
>
>Modified:
> trunk/tools/hook-scripts/commit-email.pl
>Log:
>* tools/hook-scripts/commit-email.pl:
>
[snip]

>+# Use the reference to the first project to populate.
>+my $current_project = $project_settings_list[0];
>+
>+while (@ARGV) {
>+ my $arg = shift @ARGV;
>+ if (my ($opt) = $arg =~ /^-([hlmrs])/) {
>+ unless (@ARGV) {
>+ die "$0: command line option `$arg' is missing a value.\n";
>+ }
>+ my $value = shift @ARGV;
>+ SWITCH: {
>+ $current_project->{hostname} = $value, last SWITCH if $opt eq 'h';
>+ $current_project->{log_file} = $value, last SWITCH if $opt eq 'l';
>+ $current_project->{reply_to} = $value, last SWITCH if $opt eq 'r';
>+ $current_project->{subject_prefix} = $value, last SWITCH if $opt eq 's';
>+
>+ # Here handle -match.
>+ unless ($opt eq 'm') {
>+ die "$0: internal error: should only handle -m here.\n";
>+ }
>+ $current_project = dclone($blank_settings);
>+ $current_project->{match_regex} = $value;
>+ push(@project_settings_list, $current_project);
>

I think there's a bug here. If $current_project->{email_addresses} is
empty, this'll push a useless entry on the @project_settings_list. And
this will always happen if you start with an -m option, because you
initialized the list with emtpy email_addresses.

I think the logic should be different: create a new list entry when
_any_ option is seen, if the current entries email_addresses list is not
empty:

  if (my ($opt) = $arg =~ /^-([hlmrs])/) {
    unless (@ARGV) {
      die "$0: command line option `$arg' is missing a value.\n";
    }
    if (scalar $current_project->{email_addresses}) {
      $current_project = dclone($blank_settings);
      push(@project_settings_list, $current_project);
    }
    my $value = shift @ARGV;
    SWITCH: {
      $current_project->{hostname} = $value, last SWITCH if $opt eq 'h';
      $current_project->{log_file} = $value, last SWITCH if $opt eq 'l';
      $current_project->{reply_to} = $value, last SWITCH if $opt eq 'r';
      $current_project->{subject_prefix} = $value, last SWITCH if $opt eq 's';
      $current_project->{match_regex} = $value, last SWITCH if $opt eq 'm';

      die "$0: internal error: don't know how to handle -$opt here.\n";
    }

-- 
Brane Čibej   <brane_at_xbc.nu>   http://www.xbc.nu/brane/
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Tue Jul 2 11:46:54 2002

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.