Repository navigation
Fetch only the pinned commit of a git source-repository-package - #12531
Open
ulysses4ever wants to merge 4 commits into
Open
ulysses4ever wants to merge 4 commits into
ulysses4ever wants to merge 4 commits into
Conversation
A git source-repository-package is cloned with --depth=1, which gets the tip of the default branch, and the commit that its tag or branch names is then fetched without --depth. In a shallow repository that fetches the whole history of that commit, so unless the pin is the tip, the shallow clone saves little (haskell#12523). Pass --depth=1 to that fetch too, but only in a shallow checkout. A checkout cloned from a plain local path, where git ignores --depth, stays complete, so that the other checkouts of the repository can still borrow its objects through --reference. A package that needs the history or the tags can fetch them with post-checkout-command; the docs now say how. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0176vAefrw8jPKXdh9h1wKuj
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0176vAefrw8jPKXdh9h1wKuj
Why only in a shallow checkout: a complete checkout, which is what git makes when it clones a plain local path (it ignores --depth there), stays complete, so that the other checkouts of the repository can still borrow its objects through --reference (haskell#12296). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0176vAefrw8jPKXdh9h1wKuj
ulysses4ever
marked this pull request as ready for review
November 5, 2026 15:18
ffaf1
approved these changes
Nov 5, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0176vAefrw8jPKXdh9h1wKuj
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #12523: a
source-repository-packagefrom git now downloads only the commit that itstagorbranchnames, instead of that commit's whole history. Below is the longer story from your friendly AI engine (Opus 5.5).Since #10254 (cabal 3.16), cabal clones with
--depth=1, which gets the tip of the default branch, and then runsgit fetch origin <tag>without--depth. In a shallow repository, that fetches the whole history of the pinned commit, so unless the pin is the tip, the shallow clone saves little. This passes--depth=1to that fetch as well.A complete checkout stays complete. Git ignores
--depthwhen it clones a plain local path, and such a checkout is what the other stanzas for the same repository borrow objects from through--reference(#12296). A--depth=1fetch would make it shallow and stop the sharing, so the fetch passes--depth=1only when.git/shallowexists.Packages now see only the pinned commit. Tags were already missing before this change: on master,
git describefails in the checkout too. A package that needs the history or the tags can usepost-checkout-command: git fetch --depth=2147483647 --tags, which the docs now describe.git fetch --unshallowwould make the next sync fail, because by then the checkout is complete.Testing
cabal-install:test:long-tests:syncSourceRepos, shallow, distinct tagsnow pins a tag with two commits of history and checks that every checkout has one commit; the local-path case checks for the full history. Without the change, the test fails withexpected: 1, but got: 2.file://: master's checkout has 3 commits and this branch's has 1. With thepost-checkout-commandabove, the checkout has 3 andgit describeworks, also after the pin moves to the tip; withgit fetch --unshallow --tagsinstead, that second sync fails with exit code 128.Not covered: submodules are still fetched in full, and so is the default branch on later syncs. Abbreviated hashes still fail, as they did before (#10605).
significance: significantin the changelog file.QA Notes
In an empty directory, write a
cabal.projectwithand run
cabal build --dry-run containers. Thengit -C dist-newstyle/src/contain*/ rev-list --count HEADprints 1; with cabal 3.16 to 3.18, it prints the number of commits up to the pinned one.🤖 Generated with Claude Code
https://claude.ai/code/session_0176vAefrw8jPKXdh9h1wKuj