summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Tan <jonathantanmy@google.com>2017-09-29 13:11:52 -0700
committerJunio C Hamano <gitster@pobox.com>2017-10-02 10:15:20 +0900
commit0416a9a751ed51142be2c57666466f576c07d033 (patch)
tree7ede6c2d348f2d7fd6c481cc3a69f73b3c52e7c0
parenta35ee14d114a35bd785861dc4769927cc233c5c2 (diff)
downloadgit-0416a9a751ed51142be2c57666466f576c07d033.tar.gz
clone: configure blobmaxbytes in created repos
Teach clone to configure blobmaxbytes in any repos that it generates when the --blob-max-bytes parameter is set. Also teach fetch to use this parameter. Signed-off-by: Jonathan Tan <jonathantanmy@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r--builtin/clone.c1
-rw-r--r--builtin/fetch.c4
-rw-r--r--remote.c2
-rw-r--r--remote.h2
-rwxr-xr-xt/t5500-fetch-pack.sh64
5 files changed, 67 insertions, 6 deletions
diff --git a/builtin/clone.c b/builtin/clone.c
index 4c2193dc41..58cbc8ae31 100644
--- a/builtin/clone.c
+++ b/builtin/clone.c
@@ -1179,6 +1179,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
git_config_set("core.repositoryformatversion", "1");
git_config_set("extensions.partialclone", "origin");
repository_format_partial_clone = "origin";
+ git_config_set("remote.origin.blobmaxbytes", blob_max_bytes);
}
if (is_local)
diff --git a/builtin/fetch.c b/builtin/fetch.c
index 07beaf5b54..ace238554d 100644
--- a/builtin/fetch.c
+++ b/builtin/fetch.c
@@ -1050,6 +1050,10 @@ static struct transport *prepare_transport(struct remote *remote, int deepen)
if (blob_max_bytes) {
set_option(transport, TRANS_OPT_BLOB_MAX_BYTES, blob_max_bytes);
set_option(transport, TRANS_OPT_FROM_PROMISOR, "1");
+ } else if (remote->blob_max_bytes) {
+ set_option(transport, TRANS_OPT_BLOB_MAX_BYTES,
+ remote->blob_max_bytes);
+ set_option(transport, TRANS_OPT_FROM_PROMISOR, "1");
}
return transport;
}
diff --git a/remote.c b/remote.c
index 4113090069..eade3c3125 100644
--- a/remote.c
+++ b/remote.c
@@ -440,6 +440,8 @@ static int handle_config(const char *key, const char *value, void *cb)
key, value);
} else if (!strcmp(subkey, "vcs")) {
return git_config_string(&remote->foreign_vcs, key, value);
+ } else if (!strcmp(subkey, "blobmaxbytes")) {
+ return git_config_string(&remote->blob_max_bytes, key, value);
}
return 0;
}
diff --git a/remote.h b/remote.h
index 2ecf4c8c74..3d56e62b71 100644
--- a/remote.h
+++ b/remote.h
@@ -56,6 +56,8 @@ struct remote {
*/
char *http_proxy;
char *http_proxy_authmethod;
+
+ const char *blob_max_bytes;
};
struct remote *remote_get(const char *name);
diff --git a/t/t5500-fetch-pack.sh b/t/t5500-fetch-pack.sh
index b2682862f7..ee533ea325 100755
--- a/t/t5500-fetch-pack.sh
+++ b/t/t5500-fetch-pack.sh
@@ -782,9 +782,9 @@ test_expect_success '--blob-max-bytes has no effect if support for it is not adv
test_i18ngrep "blob-max-bytes not recognized by server" err
'
-fetch_blob_max_bytes () {
- SERVER="$1"
- URL="$2"
+setup_blob_max_bytes () {
+ SERVER="$1" &&
+ URL="$2" &&
rm -rf "$SERVER" client &&
test_create_repo "$SERVER" &&
@@ -794,7 +794,11 @@ fetch_blob_max_bytes () {
git clone "$URL" client &&
test_config -C client extensions.partialclone origin &&
- test_commit -C "$SERVER" two &&
+ test_commit -C "$SERVER" two
+}
+
+do_blob_max_bytes() {
+ SERVER="$1" &&
git -C client fetch --blob-max-bytes=0 origin HEAD:somewhere &&
@@ -805,14 +809,62 @@ fetch_blob_max_bytes () {
}
test_expect_success 'fetch with --blob-max-bytes' '
- fetch_blob_max_bytes server server
+ setup_blob_max_bytes server server &&
+ do_blob_max_bytes server
+'
+
+test_expect_success 'fetch respects configured blobmaxbytes' '
+ setup_blob_max_bytes server server &&
+
+ test_config -C client remote.origin.blobmaxbytes 0 &&
+
+ git -C client fetch origin HEAD:somewhere &&
+
+ # Ensure that commit is fetched, but blob is not
+ test_config -C client extensions.partialclone "arbitrary string" &&
+ git -C client cat-file -e $(git -C server rev-parse two) &&
+ test_must_fail git -C client cat-file -e $(git hash-object server/two.t)
+'
+
+test_expect_success 'pull respects configured blobmaxbytes' '
+ setup_blob_max_bytes server server &&
+
+ # Hide two.t from tip so that client does not load it upon the
+ # automatic checkout that pull performs
+ git -C server rm two.t &&
+ test_commit -C server three &&
+
+ test_config -C server uploadpack.allowanysha1inwant 1 &&
+ test_config -C client remote.origin.blobmaxbytes 0 &&
+
+ git -C client pull origin &&
+
+ # Ensure that commit is fetched, but blob is not
+ test_config -C client extensions.partialclone "arbitrary string" &&
+ git -C client cat-file -e $(git -C server rev-parse two) &&
+ test_must_fail git -C client cat-file -e $(git hash-object server/two.t)
+'
+
+test_expect_success 'clone configures blobmaxbytes' '
+ rm -rf server client &&
+ test_create_repo server &&
+ test_commit -C server one &&
+ test_commit -C server two &&
+ test_config -C server uploadpack.allowanysha1inwant 1 &&
+
+ git clone --blob-max-bytes=12345 server client &&
+
+ # Ensure that we can, for example, checkout HEAD^
+ rm -rf client/.git/objects/* &&
+ git -C client checkout HEAD^
'
. "$TEST_DIRECTORY"/lib-httpd.sh
start_httpd
test_expect_success 'fetch with --blob-max-bytes and HTTP' '
- fetch_blob_max_bytes "$HTTPD_DOCUMENT_ROOT_PATH/server" "$HTTPD_URL/smart/server"
+ setup_blob_max_bytes "$HTTPD_DOCUMENT_ROOT_PATH/server" "$HTTPD_URL/smart/server" &&
+ do_blob_max_bytes "$HTTPD_DOCUMENT_ROOT_PATH/server"
'
stop_httpd