diff options
-rw-r--r-- | Annex/Direct.hs | 11 | ||||
-rw-r--r-- | Command/Add.hs | 38 | ||||
-rw-r--r-- | debian/changelog | 3 |
3 files changed, 29 insertions, 23 deletions
diff --git a/Annex/Direct.hs b/Annex/Direct.hs index cd0d1c3b9..9ef808163 100644 --- a/Annex/Direct.hs +++ b/Annex/Direct.hs @@ -55,16 +55,7 @@ stageDirect = do (Just key, Nothing, _) -> deletedannexed file key (Nothing, Nothing, _) -> deletegit file (_, Just _, _) -> addgit file - go (file, Nothing) = do - mstat <- liftIO $ catchMaybeIO $ getSymbolicLinkStatus file - case (mstat, toCache =<< mstat) of - (Nothing, _) -> noop - (Just stat, Just cache) - | isSymbolicLink stat -> addgit file - | otherwise -> void $ addDirect file cache - (Just stat, Nothing) - | isSymbolicLink stat -> addgit file - | otherwise -> noop + go _ = noop modifiedannexed file oldkey cache = do void $ removeAssociatedFile oldkey file diff --git a/Command/Add.hs b/Command/Add.hs index 823d8f569..6d0ae2e1c 100644 --- a/Command/Add.hs +++ b/Command/Add.hs @@ -21,14 +21,19 @@ import Annex.Perms import Utility.Touch import Utility.FileMode import Config +import qualified Git.HashObject +import qualified Git.UpdateIndex +import Git.Types def :: [Command] -def = [notDirect $ notBareRepo $ - command "add" paramPaths seek "add files to annex"] +def = [notBareRepo $ command "add" paramPaths seek "add files to annex"] {- Add acts on both files not checked into git yet, and unlocked files. -} seek :: [CommandSeek] -seek = [withFilesNotInGit start, withFilesUnlocked start] +seek = + [ withFilesNotInGit start + , whenNotDirect $ withFilesUnlocked start + ] {- The add subcommand annexes a file, generating a key for it using a - backend, and then moving it into the annex directory and setting up @@ -68,7 +73,7 @@ lockDown file = do {- Moves a locked down file into the annex. - - - In direct mode, leaves the file alone, and just updates bookeeping + - In direct mode, leaves the file alone, and just updates bookkeeping - information. -} ingest :: KeySource -> Annex (Maybe Key) @@ -146,11 +151,20 @@ link file key hascontent = handle (undo file key) $ do {- Note: Several other commands call this, and expect it to - create the symlink and add it. -} cleanup :: FilePath -> Key -> Bool -> CommandCleanup -cleanup file key hascontent = do - _ <- link file key hascontent - params <- ifM (Annex.getState Annex.force) - ( return [Param "-f"] - , return [] - ) - Annex.Queue.addCommand "add" (params++[Param "--"]) [file] - return True +cleanup file key hascontent = ifM isDirect + ( do + l <- calcGitLink file key + sha <- inRepo $ Git.HashObject.hashObject BlobObject l + Annex.Queue.addUpdateIndex =<< + inRepo (Git.UpdateIndex.stageSymlink file sha) + logStatus key InfoPresent + return True + , do + _ <- link file key hascontent + params <- ifM (Annex.getState Annex.force) + ( return [Param "-f"] + , return [] + ) + Annex.Queue.addCommand "add" (params++[Param "--"]) [file] + return True + ) diff --git a/debian/changelog b/debian/changelog index f228bd5a6..bfb8599e7 100644 --- a/debian/changelog +++ b/debian/changelog @@ -4,7 +4,8 @@ git-annex (3.20130105) UNRELEASED; urgency=low * committer: Fix a file handle leak. * assistant: Make expensive transfer scan work fully in direct mode. * More commands work in direct mode repositories: find, whereis, move, copy, - drop, log, fsck. + drop, log, fsck, add. + * sync: No longer automatically adds files in direct mode. * assistant: Detect when system is not configured with a user name, and set environment to prevent git from failing. * direct: Avoid hardlinking symlinks that point to the same content |