8000 Support for shallow-since clones/fetches by malcolmwood76 · Pull Request #7093 · libgit2/libgit2 · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Support for shallow-since clones/fetches #7093

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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

malcolmwood76
Copy link
@malcolmwood76 malcolmwood76 commented Jun 19, 2025

Support for the Git "shallow-since" option for clone/fetch. In the Git protocol the term "deepen-since" is used. The implementation below works well when the specified date is older than the newest commit - i.e. when there are commits to fetch.

The Git command-line gives a very poor error when the date specified is newer than newest last commit - i.e. no commits to fetch. The message is "error processing shallow info: 4".

Unfortunately, with this change libgit2 gives an even poorer error (GIT_EEOF). See the function: test_online_shallow__clone_since_recent.

With packet tracing enabled in the Git command-line I can see a "0002" message arriving after the one about "refs/tags/nearly-dangling". But in my test this doesn't seem to arrive, and we get GIT_EEOF in the call to recv_pkt at smart_protocol.c:447 instead.

fixes #6611

@@ -808,12 +811,22 @@ typedef struct {
/**
* Depth of the fetch to perform, or `GIT_FETCH_DEPTH_FULL`
* (or `0`) for full history, or `GIT_FETCH_DEPTH_UNSHALLOW`
* to "unshallow" a shallow repository.
* to "unshallow" a shallow repository. Cannot be used in
* conjunction with a specific shallow_since date.
*
* The default is full (`GIT_FETCH_DEPTH_FULL` or `0`).
*/
int depth;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that we have shallow_since, depth is no longer the only variable that determines whether a fetch is shallow or not. Consider clone.c: if (!options.fetch_opts.depth)
options.fetch_opts.download_tags = GIT_REMOTE_DOWNLOAD_TAGS_ALL;

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So we could have a new function that takes git_fetch_options and returns true/false if the fetch would be shallow.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tried this, but it's difficult to get a combination of name and behaviour. You only know if the fetch "would be shallow" if you know how many commits there are, which we don't. An "unshallow" operation is largely indistinguishable from a shallow fetch with a large depth.

@@ -828,13 +828,40 @@ int git_pkt_buffer_wants(
}

if (wants->depth > 0) {

if (wants->shallow_since != GIT_FETCH_SINCE_UNSPECIFIED) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we do this argument validation up in git_fetch_negotiate?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't see a better location that would definitely be hit by every codepath.

mwood added 2 commits June 20, 2025 13:47
@malcolmwood76
Copy link
Author

Renamed the detault value of shallow_since to "GIT_FETCH_SINCE_FULL", and change the value to zero. This makes its usage more consistent with the usage of "depth".

@malcolmwood76 malcolmwood76 changed the title Support for shallow-since clones/fetches Support for shallow-since clones/fetches - fixes #6611 Jun 20, 2025
@malcolmwood76 malcolmwood76 changed the title Support for shallow-since clones/fetches - fixes #6611 Support for shallow-since clones/fetches Jun 20, 2025
@lrm29
Copy link
Contributor
lrm29 commented Jun 20, 2025

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

"Shallow Since" Clones Support
2 participants
0