mirror of
https://github.com/git/git
synced 2024-08-27 19:49:21 +00:00
maintenance: use 'git fetch --prefetch'
The 'prefetch' maintenance task previously forced the following refspec for each remote: +refs/heads/*:refs/prefetch/<remote>/* If a user has specified a more strict refspec for the remote, then this prefetch task downloads more objects than necessary. The previous change introduced the '--prefetch' option to 'git fetch' which manipulates the remote's refspec to place all resulting refs into refs/prefetch/, with further partitioning based on the destinations of those refspecs. Update the documentation to be more generic about the destination refs. Do not mention custom refspecs explicitly, as that does not need to be highlighted in this documentation. The important part of placing refs in refs/prefetch/ remains. Reported-by: Tom Saeger <tom.saeger@oracle.com> Signed-off-by: Derrick Stolee <dstolee@microsoft.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
2e03115d0c
commit
cfd781ea22
|
@ -92,10 +92,8 @@ commit-graph::
|
||||||
prefetch::
|
prefetch::
|
||||||
The `prefetch` task updates the object directory with the latest
|
The `prefetch` task updates the object directory with the latest
|
||||||
objects from all registered remotes. For each remote, a `git fetch`
|
objects from all registered remotes. For each remote, a `git fetch`
|
||||||
command is run. The refmap is custom to avoid updating local or remote
|
command is run. The configured refspec is modified to place all
|
||||||
branches (those in `refs/heads` or `refs/remotes`). Instead, the
|
requested refs within `refs/prefetch/`. Also, tags are not updated.
|
||||||
remote refs are stored in `refs/prefetch/<remote>/`. Also, tags are
|
|
||||||
not updated.
|
|
||||||
+
|
+
|
||||||
This is done to avoid disrupting the remote-tracking branches. The end users
|
This is done to avoid disrupting the remote-tracking branches. The end users
|
||||||
expect these refs to stay unmoved unless they initiate a fetch. With prefetch
|
expect these refs to stay unmoved unless they initiate a fetch. With prefetch
|
||||||
|
|
|
@ -879,15 +879,14 @@ static int fetch_remote(struct remote *remote, void *cbdata)
|
||||||
struct child_process child = CHILD_PROCESS_INIT;
|
struct child_process child = CHILD_PROCESS_INIT;
|
||||||
|
|
||||||
child.git_cmd = 1;
|
child.git_cmd = 1;
|
||||||
strvec_pushl(&child.args, "fetch", remote->name, "--prune", "--no-tags",
|
strvec_pushl(&child.args, "fetch", remote->name,
|
||||||
|
"--prefetch", "--prune", "--no-tags",
|
||||||
"--no-write-fetch-head", "--recurse-submodules=no",
|
"--no-write-fetch-head", "--recurse-submodules=no",
|
||||||
"--refmap=", NULL);
|
NULL);
|
||||||
|
|
||||||
if (opts->quiet)
|
if (opts->quiet)
|
||||||
strvec_push(&child.args, "--quiet");
|
strvec_push(&child.args, "--quiet");
|
||||||
|
|
||||||
strvec_pushf(&child.args, "+refs/heads/*:refs/prefetch/%s/*", remote->name);
|
|
||||||
|
|
||||||
return !!run_command(&child);
|
return !!run_command(&child);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -141,15 +141,15 @@ test_expect_success 'prefetch multiple remotes' '
|
||||||
test_commit -C clone1 one &&
|
test_commit -C clone1 one &&
|
||||||
test_commit -C clone2 two &&
|
test_commit -C clone2 two &&
|
||||||
GIT_TRACE2_EVENT="$(pwd)/run-prefetch.txt" git maintenance run --task=prefetch 2>/dev/null &&
|
GIT_TRACE2_EVENT="$(pwd)/run-prefetch.txt" git maintenance run --task=prefetch 2>/dev/null &&
|
||||||
fetchargs="--prune --no-tags --no-write-fetch-head --recurse-submodules=no --refmap= --quiet" &&
|
fetchargs="--prefetch --prune --no-tags --no-write-fetch-head --recurse-submodules=no --quiet" &&
|
||||||
test_subcommand git fetch remote1 $fetchargs +refs/heads/\\*:refs/prefetch/remote1/\\* <run-prefetch.txt &&
|
test_subcommand git fetch remote1 $fetchargs <run-prefetch.txt &&
|
||||||
test_subcommand git fetch remote2 $fetchargs +refs/heads/\\*:refs/prefetch/remote2/\\* <run-prefetch.txt &&
|
test_subcommand git fetch remote2 $fetchargs <run-prefetch.txt &&
|
||||||
test_path_is_missing .git/refs/remotes &&
|
test_path_is_missing .git/refs/remotes &&
|
||||||
git log prefetch/remote1/one &&
|
git log prefetch/remotes/remote1/one &&
|
||||||
git log prefetch/remote2/two &&
|
git log prefetch/remotes/remote2/two &&
|
||||||
git fetch --all &&
|
git fetch --all &&
|
||||||
test_cmp_rev refs/remotes/remote1/one refs/prefetch/remote1/one &&
|
test_cmp_rev refs/remotes/remote1/one refs/prefetch/remotes/remote1/one &&
|
||||||
test_cmp_rev refs/remotes/remote2/two refs/prefetch/remote2/two &&
|
test_cmp_rev refs/remotes/remote2/two refs/prefetch/remotes/remote2/two &&
|
||||||
|
|
||||||
test_cmp_config refs/prefetch/ log.excludedecoration &&
|
test_cmp_config refs/prefetch/ log.excludedecoration &&
|
||||||
git log --oneline --decorate --all >log &&
|
git log --oneline --decorate --all >log &&
|
||||||
|
|
Loading…
Reference in a new issue