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 05/10] clone: new option to set preferred pack version for transfer
Date: Thu, 26 Sep 2013 09:26:44 +0700 [thread overview]
Message-ID: <1380162409-18224-6-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/git-clone.txt | 4 ++++
builtin/clone.c | 19 +++++++++++++++++++
t/t5601-clone.sh | 12 ++++++++++++
3 files changed, 35 insertions(+)
diff --git a/Documentation/git-clone.txt b/Documentation/git-clone.txt
index 450f158..6299a70 100644
--- a/Documentation/git-clone.txt
+++ b/Documentation/git-clone.txt
@@ -217,6 +217,10 @@ objects from the source repository into a pack in the cloned repository.
The result is Git repository can be separated from working
tree.
+--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].
<repository>::
The (possibly remote) repository to clone from. See the
diff --git a/builtin/clone.c b/builtin/clone.c
index 430307b..9c0e296 100644
--- a/builtin/clone.c
+++ b/builtin/clone.c
@@ -46,6 +46,7 @@ static const char *real_git_dir;
static char *option_upload_pack = "git-upload-pack";
static int option_verbosity;
static int option_progress = -1;
+static int pack_version;
static struct string_list option_config;
static struct string_list option_reference;
@@ -98,6 +99,8 @@ static struct option builtin_clone_options[] = {
N_("separate git dir from working tree")),
OPT_STRING_LIST('c', "config", &option_config, N_("key=value"),
N_("set config inside the new repository")),
+ OPT_INTEGER(0, "pack-version", &pack_version,
+ N_("preferred pack version for transfer")),
OPT_END()
};
@@ -764,6 +767,11 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
usage_msg_opt(_("You must specify a repository to clone."),
builtin_clone_usage, builtin_clone_options);
+ if (!pack_version)
+ pack_version = core_default_pack_version;
+ if (pack_version != 2 && pack_version != 4)
+ die(_("invalid pack version %d"), pack_version);
+
if (option_single_branch == -1)
option_single_branch = option_depth ? 1 : 0;
@@ -794,6 +802,8 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
is_local = option_local != 0 && path && !is_bundle;
if (is_local && option_depth)
warning(_("--depth is ignored in local clones; use file:// instead."));
+ if (is_local && pack_version == 4)
+ warning(_("--pack-version is ignored in local clones; use file:// instead."));
if (option_local > 0 && !is_local)
warning(_("--local is ignored"));
@@ -868,6 +878,12 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
} else {
strbuf_addf(&branch_top, "refs/remotes/%s/", option_origin);
}
+ if (pack_version != core_default_pack_version) {
+ struct strbuf sb = STRBUF_INIT;
+ strbuf_addf(&sb, "%d", pack_version);
+ git_config_set("core.preferredPackVersion", sb.buf);
+ strbuf_release(&sb);
+ }
strbuf_addf(&value, "+%s*:%s*", src_ref_prefix, branch_top.buf);
strbuf_addf(&key, "remote.%s.url", option_origin);
@@ -903,6 +919,9 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
transport_set_option(transport, TRANS_OPT_UPLOADPACK,
option_upload_pack);
+ if (pack_version == 4)
+ transport_set_option(transport, TRANS_OPT_PACKV4, "yes");
+
if (transport->smart_options && !option_depth)
transport->smart_options->check_self_contained_and_connected = 1;
}
diff --git a/t/t5601-clone.sh b/t/t5601-clone.sh
index 0629149..8118524 100755
--- a/t/t5601-clone.sh
+++ b/t/t5601-clone.sh
@@ -285,4 +285,16 @@ test_expect_success NOT_MINGW,NOT_CYGWIN 'clone local path foo:bar' '
git clone "./foo:bar" foobar
'
+test_expect_success 'clone --pack-version=4' '
+ git clone --pack-version=4 --no-local src pv4 &&
+ P=`ls pv4/.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 &&
+ git --git-dir=pv4/.git config --int core.preferredPackVersion >cfgver.actual &&
+ echo 4 >cfgver.expected &&
+ test_cmp cfgver.expected cfgver.actual
+'
+
test_done
--
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 ` [PATCH 04/10] fetch: new option to set preferred pack version for transfer 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 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-6-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).