-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fetch: enable deepening/shortening shallow clones #6662
fetch: enable deepening/shortening shallow clones #6662
Conversation
A shallow repository can currently only be completely unshallowed, which is caused by mark_local() only marking locally-existing objects as wanted if the fetch depth is set to INT_MAX (GIT_FETCH_DEPTH_UNSHALLOW). This prevents deepening the history of a shallow clone to an arbitrary number of commits, which may be preferable over full unshallowing for large repositories. Enable deepening and shortening shallow clones by marking locally-existing objects as wanted whenever the fetch depth is set to any non-default value (either GIT_FETCH_DEPTH_UNSHALLOW or an arbitrary positive integer).
git_repository_free(repo); | ||
} | ||
|
||
void test_online_shallow__shorten_four(void) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
void test_online_shallow__shorten_four(void) | |
void test_online_shallow__shorten_five(void) |
It looks like this actually deepens five not four?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Both test_online_shallow__deepen_six()
and test_online_shallow__shorten_four()
start by cloning the test repository with a depth of 5 (clone_opts.fetch_opts.depth = 5;
).
test_online_shallow__deepen_six()
then fetches from the repository again, but with a depth of 6 (fetch_opts.depth = 6;
), to demonstrate that libgit2 is able to make a shallow history deeper.
test_online_shallow__shorten_four()
, which you called out in your comment, performs the post-cloning fetch with a depth of 4 (fetch_opts.depth = 4;
), to demonstrate that libgit2 is also able to make a shallow history shorter.
Does this help?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops. 😓 Yes, sorry, I misread that.
Thanks for the fix! Sorry for the delay, I had to read the surrounding comment a few times to remember how this all works. 😅 One minor question about the name of the test - otherwise looks great. |
Thanks @kempniu ! |
A shallow repository can currently only be completely unshallowed, which is caused by mark_local() only marking locally-existing objects as wanted if the fetch depth is set to
INT_MAX
(GIT_FETCH_DEPTH_UNSHALLOW
). This prevents deepening the history of a shallow clone to an arbitrary number of commits, which may be preferable over full unshallowing for large repositories.Enable deepening and shortening shallow clones by marking locally-existing objects as wanted whenever the fetch depth is set to any non-default value (either
GIT_FETCH_DEPTH_UNSHALLOW
or an arbitrary positive integer).