repair: Fix handling of git ref names on Windows

Sponsored-by: Kevin Mueller on Patreon
This commit is contained in:
Joey Hess 2023-05-30 16:09:13 -04:00
parent 9ca81ed02a
commit 5070087a63
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
4 changed files with 14 additions and 1 deletions

View file

@ -74,6 +74,7 @@ git-annex (10.20230408) UNRELEASED; urgency=medium
* When yt-dlp is available, default to using it in preference to * When yt-dlp is available, default to using it in preference to
youtube-dl. Using youtube-dl is now deprecated, and git-annex no longer youtube-dl. Using youtube-dl is now deprecated, and git-annex no longer
tries to parse its output to display download progress tries to parse its output to display download progress
* repair: Fix handling of git ref names on Windows.
-- Joey Hess <id@joeyh.name> Sat, 08 Apr 2023 13:57:18 -0400 -- Joey Hess <id@joeyh.name> Sat, 08 Apr 2023 13:57:18 -0400

View file

@ -30,6 +30,7 @@ import Git.Types
import Git.Fsck import Git.Fsck
import Git.Index import Git.Index
import Git.Env import Git.Env
import Git.FilePath
import qualified Git.Config as Config import qualified Git.Config as Config
import qualified Git.Construct as Construct import qualified Git.Construct as Construct
import qualified Git.LsTree as LsTree import qualified Git.LsTree as LsTree
@ -252,7 +253,8 @@ getAllRefs r = getAllRefs' (fromRawFilePath (localGitDir r) </> "refs")
getAllRefs' :: FilePath -> IO [Ref] getAllRefs' :: FilePath -> IO [Ref]
getAllRefs' refdir = do getAllRefs' refdir = do
let topsegs = length (splitPath refdir) - 1 let topsegs = length (splitPath refdir) - 1
let toref = Ref . encodeBS . joinPath . drop topsegs . splitPath let toref = Ref . toInternalGitPath . encodeBS
. joinPath . drop topsegs . splitPath
map toref <$> dirContentsRecursive refdir map toref <$> dirContentsRecursive refdir
explodePackedRefsFile :: Repo -> IO () explodePackedRefsFile :: Repo -> IO ()

View file

@ -354,6 +354,7 @@ repoTests note numparts = map mk $ sep
, testCase "required_content" test_required_content , testCase "required_content" test_required_content
, testCase "add subdirs" test_add_subdirs , testCase "add subdirs" test_add_subdirs
, testCase "addurl" test_addurl , testCase "addurl" test_addurl
, testCase "repair" test_repair
] ]
where where
mk l = testGroup groupname (initTests : map adddep l) mk l = testGroup groupname (initTests : map adddep l)
@ -2091,3 +2092,8 @@ test_transition_propagation_reversion =
emptylog emptylog
where where
emptylog = git_annex_expectoutput "log" [wormannexedfile] [] emptylog = git_annex_expectoutput "log" [wormannexedfile] []
test_repair :: Assertion
test_repair = intmpclonerepo $
-- Simply running repair used to fail on Windows.
git_annex "repair" [] "repair"

View file

@ -71,3 +71,7 @@ repair: 1 failed
### Have you had any luck using git-annex before? (Sometimes we get tired of reading bug reports all day and a lil' positive end note does wonders) ### Have you had any luck using git-annex before? (Sometimes we get tired of reading bug reports all day and a lil' positive end note does wonders)
Yes. I am developing the easy-git-annex API for git-annex. Yes. I am developing the easy-git-annex API for git-annex.
> Should be [[fixed|done]] now... It was reading the contents of the refs/
> directory recursively, and treating those names as refs, which is wrong
> on Windows due to path separator being different. --[[Joey]]