aboutsummaryrefslogtreecommitdiffstats
path: root/Perl
diff options
context:
space:
mode:
authorLaura Arjona Reina <larjona>2017-11-07 16:28:34 +0000
committerLaura Arjona Reina <larjona>2017-11-07 16:28:34 +0000
commit39b85ef5ff421f26ad651e2cd8d3ef6a1ad5b0e3 (patch)
tree21105c90d3b3aa9ba553014a13e708860476c9b3 /Perl
parent68d5f76698e7d6218dcb276bb69059dccfc960ec (diff)
we don't need git checkouts, we can use git show <hash>:<pathname> to get the content of the file for a certain revision
CVS version numbers Perl/Local/VCS_git.pm: 1.11 -> 1.12
Diffstat (limited to 'Perl')
-rw-r--r--Perl/Local/VCS_git.pm22
1 files changed, 6 insertions, 16 deletions
diff --git a/Perl/Local/VCS_git.pm b/Perl/Local/VCS_git.pm
index ca21a7f27b7..cfa5affef03 100644
--- a/Perl/Local/VCS_git.pm
+++ b/Perl/Local/VCS_git.pm
@@ -440,7 +440,7 @@ Example use:
my $text = vcs_get_file( 'foo.c', '1.12' );
-FIXME: converted to use git checkouts. Assumes we provide in $file the complete path. Needs review and test
+FIXME: converted to use git show <commit>:<pathname>. Assumes we provide in $file the complete path. Needs review and test
=cut
@@ -451,30 +451,20 @@ sub vcs_get_file
croak( "No such file: $file" ) unless -f $file;
- #TODO: what happens if we're not in the root webwml dir?
- my $command1 = sprintf( 'git -q checkout %s', $rev );
- my $command2 = sprintf( 'cat %s', $file );
- my $command3 = sprintf( 'git -q checkout origin/master');
+ my $command = sprintf( 'git show %s:%s',
+ $rev, $file );
my $text;
- open ( my $git1, '-|', $command1 )
+ open ( my $git, '-|', $command1 )
or croak("Error while executing `$command1': $!");
- close( $git1 );
- open ( my $git2, '-|', $command2 )
- or croak("Error while executing `$command2': $!");
- while ( my $line = <$git2> )
+ while ( my $line = <$git> )
{
$text .= $line;
}
- close( $git2 );
+ close( $git );
croak("Error while executing `$command': $!") unless WIFEXITED($?);
- # return to git master
- open ( my $git3, '-|', $command3 )
- or croak("Error while executing `$command3': $!");
- close( $git3 );
-
# return the file
return $text;
}

© 2014-2024 Faster IT GmbH | imprint | privacy policy