Andrew's git
/
gitweb.git
/ diff
summary
|
log
|
commit
| diff |
tree
commit
grep
author
committer
pickaxe
?
re
promisor-remote: parse remote.*.partialclonefilter
author
Christian Couder
<christian.couder@gmail.com>
Tue, 25 Jun 2019 13:40:32 +0000
(15:40 +0200)
committer
Junio C Hamano
<gitster@pobox.com>
Tue, 25 Jun 2019 21:05:37 +0000
(14:05 -0700)
This makes it possible to specify a different partial clone
filter for each promisor remote.
Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/fetch.c
patch
|
blob
|
history
list-objects-filter-options.c
patch
|
blob
|
history
list-objects-filter-options.h
patch
|
blob
|
history
promisor-remote.c
patch
|
blob
|
history
promisor-remote.h
patch
|
blob
|
history
t/t0410-partial-clone.sh
patch
|
blob
|
history
t/t5601-clone.sh
patch
|
blob
|
history
t/t5616-partial-clone.sh
patch
|
blob
|
history
raw
|
patch
|
inline
| side by side (parent:
b14ed5a
)
diff --git
a/builtin/fetch.c
b/builtin/fetch.c
index f74bd78144b1fb96af74b73cb4e8818047c99d74..13d813313089c764c124d246c738a06c6fed57a4 100644
(file)
--- a/
builtin/fetch.c
+++ b/
builtin/fetch.c
@@
-1491,7
+1491,7
@@
static inline void fetch_one_setup_partial(struct remote *remote)
* the config.
*/
if (!filter_options.choice)
* the config.
*/
if (!filter_options.choice)
- partial_clone_get_default_filter_spec(&filter_options);
+ partial_clone_get_default_filter_spec(&filter_options
, remote->name
);
return;
}
return;
}
diff --git
a/list-objects-filter-options.c
b/list-objects-filter-options.c
index b0de7d3c176ab793c654e19314e84264ffe2966c..28c571f922e46cd6ff7aff659677d9003cf3c948 100644
(file)
--- a/
list-objects-filter-options.c
+++ b/
list-objects-filter-options.c
@@
-30,6
+30,9
@@
static int gently_parse_list_objects_filter(
{
const char *v0;
{
const char *v0;
+ if (!arg)
+ return 0;
+
if (filter_options->choice) {
if (errbuf) {
strbuf_addstr(
if (filter_options->choice) {
if (errbuf) {
strbuf_addstr(
@@
-148,6
+151,7
@@
void partial_clone_register(
const struct list_objects_filter_options *filter_options)
{
char *cfg_name;
const struct list_objects_filter_options *filter_options)
{
char *cfg_name;
+ char *filter_name;
/* Check if it is already registered */
if (!promisor_remote_find(remote)) {
/* Check if it is already registered */
if (!promisor_remote_find(remote)) {
@@
-162,27
+166,26
@@
void partial_clone_register(
/*
* Record the initial filter-spec in the config as
* the default for subsequent fetches from this remote.
/*
* Record the initial filter-spec in the config as
* the default for subsequent fetches from this remote.
- *
- * TODO: record it into remote.<name>.partialclonefilter
*/
*/
- core_partial_clone_filter_default =
- xstrdup(filter_options->filter_spec);
- git_config_set("core.partialclonefilter",
- core_partial_clone_filter_default);
+ filter_name = xstrfmt("remote.%s.partialclonefilter", remote);
+ git_config_set(filter_name, filter_options->filter_spec);
+ free(filter_name);
/* Make sure the config info are reset */
promisor_remote_reinit();
}
void partial_clone_get_default_filter_spec(
/* Make sure the config info are reset */
promisor_remote_reinit();
}
void partial_clone_get_default_filter_spec(
- struct list_objects_filter_options *filter_options)
+ struct list_objects_filter_options *filter_options,
+ const char *remote)
{
{
+ struct promisor_remote *promisor = promisor_remote_find(remote);
+
/*
* Parse default value, but silently ignore it if it is invalid.
*/
/*
* Parse default value, but silently ignore it if it is invalid.
*/
- if (!core_partial_clone_filter_default)
- return;
- gently_parse_list_objects_filter(filter_options,
- core_partial_clone_filter_default,
- NULL);
+ if (promisor)
+ gently_parse_list_objects_filter(filter_options,
+ promisor->partial_clone_filter,
+ NULL);
}
}
diff --git
a/list-objects-filter-options.h
b/list-objects-filter-options.h
index c54f0000fbade5608e81345a9c5dbd54137d352d..8deaa287b57cbbfd290ce4aa040883b8a5ebcd42 100644
(file)
--- a/
list-objects-filter-options.h
+++ b/
list-objects-filter-options.h
@@
-87,6
+87,7
@@
void partial_clone_register(
const char *remote,
const struct list_objects_filter_options *filter_options);
void partial_clone_get_default_filter_spec(
const char *remote,
const struct list_objects_filter_options *filter_options);
void partial_clone_get_default_filter_spec(
- struct list_objects_filter_options *filter_options);
+ struct list_objects_filter_options *filter_options,
+ const char *remote);
#endif /* LIST_OBJECTS_FILTER_OPTIONS_H */
#endif /* LIST_OBJECTS_FILTER_OPTIONS_H */
diff --git
a/promisor-remote.c
b/promisor-remote.c
index 6a8856f475502d806456d3cf8186495f0e58f733..826890f7b805f8ed73c13a66f65ff9140651514f 100644
(file)
--- a/
promisor-remote.c
+++ b/
promisor-remote.c
@@
-75,6
+75,21
@@
static int promisor_remote_config(const char *var, const char *value, void *data
free(remote_name);
return 0;
}
free(remote_name);
return 0;
}
+ if (!strcmp(subkey, "partialclonefilter")) {
+ struct promisor_remote *r;
+ char *remote_name = xmemdupz(name, namelen);
+
+ r = promisor_remote_lookup(remote_name, NULL);
+ if (!r)
+ r = promisor_remote_new(remote_name);
+
+ free(remote_name);
+
+ if (!r)
+ return 0;
+
+ return git_config_string(&r->partial_clone_filter, var, value);
+ }
return 0;
}
return 0;
}
diff --git
a/promisor-remote.h
b/promisor-remote.h
index dddd4048e0cc015df353b1b595c8904215f187fe..838cb092f3c8bb8beab2b4c99a0c6b198a4ef64f 100644
(file)
--- a/
promisor-remote.h
+++ b/
promisor-remote.h
@@
-5,10
+5,13
@@
struct object_id;
/*
* Promisor remote linked list
/*
* Promisor remote linked list
- * Its information come from remote.XXX config entries.
+ *
+ * Information in its fields come from remote.XXX config entries or
+ * from extensions.partialclone or core.partialclonefilter.
*/
struct promisor_remote {
struct promisor_remote *next;
*/
struct promisor_remote {
struct promisor_remote *next;
+ const char *partial_clone_filter;
const char name[FLEX_ARRAY];
};
const char name[FLEX_ARRAY];
};
diff --git
a/t/t0410-partial-clone.sh
b/t/t0410-partial-clone.sh
index 3559313bd030971718bfdd260cf3616974f3b47d..3082eff2bf1a378daa39bfb309fc5759f349b80f 100755
(executable)
--- a/
t/t0410-partial-clone.sh
+++ b/
t/t0410-partial-clone.sh
@@
-26,7
+26,7
@@
promise_and_delete () {
test_expect_success 'extensions.partialclone without filter' '
test_create_repo server &&
git clone --filter="blob:none" "file://$(pwd)/server" client &&
test_expect_success 'extensions.partialclone without filter' '
test_create_repo server &&
git clone --filter="blob:none" "file://$(pwd)/server" client &&
- git -C client config --unset
core
.partialclonefilter &&
+ git -C client config --unset
remote.origin
.partialclonefilter &&
git -C client fetch origin
'
git -C client fetch origin
'
diff --git
a/t/t5601-clone.sh
b/t/t5601-clone.sh
index 534d03a4d787ae2b9911c0171c91ba1493d2556d..078cf48dd610c547e71afb3b2488927afa87903a 100755
(executable)
--- a/
t/t5601-clone.sh
+++ b/
t/t5601-clone.sh
@@
-655,6
+655,7
@@
partial_clone () {
# Ensure that unneeded blobs are not inadvertently fetched.
test_config -C client remote.origin.promisor "false" &&
# Ensure that unneeded blobs are not inadvertently fetched.
test_config -C client remote.origin.promisor "false" &&
+ git -C client config --unset remote.origin.partialclonefilter &&
test_must_fail git -C client cat-file -e "$HASH1" &&
# But this blob was fetched, because clone performs an initial checkout
test_must_fail git -C client cat-file -e "$HASH1" &&
# But this blob was fetched, because clone performs an initial checkout
diff --git
a/t/t5616-partial-clone.sh
b/t/t5616-partial-clone.sh
index 8f9a62aac0b9a5cf83eb17e50a16f7690ebf356e..8ae7ba9c950f5475c920ea11797a3d15cb2ccc19 100755
(executable)
--- a/
t/t5616-partial-clone.sh
+++ b/
t/t5616-partial-clone.sh
@@
-43,7
+43,7
@@
test_expect_success 'do partial clone 1' '
test_cmp expect_1.oids observed.oids &&
test "$(git -C pc1 config --local core.repositoryformatversion)" = "1" &&
test "$(git -C pc1 config --local remote.origin.promisor)" = "true" &&
test_cmp expect_1.oids observed.oids &&
test "$(git -C pc1 config --local core.repositoryformatversion)" = "1" &&
test "$(git -C pc1 config --local remote.origin.promisor)" = "true" &&
- test "$(git -C pc1 config --local
core
.partialclonefilter)" = "blob:none"
+ test "$(git -C pc1 config --local
remote.origin
.partialclonefilter)" = "blob:none"
'
# checkout master to force dynamic object fetch of blobs at HEAD.
'
# checkout master to force dynamic object fetch of blobs at HEAD.