summaryrefslogtreecommitdiff
path: root/send-pack.c
diff options
context:
space:
mode:
authorJunio C Hamano <junkio@cox.net>2006-10-29 00:47:56 -0700
committerJunio C Hamano <junkio@cox.net>2006-10-29 00:49:17 -0700
commitc7740a943ec896247ebc5514b6be02710caf3c53 (patch)
treeab918e6d34d35d714a180f57e946afdc81aa0a57 /send-pack.c
parentb89c4e93cc1939493c2bb9b6c3f60eabaf653eff (diff)
downloadgit-c7740a943ec896247ebc5514b6be02710caf3c53.tar.gz
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 <junkio@cox.net>
Diffstat (limited to 'send-pack.c')
-rw-r--r--send-pack.c23
1 files changed, 18 insertions, 5 deletions
diff --git a/send-pack.c b/send-pack.c
index 5bb123a376..54d218c03b 100644
--- a/send-pack.c
+++ b/send-pack.c
@@ -6,13 +6,14 @@
#include "exec_cmd.h"
static const char send_pack_usage[] =
-"git-send-pack [--all] [--exec=git-receive-pack] <remote> [<head>...]\n"
+"git-send-pack [--all] [--keep] [--exec=git-receive-pack] <remote> [<head>...]\n"
" --all and explicit <head> specification are mutually exclusive.";
static const char *exec = "git-receive-pack";
static int verbose;
static int send_all;
static int force_update;
static int use_thin_pack;
+static int keep_pack;
static int is_zero_sha1(const unsigned char *sha1)
{
@@ -270,6 +271,7 @@ static int send_pack(int in, int out, int nr_refspec, char **refspec)
int new_refs;
int ret = 0;
int ask_for_status_report = 0;
+ int ask_to_keep_pack = 0;
int expect_status_report = 0;
/* No funny business with the matcher */
@@ -279,6 +281,8 @@ static int send_pack(int in, int out, int nr_refspec, char **refspec)
/* Does the other end support the reporting? */
if (server_supports("report-status"))
ask_for_status_report = 1;
+ if (server_supports("keep-pack") && keep_pack)
+ ask_to_keep_pack = 1;
/* match them up */
if (!remote_tail)
@@ -355,12 +359,17 @@ static int send_pack(int in, int out, int nr_refspec, char **refspec)
strcpy(old_hex, sha1_to_hex(ref->old_sha1));
new_hex = sha1_to_hex(ref->new_sha1);
- if (ask_for_status_report) {
- packet_write(out, "%s %s %s%c%s",
+ if (ask_for_status_report || ask_to_keep_pack) {
+ packet_write(out, "%s %s %s%c%s%s",
old_hex, new_hex, ref->name, 0,
- "report-status");
+ ask_for_status_report
+ ? " report-status" : "",
+ ask_to_keep_pack
+ ? " keep-pack" : "");
+ if (ask_for_status_report)
+ expect_status_report = 1;
ask_for_status_report = 0;
- expect_status_report = 1;
+ ask_to_keep_pack = 0;
}
else
packet_write(out, "%s %s %s",
@@ -419,6 +428,10 @@ int main(int argc, char **argv)
verbose = 1;
continue;
}
+ if (!strcmp(arg, "--keep")) {
+ keep_pack = 1;
+ continue;
+ }
if (!strcmp(arg, "--thin")) {
use_thin_pack = 1;
continue;