summaryrefslogtreecommitdiff
path: root/git-send-email.perl
diff options
context:
space:
mode:
authorLibravatar Junio C Hamano <gitster@pobox.com>2009-07-25 00:44:45 -0700
committerLibravatar Junio C Hamano <gitster@pobox.com>2009-07-25 00:44:45 -0700
commite34bbd3b3c3c12e4131e836486cb733fd1f7feed (patch)
treea829982362f6578b31ca2591f3e52b6c58167afb /git-send-email.perl
parentShow the presence of untracked files in the bash prompt. (diff)
parentsend-email: detect cycles in alias expansion (diff)
downloadtgif-e34bbd3b3c3c12e4131e836486cb733fd1f7feed.tar.xz
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 8ce6f1fe57..d508f83349 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);