fall back to checking lower case hash directories in normal repo
authorJoey Hess <joeyh@joeyh.name>
Thu, 15 Jul 2021 16:16:31 +0000 (12:16 -0400)
committerJoey Hess <joeyh@joeyh.name>
Thu, 15 Jul 2021 16:16:31 +0000 (12:16 -0400)
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
CHANGELOG
doc/forum/Can__39__t_get_some_files_from_bare_repo/comment_1_ead60b63efb06249c99202631ef0b247._comment [new file with mode: 0644]

index 1401acdaa6b0d1a3e6d5f9e110a9c7bbb0474842..6f4fbf2bd10b6f8432a432d68cc86026a02b6eab 100644 (file)
@@ -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
index 00ec380f96b4a2de91d7ea03fed388c405765ab2..d52ff6f467f2bf98e61724d94b51e478ef33a9f6 100644 (file)
--- 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 <id@joeyh.name>  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 (file)
index 0000000..71d75f2
--- /dev/null
@@ -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.)
+"""]]