From 0f6aaf8012b3dce4ba4668b3f1e6f387fe8c63b3 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 31 Oct 2014 16:14:12 -0400 Subject: [PATCH] Windows: Fix crash when user.name is not set in git config. --- Annex/Environment.hs | 2 +- Utility/UserInfo.hs | 9 +++++---- debian/changelog | 6 ++++++ ...ffectiveUserID_not_supported_on_Windows.mdwn | 6 ++++++ ..._1_26cd277e6bbfcac920ca0a2a47acfcfd._comment | 17 ----------------- 5 files changed, 18 insertions(+), 22 deletions(-) delete mode 100644 doc/bugs/getEffectiveUserID_not_supported_on_Windows/comment_1_26cd277e6bbfcac920ca0a2a47acfcfd._comment diff --git a/Annex/Environment.hs b/Annex/Environment.hs index 1ddd2b2384..ffdd071575 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 b3e191bbfc..1a557c9a52 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 8af44b3bb3..efaba2d950 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 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 458c18b901..e8271ff94b 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 f9412487c4..0000000000 --- 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 -, and see what this new, -better error message says? -"""]]