From: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
To: git@vger.kernel.org
Cc: "Nicolas Pitre" <nico@fluxnic.net>,
"Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
Subject: [PATCH 04/10] fetch: new option to set preferred pack version for transfer
Date: Thu, 26 Sep 2013 09:26:43 +0700 [thread overview]
Message-ID: <1380162409-18224-5-git-send-email-pclouds@gmail.com> (raw)
In-Reply-To: <1380162409-18224-1-git-send-email-pclouds@gmail.com>
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
Documentation/fetch-options.txt | 5 +++++
builtin/fetch.c | 10 ++++++++++
fetch-pack.c | 3 +++
fetch-pack.h | 1 +
t/t5510-fetch.sh | 13 +++++++++++++
transport.c | 4 ++++
transport.h | 5 +++++
7 files changed, 41 insertions(+)
diff --git a/Documentation/fetch-options.txt b/Documentation/fetch-options.txt
index ba1fe49..47d55e5 100644
--- a/Documentation/fetch-options.txt
+++ b/Documentation/fetch-options.txt
@@ -17,6 +17,11 @@
Convert a shallow repository to a complete one, removing all
the limitations imposed by shallow repositories.
+--pack-version=<n>::
+ Define the preferred pack format version for data transfer.
+ Valid values are 2 and 4. Default value is specified by
+ core.preferredPackVersion setting. See linkgit:git-config[1].
+
ifndef::git-pull[]
--dry-run::
Show what would be done, without making any changes.
diff --git a/builtin/fetch.c b/builtin/fetch.c
index d784b2e..695fbf1 100644
--- a/builtin/fetch.c
+++ b/builtin/fetch.c
@@ -31,6 +31,7 @@ enum {
};
static int all, append, dry_run, force, keep, multiple, prune, update_head_ok, verbosity;
+static int pack_version;
static int progress = -1, recurse_submodules = RECURSE_SUBMODULES_DEFAULT;
static int tags = TAGS_DEFAULT, unshallow;
static const char *depth;
@@ -90,6 +91,8 @@ static struct option builtin_fetch_options[] = {
{ OPTION_STRING, 0, "recurse-submodules-default",
&recurse_submodules_default, NULL,
N_("default mode for recursion"), PARSE_OPT_HIDDEN },
+ OPT_INTEGER(0, "pack-version", &pack_version,
+ N_("preferred pack version for transfer")),
OPT_END()
};
@@ -957,6 +960,8 @@ static int fetch_one(struct remote *remote, int argc, const char **argv)
set_option(TRANS_OPT_KEEP, "yes");
if (depth)
set_option(TRANS_OPT_DEPTH, depth);
+ if (pack_version == 4)
+ set_option(TRANS_OPT_PACKV4, "yes");
if (argc > 0) {
int j = 0;
@@ -1010,6 +1015,11 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
argc = parse_options(argc, argv, prefix,
builtin_fetch_options, builtin_fetch_usage, 0);
+ if (!pack_version)
+ pack_version = core_default_pack_version;
+ if (pack_version != 2 && pack_version != 4)
+ die(_("invalid pack version %d"), pack_version);
+
if (unshallow) {
if (depth)
die(_("--depth and --unshallow cannot be used together"));
diff --git a/fetch-pack.c b/fetch-pack.c
index 6684348..16aa3d0 100644
--- a/fetch-pack.c
+++ b/fetch-pack.c
@@ -324,6 +324,7 @@ static int find_common(struct fetch_pack_args *args,
if (args->no_progress) strbuf_addstr(&c, " no-progress");
if (args->include_tag) strbuf_addstr(&c, " include-tag");
if (prefer_ofs_delta) strbuf_addstr(&c, " ofs-delta");
+ if (args->packv4) strbuf_addstr(&c, " packv4");
if (agent_supported) strbuf_addf(&c, " agent=%s",
git_user_agent_sanitized());
packet_buf_write(&req_buf, "want %s%s\n", remote_hex, c.buf);
@@ -869,6 +870,8 @@ static struct ref *do_fetch_pack(struct fetch_pack_args *args,
args->no_progress = 0;
if (!server_supports("include-tag"))
args->include_tag = 0;
+ if (!server_supports("packv4"))
+ args->packv4 = 0;
if (server_supports("ofs-delta")) {
if (args->verbose)
fprintf(stderr, "Server supports ofs-delta\n");
diff --git a/fetch-pack.h b/fetch-pack.h
index 40f08ba..5f03739 100644
--- a/fetch-pack.h
+++ b/fetch-pack.h
@@ -17,6 +17,7 @@ struct fetch_pack_args {
no_progress:1,
include_tag:1,
stateless_rpc:1,
+ packv4:1,
check_self_contained_and_connected:1,
self_contained_and_connected:1;
};
diff --git a/t/t5510-fetch.sh b/t/t5510-fetch.sh
index fde6891..d3da088 100755
--- a/t/t5510-fetch.sh
+++ b/t/t5510-fetch.sh
@@ -512,4 +512,17 @@ test_expect_success 'all boundary commits are excluded' '
test_bundle_object_count .git/objects/pack/pack-${pack##pack }.pack 3
'
+test_expect_success 'fetch --pack-version=4' '
+ git init pv4 &&
+ (
+ cd pv4 &&
+ git fetch --pack-version=4 --keep file://"$D"/.git &&
+ P=`ls .git/objects/pack/pack-*.pack` &&
+ # Offset 4 is pack version
+ test-dump ntohl "$P" 4 >ver.actual &&
+ echo 4 >ver.expected &&
+ test_cmp ver.expected ver.actual
+ )
+'
+
test_done
diff --git a/transport.c b/transport.c
index e15db98..ad5a4f1 100644
--- a/transport.c
+++ b/transport.c
@@ -473,6 +473,9 @@ static int set_git_option(struct git_transport_options *opts,
} else if (!strcmp(name, TRANS_OPT_KEEP)) {
opts->keep = !!value;
return 0;
+ } else if (!strcmp(name, TRANS_OPT_PACKV4)) {
+ opts->packv4 = !!value;
+ return 0;
} else if (!strcmp(name, TRANS_OPT_DEPTH)) {
if (!value)
opts->depth = 0;
@@ -534,6 +537,7 @@ static int fetch_refs_via_pack(struct transport *transport,
args.quiet = (transport->verbose < 0);
args.no_progress = !transport->progress;
args.depth = data->options.depth;
+ args.packv4 = data->options.packv4;
args.check_self_contained_and_connected =
data->options.check_self_contained_and_connected;
diff --git a/transport.h b/transport.h
index ea70ea7..59785c0 100644
--- a/transport.h
+++ b/transport.h
@@ -8,6 +8,7 @@ struct git_transport_options {
unsigned thin : 1;
unsigned keep : 1;
unsigned followtags : 1;
+ unsigned packv4 : 1;
unsigned check_self_contained_and_connected : 1;
unsigned self_contained_and_connected : 1;
int depth;
@@ -135,6 +136,10 @@ struct transport *transport_get(struct remote *, const char *);
/* Aggressively fetch annotated tags if possible */
#define TRANS_OPT_FOLLOWTAGS "followtags"
+/* Prefer pack version 4 as the transport format */
+#define TRANS_OPT_PACKV4 "packv4"
+
+
/**
* Returns 0 if the option was used, non-zero otherwise. Prints a
* message to stderr if the option is not used.
--
1.8.2.82.gc24b958
next prev parent reply other threads:[~2013-09-26 2:27 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-09-26 2:26 [PATCH 00/10] pack v4 UI support Nguyễn Thái Ngọc Duy
2013-09-26 2:26 ` [PATCH 01/10] test-dump: new test program to examine binary data Nguyễn Thái Ngọc Duy
2013-09-26 2:26 ` [PATCH 02/10] config: add core.preferredPackVersion Nguyễn Thái Ngọc Duy
2013-09-26 2:26 ` [PATCH 03/10] upload-pack: new capability to send pack v4 Nguyễn Thái Ngọc Duy
2013-09-26 2:26 ` Nguyễn Thái Ngọc Duy [this message]
2013-09-26 2:26 ` [PATCH 05/10] clone: new option to set preferred pack version for transfer Nguyễn Thái Ngọc Duy
2013-09-26 2:26 ` [PATCH 06/10] fetch: pack v4 support on smart http Nguyễn Thái Ngọc Duy
2013-09-26 2:26 ` [PATCH 07/10] receive-pack: request for packv4 if it's the preferred version Nguyễn Thái Ngọc Duy
2013-10-17 17:26 ` Junio C Hamano
2013-09-26 2:26 ` [PATCH 08/10] send-pack: support pack v4 Nguyễn Thái Ngọc Duy
2013-09-26 2:26 ` [PATCH 09/10] repack: add --pack-version and fall back to core.preferredPackVersion Nguyễn Thái Ngọc Duy
2013-09-26 8:32 ` [PATCH] repack: Add --version parameter Stefan Beller
2013-09-26 10:17 ` Felipe Contreras
2013-09-28 8:53 ` Stefan Beller
2013-09-26 11:42 ` Duy Nguyen
2013-09-28 8:54 ` Stefan Beller
2013-09-26 2:26 ` [PATCH 10/10] count-objects: report pack v4 usage Nguyễn Thái Ngọc Duy
2013-09-26 4:51 ` [PATCH 00/10] pack v4 UI support Nicolas Pitre
2013-09-26 5:09 ` Duy Nguyen
2013-09-27 2:59 ` Nicolas Pitre
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1380162409-18224-5-git-send-email-pclouds@gmail.com \
--to=pclouds@gmail.com \
--cc=git@vger.kernel.org \
--cc=nico@fluxnic.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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 NNTP newsgroup(s).