From c8fec6ab031a25cca012f2f6858ef8251c484e50 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Mon, 16 Mar 2020 13:06:44 -0400 Subject: [PATCH] Fix a minor bug that caused options provided with -c to be passed multiple times to git. --- Annex.hs | 6 +++++- CHANGELOG | 7 +++++++ CmdLine/GitAnnex/Options.hs | 7 +++++-- doc/bugs/Some_calls_to_git_repeat_--config_values.mdwn | 2 ++ 4 files changed, 19 insertions(+), 3 deletions(-) diff --git a/Annex.hs b/Annex.hs index 9e0bcd3d81..c914748d58 100644 --- 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 } diff --git a/CHANGELOG b/CHANGELOG index 711a2b5496..de59f89727 100644 --- 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 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 diff --git a/CmdLine/GitAnnex/Options.hs b/CmdLine/GitAnnex/Options.hs index 2fe128e0e2..c901f5d4ff 100644 --- a/CmdLine/GitAnnex/Options.hs +++ b/CmdLine/GitAnnex/Options.hs @@ -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. -} diff --git a/doc/bugs/Some_calls_to_git_repeat_--config_values.mdwn b/doc/bugs/Some_calls_to_git_repeat_--config_values.mdwn index 9fbda78a0e..424dd5ceb8 100644 --- a/doc/bugs/Some_calls_to_git_repeat_--config_values.mdwn +++ b/doc/bugs/Some_calls_to_git_repeat_--config_values.mdwn @@ -37,3 +37,5 @@ worth filing in case there's a simple fix. [[!meta author=kyle]] [[!tag projects/datalad]] + +> [[fixed|done]] --[[Joey]] -- 2.30.2