summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Annex/Environment.hs20
-rw-r--r--Init.hs8
-rw-r--r--debian/changelog3
-rw-r--r--doc/bugs/view_logs_fails:_Internal_Server_Error__internal_liftAnnex.mdwn3
4 files changed, 31 insertions, 3 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
diff --git a/Init.hs b/Init.hs
index fe1b7a441..25b83be49 100644
--- a/Init.hs
+++ b/Init.hs
@@ -32,6 +32,7 @@ import Utility.FileMode
import Config
import Annex.Direct
import Annex.Content.Direct
+import Annex.Environment
import Backend
genDescription :: Maybe String -> Annex String
@@ -53,11 +54,14 @@ initialize mdescription = do
setVersion defaultVersion
checkCrippledFileSystem
checkFifoSupport
- Annex.Branch.create
gitPreCommitHookWrite
createInodeSentinalFile
u <- getUUID
- describeUUID u =<< genDescription mdescription
+ {- This will make the first commit to git, so ensure git is set up
+ - properly to allow commits when running it. -}
+ ensureCommit $ do
+ Annex.Branch.create
+ describeUUID u =<< genDescription mdescription
uninitialize :: Annex ()
uninitialize = do
diff --git a/debian/changelog b/debian/changelog
index 57f777758..d9eac61a4 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -12,6 +12,9 @@ git-annex (4.20130628) UNRELEASED; urgency=low
automatically update its working copy when git annex sync or the assistant
sync with it.
* webapp: Fix ssh setup with nonstandard port, broken in last release.
+ * init: Detect systems on which git commit fails due to not being able to
+ determine the FQDN, and put in a workaround so committing to the git-annex
+ branch works.
-- Joey Hess <joeyh@debian.org> Tue, 02 Jul 2013 15:40:55 -0400
diff --git a/doc/bugs/view_logs_fails:_Internal_Server_Error__internal_liftAnnex.mdwn b/doc/bugs/view_logs_fails:_Internal_Server_Error__internal_liftAnnex.mdwn
index 436b4c48d..0b9c54039 100644
--- a/doc/bugs/view_logs_fails:_Internal_Server_Error__internal_liftAnnex.mdwn
+++ b/doc/bugs/view_logs_fails:_Internal_Server_Error__internal_liftAnnex.mdwn
@@ -15,3 +15,6 @@ When clicking on "View logs", I get the following error:
### What version of git-annex are you using? On what operating system?
- git-annex 4.20130627 on Ubuntu 13.10, installed from debian unstable (sid) repository.
- git version 1.8.1.2
+
+> I've made it detect systems that lack a FQDN and set user.email
+> automatically. [[done]] --[[Joey]]