-}
run [] = noop
run changers = do
+ config <- Annex.getGitConfig
trustmap <- calcTrustMap <$> getStaged trustLog
remoteconfigmap <- calcRemoteConfigMap <$> getStaged remoteLog
-- partially apply, improves performance
- let changers' = map (\c -> c trustmap remoteconfigmap) changers
+ let changers' = map (\c -> c config trustmap remoteconfigmap) changers
fs <- branchFiles
forM_ fs $ \f -> do
content <- getStaged f
import Types.UUID
import Types.MetaData
import Types.Remote
+import Types.GitConfig
import Types.ProposedAccepted
import Annex.SpecialRemote.Config
= ChangeFile Builder
| PreserveFile
-type TransitionCalculator = TrustMap -> M.Map UUID RemoteConfig -> RawFilePath -> L.ByteString -> FileTransition
+type TransitionCalculator = GitConfig -> TrustMap -> M.Map UUID RemoteConfig -> RawFilePath -> L.ByteString -> FileTransition
getTransitionCalculator :: Transition -> Maybe TransitionCalculator
getTransitionCalculator ForgetGitHistory = Nothing
-- is not removed from the remote log, for the same reason the trust log
-- is not changed.
dropDead :: TransitionCalculator
-dropDead trustmap remoteconfigmap f content = case getLogVariety f of
+dropDead config trustmap remoteconfigmap f content = case getLogVariety config f of
Just OldUUIDBasedLog
| f == trustLog -> PreserveFile
| f == remoteLog -> ChangeFile $
be used, to clearly state why.
* Avoid throwing fatal errors when asked to write to a readonly
git remote on http.
+ * Fix support for repositories tuned with annex.tune.branchhash1=true,
+ including --all not working and git-annex log not displaying anything
+ for annexed files.
-- Joey Hess <id@joeyh.name> Fri, 14 Feb 2020 14:12:25 -0400
getGitLog :: [FilePath] -> [CommandParam] -> Annex ([RefChange], IO Bool)
getGitLog fs os = do
+ config <- Annex.getGitConfig
(ls, cleanup) <- inRepo $ pipeNullSplit $
[ Param "log"
, Param "-z"
[ Param $ Git.fromRef Annex.Branch.fullname
, Param "--"
] ++ map Param fs
- return (parseGitRawLog (map decodeBL' ls), cleanup)
+ return (parseGitRawLog config (map decodeBL' ls), cleanup)
-- Parses chunked git log --raw output, which looks something like:
--
--
-- The timestamp is not included before all changelines, so
-- keep track of the most recently seen timestamp.
-parseGitRawLog :: [String] -> [RefChange]
-parseGitRawLog = parse epoch
+parseGitRawLog :: GitConfig -> [String] -> [RefChange]
+parseGitRawLog config = parse epoch
where
epoch = toEnum 0 :: POSIXTime
parse oldts ([]:rest) = parse oldts rest
(tss, cl') -> (parseTimeStamp tss, cl')
mrc = do
(old, new) <- parseRawChangeLine cl
- key <- locationLogFileKey (toRawFilePath c2)
+ key <- locationLogFileKey config (toRawFilePath c2)
return $ RefChange
{ changetime = ts
, oldref = old
{- git-annex log file names
-
- - Copyright 2013-2019 Joey Hess <id@joeyh.name>
+ - Copyright 2013-2020 Joey Hess <id@joeyh.name>
-
- Licensed under the GNU AGPL version 3 or higher.
-}
{- Converts a path from the git-annex branch into one of the varieties
- of logs used by git-annex, if it's a known path. -}
-getLogVariety :: RawFilePath -> Maybe LogVariety
-getLogVariety f
+getLogVariety :: GitConfig -> RawFilePath -> Maybe LogVariety
+getLogVariety config f
| f `elem` topLevelOldUUIDBasedLogs = Just OldUUIDBasedLog
| f `elem` topLevelNewUUIDBasedLogs = Just NewUUIDBasedLog
| isRemoteStateLog f = Just NewUUIDBasedLog
| isChunkLog f = ChunkLog <$> extLogFileKey chunkLogExt f
| isRemoteMetaDataLog f = Just RemoteMetaDataLog
| isMetaDataLog f || f `elem` otherLogs = Just OtherLog
- | otherwise = PresenceLog <$> firstJust (presenceLogs f)
+ | otherwise = PresenceLog <$> firstJust (presenceLogs config f)
{- All the old-format uuid-based logs stored in the top of the git-annex branch. -}
topLevelOldUUIDBasedLogs :: [RawFilePath]
{- All the ways to get a key from a presence log file -}
-presenceLogs :: RawFilePath -> [Maybe Key]
-presenceLogs f =
+presenceLogs :: GitConfig -> RawFilePath -> [Maybe Key]
+presenceLogs config f =
[ urlLogFileKey f
- , locationLogFileKey f
+ , locationLogFileKey config f
]
{- Top-level logs that are neither UUID based nor presence logs. -}
urlLogFileKey = extLogFileKey urlLogExt
{- Converts a pathname into a key if it's a location log. -}
-locationLogFileKey :: RawFilePath -> Maybe Key
-locationLogFileKey path
- -- Want only xx/yy/foo.log, not .log files in other places.
- | length (splitDirectories (fromRawFilePath path)) /= 3 = Nothing
+locationLogFileKey :: GitConfig -> RawFilePath -> Maybe Key
+locationLogFileKey config path
+ | length (splitDirectories (fromRawFilePath path)) /= locationLogFileDepth config = Nothing
| otherwise = extLogFileKey ".log" path
+
+{- Depth of location log files within the git-annex branch.
+ -
+ - Normally they are xx/yy/key.log so depth 3.
+ - The same extension is also used for other logs that
+ - are not location logs. -}
+locationLogFileDepth :: GitConfig -> Int
+locationLogFileDepth config = hashlevels + 1
+ where
+ HashLevels hashlevels = branchHashLevels config
loggedKeys = loggedKeys' (not <$$> checkDead)
loggedKeys' :: (Key -> Annex Bool) -> Annex [Unchecked Key]
-loggedKeys' check = mapMaybe (defercheck <$$> locationLogFileKey)
- <$> Annex.Branch.files
+loggedKeys' check = do
+ config <- Annex.getGitConfig
+ mapMaybe (defercheck <$$> locationLogFileKey config)
+ <$> Annex.Branch.files
where
defercheck k = Unchecked $ ifM (check k)
( return (Just k)
locationLogs :: Annex [(Key, FilePath)]
locationLogs = do
+ config <- Annex.getGitConfig
dir <- fromRepo gitStateDir
liftIO $ do
levela <- dirContents dir
levelb <- mapM tryDirContents levela
files <- mapM tryDirContents (concat levelb)
- return $ mapMaybe islogfile (concat files)
+ return $ mapMaybe (islogfile config) (concat files)
where
tryDirContents d = catchDefaultIO [] $ dirContents d
- islogfile f = maybe Nothing (\k -> Just (k, f)) $
- locationLogFileKey (toRawFilePath f)
+ islogfile config f = maybe Nothing (\k -> Just (k, f)) $
+ locationLogFileKey config (toRawFilePath f)
inject :: FilePath -> FilePath -> Annex ()
inject source dest = do
Of course, I love it! Great project, thanks, Joey!
However, /me always wants more features from it. It's great that git-annex continues to develop.
+
+> [[fixed|done]] --[[Joey]]
--- /dev/null
+[[!comment format=mdwn
+ username="joey"
+ subject="""comment 1"""
+ date="2020-02-14T19:01:50Z"
+ content="""
+Indeed this is a bug. Easy to see why, note that "3":
+
+ locationLogFileKey path
+ -- Want only xx/yy/foo.log, not .log files in other places.
+ | length (splitDirectories (fromRawFilePath path)) /= 3 = Nothing
+
+So this also affected some other things that use that. Including `git-annex log`,
+potentially something to do with v2 upgrade (if a v2 repo could be tuned this way?),
+and handling transitions set up by `git annex forget`.
+
+(I also checked if annex.tune.objecthash1 similarly broke stuff that
+enumerated .git/annex/objects, but that was handled ok already.)
+"""]]