summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Checks.hs6
-rw-r--r--Command.hs7
-rw-r--r--Command/Add.hs4
-rw-r--r--Command/AddUnused.hs6
-rw-r--r--Command/AddUrl.hs2
-rw-r--r--Command/Copy.hs5
-rw-r--r--Command/Drop.hs2
-rw-r--r--Command/Find.hs2
-rw-r--r--Command/Fix.hs2
-rw-r--r--Command/FromKey.hs2
-rw-r--r--Command/Fsck.hs2
-rw-r--r--Command/Import.hs3
-rw-r--r--Command/Lock.hs2
-rw-r--r--Command/Log.hs2
-rw-r--r--Command/Migrate.hs3
-rw-r--r--Command/Move.hs2
-rw-r--r--Command/ReKey.hs2
-rw-r--r--Command/Reinject.hs2
-rw-r--r--Command/Unannex.hs3
-rw-r--r--Command/Uninit.hs2
-rw-r--r--Command/Unlock.hs2
-rw-r--r--Command/Whereis.hs2
-rw-r--r--debian/changelog4
-rw-r--r--doc/direct_mode.mdwn12
24 files changed, 41 insertions, 40 deletions
diff --git a/Checks.hs b/Checks.hs
index 94ee75291..3757abb27 100644
--- a/Checks.hs
+++ b/Checks.hs
@@ -13,6 +13,7 @@ module Checks where
import Common.Annex
import Types.Command
import Init
+import Config
commonChecks :: [CommandCheck]
commonChecks = [repoExists]
@@ -20,6 +21,10 @@ commonChecks = [repoExists]
repoExists :: CommandCheck
repoExists = CommandCheck 0 ensureInitialized
+notDirect :: Command -> Command
+notDirect = addCheck $ whenM isDirect $
+ error "You cannot run this subcommand in a direct mode repository."
+
dontCheck :: CommandCheck -> Command -> Command
dontCheck check cmd = mutateCheck cmd $ \c -> filter (/= check) c
@@ -29,3 +34,4 @@ addCheck check cmd = mutateCheck cmd $ \c ->
mutateCheck :: Command -> ([CommandCheck] -> [CommandCheck]) -> Command
mutateCheck cmd@(Command { cmdcheck = c }) a = cmd { cmdcheck = a c }
+
diff --git a/Command.hs b/Command.hs
index 6c127c15d..478dfdc39 100644
--- a/Command.hs
+++ b/Command.hs
@@ -18,7 +18,6 @@ module Command (
whenAnnexed,
ifAnnexed,
notBareRepo,
- notDirect,
isBareRepo,
numCopies,
numCopiesCheck,
@@ -104,12 +103,6 @@ notBareRepo a = do
error "You cannot run this subcommand in a bare repository."
a
-notDirect :: Annex a -> Annex a
-notDirect a = ifM isDirect
- ( error "You cannot run this subcommand in a direct mode repository."
- , a
- )
-
isBareRepo :: Annex Bool
isBareRepo = fromRepo Git.repoIsLocalBare
diff --git a/Command/Add.hs b/Command/Add.hs
index e18f8592c..9f203346f 100644
--- a/Command/Add.hs
+++ b/Command/Add.hs
@@ -23,7 +23,7 @@ import Utility.FileMode
import Config
def :: [Command]
-def = [command "add" paramPaths seek "add files to annex"]
+def = [notDirect $ command "add" paramPaths seek "add files to annex"]
{- Add acts on both files not checked into git yet, and unlocked files. -}
seek :: [CommandSeek]
@@ -33,7 +33,7 @@ seek = [withFilesNotInGit start, withFilesUnlocked start]
- backend, and then moving it into the annex directory and setting up
- the symlink pointing to its content. -}
start :: FilePath -> CommandStart
-start file = notBareRepo $ notDirect $ ifAnnexed file fixup add
+start file = notBareRepo $ ifAnnexed file fixup add
where
add = do
s <- liftIO $ getSymbolicLinkStatus file
diff --git a/Command/AddUnused.hs b/Command/AddUnused.hs
index 519c67e1b..23dbdfcca 100644
--- a/Command/AddUnused.hs
+++ b/Command/AddUnused.hs
@@ -14,14 +14,16 @@ import qualified Command.Add
import Types.Key
def :: [Command]
-def = [command "addunused" (paramRepeating paramNumRange)
+def = [notDirect $ command "addunused" (paramRepeating paramNumRange)
seek "add back unused files"]
seek :: [CommandSeek]
seek = [withUnusedMaps start]
start :: UnusedMaps -> Int -> CommandStart
-start = startUnused "addunused" perform (performOther "bad") (performOther "tmp")
+start = startUnused "addunused" perform
+ (performOther "bad")
+ (performOther "tmp")
perform :: Key -> CommandPerform
perform key = next $ Command.Add.cleanup file key True
diff --git a/Command/AddUrl.hs b/Command/AddUrl.hs
index 0003237eb..dca515b70 100644
--- a/Command/AddUrl.hs
+++ b/Command/AddUrl.hs
@@ -24,7 +24,7 @@ import Types.KeySource
import Config
def :: [Command]
-def = [withOptions [fileOption, pathdepthOption] $
+def = [notDirect $ withOptions [fileOption, pathdepthOption] $
command "addurl" (paramRepeating paramUrl) seek "add urls to annex"]
fileOption :: Option
diff --git a/Command/Copy.hs b/Command/Copy.hs
index 6967c2f93..08c95369b 100644
--- a/Command/Copy.hs
+++ b/Command/Copy.hs
@@ -14,8 +14,9 @@ import qualified Remote
import Annex.Wanted
def :: [Command]
-def = [withOptions Command.Move.options $ command "copy" paramPaths seek
- "copy content of files to/from another repository"]
+def = [notDirect $
+ withOptions Command.Move.options $ command "copy" paramPaths seek
+ "copy content of files to/from another repository"]
seek :: [CommandSeek]
seek = [withField Command.Move.toOption Remote.byName $ \to ->
diff --git a/Command/Drop.hs b/Command/Drop.hs
index 3a30703d5..cb38275bf 100644
--- a/Command/Drop.hs
+++ b/Command/Drop.hs
@@ -20,7 +20,7 @@ import qualified Option
import Annex.Wanted
def :: [Command]
-def = [withOptions [fromOption] $ command "drop" paramPaths seek
+def = [notDirect $ withOptions [fromOption] $ command "drop" paramPaths seek
"indicate content of files not currently wanted"]
fromOption :: Option
diff --git a/Command/Find.hs b/Command/Find.hs
index 96f47ec87..8090f11c6 100644
--- a/Command/Find.hs
+++ b/Command/Find.hs
@@ -20,7 +20,7 @@ import Types.Key
import qualified Option
def :: [Command]
-def = [noCommit $ withOptions [formatOption, print0Option] $
+def = [notDirect $ noCommit $ withOptions [formatOption, print0Option] $
command "find" paramPaths seek "lists available files"]
formatOption :: Option
diff --git a/Command/Fix.hs b/Command/Fix.hs
index 38c8ac6e6..4b0151342 100644
--- a/Command/Fix.hs
+++ b/Command/Fix.hs
@@ -13,7 +13,7 @@ import qualified Annex.Queue
import Annex.Content
def :: [Command]
-def = [noCommit $ command "fix" paramPaths seek
+def = [notDirect $ noCommit $ command "fix" paramPaths seek
"fix up symlinks to point to annexed content"]
seek :: [CommandSeek]
diff --git a/Command/FromKey.hs b/Command/FromKey.hs
index f998fe1e6..a2ab55c9c 100644
--- a/Command/FromKey.hs
+++ b/Command/FromKey.hs
@@ -14,7 +14,7 @@ import Annex.Content
import Types.Key
def :: [Command]
-def = [command "fromkey" (paramPair paramKey paramPath) seek
+def = [notDirect $ command "fromkey" (paramPair paramKey paramPath) seek
"adds a file using a specific key"]
seek :: [CommandSeek]
diff --git a/Command/Fsck.hs b/Command/Fsck.hs
index 09f8b1136..04837a9e8 100644
--- a/Command/Fsck.hs
+++ b/Command/Fsck.hs
@@ -34,7 +34,7 @@ import System.Posix.Types (EpochTime)
import System.Locale
def :: [Command]
-def = [withOptions options $ command "fsck" paramPaths seek
+def = [notDirect $ withOptions options $ command "fsck" paramPaths seek
"check for problems"]
fromOption :: Option
diff --git a/Command/Import.hs b/Command/Import.hs
index cf91f7b5a..fc1bf5b4b 100644
--- a/Command/Import.hs
+++ b/Command/Import.hs
@@ -13,7 +13,8 @@ import qualified Annex
import qualified Command.Add
def :: [Command]
-def = [command "import" paramPaths seek "move and add files from outside git working copy"]
+def = [notDirect $ command "import" paramPaths seek
+ "move and add files from outside git working copy"]
seek :: [CommandSeek]
seek = [withPathContents start]
diff --git a/Command/Lock.hs b/Command/Lock.hs
index 8aadf3f59..c34e6a16b 100644
--- a/Command/Lock.hs
+++ b/Command/Lock.hs
@@ -12,7 +12,7 @@ import Command
import qualified Annex.Queue
def :: [Command]
-def = [command "lock" paramPaths seek "undo unlock command"]
+def = [notDirect $ command "lock" paramPaths seek "undo unlock command"]
seek :: [CommandSeek]
seek = [withFilesUnlocked start, withFilesUnlockedToBeCommitted start]
diff --git a/Command/Log.hs b/Command/Log.hs
index 6608a9906..b20d17674 100644
--- a/Command/Log.hs
+++ b/Command/Log.hs
@@ -36,7 +36,7 @@ data RefChange = RefChange
type Outputter = Bool -> POSIXTime -> [UUID] -> Annex ()
def :: [Command]
-def = [withOptions options $
+def = [notDirect $ withOptions options $
command "log" paramPaths seek "shows location log"]
options :: [Option]
diff --git a/Command/Migrate.hs b/Command/Migrate.hs
index d486eeb09..f3ff0dd72 100644
--- a/Command/Migrate.hs
+++ b/Command/Migrate.hs
@@ -18,7 +18,8 @@ import qualified Command.ReKey
import qualified Command.Fsck
def :: [Command]
-def = [command "migrate" paramPaths seek "switch data to different backend"]
+def = [notDirect $
+ command "migrate" paramPaths seek "switch data to different backend"]
seek :: [CommandSeek]
seek = [withFilesInGit $ whenAnnexed start]
diff --git a/Command/Move.hs b/Command/Move.hs
index 316e4192e..80b362c8a 100644
--- a/Command/Move.hs
+++ b/Command/Move.hs
@@ -19,7 +19,7 @@ import Logs.Presence
import Logs.Transfer
def :: [Command]
-def = [withOptions options $ command "move" paramPaths seek
+def = [notDirect $ withOptions options $ command "move" paramPaths seek
"move content of files to/from another repository"]
fromOption :: Option
diff --git a/Command/ReKey.hs b/Command/ReKey.hs
index ea06873c4..df878a581 100644
--- a/Command/ReKey.hs
+++ b/Command/ReKey.hs
@@ -16,7 +16,7 @@ import qualified Command.Add
import Logs.Web
def :: [Command]
-def = [command "rekey"
+def = [notDirect $ command "rekey"
(paramOptional $ paramRepeating $ paramPair paramPath paramKey)
seek "change keys used for files"]
diff --git a/Command/Reinject.hs b/Command/Reinject.hs
index d346925fa..12657f7f4 100644
--- a/Command/Reinject.hs
+++ b/Command/Reinject.hs
@@ -14,7 +14,7 @@ import Annex.Content
import qualified Command.Fsck
def :: [Command]
-def = [command "reinject" (paramPair "SRC" "DEST") seek
+def = [notDirect $ command "reinject" (paramPair "SRC" "DEST") seek
"sets content of annexed file"]
seek :: [CommandSeek]
diff --git a/Command/Unannex.hs b/Command/Unannex.hs
index 89134bb84..c5ab028cd 100644
--- a/Command/Unannex.hs
+++ b/Command/Unannex.hs
@@ -16,7 +16,8 @@ import qualified Git.Command
import qualified Git.LsFiles as LsFiles
def :: [Command]
-def = [command "unannex" paramPaths seek "undo accidential add command"]
+def = [notDirect $
+ command "unannex" paramPaths seek "undo accidential add command"]
seek :: [CommandSeek]
seek = [withFilesInGit $ whenAnnexed start]
diff --git a/Command/Uninit.hs b/Command/Uninit.hs
index 37b3ff511..beb17394d 100644
--- a/Command/Uninit.hs
+++ b/Command/Uninit.hs
@@ -18,7 +18,7 @@ import qualified Annex.Branch
import Annex.Content
def :: [Command]
-def = [addCheck check $ command "uninit" paramPaths seek
+def = [notDirect $ addCheck check $ command "uninit" paramPaths seek
"de-initialize git-annex and clean out repository"]
check :: Annex ()
diff --git a/Command/Unlock.hs b/Command/Unlock.hs
index 5a0e6efeb..422afcc55 100644
--- a/Command/Unlock.hs
+++ b/Command/Unlock.hs
@@ -18,7 +18,7 @@ def =
, c "edit" "same as unlock"
]
where
- c n = command n paramPaths seek
+ c n = notDirect . command n paramPaths seek
seek :: [CommandSeek]
seek = [withFilesInGit $ whenAnnexed start]
diff --git a/Command/Whereis.hs b/Command/Whereis.hs
index 251c4ec7a..6c60ab19d 100644
--- a/Command/Whereis.hs
+++ b/Command/Whereis.hs
@@ -15,7 +15,7 @@ import Remote
import Logs.Trust
def :: [Command]
-def = [noCommit $ command "whereis" paramPaths seek
+def = [notDirect $ noCommit $ command "whereis" paramPaths seek
"lists repositories that have file content"]
seek :: [CommandSeek]
diff --git a/debian/changelog b/debian/changelog
index ef1c7ee34..793fa7404 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -3,8 +3,8 @@ git-annex (3.20121212) UNRELEASED; urgency=low
* direct, indirect: New commands, that switch a repository to and from
direct mode. In direct mode, files are accessed directly, rather than
via symlinks. Note that direct mode is currently experimental. Many
- git and git-annex commands do not work, or can even cause data loss in
- direct mode.
+ git-annex commands do not work in direct mode. Some git commands can
+ cause data loss when used in direct mode repositories.
* assistant: Support direct mode.
* OSX assistant: Now uses the FSEvents API to detect file changes.
This avoids issues with running out of file descriptors on large trees,
diff --git a/doc/direct_mode.mdwn b/doc/direct_mode.mdwn
index 2acf52fd5..862a843cf 100644
--- a/doc/direct_mode.mdwn
+++ b/doc/direct_mode.mdwn
@@ -42,9 +42,9 @@ changed files to git, pushes them out, pulls down any changes, etc.
You can also run `git annex get` to transfer the content of files into your
direct mode repository. Or if the direct mode repository is a remote of
-some other, regular git-annex repository, you can use commands like `git
-annex copy` and `git annex move` to transfer the contents of files to the
-direct mode repository.
+some other, regular git-annex repository, you can use commands in the other
+repository like `git annex copy` and `git annex move` to transfer the
+contents of files to the direct mode repository.
You can use `git commit --staged`. (But not `git commit -a` .. It'll commit
whole large files into git!)
@@ -53,15 +53,11 @@ You can use `git log` and other git query commands.
## what doesn't work in direct mode
-Don't use `git annex add` -- it thinks all direct mode files are unlocked,
-and locks them.
-
In general git-annex commands will only work in direct mode repositories on
files whose content is not present. That's because such files are still
represented as symlinks, which git-annex commands know how to operate on.
So, `git annex get` works, but `git annex drop` and `git annex move` don't,
-and things like `git annex fsck` and `git annex status` show incomplete
-information.
+and things like `git annex status` show incomplete information.
It's technically possible to make all git-annex commands work in direct
mode repositories, so this might change. Check back to this page to see