repair: Fix reversion in version 8.20200522 that prevented fetching missing objects from remotes

In commit dfc4e641b5 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
This commit is contained in:
Joey Hess 2021-06-29 13:15:15 -04:00
parent 199391befe
commit 6b0d732746
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
2 changed files with 8 additions and 0 deletions

View file

@ -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

View 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)