summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2014-10-31 16:14:12 -0400
committerGravatar Joey Hess <joey@kitenet.net>2014-10-31 16:14:12 -0400
commite7b70553d40a8bb2f894ce311cf618826095c294 (patch)
tree93b53503895fe726b9187e33cef50681c06828d4
parent90d840d64e9e94d5cd8c1c1fa2fa74855217e83d (diff)
Windows: Fix crash when user.name is not set in git config.
-rw-r--r--Annex/Environment.hs2
-rw-r--r--Utility/UserInfo.hs9
-rw-r--r--debian/changelog6
-rw-r--r--doc/bugs/getEffectiveUserID_not_supported_on_Windows.mdwn6
-rw-r--r--doc/bugs/getEffectiveUserID_not_supported_on_Windows/comment_1_26cd277e6bbfcac920ca0a2a47acfcfd._comment17
5 files changed, 18 insertions, 22 deletions
diff --git a/Annex/Environment.hs b/Annex/Environment.hs
index 1ddd2b238..ffdd07157 100644
--- a/Annex/Environment.hs
+++ b/Annex/Environment.hs
@@ -32,7 +32,7 @@ checkEnvironment = do
liftIO checkEnvironmentIO
checkEnvironmentIO :: IO ()
-checkEnvironmentIO = whenM (null <$> myUserGecos) $ do
+checkEnvironmentIO = whenM (isNothing <$> myUserGecos) $ do
username <- myUserName
ensureEnv "GIT_AUTHOR_NAME" username
ensureEnv "GIT_COMMITTER_NAME" username
diff --git a/Utility/UserInfo.hs b/Utility/UserInfo.hs
index b3e191bbf..1a557c9a5 100644
--- a/Utility/UserInfo.hs
+++ b/Utility/UserInfo.hs
@@ -40,11 +40,12 @@ myUserName = myVal env userName
env = ["USERNAME", "USER", "LOGNAME"]
#endif
-myUserGecos :: IO String
-#ifdef __ANDROID__
-myUserGecos = return "" -- userGecos crashes on Android
+myUserGecos :: IO (Maybe String)
+-- userGecos crashes on Android and is not available on Windows.
+#if defined(__ANDROID__) || defined(mingw32_HOST_OS)
+myUserGecos = return Nothing
#else
-myUserGecos = myVal [] userGecos
+myUserGecos = Just <$> myVal [] userGecos
#endif
myVal :: [String] -> (UserEntry -> String) -> IO String
diff --git a/debian/changelog b/debian/changelog
index 8af44b3bb..efaba2d95 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
+git-annex (5.20141025) UNRELEASED; urgency=medium
+
+ * Windows: Fix crash when user.name is not set in git config.
+
+ -- Joey Hess <joeyh@debian.org> Fri, 31 Oct 2014 16:13:43 -0400
+
git-annex (5.20141024) unstable; urgency=medium
* vicfg: Deleting configurations now resets to the default, where
diff --git a/doc/bugs/getEffectiveUserID_not_supported_on_Windows.mdwn b/doc/bugs/getEffectiveUserID_not_supported_on_Windows.mdwn
index 458c18b90..e8271ff94 100644
--- a/doc/bugs/getEffectiveUserID_not_supported_on_Windows.mdwn
+++ b/doc/bugs/getEffectiveUserID_not_supported_on_Windows.mdwn
@@ -20,3 +20,9 @@ Running Windows 7, x64. Also tried running as administrator and in a cmd.exe she
### Please provide any additional information below.
The `git annex test` command does work, and all 84 tests passes.
+
+> [[fixed|done]]; I was able to reproduce this bug, and it was crashing
+> trying to look up the geckos username. I don't understand why this worked
+> before; some change exposed this code path on Windows. In any case, I've
+> fixed the crash, and I will be updating the windows builds with this bug
+> fix. --[[Joey]]
diff --git a/doc/bugs/getEffectiveUserID_not_supported_on_Windows/comment_1_26cd277e6bbfcac920ca0a2a47acfcfd._comment b/doc/bugs/getEffectiveUserID_not_supported_on_Windows/comment_1_26cd277e6bbfcac920ca0a2a47acfcfd._comment
deleted file mode 100644
index f9412487c..000000000
--- a/doc/bugs/getEffectiveUserID_not_supported_on_Windows/comment_1_26cd277e6bbfcac920ca0a2a47acfcfd._comment
+++ /dev/null
@@ -1,17 +0,0 @@
-[[!comment format=mdwn
- username="joey"
- subject="""comment 1"""
- date="2014-10-31T16:57:05Z"
- content="""
-This code path should only be called when USERPROFILE or
-one of USERNAME/USER/LOGNAME is not set. Which should not usually be the case
-when using git-annex on windows.
-
-However, since we know that won't work on Windows it might as well not even
-try.. So I've made it instead print an error that indicates which
-environment variables need to be set.
-
-Can you please download the windows daily build from
-<http://git-annex.branchable.com/install/windows>, and see what this new,
-better error message says?
-"""]]