From: Robin Ruede <r.ruede@gmail.com>
To: git@vger.kernel.org
Cc: Robin Ruede <r.ruede@gmail.com>
Subject: [PATCH/RFC 5/7] fetch: add sparse-prefix option
Date: Thu, 28 Jul 2016 18:02:24 +0200 [thread overview]
Message-ID: <20160728160226.24018-6-r.ruede@gmail.com> (raw)
In-Reply-To: <20160728160226.24018-1-r.ruede@gmail.com>
also pass sparse-prefix option from fetch to rev-list while checking
connectivity
Signed-off-by: Robin Ruede <r.ruede@gmail.com>
---
builtin/fetch.c | 19 ++++++++++++++-----
connected.c | 7 ++++++-
transport.c | 4 ++++
transport.h | 4 ++++
4 files changed, 28 insertions(+), 6 deletions(-)
diff --git a/builtin/fetch.c b/builtin/fetch.c
index acd0cf1..b48537f 100644
--- a/builtin/fetch.c
+++ b/builtin/fetch.c
@@ -41,6 +41,7 @@ static int tags = TAGS_DEFAULT, unshallow, update_shallow;
static int max_children = -1;
static enum transport_family family;
static const char *depth;
+static const char *sparse_prefix;
static const char *upload_pack;
static struct strbuf default_rla = STRBUF_INIT;
static struct transport *gtransport;
@@ -117,6 +118,8 @@ static struct option builtin_fetch_options[] = {
OPT_BOOL(0, "progress", &progress, N_("force progress reporting")),
OPT_STRING(0, "depth", &depth, N_("depth"),
N_("deepen history of shallow clone")),
+ OPT_STRING(0, "sparse-prefix", &sparse_prefix, N_("path-prefix"),
+ N_("only fetch blobs for the specified path-prefix")),
{ OPTION_SET_INT, 0, "unshallow", &unshallow, NULL,
N_("convert to a complete repository"),
PARSE_OPT_NONEG | PARSE_OPT_NOARG, NULL, 1 },
@@ -706,9 +709,11 @@ static int iterate_ref_map(void *cb_data, unsigned char sha1[20])
return 0;
}
-static int store_updated_refs(const char *raw_url, const char *remote_name,
+static int store_updated_refs(struct transport *transport,
struct ref *ref_map)
{
+ const char *raw_url = transport->url;
+ const char *remote_name = transport->remote->name;
FILE *fp;
struct commit *commit;
int url_len, i, rc = 0;
@@ -729,7 +734,8 @@ static int store_updated_refs(const char *raw_url, const char *remote_name,
url = xstrdup("foreign");
rm = ref_map;
- if (check_everything_connected(iterate_ref_map, 0, &rm)) {
+ if (check_everything_connected_with_transport(iterate_ref_map, 0, &rm,
+ transport)) {
rc = error(_("%s did not send all necessary objects\n"), url);
goto abort;
}
@@ -885,9 +891,7 @@ static int fetch_refs(struct transport *transport, struct ref *ref_map)
if (ret)
ret = transport_fetch_refs(transport, ref_map);
if (!ret)
- ret |= store_updated_refs(transport->url,
- transport->remote->name,
- ref_map);
+ ret |= store_updated_refs(transport, ref_map);
transport_unlock_pack(transport);
return ret;
}
@@ -993,6 +997,11 @@ static struct transport *prepare_transport(struct remote *remote)
set_option(transport, TRANS_OPT_KEEP, "yes");
if (depth)
set_option(transport, TRANS_OPT_DEPTH, depth);
+ if (sparse_prefix) {
+ if(sparse_prefix[0] != '/')
+ die(N_("sparse prefix must start with /"));
+ set_option(transport, TRANS_OPT_SPARSE_PREFIX, sparse_prefix);
+ }
if (update_shallow)
set_option(transport, TRANS_OPT_UPDATE_SHALLOW, "yes");
return transport;
diff --git a/connected.c b/connected.c
index bf1b12e..1534c5c 100644
--- a/connected.c
+++ b/connected.c
@@ -26,7 +26,7 @@ static int check_everything_connected_real(sha1_iterate_fn fn,
const char *shallow_file)
{
struct child_process rev_list = CHILD_PROCESS_INIT;
- const char *argv[9];
+ const char *argv[11];
char commit[41];
unsigned char sha1[20];
int err = 0, ac = 0;
@@ -56,6 +56,11 @@ static int check_everything_connected_real(sha1_iterate_fn fn,
argv[ac++] = "--stdin";
argv[ac++] = "--not";
argv[ac++] = "--all";
+ if(transport && transport->smart_options &&
+ transport->smart_options->sparse_prefix) {
+ argv[ac++] = "--sparse-prefix";
+ argv[ac++] = transport->smart_options->sparse_prefix;
+ }
if (quiet)
argv[ac++] = "--quiet";
argv[ac] = NULL;
diff --git a/transport.c b/transport.c
index b233e3e..ce7e2e1 100644
--- a/transport.c
+++ b/transport.c
@@ -141,6 +141,9 @@ static int set_git_option(struct git_transport_options *opts,
} else if (!strcmp(name, TRANS_OPT_UPDATE_SHALLOW)) {
opts->update_shallow = !!value;
return 0;
+ } else if (!strcmp(name, TRANS_OPT_SPARSE_PREFIX)) {
+ opts->sparse_prefix = value;
+ return 0;
} else if (!strcmp(name, TRANS_OPT_DEPTH)) {
if (!value)
opts->depth = 0;
@@ -211,6 +214,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.sparse_prefix = data->options.sparse_prefix;
args.check_self_contained_and_connected =
data->options.check_self_contained_and_connected;
args.cloning = transport->cloning;
diff --git a/transport.h b/transport.h
index c681408..abee186 100644
--- a/transport.h
+++ b/transport.h
@@ -15,6 +15,7 @@ struct git_transport_options {
int depth;
const char *uploadpack;
const char *receivepack;
+ const char *sparse_prefix;
struct push_cas_option *cas;
};
@@ -179,6 +180,9 @@ int transport_restrict_protocols(void);
/* Limit the depth of the fetch if not null */
#define TRANS_OPT_DEPTH "depth"
+/* Only fetch blobs whose referenced path begins with this if not null */
+#define TRANS_OPT_SPARSE_PREFIX "sparse-prefix"
+
/* Aggressively fetch annotated tags if possible */
#define TRANS_OPT_FOLLOWTAGS "followtags"
--
2.9.1.283.g3ca5b4c.dirty
next prev parent reply other threads:[~2016-07-28 16:03 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-07-28 16:02 [PATCH/RFC 0/7] Add possibility to clone specific subdirectories Robin Ruede
2016-07-28 16:02 ` [PATCH/RFC 1/7] list-objects: add sparse-prefix option to rev_info Robin Ruede
2016-07-28 16:02 ` [PATCH/RFC 2/7] pack-objects: add sparse-prefix Robin Ruede
2016-07-28 16:02 ` [PATCH/RFC 3/7] Skip checking integrity of files ignored by sparse Robin Ruede
2016-07-28 16:02 ` [PATCH/RFC 4/7] fetch-pack: add sparse prefix to smart protocol Robin Ruede
2016-07-28 16:02 ` Robin Ruede [this message]
2016-07-28 16:02 ` [PATCH/RFC 6/7] clone: add sparse-prefix option Robin Ruede
2016-07-28 16:02 ` [PATCH/RFC 7/7] remote-curl: add sparse prefix Robin Ruede
2016-07-28 16:59 ` [PATCH/RFC 0/7] Add possibility to clone specific subdirectories Duy Nguyen
2016-07-28 17:03 ` Duy Nguyen
2016-07-28 20:33 ` Junio C Hamano
2016-07-29 15:51 ` Duy Nguyen
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
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20160728160226.24018-6-r.ruede@gmail.com \
--to=r.ruede@gmail.com \
--cc=git@vger.kernel.org \
/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.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
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 read-only IMAP folder(s) and NNTP newsgroup(s).