-
-
Notifications
You must be signed in to change notification settings - Fork 394
Open
Labels
acknowledgedan issue is accepted as shortcoming to be fixedan issue is accepted as shortcoming to be fixed
Description
Current behavior 😯
In current implementation of fetch_only, the refspecs is hardcoded to +refs/heads/*:refs/remotes/{remote_name}/* even when shallow cloning. As a result, the cloned repo is significantly larger than repo cloned by git.
Expected behavior 🤔
The repo size and fetch config should be the same with git
Git behavior
In git's implementation (https://github.com/git/git/blob/133d151831d32bdcc02422599a3f26cef44f929b/builtin/clone.c#L810), the fetch config varies based on the option:
if (option_single_branch && !option_mirror) {
if (option_branch) {
if (starts_with(our_head_points_at->name, "refs/tags/"))
strbuf_addf(&value, "+%s:%s", our_head_points_at->name,
our_head_points_at->name);
else
strbuf_addf(&value, "+%s:%s%s", our_head_points_at->name,
branch_top->buf, option_branch);
} else if (remote_head_points_at) {
const char *head = remote_head_points_at->name;
if (!skip_prefix(head, "refs/heads/", &head))
BUG("remote HEAD points at non-head?");
strbuf_addf(&value, "+%s:%s%s", remote_head_points_at->name,
branch_top->buf, head);
}
/*
* otherwise, the next "git fetch" will
* simply fetch from HEAD without updating
* any remote-tracking branch, which is what
* we want.
*/
} else {
strbuf_addf(&value, "+%s*:%s*", src_ref_prefix, branch_top->buf);
}
/* Configure the remote */
if (value.len) {
strbuf_addf(&key, "remote.%s.fetch", remote_name);
repo_config_set_multivar(the_repository, key.buf, value.buf, "^$", 0);
strbuf_reset(&key);
if (option_mirror) {
strbuf_addf(&key, "remote.%s.mirror", remote_name);
repo_config_set(the_repository, key.buf, "true");
strbuf_reset(&key);
}
}Steps to reproduce 🕹
- Run
gix clone --depth 1 https://github.com/GitoxideLabs/gitoxide - The size of cloned gitoxide is about 130MB and the fetch config is
fetch = +refs/heads/*:refs/remotes/origin/*. Runninggit taginside gitoxide shows a lot of tags. - Run
git clone --depth 1 https://github.com/GitoxideLabs/gitoxide - The size of gitoxide is about 70MB and the fetch config is
fetch = +refs/heads/main:refs/remotes/origin/main.git tagshows nothing
Metadata
Metadata
Assignees
Labels
acknowledgedan issue is accepted as shortcoming to be fixedan issue is accepted as shortcoming to be fixed