git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] Make git-remote.perl "use strict" compliant

From
RGRafael Garcia-Suarez <rgarciasuarez@gmail.com>
Date
Feb 4, 2008, 10:09 UTC
Message-ID
<b77c1dce0802040209m11ad0ba7w67d07aee6fc4bccb@mail.gmail.com>

I was looking at some of the perl commands, and noticed that git-remote was the only one to lack a 'use strict' pragma at the top, which could be a good thing for its maintainability. Hopefully, the required changes are minimal.

Make git-remote.perl "use strict" compliant
Signed-off-by: Rafael Garcia-Suarez <rgarciasuarez@gmail.com>
---
 git-remote.perl |   10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/git-remote.perl b/git-remote.perl
index d13e4c1..5cd6951 100755
--- a/git-remote.perl
+++ b/git-remote.perl
@@ -1,5 +1,6 @@
 #!/usr/bin/perl -w

+use strict;
 use Git;
 my $git = Git->repository();

@@ -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]);
 	}
 }
Message 1 of 1 in “Make git-remote.perl "use strict" compliant”
  1. Make git-remote.perl "use strict" compliantRafael Garcia-Suarez, Feb 4, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.