Sync with 1.7.0 series
[gitweb.git] / contrib / examples / git-remote.perl
index 5cd69513cf84111d1152d07f8cda77b201ffc416..b17952a785d9e45dea8a71c211f76f0271e659da 100755 (executable)
@@ -7,10 +7,10 @@
 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'} ||= [];
@@ -129,10 +129,7 @@ sub update_ls_remote {
        return if (($harder == 0) ||
                   (($harder == 1) && exists $info->{'LS_REMOTE'}));
 
-       my @ref = map {
-               s|^[0-9a-f]{40}\s+refs/heads/||;
-               $_;
-       } $git->command(qw(ls-remote --heads), $info->{'URL'});
+       my @ref = map { s|refs/heads/||; $_; } keys %{$git->remote_refs($info->{'URL'}, [ 'heads' ])};
        $info->{'LS_REMOTE'} = \@ref;
 }
 
@@ -312,7 +309,7 @@ sub update_remote {
                        }
                }
        } else {
-               print STDERR "Remote group $name does not exists.\n";
+               print STDERR "Remote group $name does not exist.\n";
                exit(1);
        }
        for (@remotes) {