From: Jeff Hostetler <git@jeffhostetler•com>
To: git@vger•kernel.org
Cc: gitster@pobox•com, peff@peff•net, jonathantanmy@google•com,
Jeff Hostetler <jeffhost@microsoft•com>
Subject: [PATCH v4 12/15] t5601: test for partial clone
Date: Thu, 16 Nov 2017 18:17:20 +0000 [thread overview]
Message-ID: <20171116181723.62033-13-git@jeffhostetler.com> (raw)
In-Reply-To: <20171116181723.62033-1-git@jeffhostetler.com>
From: Jonathan Tan <jonathantanmy@google•com>
Signed-off-by: Jonathan Tan <jonathantanmy@google•com>
Signed-off-by: Jeff Hostetler <jeffhost@microsoft•com>
---
builtin/clone.c | 15 ++++++++++++---
t/t5601-clone.sh | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 61 insertions(+), 3 deletions(-)
diff --git a/builtin/clone.c b/builtin/clone.c
index fceb9e7..5719690 100644
--- a/builtin/clone.c
+++ b/builtin/clone.c
@@ -889,6 +889,8 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
struct refspec *refspec;
const char *fetch_pattern;
+ fetch_if_missing = 0;
+
packet_trace_identity("clone");
argc = parse_options(argc, argv, prefix, builtin_clone_options,
builtin_clone_usage, 0);
@@ -1109,11 +1111,13 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
transport_set_option(transport, TRANS_OPT_UPLOADPACK,
option_upload_pack);
- if (filter_options.choice)
+ if (filter_options.choice) {
transport_set_option(transport, TRANS_OPT_LIST_OBJECTS_FILTER,
filter_options.raw_value);
+ transport_set_option(transport, TRANS_OPT_FROM_PROMISOR, "1");
+ }
- if (transport->smart_options && !deepen)
+ if (transport->smart_options && !deepen && !filter_options.choice)
transport->smart_options->check_self_contained_and_connected = 1;
refs = transport_get_remote_refs(transport);
@@ -1173,13 +1177,17 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
write_refspec_config(src_ref_prefix, our_head_points_at,
remote_head_points_at, &branch_top);
+ if (filter_options.choice)
+ partial_clone_register("origin", &filter_options);
+
if (is_local)
clone_local(path, git_dir);
else if (refs && complete_refs_before_fetch)
transport_fetch_refs(transport, mapped_refs);
update_remote_refs(refs, mapped_refs, remote_head_points_at,
- branch_top.buf, reflog_msg.buf, transport, !is_local);
+ branch_top.buf, reflog_msg.buf, transport,
+ !is_local && !filter_options.choice);
update_head(our_head_points_at, remote_head, reflog_msg.buf);
@@ -1200,6 +1208,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
}
junk_mode = JUNK_LEAVE_REPO;
+ fetch_if_missing = 1;
err = checkout(submodule_progress);
strbuf_release(&reflog_msg);
diff --git a/t/t5601-clone.sh b/t/t5601-clone.sh
index 9c56f77..6d37c6d 100755
--- a/t/t5601-clone.sh
+++ b/t/t5601-clone.sh
@@ -571,4 +571,53 @@ test_expect_success 'GIT_TRACE_PACKFILE produces a usable pack' '
git -C replay.git index-pack -v --stdin <tmp.pack
'
+partial_clone () {
+ SERVER="$1" &&
+ URL="$2" &&
+
+ rm -rf "$SERVER" client &&
+ test_create_repo "$SERVER" &&
+ test_commit -C "$SERVER" one &&
+ HASH1=$(git hash-object "$SERVER/one.t") &&
+ git -C "$SERVER" revert HEAD &&
+ test_commit -C "$SERVER" two &&
+ HASH2=$(git hash-object "$SERVER/two.t") &&
+ test_config -C "$SERVER" uploadpack.allowfilter 1 &&
+ test_config -C "$SERVER" uploadpack.allowanysha1inwant 1 &&
+
+ git clone --filter=blob:limit=0 "$URL" client &&
+
+ git -C client fsck &&
+
+ # Ensure that unneeded blobs are not inadvertently fetched.
+ test_config -C client extensions.partialclone "not a remote" &&
+ test_must_fail git -C client cat-file -e "$HASH1" &&
+
+ # But this blob was fetched, because clone performs an initial checkout
+ git -C client cat-file -e "$HASH2"
+}
+
+test_expect_success 'partial clone' '
+ partial_clone server "file://$(pwd)/server"
+'
+
+test_expect_success 'partial clone: warn if server does not support object filtering' '
+ rm -rf server client &&
+ test_create_repo server &&
+ test_commit -C server one &&
+
+ git clone --filter=blob:limit=0 "file://$(pwd)/server" client 2> err &&
+
+ test_i18ngrep "filtering not recognized by server" err
+'
+
+. "$TEST_DIRECTORY"/lib-httpd.sh
+start_httpd
+
+test_expect_success 'partial clone using HTTP' '
+ partial_clone "$HTTPD_DOCUMENT_ROOT_PATH/server" "$HTTPD_URL/smart/server"
+'
+
+stop_httpd
+
test_done
--
2.9.3
next prev parent reply other threads:[~2017-11-16 18:18 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-16 18:17 [PATCH v4 00/15] Parial clone part 3: clone, fetch, fetch-pack, upload-pack, and tests Jeff Hostetler
2017-11-16 18:17 ` [PATCH v4 01/15] upload-pack: add object filtering for partial clone Jeff Hostetler
2017-11-16 18:17 ` [PATCH v4 02/15] clone, fetch-pack, index-pack, transport: " Jeff Hostetler
2017-11-16 18:17 ` [PATCH v4 03/15] fetch: refactor calculation of remote list Jeff Hostetler
2017-11-16 18:17 ` [PATCH v4 04/15] fetch: add object filtering for partial fetch Jeff Hostetler
2017-11-16 18:17 ` [PATCH v4 05/15] remote-curl: add object filtering for partial clone Jeff Hostetler
2017-11-16 18:17 ` [PATCH v4 06/15] pack-objects: test support for blob filtering Jeff Hostetler
2017-11-16 18:17 ` [PATCH v4 07/15] fetch-pack: test support excluding large blobs Jeff Hostetler
2017-11-16 18:17 ` [PATCH v4 08/15] partial-clone: define partial clone settings in config Jeff Hostetler
2017-11-16 18:17 ` [PATCH v4 09/15] fetch-pack: test support excluding large blobs Jeff Hostetler
2017-11-16 18:17 ` [PATCH v4 10/15] fetch: add from_promisor and exclude-promisor-objects parameters Jeff Hostetler
2017-11-16 18:17 ` [PATCH v4 11/15] t5500: add fetch-pack tests for partial clone Jeff Hostetler
2017-11-16 18:17 ` Jeff Hostetler [this message]
2017-11-16 18:17 ` [PATCH v4 13/15] t5500: more tests for partial clone and fetch Jeff Hostetler
2017-11-16 18:17 ` [PATCH v4 14/15] unpack-trees: batch fetching of missing blobs Jeff Hostetler
2017-11-16 18:17 ` [PATCH v4 15/15] fetch-pack: restore save_commit_buffer after use Jeff Hostetler
2017-11-17 6:19 ` [PATCH v4 00/15] Parial clone part 3: clone, fetch, fetch-pack, upload-pack, and tests Junio C Hamano
2017-11-21 18:17 ` Jonathan Tan
2017-11-21 20:46 ` Jeff Hostetler
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=20171116181723.62033-13-git@jeffhostetler.com \
--to=git@jeffhostetler$(echo .)com \
--cc=git@vger$(echo .)kernel.org \
--cc=gitster@pobox$(echo .)com \
--cc=jeffhost@microsoft$(echo .)com \
--cc=jonathantanmy@google$(echo .)com \
--cc=peff@peff$(echo .)net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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