@@ -539,8 +539,38 @@ vcsGit =
539
539
ref <- case srpBranch `mplus` srpTag of
540
540
Nothing -> pure " HEAD"
541
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.
542
572
git localDir (" fetch" : verboseArg ++ [" origin" , ref])
543
- pure ref
573
+ pure " FETCH_HEAD "
544
574
545
575
-- Then, reset to the appropriate ref.
546
576
git localDir $
0 commit comments