]> Kevux Git Server - rit/commitdiff
maintenance: respect remote.*.skipFetchAll
authorDerrick Stolee <dstolee@microsoft.com>
Fri, 16 Apr 2021 12:49:59 +0000 (12:49 +0000)
committerJunio C Hamano <gitster@pobox.com>
Fri, 16 Apr 2021 20:36:55 +0000 (13:36 -0700)
If a remote has the skipFetchAll setting enabled, then that remote is
not intended for frequent fetching. It makes sense to not fetch that
data during the 'prefetch' maintenance task. Skip that remote in the
iteration without error. The skip_default_update member is initialized
in remote.c:handle_config() as part of initializing the 'struct remote'.

Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/gc.c
t/t7900-maintenance.sh

index 9d35f7d..98a8031 100644 (file)
@@ -878,6 +878,9 @@ static int fetch_remote(struct remote *remote, void *cbdata)
        struct maintenance_run_opts *opts = cbdata;
        struct child_process child = CHILD_PROCESS_INIT;
 
+       if (remote->skip_default_update)
+               return 0;
+
        child.git_cmd = 1;
        strvec_pushl(&child.args, "fetch", remote->name,
                     "--prefetch", "--prune", "--no-tags",
index eadb800..b93ae01 100755 (executable)
@@ -153,7 +153,13 @@ test_expect_success 'prefetch multiple remotes' '
 
        test_cmp_config refs/prefetch/ log.excludedecoration &&
        git log --oneline --decorate --all >log &&
-       ! grep "prefetch" log
+       ! grep "prefetch" log &&
+
+       test_when_finished git config --unset remote.remote1.skipFetchAll &&
+       git config remote.remote1.skipFetchAll true &&
+       GIT_TRACE2_EVENT="$(pwd)/skip-remote1.txt" git maintenance run --task=prefetch 2>/dev/null &&
+       test_subcommand ! git fetch remote1 $fetchargs <skip-remote1.txt &&
+       test_subcommand git fetch remote2 $fetchargs <skip-remote1.txt
 '
 
 test_expect_success 'prefetch and existing log.excludeDecoration values' '