From 84e729fda5222375a9946a462ac459db093ef63c Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Thu, 20 Jun 2019 20:30:24 -0400 Subject: [PATCH] fix init default description reversion init: Fix a reversion in the last release that prevented automatically generating and setting a description for the repository. Seemed best to factor out uuidDescMapRaw that does not have the default mempty descrition behavior. I don't much like that behavior, but I know things depend on it. One thing in particular is `git annex info` which lists the uuids and descriptions; if the current repo has been initialized in some way that means it does not have a description, it would not show up w/o that. (Not only repos created due to this bug might lack that. For example a repo that was marked dead and had --drop-dead delete its git-annex branch info, and then came back from the dead would similarly not be in the uuid.log. Also there have been other versions of git-annex that didn't set a default description; for years there was no default description.) --- Annex/Init.hs | 2 +- CHANGELOG | 2 ++ Logs/UUID.hs | 15 ++++++++++----- ...t_no_longer_generates_default_description.mdwn | 2 ++ ...nt_3_6edae77c6ee7e4c4f94f9c0daff375ad._comment | 13 +++++++++++++ 5 files changed, 28 insertions(+), 6 deletions(-) create mode 100644 doc/bugs/annex_init_no_longer_generates_default_description/comment_3_6edae77c6ee7e4c4f94f9c0daff375ad._comment diff --git a/Annex/Init.hs b/Annex/Init.hs index cb7f8905e1..6a49f4ba7a 100644 --- a/Annex/Init.hs +++ b/Annex/Init.hs @@ -92,7 +92,7 @@ initialize mdescription mversion = checkCanInitialize $ do u <- getUUID {- Avoid overwriting existing description with a default - description. -} - whenM (pure (isJust mdescription) <||> not . M.member u <$> uuidDescMap) $ + whenM (pure (isJust mdescription) <||> not . M.member u <$> uuidDescMapRaw) $ describeUUID u =<< genDescription mdescription -- Everything except for uuid setup, shared clone setup, and initial diff --git a/CHANGELOG b/CHANGELOG index 5bf1204f40..fdb41cba0d 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -12,6 +12,8 @@ git-annex (7.20190616) UNRELEASED; urgency=medium fix a case where importfeed downloaded a partial feed from such a server. * importfeed: When there's a problem parsing the feed, --debug will output the feed content that was downloaded. + * init: Fix a reversion in the last release that prevented automatically + generating and setting a description for the repository. -- Joey Hess Sat, 15 Jun 2019 12:38:25 -0400 diff --git a/Logs/UUID.hs b/Logs/UUID.hs index e7bde47b40..7dd1213517 100644 --- a/Logs/UUID.hs +++ b/Logs/UUID.hs @@ -11,7 +11,8 @@ module Logs.UUID ( uuidLog, describeUUID, uuidDescMap, - uuidDescMapLoad + uuidDescMapLoad, + uuidDescMapRaw, ) where import Types.UUID @@ -38,13 +39,13 @@ describeUUID uuid desc = do uuidDescMap :: Annex UUIDDescMap uuidDescMap = maybe uuidDescMapLoad return =<< Annex.getState Annex.uuiddescmap -{- Read the uuidLog into a simple Map. +{- Read the uuidLog into a map, and cache it for later use. - - - The UUID of the current repository is included explicitly, since - - it may not have been described and otherwise would not appear. -} + - If the current repository has not been described, it is still included + - in the map with an empty description. -} uuidDescMapLoad :: Annex UUIDDescMap uuidDescMapLoad = do - m <- simpleMap . parseUUIDLog <$> Annex.Branch.get uuidLog + m <- uuidDescMapRaw u <- Annex.UUID.getUUID let m' = M.insertWith preferold u mempty m Annex.changeState $ \s -> s { Annex.uuiddescmap = Just m' } @@ -52,5 +53,9 @@ uuidDescMapLoad = do where preferold = flip const +{- Read the uuidLog into a map. Includes only actually set descriptions. -} +uuidDescMapRaw :: Annex UUIDDescMap +uuidDescMapRaw = simpleMap . parseUUIDLog <$> Annex.Branch.get uuidLog + parseUUIDLog :: L.ByteString -> Log UUIDDesc parseUUIDLog = parseLogOld (UUIDDesc <$> A.takeByteString) diff --git a/doc/bugs/annex_init_no_longer_generates_default_description.mdwn b/doc/bugs/annex_init_no_longer_generates_default_description.mdwn index 814ae263f7..c571881b42 100644 --- a/doc/bugs/annex_init_no_longer_generates_default_description.mdwn +++ b/doc/bugs/annex_init_no_longer_generates_default_description.mdwn @@ -94,3 +94,5 @@ init ok ``` Note that the description for here is a blank string. + +> [[fixed|done]] --[[Joey]] diff --git a/doc/bugs/annex_init_no_longer_generates_default_description/comment_3_6edae77c6ee7e4c4f94f9c0daff375ad._comment b/doc/bugs/annex_init_no_longer_generates_default_description/comment_3_6edae77c6ee7e4c4f94f9c0daff375ad._comment new file mode 100644 index 0000000000..22bdd05c62 --- /dev/null +++ b/doc/bugs/annex_init_no_longer_generates_default_description/comment_3_6edae77c6ee7e4c4f94f9c0daff375ad._comment @@ -0,0 +1,13 @@ +[[!comment format=mdwn + username="joey" + subject="""comment 3""" + date="2019-06-21T00:12:51Z" + content=""" +Thanks Kyle, that does point at the problem. In uuidDescMapLoad +it implicitly adds the UUID of the current repo, with an empty +description if none is set. So, the added check of uuidDescMap +always finds the UUID in it already. Your uuidDescMapLoad hack +avoids this by loading the map before the current repo has a UUID. + +Fixed more cleanly.. +"""]]