diff --git a/CHANGELOG b/CHANGELOG index e5202600f8..649e54f877 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -12,6 +12,7 @@ git-annex (10.20230228) UNRELEASED; urgency=medium whose kernels are too old to support kernels used by the current arm64 build. * importfeed: Display feed title. + * init: Support being ran in a repository that has a newline in its path. -- Joey Hess Mon, 27 Feb 2023 12:31:14 -0400 diff --git a/Logs/UUID.hs b/Logs/UUID.hs index 6681860da7..1a3142e198 100644 --- a/Logs/UUID.hs +++ b/Logs/UUID.hs @@ -2,11 +2,13 @@ - - uuid.log stores a list of known uuids, and their descriptions. - - - Copyright 2010-2019 Joey Hess + - Copyright 2010-2023 Joey Hess - - Licensed under the GNU AGPL version 3 or higher. -} +{-# LANGUAGE OverloadedStrings #-} + module Logs.UUID ( uuidLog, describeUUID, @@ -25,15 +27,24 @@ import Logs.UUIDBased import qualified Annex.UUID import qualified Data.Map.Strict as M +import qualified Data.ByteString as B import qualified Data.ByteString.Lazy as L import qualified Data.Attoparsec.ByteString.Lazy as A +import Data.ByteString.Builder +import Data.Char {- Records a description for a uuid in the log. -} describeUUID :: UUID -> UUIDDesc -> Annex () describeUUID uuid desc = do c <- currentVectorClock Annex.Branch.change (Annex.Branch.RegardingUUID [uuid]) uuidLog $ - buildLogOld buildUUIDDesc . changeLog c uuid desc . parseUUIDLog + buildLogOld builder . changeLog c uuid desc . parseUUIDLog + where + builder (UUIDDesc b) = byteString (escnewline b) + -- Escape any newline in the description, since newlines cannot + -- be present in the logged value. This is a one-way escaping. + escnewline = B.intercalate "\\n" . B.split newline + newline = fromIntegral (ord '\n') {- The map is cached for speed. -} uuidDescMap :: Annex UUIDDescMap diff --git a/Types/UUID.hs b/Types/UUID.hs index 3e59fc685c..08f7f8b04a 100644 --- a/Types/UUID.hs +++ b/Types/UUID.hs @@ -82,9 +82,6 @@ fromUUIDDesc (UUIDDesc d) = decodeBS d toUUIDDesc :: String -> UUIDDesc toUUIDDesc = UUIDDesc . encodeBS -buildUUIDDesc :: UUIDDesc -> Builder -buildUUIDDesc (UUIDDesc b) = byteString b - type UUIDDescMap = M.Map UUID UUIDDesc instance Proto.Serializable UUID where diff --git a/doc/bugs/init_fails_in_a_folder_with_newline_in_its_name.mdwn b/doc/bugs/init_fails_in_a_folder_with_newline_in_its_name.mdwn index cfb2c55bdc..0a071a6357 100644 --- a/doc/bugs/init_fails_in_a_folder_with_newline_in_its_name.mdwn +++ b/doc/bugs/init_fails_in_a_folder_with_newline_in_its_name.mdwn @@ -32,3 +32,5 @@ git-annex version: 10.20230214+git26-g8f2829e646-1~ndall+1 as `git` doesn't mind, and now annex batched commands support `-z` already for filenames with newlines in them, I think git-annex should tolerate repository folders with newlines in them too. [[!tag projects/datalad]] + +> [[fixed|done]] --[[Joey]] diff --git a/doc/bugs/init_fails_in_a_folder_with_newline_in_its_name/comment_1_2690ed9441685068c291a182d39c2616._comment b/doc/bugs/init_fails_in_a_folder_with_newline_in_its_name/comment_1_2690ed9441685068c291a182d39c2616._comment index 201c6f93c4..949bee65a5 100644 --- a/doc/bugs/init_fails_in_a_folder_with_newline_in_its_name/comment_1_2690ed9441685068c291a182d39c2616._comment +++ b/doc/bugs/init_fails_in_a_folder_with_newline_in_its_name/comment_1_2690ed9441685068c291a182d39c2616._comment @@ -14,10 +14,4 @@ written to uuid.log contains a newline, which prevents parsing that line of the log correctly. This can also be seen by passing a value with a newline to `git-annex describe`. It would also happen in the case with the newline directory if it didn't fail earlier. - -Another log file that has a similar problem BTW is config.log, -which can get a newline in a value with eg -`git annex config --set annex.largefiles "xxx\nyyy"` -and the result is that reading the value back out omits -the part after the newline. """]]