Merge branch 'sp/smart-http'
* sp/smart-http: (37 commits) http-backend: Let gcc check the format of more printf-type functions. http-backend: Fix access beyond end of string. http-backend: Fix bad treatment of uintmax_t in Content-Length t5551-http-fetch: Work around broken Accept header in libcurl t5551-http-fetch: Work around some libcurl versions http-backend: Protect GIT_PROJECT_ROOT from /../ requests Git-aware CGI to provide dumb HTTP transport http-backend: Test configuration options http-backend: Use http.getanyfile to disable dumb HTTP serving test smart http fetch and push http tests: use /dumb/ URL prefix set httpd port before sourcing lib-httpd t5540-http-push: remove redundant fetches Smart HTTP fetch: gzip requests Smart fetch over HTTP: client side Smart push over HTTP: client side Discover refs via smart HTTP server when available http-backend: more explict LocationMatch http-backend: add example for gitweb on same URL http-backend: use mod_alias instead of mod_rewrite ... Conflicts: .gitignore remote-curl.c
This commit is contained in:
@ -39,6 +39,8 @@ static unsigned int timeout;
|
||||
*/
|
||||
static int use_sideband;
|
||||
static int debug_fd;
|
||||
static int advertise_refs;
|
||||
static int stateless_rpc;
|
||||
|
||||
static void reset_timeout(void)
|
||||
{
|
||||
@ -500,7 +502,7 @@ static int get_common_commits(void)
|
||||
{
|
||||
static char line[1000];
|
||||
unsigned char sha1[20];
|
||||
char hex[41], last_hex[41];
|
||||
char last_hex[41];
|
||||
|
||||
save_commit_buffer = 0;
|
||||
|
||||
@ -511,25 +513,30 @@ static int get_common_commits(void)
|
||||
if (!len) {
|
||||
if (have_obj.nr == 0 || multi_ack)
|
||||
packet_write(1, "NAK\n");
|
||||
if (stateless_rpc)
|
||||
exit(0);
|
||||
continue;
|
||||
}
|
||||
strip(line, len);
|
||||
if (!prefixcmp(line, "have ")) {
|
||||
switch (got_sha1(line+5, sha1)) {
|
||||
case -1: /* they have what we do not */
|
||||
if (multi_ack && ok_to_give_up())
|
||||
packet_write(1, "ACK %s continue\n",
|
||||
sha1_to_hex(sha1));
|
||||
if (multi_ack && ok_to_give_up()) {
|
||||
const char *hex = sha1_to_hex(sha1);
|
||||
if (multi_ack == 2)
|
||||
packet_write(1, "ACK %s ready\n", hex);
|
||||
else
|
||||
packet_write(1, "ACK %s continue\n", hex);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
memcpy(hex, sha1_to_hex(sha1), 41);
|
||||
if (multi_ack) {
|
||||
const char *msg = "ACK %s continue\n";
|
||||
packet_write(1, msg, hex);
|
||||
memcpy(last_hex, hex, 41);
|
||||
}
|
||||
memcpy(last_hex, sha1_to_hex(sha1), 41);
|
||||
if (multi_ack == 2)
|
||||
packet_write(1, "ACK %s common\n", last_hex);
|
||||
else if (multi_ack)
|
||||
packet_write(1, "ACK %s continue\n", last_hex);
|
||||
else if (have_obj.nr == 1)
|
||||
packet_write(1, "ACK %s\n", hex);
|
||||
packet_write(1, "ACK %s\n", last_hex);
|
||||
break;
|
||||
}
|
||||
continue;
|
||||
@ -589,7 +596,9 @@ static void receive_needs(void)
|
||||
get_sha1_hex(line+5, sha1_buf))
|
||||
die("git upload-pack: protocol error, "
|
||||
"expected to get sha, not '%s'", line);
|
||||
if (strstr(line+45, "multi_ack"))
|
||||
if (strstr(line+45, "multi_ack_detailed"))
|
||||
multi_ack = 2;
|
||||
else if (strstr(line+45, "multi_ack"))
|
||||
multi_ack = 1;
|
||||
if (strstr(line+45, "thin-pack"))
|
||||
use_thin_pack = 1;
|
||||
@ -683,7 +692,7 @@ static int send_ref(const char *refname, const unsigned char *sha1, int flag, vo
|
||||
{
|
||||
static const char *capabilities = "multi_ack thin-pack side-band"
|
||||
" side-band-64k ofs-delta shallow no-progress"
|
||||
" include-tag";
|
||||
" include-tag multi_ack_detailed";
|
||||
struct object *o = parse_object(sha1);
|
||||
|
||||
if (!o)
|
||||
@ -707,12 +716,32 @@ static int send_ref(const char *refname, const unsigned char *sha1, int flag, vo
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int mark_our_ref(const char *refname, const unsigned char *sha1, int flag, void *cb_data)
|
||||
{
|
||||
struct object *o = parse_object(sha1);
|
||||
if (!o)
|
||||
die("git upload-pack: cannot find object %s:", sha1_to_hex(sha1));
|
||||
if (!(o->flags & OUR_REF)) {
|
||||
o->flags |= OUR_REF;
|
||||
nr_our_refs++;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void upload_pack(void)
|
||||
{
|
||||
reset_timeout();
|
||||
head_ref(send_ref, NULL);
|
||||
for_each_ref(send_ref, NULL);
|
||||
packet_flush(1);
|
||||
if (advertise_refs || !stateless_rpc) {
|
||||
reset_timeout();
|
||||
head_ref(send_ref, NULL);
|
||||
for_each_ref(send_ref, NULL);
|
||||
packet_flush(1);
|
||||
} else {
|
||||
head_ref(mark_our_ref, NULL);
|
||||
for_each_ref(mark_our_ref, NULL);
|
||||
}
|
||||
if (advertise_refs)
|
||||
return;
|
||||
|
||||
receive_needs();
|
||||
if (want_obj.nr) {
|
||||
get_common_commits();
|
||||
@ -734,6 +763,14 @@ int main(int argc, char **argv)
|
||||
|
||||
if (arg[0] != '-')
|
||||
break;
|
||||
if (!strcmp(arg, "--advertise-refs")) {
|
||||
advertise_refs = 1;
|
||||
continue;
|
||||
}
|
||||
if (!strcmp(arg, "--stateless-rpc")) {
|
||||
stateless_rpc = 1;
|
||||
continue;
|
||||
}
|
||||
if (!strcmp(arg, "--strict")) {
|
||||
strict = 1;
|
||||
continue;
|
||||
|
||||
Reference in New Issue
Block a user