override rather than setting user.name and user.email
authorJoey Hess <joeyh@joeyh.name>
Tue, 4 Apr 2023 18:56:44 +0000 (14:56 -0400)
committerJoey Hess <joeyh@joeyh.name>
Tue, 4 Apr 2023 18:56:44 +0000 (14:56 -0400)
Avoid setting user.name and user.email in the git config when git is unable
to detect them.

git-annex has good reason to want to ensure git commit succeeds when eg
committing to the git-annex branch. But it's not playing nice to set these
values where other commands can see them.

Sponsored-by: Brett Eisenberg on Patreon
Annex/Environment.hs
CHANGELOG

index 3da7ce980b9fe894d85e6512cad86de01ded1584..e0586ae78bc5449ee9a789e02992a6255ae7a557 100644 (file)
@@ -1,6 +1,6 @@
 {- git-annex environment
  -
- - Copyright 2012, 2013 Joey Hess <id@joeyh.name>
+ - Copyright 2012-2023 Joey Hess <id@joeyh.name>
  -
  - Licensed under the GNU AGPL version 3 or higher.
  -}
@@ -10,9 +10,9 @@
 module Annex.Environment where
 
 import Annex.Common
+import qualified Annex
 import Utility.UserInfo
 import qualified Git.Config
-import Config
 import Utility.Env.Set
 
 {- Checks that the system's environment allows git to function.
@@ -41,12 +41,13 @@ checkEnvironmentIO = whenM (isNothing <$> myUserGecos) $ do
        ensureEnv var val = setEnv var val False
 
 {- Runs an action that commits to the repository, and if it fails, 
- - sets user.email and user.name to a dummy value and tries the action again. -}
+ - overrides user.email and user.name to a dummy value and tries
+ - the action again. -}
 ensureCommit :: Annex a -> Annex a
 ensureCommit a = either retry return =<< tryNonAsync a 
   where
        retry _ = do
                name <- liftIO $ either (const "unknown") id <$> myUserName
-               setConfig "user.name" name
-               setConfig "user.email" name
+               Annex.addGitConfigOverride ("user.name=" ++ name)
+               Annex.addGitConfigOverride ("user.email=" ++ name)
                a
index 2304c747c3708aeb60d621de32273d5436eb4620..b8973b66362c80b9b1feb941b2455bd85fb91fd5 100644 (file)
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -5,6 +5,8 @@ git-annex (10.20230330) UNRELEASED; urgency=medium
   * Sped up sqlite inserts 2x when built with persistent 2.14.5.0
   * Fix laziness bug introduced in last release that breaks use
     of --unlock-present and --hide-missing adjusted branches.
+  * Avoid setting user.name and user.email in the git config
+    when git is unable to detect them.
 
  -- Joey Hess <id@joeyh.name>  Fri, 31 Mar 2023 12:48:54 -0400