summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Commands.hs20
-rw-r--r--TODO6
2 files changed, 19 insertions, 7 deletions
diff --git a/Commands.hs b/Commands.hs
index 8afe66b91..9a3f92524 100644
--- a/Commands.hs
+++ b/Commands.hs
@@ -24,7 +24,8 @@ import Core
import qualified Remotes
import qualified BackendTypes
-data CmdWants = FilesInGit | FilesNotInGit | RepoName | SingleString
+data CmdWants = FilesInGit | FilesNotInGit | FilesInOrNotInGit |
+ RepoName | SingleString
data Command = Command {
cmdname :: String,
cmdaction :: (String -> Annex ()),
@@ -40,7 +41,7 @@ cmds = [
, (Command "pull" pullCmd RepoName)
, (Command "unannex" unannexCmd FilesInGit)
, (Command "describe" describeCmd SingleString)
- , (Command "fix" fixCmd FilesInGit)
+ , (Command "fix" fixCmd FilesInOrNotInGit)
]
options = [
@@ -57,6 +58,10 @@ findWanted FilesNotInGit params repo = do
findWanted FilesInGit params repo = do
files <- mapM (Git.inRepo repo) params
return $ foldl (++) [] files
+findWanted FilesInOrNotInGit params repo = do
+ a <- findWanted FilesInGit params repo
+ b <- findWanted FilesNotInGit params repo
+ return $ union a b
findWanted SingleString params _ = do
return $ [unwords params]
findWanted RepoName params _ = do
@@ -178,20 +183,25 @@ dropCmd file = notinBackend file err $ \(key, backend) -> do
{- Fixes the symlink to an annexed file. -}
fixCmd :: String -> Annex ()
fixCmd file = notinBackend file err $ \(key, backend) -> do
+ liftIO $ putStrLn $ "fix " ++ file
link <- calcGitLink file key
- checkLegal file
+ checkLegal file link
liftIO $ createDirectoryIfMissing True (parentDir file)
liftIO $ removeFile file
liftIO $ createSymbolicLink link file
gitAdd file $ Just $ "git-annex fix " ++ file
where
- checkLegal file = do
+ checkLegal file link = do
s <- liftIO $ getSymbolicLinkStatus file
force <- Annex.flagIsSet Force
if (not (isSymbolicLink s) && not force)
then error $ "not a symbolic link : " ++ file ++
" (use --force to override this sanity check)"
- else return ()
+ else do
+ l <- liftIO $ readSymbolicLink file
+ if (link == l)
+ then error $ "symbolic link already ok for: " ++ file
+ else return ()
err = error $ "not annexed " ++ file
{- Pushes all files to a remote repository. -}
diff --git a/TODO b/TODO
index fedcce6dd..038ed0d4a 100644
--- a/TODO
+++ b/TODO
@@ -3,15 +3,17 @@
* --push/--pull/--want
-* how to handle git mv file?
+* how to handle git mv file? -> git annex fix -> run automatically?
* how to handle git rm file? (should try to drop keys that have no
referring file, if it seems safe..)
+* add a git annex fsck that finds keys that have no referring file
+
* Support for remote git repositories (ssh:// specifically can be made to
work, although the other end probably needs to have git-annex installed..)
-* Copy files atomically, don't leaf a partial key on interrupt.
+* Copy files atomically, don't leave a partial key on interrupt.
(Fix for URL download too..)
* Find a way to copy a file with a progress bar, while still preserving