git-svn: Don't rely on $_ after making a function call
Many functions and operators in perl set $_, so its value cannot be relied upon after calling arbitrary functions. The solution is simply to copy the value of $_ into a local variable that will not get overwritten. Signed-off-by: Adam Roben <aroben@apple.com> Acked-by: Eric Wong <normalperson@yhbt.net> Signed-off-by: Junio C Hamano <junkio@cox.net>
Adam Roben committed
Apr 25, 2007 at 11:50 UTC
b03c7a63a0fae58a576749d7a6b0507edde12584
1 file changed
+5
-5
git-svn.perl
+5
-5
@@ -771,19 +771,19 @@ sub cmt_metadata {
771
sub working_head_info {
772
my ($head, $refs) = @_;
773
my ($fh, $ctx) = command_output_pipe('rev-list', $head);
774
- while (<$fh>) {
775
- chomp;
776
- my ($url, $rev, $uuid) = cmt_metadata($_);
774
+ while (my $hash = <$fh>) {
775
+ chomp($hash);
776
+ my ($url, $rev, $uuid) = cmt_metadata($hash);
777
if (defined $url && defined $rev) {
778
if (my $gs = Git::SVN->find_by_url($url)) {
779
my $c = $gs->rev_db_get($rev);
780
- if ($c && $c eq $_) {
780
+ if ($c && $c eq $hash) {
781
close $fh; # break the pipe
782
return ($url, $rev, $uuid, $gs);
783
}
784
}
785
}
786
- unshift @$refs, $_ if $refs;
786
+ unshift @$refs, $hash if $refs;
787
}
788
command_close_pipe($fh, $ctx);
789
(undef, undef, undef, undef);