fix obviously wrong attoparsec parser
authorJoey Hess <joeyh@joeyh.name>
Mon, 7 Feb 2022 18:09:43 +0000 (14:09 -0400)
committerJoey Hess <joeyh@joeyh.name>
Mon, 7 Feb 2022 18:15:17 +0000 (14:15 -0400)
takeByteString can only be used at the end of a parser, not before other
input. This was a dumb enough mistake that I audited the rest of the
code base for similar mistakes. Pity that attoparsec cannot avoid it at
the type level.

Fixes git-annex forget propagation between repositories. (reversion
introduced in version 7.20190122)

Sponsored-by: Brock Spratlen on Patreon
CHANGELOG
Logs/Transitions.hs
doc/bugs/sync_does_not_propagate_forgetfulness.mdwn
doc/bugs/sync_does_not_propagate_forgetfulness/comment_1_acc9744be183c297c6410f9b0a30b46b._comment [new file with mode: 0644]
doc/forum/No_luck_getting_forgetfulness_does_not_propagate/comment_2_81c98f50953860c15473e958c55d1e4b._comment [new file with mode: 0644]

index cb67fa3924fc13b3f3527a49b6a8c8fe65e0d7dc..5e5c20cb225bbd1b9af4c0b7af52aa4c4936a723 100644 (file)
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -2,6 +2,8 @@ git-annex (10.20220128) UNRELEASED; urgency=medium
 
   * adb: Avoid find failing with "Argument list too long"
   * Pass --no-textconv when running git diff internally.
+  * Fix git-annex forget propagation between repositories.
+    (reversion introduced in version 7.20190122)
 
  -- Joey Hess <id@joeyh.name>  Mon, 31 Jan 2022 13:14:42 -0400
 
index 9052fc952d25599d33c697b6dfa4152eb61278d9..c352709c0fe7df41630e23f4ccd0220ac74202f7 100644 (file)
@@ -25,6 +25,7 @@ import Annex.CatFile
 
 import qualified Data.Set as S
 import Data.Either
+import Data.Char
 import Data.ByteString (ByteString)
 import Data.ByteString.Builder
 import qualified Data.ByteString.Lazy as L
@@ -82,7 +83,7 @@ parseTransitionsStrictly source b =
 
 transitionLineParser :: A.Parser TransitionLine
 transitionLineParser = do
-       t <- (parsetransition <$> A.takeByteString)
+       t <- parsetransition <$> A.takeTill (== sp)
        _ <- A8.char ' '
        c <- vectorClockParser
        return $ TransitionLine c t
@@ -90,6 +91,7 @@ transitionLineParser = do
        parsetransition b = case readish (decodeBS b) of
                Just t -> Right t
                Nothing -> Left b
+       sp = fromIntegral (ord ' ')
 
 combineTransitions :: [Transitions] -> Transitions
 combineTransitions = S.unions
index d0419f504d7cda6aa666fe94b438b7058ca66612..ebc018cbcbd617fd28d66f58816275289534f05a 100644 (file)
@@ -31,3 +31,5 @@ Reproduction script:
        git-annex log foo
 
 --[[Joey]]
+
+> [[fixed|done]] --[[Joey]]
diff --git a/doc/bugs/sync_does_not_propagate_forgetfulness/comment_1_acc9744be183c297c6410f9b0a30b46b._comment b/doc/bugs/sync_does_not_propagate_forgetfulness/comment_1_acc9744be183c297c6410f9b0a30b46b._comment
new file mode 100644 (file)
index 0000000..2646ff3
--- /dev/null
@@ -0,0 +1,9 @@
+[[!comment format=mdwn
+ username="joey"
+ subject="""comment 1"""
+ date="2022-02-07T17:49:37Z"
+ content="""
+Reversion introduced in [[!commit 2eadb6cd68073a905e8ff32cc8093a43d0b05c81]].
+Parsing of the transitions log silently failed, so all propagation of
+transitions was broken. 
+"""]]
diff --git a/doc/forum/No_luck_getting_forgetfulness_does_not_propagate/comment_2_81c98f50953860c15473e958c55d1e4b._comment b/doc/forum/No_luck_getting_forgetfulness_does_not_propagate/comment_2_81c98f50953860c15473e958c55d1e4b._comment
new file mode 100644 (file)
index 0000000..711f847
--- /dev/null
@@ -0,0 +1,15 @@
+[[!comment format=mdwn
+ username="joey"
+ subject="""comment 2"""
+ date="2022-02-07T16:43:26Z"
+ content="""
+I'm sure this used to work, but I've confirmed it no longer does
+and opened a bug report [[sync_does_not_propagate_forgetfulness]]
+
+Update: The bug I found is fixed. I'm fairly sure it caused the problem you
+saw as well, although I have not tried to reproduce your exact situation.
+
+Once you upgrade to the next release of git-annex (or tomorrow's daily
+build), you will need to re-run the git-annex forget command, and then it
+should propagate that new forgetting properly.
+"""]]