@@ -483,9 +483,6 @@ vcsGit =
483483 resetArgs tag = " reset" : verboseArg ++ [" --hard" , tag, " --" ]
484484 verboseArg = [" --quiet" | verbosity < Verbosity. normal]
485485
486- -- Note: No --depth=1 for vcsCloneRepo since that is used for `cabal get -s`,
487- -- whereas `vcsSyncRepo` is used for source-repository-package where we do want shallow clones.
488-
489486 vcsSyncRepos
490487 :: Verbosity
491488 -> ConfiguredProgram
@@ -535,44 +532,9 @@ vcsGit =
535532 (\ e -> if isPermissionError e then removePathForcibly gitModulesDir else throw e)
536533 else removeDirectoryRecursive gitModulesDir
537534
538- -- If we want a particular branch or tag, fetch it.
539- ref <- case srpBranch `mplus` srpTag of
540- Nothing -> pure " HEAD"
541- Just ref -> do
542- -- /!\ /!\ /!\ /!\ /!\ /!\ /!\ /!\ /!\ /!\ /!\ /!\ /!\ /!\ /!\ /!\ /!\
543- -- /!\ MULTIPLE HOURS HAVE BEEN LOST HERE!! /!\
544- -- /!\ /!\ /!\ /!\ /!\ /!\ /!\ /!\ /!\ /!\ /!\ /!\ /!\ /!\ /!\ /!\ /!\
545- --
546- -- If you run `git fetch origin MY_TAG`, then the tag _will_ be
547- -- fetched, but no local ref (e.g. `refs/tags/MY_TAG`) will be
548- -- created.
549- --
550- -- This means that doing `git fetch origin MY_TAG && git reset --hard
551- -- MY_TAG` will fail with a message like `unknown revision MY_TAG`.
552- --
553- -- There are two ways around this:
554- --
555- -- 1. Provide a refmap explicitly:
556- --
557- -- git fetch --refmap="+refs/tags/*:refs/tags/*" origin MYTAG
558- --
559- -- This tells Git to create local tags matching remote tags. It's
560- -- not in the default refmap so you need to set it explicitly.
561- -- (You can also set it with `git config set --local
562- -- remote.origin.fetch ...`.)
563- --
564- -- 2. Use `FETCH_HEAD` directly: Git writes a `FETCH_HEAD` ref
565- -- containing the commit that was just fetched. This feels a bit
566- -- nasty but seems to work reliably, even if nothing was fetched.
567- -- (That is, deleting `FETCH_HEAD` and re-running a `git fetch`
568- -- command will succesfully recreate the `FETCH_HEAD` ref.)
569- --
570- -- Option 2 is what Cabal has done historically, and we're keeping it
571- -- for now. Option 1 is possible but seems to have little benefit.
572- git localDir (" fetch" : verboseArg ++ [" origin" , ref])
573- pure " FETCH_HEAD"
574-
575- -- Then, reset to the appropriate ref.
535+ -- If we want a particular branch or tag, reset to it.
536+ -- Otherwise, check out the default `HEAD`.
537+ let ref = fromMaybe " HEAD" $ srpBranch `mplus` srpTag
576538 git localDir $
577539 " reset"
578540 : verboseArg
@@ -594,7 +556,7 @@ vcsGit =
594556 }
595557
596558 cloneArgs =
597- [" clone" , " --depth=1 " , " -- no-checkout" , loc, localDir]
559+ [" clone" , " --no-checkout" , loc, localDir]
598560 ++ case peer of
599561 Nothing -> []
600562 Just peerLocalDir -> [" --reference" , peerLocalDir]
0 commit comments