move commitStaged out of Command.Sync which no longer uses it
authorJoey Hess <joeyh@joeyh.name>
Wed, 7 Feb 2024 20:19:28 +0000 (16:19 -0400)
committerJoey Hess <joeyh@joeyh.name>
Wed, 7 Feb 2024 20:19:28 +0000 (16:19 -0400)
It's trivial enough that it it's not worth factoring it out to somewhere
in common with Command.Undo and the assistant.

Sponsored-by: the NIH-funded NICEMAN (ReproNim TR&D3) project
Assistant/Threads/Committer.hs
Command/Sync.hs
Command/Undo.hs

index 5a3a88b47d625b72c9078e301e9f2cf683536e02..79eed77e95be5de924759ee194149fd50125aaff 100644 (file)
@@ -40,6 +40,7 @@ import qualified Database.Keys
 import qualified Command.Sync
 import qualified Command.Add
 import Config.GitConfig
+import qualified Git.Branch
 import Utility.Tuple
 import Utility.Metered
 import qualified Utility.RawFilePath as R
@@ -240,7 +241,11 @@ commitStaged msg = do
                Left _ -> return False
                Right _ -> do
                        cmode <- annexCommitMode <$> Annex.getGitConfig
-                       ok <- Command.Sync.commitStaged cmode msg
+                       ok <- inRepo $ Git.Branch.commitCommand cmode
+                               (Git.Branch.CommitQuiet True)
+                               [ Param "-m"
+                               , Param msg
+                               ]
                        when ok $
                                Command.Sync.updateBranches =<< getCurrentBranch
                        return ok
index 52fe4c4aa0d04c8716b76cb0707144f6e7e07484..e222dd087487182cba1115ce00a1b72c47ecbe34 100644 (file)
@@ -19,7 +19,6 @@ module Command.Sync (
        prepMerge,
        mergeLocal,
        mergeRemote,
-       commitStaged,
        commitMsg,
        pushBranch,
        updateBranch,
@@ -429,14 +428,6 @@ commitMsg = do
        m <- uuidDescMap
        return $ "git-annex in " ++ maybe "unknown" fromUUIDDesc (M.lookup u m)
 
-commitStaged :: Git.Branch.CommitMode -> String -> Annex Bool
-commitStaged commitmode commitmessage =
-       inRepo $ Git.Branch.commitCommand commitmode
-               (Git.Branch.CommitQuiet True)
-               [ Param "-m"
-               , Param commitmessage
-               ]
-
 mergeLocal :: [Git.Merge.MergeConfig] -> SyncOptions -> CurrBranch -> CommandStart
 mergeLocal mergeconfig o currbranch = stopUnless (notOnlyAnnex o) $
        mergeLocal' mergeconfig o currbranch
index ceb70d279bb17b35a01a9e75ca66955177b6095c..000cc1c313f46e0e22a89dbc52aa4a4b0c062665 100644 (file)
@@ -1,6 +1,6 @@
 {- git-annex command
  -
- - Copyright 2014 Joey Hess <id@joeyh.name>
+ - Copyright 2014-2024 Joey Hess <id@joeyh.name>
  -
  - Licensed under the GNU AGPL version 3 or higher.
  -}
@@ -18,7 +18,6 @@ import qualified Annex
 import qualified Git.LsFiles as LsFiles
 import qualified Git.Command as Git
 import qualified Git.Branch
-import qualified Command.Sync
 import qualified Utility.RawFilePath as R
 
 cmd :: Command
@@ -42,7 +41,7 @@ seek ps = do
        -- Committing staged changes before undo allows later
        -- undoing the undo. It would be nicer to only commit staged
        -- changes to the specified files, rather than all staged changes.
-       void $ Command.Sync.commitStaged Git.Branch.ManualCommit
+       void $ commitStaged Git.Branch.ManualCommit
                "commit before undo"
        
        withStrings (commandAction . start) ps
@@ -81,3 +80,11 @@ perform p = do
                inRepo $ Git.run [Param "checkout", Param "--", File f]
 
        next $ liftIO cleanup
+
+commitStaged :: Git.Branch.CommitMode -> String -> Annex Bool
+commitStaged commitmode commitmessage =
+       inRepo $ Git.Branch.commitCommand commitmode
+               (Git.Branch.CommitQuiet True)
+               [ Param "-m"
+               , Param commitmessage
+               ]