From: Junio C Hamano Date: Fri, 11 Dec 2009 00:20:59 +0000 (-0800) Subject: Sync with 1.6.5.6 X-Git-Tag: v1.6.6-rc3~4 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/4cb51a65a478ff005630d8806d01cd76a8889faf?hp=-c Sync with 1.6.5.6 Signed-off-by: Junio C Hamano --- 4cb51a65a478ff005630d8806d01cd76a8889faf diff --combined Documentation/git.txt index ad6037baa0,c1fcfffebd..3d0cbf63ed --- a/Documentation/git.txt +++ b/Documentation/git.txt @@@ -10,7 -10,7 +10,7 @@@ SYNOPSI -------- [verse] 'git' [--version] [--exec-path[=GIT_EXEC_PATH]] [--html-path] - [-p|--paginate|--no-pager] + [-p|--paginate|--no-pager] [--no-replace-objects] [--bare] [--git-dir=GIT_DIR] [--work-tree=GIT_WORK_TREE] [--help] COMMAND [ARGS] @@@ -43,9 -43,10 +43,10 @@@ unreleased) version of git, that is ava branch of the `git.git` repository. Documentation for older releases are available here: - * link:v1.6.5.5/git.html[documentation for release 1.6.5.5] + * link:v1.6.5.6/git.html[documentation for release 1.6.5.6] * release notes for + link:RelNotes-1.6.5.6.txt[1.6.5.6], link:RelNotes-1.6.5.5.txt[1.6.5.5], link:RelNotes-1.6.5.4.txt[1.6.5.4], link:RelNotes-1.6.5.3.txt[1.6.5.3], @@@ -242,10 -243,6 +243,10 @@@ help ...` environment is not set, it is set to the current working directory. +--no-replace-objects:: + Do not use replacement refs to replace git objects. See + linkgit:git-replace[1] for more information. + FURTHER DOCUMENTATION --------------------- diff --combined Documentation/githooks.txt index 4cc3d1387f,3ab4f4d42c..29eeae77ca --- a/Documentation/githooks.txt +++ b/Documentation/githooks.txt @@@ -229,7 -229,7 +229,7 @@@ from updating that ref This hook can be used to prevent 'forced' update on certain refs by making sure that the object name is a commit object that is a descendant of the commit object named by the old object name. -That is, to enforce a "fast forward only" policy. +That is, to enforce a "fast-forward only" policy. It could also be used to log the old..new status. However, it does not know the entire set of branches, so it would end up @@@ -310,35 -310,6 +310,6 @@@ Both standard output and standard erro 'git-send-pack' on the other end, so you can simply `echo` messages for the user. - post-upload-pack - ---------------- - - After upload-pack successfully finishes its operation, this hook is called - for logging purposes. - - The hook is passed various pieces of information, one per line, from its - standard input. Currently the following items can be fed to the hook, but - more types of information may be added in the future: - - want SHA-1:: - 40-byte hexadecimal object name the client asked to include in the - resulting pack. Can occur one or more times in the input. - - have SHA-1:: - 40-byte hexadecimal object name the client asked to exclude from - the resulting pack, claiming to have them already. Can occur zero - or more times in the input. - - time float:: - Number of seconds spent for creating the packfile. - - size decimal:: - Size of the resulting packfile in bytes. - - kind string: - Either "clone" (when the client did not give us any "have", and asked - for all our refs with "want"), or "fetch" (otherwise). - pre-auto-gc ~~~~~~~~~~~ diff --combined upload-pack.c index 6bfb500eb4,0ea8516ebf..df151813f9 --- a/upload-pack.c +++ b/upload-pack.c @@@ -39,8 -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) { @@@ -148,66 -146,8 +148,8 @@@ static int do_rev_list(int fd, void *cr return 0; } - static int feed_msg_to_hook(int fd, const char *fmt, ...) - { - int cnt; - char buf[1024]; - va_list params; - - va_start(params, fmt); - cnt = vsprintf(buf, fmt, params); - va_end(params); - return write_in_full(fd, buf, cnt) != cnt; - } - - static int feed_obj_to_hook(const char *label, struct object_array *oa, int i, int fd) - { - return feed_msg_to_hook(fd, "%s %s\n", label, - sha1_to_hex(oa->objects[i].item->sha1)); - } - - static int run_post_upload_pack_hook(size_t total, struct timeval *tv) - { - const char *argv[2]; - struct child_process proc; - int err, i; - - argv[0] = "hooks/post-upload-pack"; - argv[1] = NULL; - - if (access(argv[0], X_OK) < 0) - return 0; - - memset(&proc, 0, sizeof(proc)); - proc.argv = argv; - proc.in = -1; - proc.stdout_to_stderr = 1; - err = start_command(&proc); - if (err) - return err; - for (i = 0; !err && i < want_obj.nr; i++) - err |= feed_obj_to_hook("want", &want_obj, i, proc.in); - for (i = 0; !err && i < have_obj.nr; i++) - err |= feed_obj_to_hook("have", &have_obj, i, proc.in); - if (!err) - err |= feed_msg_to_hook(proc.in, "time %ld.%06ld\n", - (long)tv->tv_sec, (long)tv->tv_usec); - if (!err) - err |= feed_msg_to_hook(proc.in, "size %ld\n", (long)total); - if (!err) - err |= feed_msg_to_hook(proc.in, "kind %s\n", - (nr_our_refs == want_obj.nr && !have_obj.nr) - ? "clone" : "fetch"); - if (close(proc.in)) - err = 1; - if (finish_command(&proc)) - err = 1; - return err; - } - static void create_pack_file(void) { - struct timeval start_tv, tv; struct async rev_list; struct child_process pack_objects; int create_full_pack = (nr_our_refs == want_obj.nr && !have_obj.nr); @@@ -215,12 -155,10 +157,10 @@@ char abort_msg[] = "aborting due to possible repository " "corruption on the remote side."; int buffered = -1; - ssize_t sz, total_sz; + ssize_t sz; const char *argv[10]; int arg = 0; - gettimeofday(&start_tv, NULL); - total_sz = 0; if (shallow_nr) { rev_list.proc = do_rev_list; rev_list.data = 0; @@@ -346,7 -284,7 +286,7 @@@ sz = xread(pack_objects.out, cp, sizeof(data) - outsz); if (0 < sz) - total_sz += sz; + ; else if (sz == 0) { close(pack_objects.out); pack_objects.out = -1; @@@ -383,16 -321,6 +323,6 @@@ } if (use_sideband) packet_flush(1); - - gettimeofday(&tv, NULL); - tv.tv_sec -= start_tv.tv_sec; - if (tv.tv_usec < start_tv.tv_usec) { - tv.tv_sec--; - tv.tv_usec += 1000000; - } - tv.tv_usec -= start_tv.tv_usec; - if (run_post_upload_pack_hook(total_sz, &tv)) - warning("post-upload-hook failed"); return; fail: @@@ -502,7 -430,7 +432,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; @@@ -513,30 -441,25 +443,30 @@@ 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; @@@ -596,9 -519,7 +526,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; @@@ -692,7 -613,7 +622,7 @@@ static int send_ref(const char *refname { 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) @@@ -716,32 -637,12 +646,32 @@@ 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(); @@@ -763,14 -664,6 +693,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;