diff options
-rwxr-xr-x | bin/git-push-all | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/bin/git-push-all b/bin/git-push-all index 8178ea70..cdab5bf0 100755 --- a/bin/git-push-all +++ b/bin/git-push-all @@ -53,6 +53,8 @@ my ($pushDefault) my %pushes; +my $dry_run = grep $_ eq "-n", @ARGV; + foreach my $branch (@local_branches) { (my $short_branch = $branch) =~ s#^refs/heads/##; my ($pushRemote) = $git->config(qw|--local --get --default|, @@ -68,17 +70,20 @@ foreach my $branch (@local_branches) { # push unless the branch already exists on the remote: this script # avoids creating new branches if ($pushRemote) { - # say "I: pushing $short_branch to $pushRemote (its pushRemote)"; + say "I: would push $short_branch to $pushRemote (its pushRemote)" + if $dry_run; push $pushes{$pushRemote}->@*, $branch; } elsif ($pushDefault and exists $remote_branches{"refs/remotes/$pushDefault/$short_branch"}) { - # say "I: pushing $short_branch to $pushDefault (the remote.pushDefault)"; + say "I: would push $short_branch to $pushDefault (the remote.pushDefault)" + if $dry_run; push $pushes{$pushDefault}->@*, $branch; } elsif (!$pushDefault and $tracking and !$need_pull_tracking and exists $remote_branches{$tracking}) { - # say "I: pushing $short_branch to its tracking branch, $tracking"; + say "I: would push $short_branch to its tracking branch, $tracking" + if $dry_run; push $pushes{$tracking_remote}->@*, $branch; } elsif (!$need_pull_tracking) { say "W: couldn't find anywhere to push $branch"; @@ -86,6 +91,8 @@ foreach my $branch (@local_branches) { } } +$dry_run and exit; + foreach my $remote (keys %pushes) { # TODO if $remote eq $pushDefault, consider s/follow-// below (and # pushRemote of master branch, if that exists?) |