Skip to content

docs: correct the shallow clone claim for commit plus branch - #2147

Merged
matheuscscp merged 1 commit into
fluxcd:mainfrom
SaiPisey2:docs/commit-branch-is-not-a-shallow-clone
Sep 1, 2026
Merged

docs: correct the shallow clone claim for commit plus branch#2147
matheuscscp merged 1 commit into
fluxcd:mainfrom
SaiPisey2:docs/commit-branch-is-not-a-shallow-clone

Conversation

@SaiPisey2

Copy link
Copy Markdown
Contributor

Part of #2146 — the documentation half only.

The v1 GitRepository docs say that combining .spec.ref.commit with .spec.ref.branch performs a shallow clone of the branch. It does not.

In fluxcd/pkg/git/gogit, cloneBranch, cloneTag and cloneSemVer all set Depth from opts.ShallowClone. cloneCommit has no Depth field in its CloneOptions at all, and Client.clone dispatches on Commit before any other ref field, so a commit-pinned GitRepository always takes that path. Setting a branch alongside it only sets SingleBranch and ReferenceName, so the clone is narrowed to one branch but still fetches that branch in full.

The wording appears to predate the gitImplementation: go-git | libgit2 split, where it was carried over from the v1beta2 field comment.

This only corrects the documentation. The bounded-depth mechanism and the LastObservedCommit fast path also raised in #2146 are behaviour changes in fluxcd/pkg and are left for maintainers to weigh in on first.

Combining .spec.ref.commit with .spec.ref.branch does not shallow clone.
cloneCommit in fluxcd/pkg/git/gogit sets no Depth at all, unlike the
branch, tag and semver paths, so a branch only narrows the clone to a
single branch and the full history of that branch is still fetched.

The wording predates the go-git and libgit2 split and has been inaccurate
since.

Signed-off-by: SaiPisey2 <piseysai0202@gmail.com>

@matheuscscp matheuscscp left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@matheuscscp matheuscscp added area/docs Documentation related issues and pull requests backport:release/v1.9.x To be backported to release/v1.9.x labels Sep 1, 2026
@matheuscscp
matheuscscp merged commit 3d828e0 into fluxcd:main Sep 1, 2026
8 checks passed
@fluxcdbot

Copy link
Copy Markdown
Member

Successfully created backport PR for release/v1.9.x:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/docs Documentation related issues and pull requests backport:release/v1.9.x To be backported to release/v1.9.x

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants