summaryrefslogtreecommitdiff
path: root/Annex
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2013-07-05 12:24:28 -0400
committerGravatar Joey Hess <joey@kitenet.net>2013-07-05 12:24:28 -0400
commitfdd1a7beea7fca2e7ec253a943e414555af85dca (patch)
treeec9abf8f2f82cd75839ce51d03bba45f86518065 /Annex
parent3a069e678f7eaff6bef9ca983ec81e955f606d66 (diff)
detect system with no dot in FQDN, where git commit will fail, and workaround
Sigh, git is so *fragile*. Or rather, across the set of systems that use git-annex, where are no many horribly broken systems..
Diffstat (limited to 'Annex')
-rw-r--r--Annex/Environment.hs20
1 files changed, 19 insertions, 1 deletions
diff --git a/Annex/Environment.hs b/Annex/Environment.hs
index 33569386e..18097d11d 100644
--- a/Annex/Environment.hs
+++ b/Annex/Environment.hs
@@ -13,10 +13,19 @@ import Common.Annex
import Utility.Env
import Utility.UserInfo
import qualified Git.Config
+import Config
+import Annex.Exception
{- Checks that the system's environment allows git to function.
- Git requires a GECOS username, or suitable git configuration, or
- - environment variables. -}
+ - environment variables.
+ -
+ - Git also requires the system have a hostname containing a dot.
+ - Otherwise, it tries various methods to find a FQDN, and will fail if it
+ - does not. To avoid replicating that code here, which would break if its
+ - methods change, this function does not check the hostname is valid.
+ - Instead, code that commits can use ensureCommit.
+ -}
checkEnvironment :: Annex ()
checkEnvironment = do
gitusername <- fromRepo $ Git.Config.getMaybe "user.name"
@@ -42,3 +51,12 @@ checkEnvironmentIO =
ensureEnv _ _ = noop
#endif
#endif
+
+{- Runs an action that commits to the repository, and if it fails,
+ - sets user.email to a dummy value and tries the action again. -}
+ensureCommit :: Annex a -> Annex a
+ensureCommit a = either retry return =<< tryAnnex a
+ where
+ retry _ = do
+ setConfig (ConfigKey "user.email") =<< liftIO myUserName
+ a