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.)
This commit is contained in:
parent
7264203eb1
commit
84e729fda5
5 changed files with 28 additions and 6 deletions
|
@ -92,7 +92,7 @@ initialize mdescription mversion = checkCanInitialize $ do
|
||||||
u <- getUUID
|
u <- getUUID
|
||||||
{- Avoid overwriting existing description with a default
|
{- Avoid overwriting existing description with a default
|
||||||
- description. -}
|
- description. -}
|
||||||
whenM (pure (isJust mdescription) <||> not . M.member u <$> uuidDescMap) $
|
whenM (pure (isJust mdescription) <||> not . M.member u <$> uuidDescMapRaw) $
|
||||||
describeUUID u =<< genDescription mdescription
|
describeUUID u =<< genDescription mdescription
|
||||||
|
|
||||||
-- Everything except for uuid setup, shared clone setup, and initial
|
-- Everything except for uuid setup, shared clone setup, and initial
|
||||||
|
|
|
@ -12,6 +12,8 @@ git-annex (7.20190616) UNRELEASED; urgency=medium
|
||||||
fix a case where importfeed downloaded a partial feed from such a server.
|
fix a case where importfeed downloaded a partial feed from such a server.
|
||||||
* importfeed: When there's a problem parsing the feed, --debug will
|
* importfeed: When there's a problem parsing the feed, --debug will
|
||||||
output the feed content that was downloaded.
|
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 <id@joeyh.name> Sat, 15 Jun 2019 12:38:25 -0400
|
-- Joey Hess <id@joeyh.name> Sat, 15 Jun 2019 12:38:25 -0400
|
||||||
|
|
||||||
|
|
15
Logs/UUID.hs
15
Logs/UUID.hs
|
@ -11,7 +11,8 @@ module Logs.UUID (
|
||||||
uuidLog,
|
uuidLog,
|
||||||
describeUUID,
|
describeUUID,
|
||||||
uuidDescMap,
|
uuidDescMap,
|
||||||
uuidDescMapLoad
|
uuidDescMapLoad,
|
||||||
|
uuidDescMapRaw,
|
||||||
) where
|
) where
|
||||||
|
|
||||||
import Types.UUID
|
import Types.UUID
|
||||||
|
@ -38,13 +39,13 @@ describeUUID uuid desc = do
|
||||||
uuidDescMap :: Annex UUIDDescMap
|
uuidDescMap :: Annex UUIDDescMap
|
||||||
uuidDescMap = maybe uuidDescMapLoad return =<< Annex.getState 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
|
- If the current repository has not been described, it is still included
|
||||||
- it may not have been described and otherwise would not appear. -}
|
- in the map with an empty description. -}
|
||||||
uuidDescMapLoad :: Annex UUIDDescMap
|
uuidDescMapLoad :: Annex UUIDDescMap
|
||||||
uuidDescMapLoad = do
|
uuidDescMapLoad = do
|
||||||
m <- simpleMap . parseUUIDLog <$> Annex.Branch.get uuidLog
|
m <- uuidDescMapRaw
|
||||||
u <- Annex.UUID.getUUID
|
u <- Annex.UUID.getUUID
|
||||||
let m' = M.insertWith preferold u mempty m
|
let m' = M.insertWith preferold u mempty m
|
||||||
Annex.changeState $ \s -> s { Annex.uuiddescmap = Just m' }
|
Annex.changeState $ \s -> s { Annex.uuiddescmap = Just m' }
|
||||||
|
@ -52,5 +53,9 @@ uuidDescMapLoad = do
|
||||||
where
|
where
|
||||||
preferold = flip const
|
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 :: L.ByteString -> Log UUIDDesc
|
||||||
parseUUIDLog = parseLogOld (UUIDDesc <$> A.takeByteString)
|
parseUUIDLog = parseLogOld (UUIDDesc <$> A.takeByteString)
|
||||||
|
|
|
@ -94,3 +94,5 @@ init ok
|
||||||
```
|
```
|
||||||
|
|
||||||
Note that the description for here is a blank string.
|
Note that the description for here is a blank string.
|
||||||
|
|
||||||
|
> [[fixed|done]] --[[Joey]]
|
||||||
|
|
|
@ -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..
|
||||||
|
"""]]
|
Loading…
Add table
Add a link
Reference in a new issue