From c7740a943ec896247ebc5514b6be02710caf3c53 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Sun, 29 Oct 2006 00:47:56 -0700 Subject: send-pack --keep: do not explode into loose objects on the receiving end. This adds "keep-pack" extension to send-pack vs receive pack protocol, and makes the receiver invoke "index-pack --stdin --fix-thin". With this, you can ask send-pack not to explode the result into loose objects on the receiving end. I've patched has_sha1_file() to re-check for added packs just like is done in read_sha1_file() for now, but I think the static "re-prepare" interface for packs was a mistake. Creation of a new pack inside a process that needs to read objects in them back ought to be a rare event, so we are better off making the callers (such as receive-pack that calls "index-pack --stdin --fix-thin") explicitly call re-prepare. That way we do not have to penalize ordinary users of read_sha1_file() and has_sha1_file(). We would need to fix this someday. Signed-off-by: Junio C Hamano --- receive-pack.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'receive-pack.c') diff --git a/receive-pack.c b/receive-pack.c index ea2dbd4e33..ef50226f4d 100644 --- a/receive-pack.c +++ b/receive-pack.c @@ -8,10 +8,14 @@ static const char receive_pack_usage[] = "git-receive-pack "; static const char *unpacker[] = { "unpack-objects", NULL }; +static const char *keep_packer[] = { + "index-pack", "--stdin", "--fix-thin", NULL +}; static int report_status; +static int keep_pack; -static char capabilities[] = "report-status"; +static char capabilities[] = "report-status keep-pack"; static int capabilities_sent; static int show_ref(const char *path, const unsigned char *sha1) @@ -261,6 +265,8 @@ static void read_head_info(void) if (reflen + 82 < len) { if (strstr(refname + reflen + 1, "report-status")) report_status = 1; + if (strstr(refname + reflen + 1, "keep-pack")) + keep_pack = 1; } cmd = xmalloc(sizeof(struct command) + len - 80); hashcpy(cmd->old_sha1, old_sha1); @@ -275,7 +281,14 @@ static void read_head_info(void) static const char *unpack(int *error_code) { - int code = run_command_v_opt(1, unpacker, RUN_GIT_CMD); + int code; + + if (keep_pack) + code = run_command_v_opt(ARRAY_SIZE(keep_packer) - 1, + keep_packer, RUN_GIT_CMD); + else + code = run_command_v_opt(ARRAY_SIZE(unpacker) - 1, + unpacker, RUN_GIT_CMD); *error_code = 0; switch (code) { @@ -335,7 +348,7 @@ int main(int argc, char **argv) if (!dir) usage(receive_pack_usage); - if(!enter_repo(dir, 0)) + if (!enter_repo(dir, 0)) die("'%s': unable to chdir or not a git archive", dir); write_head_info(); -- cgit v1.2.3