summaryrefslogtreecommitdiff
path: root/Command/Sync.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2015-03-04 15:25:13 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2015-03-04 15:25:35 -0400
commit15ffb8b60e26bd8707c132f2452cb4adbe7e6d02 (patch)
tree3db0ba20a0f03c918af18afaa8481b591e9001b0 /Command/Sync.hs
parent8ad7398e29c9bd2ec25274bcca808650778e1457 (diff)
sync: Fix committing when in a direct mode repo that has no HEAD ref.
Seen for example, a newly checked out git submodule. In this case, .git/HEAD is a raw sha, rather than the usual reference to a ref. Removed currentSha in passing, since it was a more roundabout way of doing what headSha does, and headSha is more robust.
Diffstat (limited to 'Command/Sync.hs')
-rw-r--r--Command/Sync.hs18
1 files changed, 9 insertions, 9 deletions
diff --git a/Command/Sync.hs b/Command/Sync.hs
index 103f93e32..130693909 100644
--- a/Command/Sync.hs
+++ b/Command/Sync.hs
@@ -174,15 +174,15 @@ commitMsg = do
return $ "git-annex in " ++ fromMaybe "unknown" (M.lookup u m)
commitStaged :: Git.Branch.CommitMode -> String -> Annex Bool
-commitStaged commitmode commitmessage = go =<< inRepo Git.Branch.currentUnsafe
- where
- go Nothing = return False
- go (Just branch) = do
- runAnnexHook preCommitAnnexHook
- parent <- inRepo $ Git.Ref.sha branch
- void $ inRepo $ Git.Branch.commit commitmode False commitmessage branch
- (maybeToList parent)
- return True
+commitStaged commitmode commitmessage = do
+ runAnnexHook preCommitAnnexHook
+ mb <- inRepo Git.Branch.currentUnsafe
+ let (getparent, branch) = case mb of
+ Just b -> (Git.Ref.sha b, b)
+ Nothing -> (Git.Ref.headSha, Git.Ref.headRef)
+ parents <- maybeToList <$> inRepo getparent
+ void $ inRepo $ Git.Branch.commit commitmode False commitmessage branch parents
+ return True
mergeLocal :: Maybe Git.Ref -> CommandStart
mergeLocal Nothing = stop