assistant: Check small files into git directly.
authorJoey Hess <joey@kitenet.net>
Fri, 29 Mar 2013 20:54:59 +0000 (16:54 -0400)
committerJoey Hess <joey@kitenet.net>
Fri, 29 Mar 2013 20:54:59 +0000 (16:54 -0400)
Assistant/Threads/Watcher.hs
Assistant/Types/Changes.hs
debian/changelog

index 84193de208dba930f8865e4e1d6a763ed56c3d5e..c2ba90ebe4551d40fa31b1ca2d269101dfca3ee0 100644 (file)
@@ -168,15 +168,19 @@ runHandler handler file filestatus = void $ do
                        liftAnnex $ Annex.Queue.flushWhenFull
                        recordChange change
 
-checkAdd :: FileMatcher -> FilePath -> Assistant (Maybe Change)
-checkAdd matcher file = ifM (liftAnnex $ checkFileMatcher matcher file)
+{- Small files are added to git as-is, while large ones go into the annex. -}
+add :: FileMatcher -> FilePath -> Assistant (Maybe Change)
+add bigfilematcher file = ifM (liftAnnex $ checkFileMatcher bigfilematcher file)
        ( pendingAddChange file
-       , noChange
+       , do
+               liftAnnex $ Annex.Queue.addCommand "add"
+                       [Params "--force --"] [file]
+               madeChange file AddFileChange
        )
 
 onAdd :: FileMatcher -> Handler
 onAdd matcher file filestatus
-       | maybe False isRegularFile filestatus = checkAdd matcher file
+       | maybe False isRegularFile filestatus = add matcher file
        | otherwise = noChange
 
 {- In direct mode, add events are received for both new files, and
@@ -192,9 +196,9 @@ onAddDirect matcher file fs = do
                                ( noChange
                                , do
                                        liftAnnex $ changedDirect key file
-                                       checkAdd matcher file
+                                       add matcher file
                                )
-               _ -> checkAdd matcher file
+               _ -> add matcher file
 
 {- A symlink might be an arbitrary symlink, which is just added.
  - Or, if it is a git-annex symlink, ensure it points to the content
index 651085947195c4a46db6865204c0a5e425cec7ed..9729acfbdb2962ba76242380f8d0f774592fc90c 100644 (file)
@@ -14,11 +14,11 @@ import Utility.TSet
 import Data.Time.Clock
 import Control.Concurrent.STM
 
-data ChangeInfo = AddChange Key | LinkChange (Maybe Key) | RmChange
+data ChangeInfo = AddKeyChange Key | AddFileChange | LinkChange (Maybe Key) | RmChange
        deriving (Show, Eq)
 
 changeInfoKey :: ChangeInfo -> Maybe Key
-changeInfoKey (AddChange k) = Just k
+changeInfoKey (AddKeyChange k) = Just k
 changeInfoKey (LinkChange (Just k)) = Just k
 changeInfoKey _ = Nothing
 
@@ -60,6 +60,6 @@ finishedChange :: Change -> Key -> Change
 finishedChange c@(InProcessAddChange { keySource = ks }) k = Change
        { changeTime = changeTime c
        , _changeFile = keyFilename ks
-       , changeInfo = AddChange k
+       , changeInfo = AddKeyChange k
        }
 finishedChange c _ = c
index 241fd4bded210f24e96a710ce6f03f44899828eb..815b39a6ca08d0b8ab6b05bf221d97a27cb060c8 100644 (file)
@@ -12,6 +12,7 @@ git-annex (4.20130324) UNRELEASED; urgency=low
     such as csh.
   * New annex.largefiles setting, which configures which files
     `git annex add` and the assistant add to the annex.
+  * assistant: Check small files into git directly.
 
  -- Joey Hess <joeyh@debian.org>  Mon, 25 Mar 2013 10:21:46 -0400