Code

fetch-pack: check parse_commit/object results
[git.git] / git-remote.perl
index d13e4c1fea93f0c345f6638bfd8a3715c73fa693..b30ed734e7102b6a5d88c01364fa7d18db8f8bfe 100755 (executable)
@@ -1,15 +1,16 @@
 #!/usr/bin/perl -w
 
+use strict;
 use Git;
 my $git = Git->repository();
 
 sub add_remote_config {
        my ($hash, $name, $what, $value) = @_;
        if ($what eq 'url') {
-               if (exists $hash->{$name}{'URL'}) {
-                       print STDERR "Warning: more than one remote.$name.url\n";
+               # Having more than one is Ok -- it is used for push.
+               if (! exists $hash->{'URL'}) {
+                       $hash->{$name}{'URL'} = $value;
                }
-               $hash->{$name}{'URL'} = $value;
        }
        elsif ($what eq 'fetch') {
                $hash->{$name}{'FETCH'} ||= [];
@@ -296,12 +297,13 @@ sub add_remote {
 
 sub update_remote {
        my ($name) = @_;
+       my @remotes;
 
         my $conf = $git->config("remotes." . $name);
        if (defined($conf)) {
                @remotes = split(' ', $conf);
        } elsif ($name eq 'default') {
-               undef @remotes;
+               @remotes = ();
                for (sort keys %$remote) {
                        my $do_fetch = $git->config_bool("remote." . $_ .
                                                    ".skipDefaultUpdate");
@@ -341,7 +343,7 @@ sub rm_remote {
        my @refs = $git->command('for-each-ref',
                '--format=%(refname) %(objectname)', "refs/remotes/$name");
        for (@refs) {
-               ($ref, $object) = split;
+               my ($ref, $object) = split;
                $git->command(qw(update-ref -d), $ref, $object);
        }
        return 0;
@@ -352,7 +354,7 @@ sub add_usage {
        exit(1);
 }
 
-local $VERBOSE = 0;
+my $VERBOSE = 0;
 @ARGV = grep {
        if ($_ eq '-v' or $_ eq '--verbose') {
                $VERBOSE=1;
@@ -395,7 +397,7 @@ elsif ($ARGV[0] eq 'update') {
                update_remote("default");
                exit(1);
        }
-       for ($i = 1; $i < @ARGV; $i++) {
+       for (my $i = 1; $i < @ARGV; $i++) {
                update_remote($ARGV[$i]);
        }
 }