From 6b0d732746989b17ffe9f3212fd64226519d76c5 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Tue, 29 Jun 2021 13:15:15 -0400 Subject: [PATCH] repair: Fix reversion in version 8.20200522 that prevented fetching missing objects from remotes 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 | 2 ++ Git/Repair.hs | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index 850d88ff4a..14048bc396 100644 --- 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 Mon, 21 Jun 2021 12:25:25 -0400 diff --git a/Git/Repair.hs b/Git/Repair.hs index d52d70ba07..df5608a014 100644 --- a/Git/Repair.hs +++ b/Git/Repair.hs @@ -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)