Revert "override rather than setting user.name and user.email"
authorJoey Hess <joeyh@joeyh.name>
Tue, 4 Apr 2023 19:15:02 +0000 (15:15 -0400)
committerJoey Hess <joeyh@joeyh.name>
Tue, 4 Apr 2023 19:15:02 +0000 (15:15 -0400)
This reverts commit 66eb63dd820ade940b26b8eb00759d1b0f9242a0.

git-annex init is the only thing that uses ensureCommit. So overriding
there will make later commits to the git-annex branch or by git-annex sync
fail.

It's ugly that git-annex init sets user.name and user.email, but it only
does it on systems that are badly configured.

Annex/Environment.hs
CHANGELOG

index b153518499b1a05dd9f43990a152e0955722d5c4..fb1fecd217146c39448601760d8bb91fd8d5df0c 100644 (file)
@@ -1,6 +1,6 @@
 {- git-annex environment
  -
- - Copyright 2012-2023 Joey Hess <id@joeyh.name>
+ - Copyright 2012, 2013 Joey Hess <id@joeyh.name>
  -
  - Licensed under the GNU AGPL version 3 or higher.
  -}
@@ -14,9 +14,9 @@ module Annex.Environment (
 ) where
 
 import Annex.Common
-import qualified Annex
 import Utility.UserInfo
 import qualified Git.Config
+import Config
 import Utility.Env.Set
 
 import Control.Exception
@@ -48,8 +48,11 @@ checkEnvironmentIO = whenM (isNothing <$> myUserGecos) $ do
        ensureEnv var val = setEnv var val False
 
 {- Runs an action that commits to the repository, and if it fails, 
- - overrides user.email and user.name to a dummy value and tries
- - the action again. -}
+ - sets user.email and user.name to a dummy value and tries the action again.
+ -
+ - Note that user.email and user.name are left set afterwards, so this only
+ - needs to be used once to make sure that future commits will succeed.
+ -}
 ensureCommit :: Annex a -> Annex a
 ensureCommit a = either retry return =<< tryNonAsync a 
   where
@@ -57,8 +60,8 @@ ensureCommit a = either retry return =<< tryNonAsync a
                ( liftIO (throwIO e)
                , do
                        name <- liftIO $ either (const "unknown") id <$> myUserName
-                       Annex.addGitConfigOverride ("user.name=" ++ name)
-                       Annex.addGitConfigOverride ("user.email=" ++ name)
+                       setConfig "user.name" name
+                       setConfig "user.email" name
                        a
                )
 
index 76037f24d346cc8529527156995b197b70982577..1ca2a8c51265e3065ac144079887e673917df50a 100644 (file)
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -5,8 +5,6 @@ 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.
   * Support user.useConfigOnly git config.
 
  -- Joey Hess <id@joeyh.name>  Fri, 31 Mar 2023 12:48:54 -0400