Skip to content

Commit 23547c4

Browse files
jonathantanmygitster
authored andcommitted
fetch: do not override partial clone filter
When a fetch with the --filter argument is made, the configured default filter is set even if one already exists. This change was made in 5e46139 ("builtin/fetch: remove unique promisor remote limitation", 2019-06-25) - in particular, changing from: * If this is the FIRST partial-fetch request, we enable partial * on this repo and remember the given filter-spec as the default * for subsequent fetches to this remote. to: * If this is a partial-fetch request, we enable partial on * this repo if not already enabled and remember the given * filter-spec as the default for subsequent fetches to this * remote. (The given filter-spec is "remembered" even if there is already an existing one.) This is problematic whenever a lazy fetch is made, because lazy fetches are made using "git fetch --filter=blob:none", but this will also happen if the user invokes "git fetch --filter=<filter>" manually. Therefore, restore the behavior prior to 5e46139, which writes a filter-spec only if the current fetch request is the first partial-fetch one (for that remote). Signed-off-by: Jonathan Tan <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 625e7f1 commit 23547c4

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

builtin/fetch.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1677,7 +1677,7 @@ static inline void fetch_one_setup_partial(struct remote *remote)
16771677
* If this is a partial-fetch request, we enable partial on
16781678
* this repo if not already enabled and remember the given
16791679
* filter-spec as the default for subsequent fetches to this
1680-
* remote.
1680+
* remote if there is currently no default filter-spec.
16811681
*/
16821682
if (filter_options.choice) {
16831683
partial_clone_register(remote->name, &filter_options);

list-objects-filter-options.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,11 +344,19 @@ void partial_clone_register(
344344
const char *remote,
345345
struct list_objects_filter_options *filter_options)
346346
{
347+
struct promisor_remote *promisor_remote;
347348
char *cfg_name;
348349
char *filter_name;
349350

350351
/* Check if it is already registered */
351-
if (!promisor_remote_find(remote)) {
352+
if ((promisor_remote = promisor_remote_find(remote))) {
353+
if (promisor_remote->partial_clone_filter)
354+
/*
355+
* Remote is already registered and a filter is already
356+
* set, so we don't need to do anything here.
357+
*/
358+
return;
359+
} else {
352360
if (upgrade_repository_format(1) < 0)
353361
die(_("unable to upgrade repository format to support partial clone"));
354362

t/t5601-clone.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -669,7 +669,8 @@ test_expect_success 'partial clone' '
669669

670670
test_expect_success 'partial clone with -o' '
671671
partial_clone_server server &&
672-
git clone -o blah --filter=blob:limit=0 "file://$(pwd)/server" client
672+
git clone -o blah --filter=blob:limit=0 "file://$(pwd)/server" client &&
673+
test_cmp_config -C client "blob:limit=0" --get-all remote.blah.partialclonefilter
673674
'
674675

675676
test_expect_success 'partial clone: warn if server does not support object filtering' '

0 commit comments

Comments
 (0)