Repository navigation
cabal get: check out the tag without moving the cloned branch - #12644
Open
swinilohani616-dot wants to merge 3 commits into
Open
swinilohani616-dot wants to merge 3 commits into
swinilohani616-dot wants to merge 3 commits into
Conversation
When cloning a git source-repository that has a tag, cabal get -s ran "git reset --hard <tag>" after cloning. That moved the branch it had just cloned back to the tag, so the local branch no longer matched the remote (and if a branch: was given too, that branch was the one moved). Check the tag out as a detached HEAD instead, so the working tree is at the tag and the cloned branch stays where it is on the remote. This only affects vcsCloneRepo, which is used by cabal get; syncing source-repository-package checkouts is unchanged. Fixes haskell#10278
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 #10278.
When a package's
source-repositoryhas atag:,cabal get -sclones the repo and then runsgit reset --hard <tag>. The files end up at the tag, which is right, but the reset also drags the branch youjust cloned back to that tag. So you're sitting on
main, except yourmainnow points at an old release andgit tells you it's behind
origin/main. That's not what anyone expects after a fresh clone.I've changed that second step to
git checkout --detach <tag>. You still get exactly the tag's files, but thebranch is left alone and keeps matching the remote. This only affects the clone
cabal getdoes.source-repository-packagecheckouts go through a different code path, so they behave the same as before.The issue also floats making
branch:andtag:mutually exclusive and changing what-dmeans. Those feltlike bigger design questions, so I kept this PR to the bug itself, but I'm happy to pick them up separately if
people want.
v1and a newer commit onmain.source-repository thispoints at it withtag: v1(addingbranch: mainis finetoo), and put its sdist in a local repository.
cabal get <pkg> --source-repository=this, thengit statusinside the clone.Without this change you'll see
main...origin/main [behind 1]. With it,HEADshould be detached atv1andmainshould still matchorigin/main.UnitTests.Distribution.Client.VCSthat clones at a tag and checksthat the files are at the tag while the cloned branch still matches the source repo.