From dd31fe7b9e44c42a3e0623cc06cd507bc60930ce Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Thu, 15 Jul 2021 12:16:31 -0400 Subject: [PATCH] fall back to checking lower case hash directories in normal repo Fix a bug that prevented getting content from a repository that started out as a bare repository, or had annex.crippledfilesystem set, and was converted to a non-bare repository. This unfortunately means that inAnnex check gets slowed down by a stat call in normal repos when the content is not present. Oh well, such is the cost of backwards compatability with old mistakes. Sponsored-by: Mark Reidenbach on Patreon --- Annex/Locations.hs | 11 ++++--- CHANGELOG | 3 ++ ..._ead60b63efb06249c99202631ef0b247._comment | 29 +++++++++++++++++++ 3 files changed, 39 insertions(+), 4 deletions(-) create mode 100644 doc/forum/Can__39__t_get_some_files_from_bare_repo/comment_1_ead60b63efb06249c99202631ef0b247._comment diff --git a/Annex/Locations.hs b/Annex/Locations.hs index 1401acdaa6..6f4fbf2bd1 100644 --- a/Annex/Locations.hs +++ b/Annex/Locations.hs @@ -172,6 +172,8 @@ gitAnnexLocation' key r config crippled symlinkssupported checker gitdir {- Bare repositories default to hashDirLower for new - content, as it's more portable. But check all locations. -} | Git.repoIsLocalBare r = checkall + {- If the repository is configured to only use lower, no need + - to check both. -} | hasDifference ObjectHashLower (annexDifferences config) = only hashDirLower {- Repositories on crippled filesystems use hashDirLower @@ -181,10 +183,11 @@ gitAnnexLocation' key r config crippled symlinkssupported checker gitdir | crippled = if symlinkssupported then check $ map inrepo $ reverse $ annexLocations config key else checkall - {- Regular repositories only use hashDirMixed, so - - don't need to do any work to check if the file is - - present. -} - | otherwise = only hashDirMixed + {- Regular repositories usually only use hashDirMixed. + - However, it's always possible that a bare repository was + - converted to non-bare, or that the cripped filesystem + - setting changed, so still need to check both. -} + | otherwise = checkall where only = return . inrepo . annexLocation config key checkall = check $ map inrepo $ annexLocations config key diff --git a/CHANGELOG b/CHANGELOG index 00ec380f96..d52ff6f467 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -2,6 +2,9 @@ git-annex (8.20210715) UNRELEASED; urgency=medium * whereused: New command, finds what files use a key, or where a key was used historically. + * Fix a bug that prevented getting content from a repository that + started out as a bare repository, or had annex.crippledfilesystem + set, and was converted to a non-bare repository. -- Joey Hess Wed, 14 Jul 2021 14:26:36 -0400 diff --git a/doc/forum/Can__39__t_get_some_files_from_bare_repo/comment_1_ead60b63efb06249c99202631ef0b247._comment b/doc/forum/Can__39__t_get_some_files_from_bare_repo/comment_1_ead60b63efb06249c99202631ef0b247._comment new file mode 100644 index 0000000000..71d75f213c --- /dev/null +++ b/doc/forum/Can__39__t_get_some_files_from_bare_repo/comment_1_ead60b63efb06249c99202631ef0b247._comment @@ -0,0 +1,29 @@ +[[!comment format=mdwn + username="joey" + subject="""comment 1""" + date="2021-07-15T15:51:16Z" + content=""" +Note that 8.20.200226 is not a valid git-annex version and it would be good +to know the actual version used on WSL. + +The mixed-case folder name is what git-annex uses when storing files in a +git repository that is not bare. The lower-case 3 letter name is used in a bare +repository. It is also used when git-annex detects a crippled filesystem +-- which it likely would for a USB drive using FAT or something. +Does the repository have annex.crippledfilesystem set in its git config? + +Ok, I found a way to reproduce this. I made a repository with +annex.crippledfilesystem set, and copied a file to it. Then I unset +annex.crippledfilesystem. Getting the file in another repository then +fails. + +git-annex does already deal with cases where a non-bare repo is converted +to bare, by trying both names, but it does not in this case. + +I've fixed the problem, but am still curious about how you got into this +situation. Anyway, install a git-annex autobuild a few hours after this +comment to get the fix. + +(Please use [[bugs]] to report bug reports in the future, this forum is not +a BTS and you cause extra work by posting bugs here.) +"""]] -- 2.30.2