mirror of
https://github.com/git/git
synced 2024-08-28 20:20:07 +00:00
Merge branch 'jk/maint-send-email-alias-loop'
* jk/maint-send-email-alias-loop: send-email: detect cycles in alias expansion
This commit is contained in:
commit
e34bbd3b3c
|
@ -654,13 +654,17 @@ sub ask {
|
|||
}
|
||||
|
||||
sub expand_aliases {
|
||||
my @cur = @_;
|
||||
my @last;
|
||||
do {
|
||||
@last = @cur;
|
||||
@cur = map { $aliases{$_} ? @{$aliases{$_}} : $_ } @last;
|
||||
} while (join(',',@cur) ne join(',',@last));
|
||||
return @cur;
|
||||
return map { expand_one_alias($_) } @_;
|
||||
}
|
||||
|
||||
my %EXPANDED_ALIASES;
|
||||
sub expand_one_alias {
|
||||
my $alias = shift;
|
||||
if ($EXPANDED_ALIASES{$alias}) {
|
||||
die "fatal: alias '$alias' expands to itself\n";
|
||||
}
|
||||
local $EXPANDED_ALIASES{$alias} = 1;
|
||||
return $aliases{$alias} ? expand_aliases(@{$aliases{$alias}}) : $alias;
|
||||
}
|
||||
|
||||
@to = expand_aliases(@to);
|
||||
|
|
Loading…
Reference in a new issue