summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Logs/PreferredContent.hs5
-rw-r--r--Utility/Matcher.hs9
-rw-r--r--debian/changelog4
-rw-r--r--doc/bugs/Prefered_Content_not_Taken_into_Account.mdwn2
-rw-r--r--doc/bugs/Prefered_Content_not_Taken_into_Account/comment_1_70bccb282707b2e9b75c417832ed3459._comment33
5 files changed, 51 insertions, 2 deletions
diff --git a/Logs/PreferredContent.hs b/Logs/PreferredContent.hs
index a81c16f26..c21d67010 100644
--- a/Logs/PreferredContent.hs
+++ b/Logs/PreferredContent.hs
@@ -77,8 +77,9 @@ preferredRequiredMapsLoad = do
<$> Annex.Branch.get l
pc <- genmap preferredContentLog =<< groupPreferredContentMapRaw
rc <- genmap requiredContentLog M.empty
- -- Required content is implicitly also preferred content, so OR
- let m = M.unionWith MOr pc rc
+ -- Required content is implicitly also preferred content, so
+ -- combine.
+ let m = M.unionWith combineMatchers pc rc
Annex.changeState $ \s -> s
{ Annex.preferredcontentmap = Just m
, Annex.requiredcontentmap = Just rc
diff --git a/Utility/Matcher.hs b/Utility/Matcher.hs
index 19a77201c..d78e597dc 100644
--- a/Utility/Matcher.hs
+++ b/Utility/Matcher.hs
@@ -27,6 +27,7 @@ module Utility.Matcher (
matchM,
matchMrun,
isEmpty,
+ combineMatchers,
prop_matcher_sane
) where
@@ -142,6 +143,14 @@ isEmpty :: Matcher a -> Bool
isEmpty MAny = True
isEmpty _ = False
+{- Combines two matchers, yielding a matcher that will match anything
+ - both do. -}
+combineMatchers :: Matcher a -> Matcher a -> Matcher a
+combineMatchers a b
+ | isEmpty a = b
+ | isEmpty b = a
+ | otherwise = a `MOr` b
+
prop_matcher_sane :: Bool
prop_matcher_sane = all (\m -> match dummy m ()) $ map generate
[ [Operation True]
diff --git a/debian/changelog b/debian/changelog
index f2f166ed7..74a73adb4 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -26,6 +26,10 @@ git-annex (5.20150825) UNRELEASED; urgency=medium
in appropriate places.
* Special remotes configured with autoenable=true will be automatically
enabled when git-annex init is run.
+ * Fix bug in combination of preferred and required content settings.
+ When one was set to the empty string and the other set to some expression,
+ this bug caused all files to be wanted, instead of only files matching
+ the expression.
-- Joey Hess <id@joeyh.name> Tue, 01 Sep 2015 14:46:18 -0700
diff --git a/doc/bugs/Prefered_Content_not_Taken_into_Account.mdwn b/doc/bugs/Prefered_Content_not_Taken_into_Account.mdwn
index 818181dff..bdb3c9d97 100644
--- a/doc/bugs/Prefered_Content_not_Taken_into_Account.mdwn
+++ b/doc/bugs/Prefered_Content_not_Taken_into_Account.mdwn
@@ -360,3 +360,5 @@ On Ubuntu 14.04. All repos are on external USB drives on the same machine except
[1] https://git-annex.branchable.com/forum/git-annex_does_not_respect_preferred_content_settings/
+
+> [[fixed|done]] --[[Joey]]
diff --git a/doc/bugs/Prefered_Content_not_Taken_into_Account/comment_1_70bccb282707b2e9b75c417832ed3459._comment b/doc/bugs/Prefered_Content_not_Taken_into_Account/comment_1_70bccb282707b2e9b75c417832ed3459._comment
new file mode 100644
index 000000000..ff8326d95
--- /dev/null
+++ b/doc/bugs/Prefered_Content_not_Taken_into_Account/comment_1_70bccb282707b2e9b75c417832ed3459._comment
@@ -0,0 +1,33 @@
+[[!comment format=mdwn
+ username="joey"
+ subject="""comment 1"""
+ date="2015-09-15T16:04:28Z"
+ content="""
+I find it's not useful to split a conversation between multiple different
+pages, so this bug is a bit counterproductive.
+
+But, you made up for that by posting the whole vicfg, which I was somehow
+able to notice, amoungst all the noise, has this unusual bit:
+
+ required 132503d4-dcde-4790-aabb-ee5ba539a3a0 =
+ # (for ozge)
+ required 1e1d0c4e-b1da-465f-9140-7128a7e3ee13 =
+ # (for irem)
+ required aabc3536-a423-42b6-a234-5f110607296e =
+ # (for yesim)
+ required ba3593c0-ddf1-4433-9916-aa25d1a52895 =
+ # (for buse [origin])
+ required bff7238e-bd92-4929-88a8-c59c1a1dcf03 =
+
+So, required content has been set to "". It turns out that when this is done,
+git-annex thinks that all files are preferred! This is because of a bug
+when combining the required content and preferred content expressions.
+
+I reproduced this; `git annex get --auto` was not getting a file,
+which was already known to be in another PodA repository. Then I ran `git annex required . ""`
+and `git annex get --auto` started getting all files.
+
+You can't unset a required content setting back to being commented out.
+A reasonable workaround is to set those to "groupwanted" too. Or get the
+next git-annex release.
+"""]]