summaryrefslogtreecommitdiff
path: root/git-send-email.perl
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2009-07-25 07:44:45 (GMT)
committerJunio C Hamano <gitster@pobox.com>2009-07-25 07:44:45 (GMT)
commite34bbd3b3c3c12e4131e836486cb733fd1f7feed (patch)
treea829982362f6578b31ca2591f3e52b6c58167afb /git-send-email.perl
parent397f7c6371d309aa399bf32b773397f3c068d0c9 (diff)
parent302e04ea4d0c0414cedd716de882fa3dbe3480eb (diff)
downloadgit-e34bbd3b3c3c12e4131e836486cb733fd1f7feed.zip
git-e34bbd3b3c3c12e4131e836486cb733fd1f7feed.tar.gz
git-e34bbd3b3c3c12e4131e836486cb733fd1f7feed.tar.bz2
Merge branch 'jk/maint-send-email-alias-loop'
* jk/maint-send-email-alias-loop: send-email: detect cycles in alias expansion
Diffstat (limited to 'git-send-email.perl')
-rwxr-xr-xgit-send-email.perl18
1 files changed, 11 insertions, 7 deletions
diff --git a/git-send-email.perl b/git-send-email.perl
index 8ce6f1f..d508f83 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -654,13 +654,17 @@ if (!@to) {
}
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);