actually, unannex w/o commit can work

just have to git rm
This commit is contained in:
Joey Hess 2010-10-16 22:49:09 -04:00
parent 96451ac392
commit c0b16e0a73

View file

@ -122,26 +122,25 @@ addCmd file = inBackend file err $ do
{- Undo addCmd. -} {- Undo addCmd. -}
unannexCmd :: FilePath -> Annex () unannexCmd :: FilePath -> Annex ()
unannexCmd file = notinBackend file err $ \(key, backend) -> do unannexCmd file = notinBackend file err $ \(key, backend) -> do
nocommit <- Annex.flagIsSet NoCommit Backend.removeKey backend key
if (nocommit) logStatus key ValueMissing
then error "--nocommit cannot be used in unannex mode" g <- Annex.gitRepo
else do let src = annexLocation g key
Backend.removeKey backend key moveout g src
logStatus key ValueMissing
g <- Annex.gitRepo
let src = annexLocation g key
liftIO $ moveout g src
where where
err = error $ "not annexed " ++ file err = error $ "not annexed " ++ file
moveout g src = do moveout g src = do
removeFile file nocommit <- Annex.flagIsSet NoCommit
Git.run g ["rm", file] liftIO removeFile file
Git.run g ["commit", "-m", liftIO Git.run g ["rm", file]
("git-annex unannexed " ++ file), file] if (not nocommit)
then liftIO Git.run g ["commit", "-m",
("git-annex unannexed " ++ file), file]
else return ()
-- git rm deletes empty directories; -- git rm deletes empty directories;
-- put them back -- put them back
createDirectoryIfMissing True (parentDir file) liftIO createDirectoryIfMissing True (parentDir file)
renameFile src file liftIO renameFile src file
return () return ()
{- Gets an annexed file from one of the backends. -} {- Gets an annexed file from one of the backends. -}