repair: Fix reversion in version 8.20200522 that prevented fetching missing objects...
authorJoey Hess <joeyh@joeyh.name>
Tue, 29 Jun 2021 17:15:15 +0000 (13:15 -0400)
committerJoey Hess <joeyh@joeyh.name>
Tue, 29 Jun 2021 17:15:15 +0000 (13:15 -0400)
In commit dfc4e641b5c14418ec1c1b45bed1325cf8cbb0c3 git repair was changed
to use remote name, not url, when fetching. But it fetches into a temporary
git repo, which doesn't have remotes configured. Oops.

(In my defense, that commit was made just as covid lockdown started. But
testing? Urk.)

Sponsored-by: Mark Reidenbach on Patreon
CHANGELOG
Git/Repair.hs

index 850d88ff4ad576b9272c4a22733ec0c550294cc4..14048bc3963d10fde13e46da0f89902cded6a781 100644 (file)
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -16,6 +16,8 @@ git-annex (8.20210622) UNRELEASED; urgency=medium
   * Fixed bug that interrupting git-annex repair (or assistant) while
     it was fixing repository corruption would lose objects that were
     contained in pack files.
+  * repair: Fix reversion in version 8.20200522 that prevented fetching
+    missing objects from remotes.
 
  -- Joey Hess <id@joeyh.name>  Mon, 21 Jun 2021 12:25:25 -0400
 
index d52d70ba07eec30b119f03784bb12e699fe69e74..df5608a014557b34e386ba7a197c87cf833cae63 100644 (file)
@@ -42,6 +42,7 @@ import Utility.Directory.Create
 import Utility.Tmp.Dir
 import Utility.Rsync
 import Utility.FileMode
+import Utility.CopyFile
 import qualified Utility.RawFilePath as R
 
 import qualified Data.Set as S
@@ -115,7 +116,12 @@ retrieveMissingObjects missing referencerepo r
        | otherwise = withTmpDir "tmprepo" $ \tmpdir -> do
                unlessM (boolSystem "git" [Param "init", File tmpdir]) $
                        error $ "failed to create temp repository in " ++ tmpdir
+               let repoconfig r' = fromRawFilePath (localGitDir r' P.</> "config")
                tmpr <- Config.read =<< Construct.fromPath (toRawFilePath tmpdir)
+               whenM (doesFileExist (repoconfig r)) $
+                       void $ copyFileExternal CopyAllMetaData
+                               (repoconfig r)
+                               (repoconfig tmpr)
                rs <- Construct.fromRemotes r
                stillmissing <- pullremotes tmpr rs fetchrefstags missing
                if S.null (knownMissing stillmissing)