git@vger.kernel.org list mirror (unofficial, one of many)
 help / color / mirror / code / Atom feed
0766e1603288b18602619e20ff01b825647cfa4a blob 2206 bytes (raw)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
 
#!/usr/bin/perl
#

use 5.008;
use lib (split(/:/, $ENV{GITPERLLIB}));
use strict;
use warnings;
use Git::Packet;
use LWP::UserAgent;
use HTTP::Request::Common;

packet_initialize("git-read-object", 1);

my %remote_caps = packet_read_and_check_capabilities("get_raw_obj", "put_raw_obj");
packet_check_and_write_capabilities(\%remote_caps, "get_raw_obj", "put_raw_obj");

my $http_url = $ENV{HTTPD_URL};

while (1) {
	my ($res, $command) = packet_txt_read();

	if ( $res == -1 ) {
		exit 0;
	}

	$command =~ s/^command=//;

	if ( $command eq "init" ) {
		packet_bin_read();

		packet_txt_write("status=success");
		packet_flush();
	} elsif ( $command eq "get_raw_obj" ) {
		my ($sha1) = packet_txt_read() =~ /^sha1=([0-9a-f]{40})$/;
		packet_bin_read();

		my $get_url = $http_url . "/list/?sha1=" . $sha1;

		my $userAgent = LWP::UserAgent->new();

		my $response = $userAgent->get( $get_url );

		if ($response->is_error) {
		    packet_txt_write("size=0");
		    packet_txt_write("kind=none");	    
		    packet_txt_write("status=notfound");
		} else {
		    packet_txt_write("size=" . length($response->content));
		    packet_txt_write("kind=blob");
		    packet_bin_write($response->content);
		    packet_flush();
		    packet_txt_write("status=success");
		}

		packet_flush();
	} elsif ( $command eq "put_raw_obj" ) {
		my ($sha1) = packet_txt_read() =~ /^sha1=([0-9a-f]{40})$/;
		my ($size) = packet_txt_read() =~ /^size=([0-9]+)$/;
		my ($kind) = packet_txt_read() =~ /^kind=(\w+)$/;
		packet_bin_read();

		# We must read the content we are sent and send it to the right url
		my ($res, $buf) = packet_bin_read();
		die "bad packet_bin_read res ($res)" unless ($res eq 0);
		( packet_bin_read() eq ( 1, "" ) ) || die "bad send end";		

		my $upload_url = $http_url . "/upload/?sha1=" . $sha1 . "&size=" . $size . "&type=blob";

		my $userAgent = LWP::UserAgent->new();
		my $request = POST $upload_url, Content_Type => 'multipart/form-data', Content => $buf;

		my $response = $userAgent->request($request);

		if ($response->is_error) {
			packet_txt_write("status=failure");
		} else {
			packet_txt_write("status=success");
		}
		packet_flush();
	} else {
		die "bad command '$command'";
	}
}
debug log:

solving 0766e16032 ...
found 0766e16032 in https://public-inbox.org/git/20180319133147.15413-33-chriscool@tuxfamily.org/

applying [1/1] https://public-inbox.org/git/20180319133147.15413-33-chriscool@tuxfamily.org/
diff --git a/t/t0570/read-object-plain b/t/t0570/read-object-plain
new file mode 100755
index 0000000000..0766e16032

1:51: trailing whitespace.
		    packet_txt_write("kind=none");	    
1:71: trailing whitespace.
		( packet_bin_read() eq ( 1, "" ) ) || die "bad send end";		
Checking patch t/t0570/read-object-plain...
Applied patch t/t0570/read-object-plain cleanly.
warning: 2 lines add whitespace errors.

index at:
100755 0766e1603288b18602619e20ff01b825647cfa4a	t/t0570/read-object-plain

Code repositories for project(s) associated with this inbox:

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).