You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Auto merge of #13252 - connorworley:shallow_libgit2_fetches, r=weihanglo
Implementation of shallow libgit2 fetches behind an unstable flag
This is my first contribution, so guidance is appreciated.
Fixes#1171 by moving the `shallow-index` and `shallow-deps` aspects of `-Zgitoxide` to a new `-Zgit` unstable flag.
The only change in interaction with libgit2 happens in `src/cargo/sources/git/utils.rs`, where we set the depth fetch option if applicable.
Shallow fetch tests for gitoxide continue to pass, but libgit2 is harder to test as it silently ignores the depth option for local fetches. I would love any ideas on how to test it in a lightweight way or whether it's OK to wait for an upstream fix.
With the 'git' unstable feature, both `gitoxide` and `git2` will perform shallow fetches of the crate
1182
+
index and git dependencies.
1183
+
1184
+
While `-Zgit` enables all currently implemented features, one can individually select when to perform
1185
+
shallow fetches with the `-Zgit=operation[,operationN]` syntax.
1186
+
1187
+
Valid operations are the following:
1188
+
1175
1189
*`shallow-index` - perform a shallow clone of the index.
1176
1190
*`shallow-deps` - perform a shallow clone of git dependencies.
1177
-
*`checkout`*(planned)* - checkout the worktree, with support for filters and submodules.
1178
1191
1179
1192
**Details on shallow clones**
1180
1193
1181
-
* To enable shallow clones, add `-Zgitoxide=fetch,shallow_deps` for fetching git dependencies or `-Zgitoxide=fetch,shallow_index` for fetching registry index.
1194
+
* To enable shallow clones, add `-Zgit=shallow-deps` for fetching git dependencies or `-Zgit=shallow-index` for fetching registry index.
1182
1195
* Shallow-cloned and shallow-checked-out git repositories reside at their own `-shallow` suffixed directories, i.e,
1183
1196
-`~/.cargo/registry/index/*-shallow`
1184
1197
-`~/.cargo/git/db/*-shallow`
1185
1198
-`~/.cargo/git/checkouts/*-shallow`
1186
1199
* When the unstable feature is on, fetching/cloning a git repository is always a shallow fetch. This roughly equals to `git fetch --depth 1` everywhere.
1187
-
* Even with the presence of `Cargo.lock` or specifying a commit `{ rev = "…" }`, gitoxide is still smart enough to shallow fetch without unshallowing the existing repository.
1200
+
* Even with the presence of `Cargo.lock` or specifying a commit `{ rev = "…" }`, gitoxide and libgit2 are still smart enough to shallow fetch without unshallowing the existing repository.
0 commit comments