Fix a minor bug that caused options provided with -c to be passed multiple times...
authorJoey Hess <joeyh@joeyh.name>
Mon, 16 Mar 2020 17:06:44 +0000 (13:06 -0400)
committerJoey Hess <joeyh@joeyh.name>
Mon, 16 Mar 2020 17:06:44 +0000 (13:06 -0400)
Annex.hs
CHANGELOG
CmdLine/GitAnnex/Options.hs
doc/bugs/Some_calls_to_git_repeat_--config_values.mdwn

index 9e0bcd3d81750c13303332fc6f96f68ca6c33951..c914748d58f0150f8ab914407a420a4490c3d77a 100644 (file)
--- a/Annex.hs
+++ b/Annex.hs
@@ -325,7 +325,11 @@ overrideGitConfig f = changeState $ \s -> s
        }
 
 {- Adds an adjustment to the Repo data. Adjustments persist across reloads
- - of the repo's config. -}
+ - of the repo's config.
+ -
+ - Note that the action may run more than once, and should avoid eg,
+ - appending the same value to a repo's config when run repeatedly.
+ -}
 adjustGitRepo :: (Git.Repo -> IO Git.Repo) -> Annex ()
 adjustGitRepo a = do
        changeState $ \s -> s { repoadjustment = \r -> repoadjustment s r >>= a }
index 711a2b5496fe49f7440926a4352ded16a15e2040..de59f8972766cd156c35919374af242f5aad335a 100644 (file)
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,10 @@
+git-annex (8.20200310) UNRELEASED; urgency=medium
+
+  * Fix a minor bug that caused options provided with -c to be passed
+    multiple times to git.
+
+ -- Joey Hess <id@joeyh.name>  Mon, 16 Mar 2020 12:43:33 -0400
+
 git-annex (8.20200309) upstream; urgency=medium
 
   * Fix bug that caused unlocked annexed dotfiles to be added to git by the
index 2fe128e0e2c34b113f98b654a14fc25da3ec33b0..c901f5d4ff5a8f481e3b7dfb24431f1ae2069236 100644 (file)
@@ -93,8 +93,11 @@ gitAnnexGlobalOptions = commonGlobalOptions ++
   where
        setnumcopies n = Annex.changeState $ \s -> s { Annex.forcenumcopies = Just $ NumCopies n }
        setuseragent v = Annex.changeState $ \s -> s { Annex.useragent = Just v }
-       setgitconfig v = Annex.adjustGitRepo $ \r -> Git.Config.store (encodeBS' v) $ 
-               r { gitGlobalOpts = gitGlobalOpts r ++ [Param "-c", Param v] }
+       setgitconfig v = Annex.adjustGitRepo $ \r -> 
+               if Param v `elem` gitGlobalOpts r
+                       then return r
+                       else Git.Config.store (encodeBS' v) $ 
+                               r { gitGlobalOpts = gitGlobalOpts r ++ [Param "-c", Param v] }
        setdesktopnotify v = Annex.changeState $ \s -> s { Annex.desktopnotify = Annex.desktopnotify s <> v }
 
 {- Parser that accepts all non-option params. -}
index 9fbda78a0ed0c95556cff3589dcdd1fab2a72501..424dd5ceb861bdfc516996b4ce3818dd3c6ce7b5 100644 (file)
@@ -37,3 +37,5 @@ worth filing in case there's a simple fix.
 
 [[!meta author=kyle]]
 [[!tag projects/datalad]]
+
+> [[fixed|done]] --[[Joey]]