summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2011-02-01 21:58:47 -0400
committerGravatar Joey Hess <joey@kitenet.net>2011-02-01 22:02:19 -0400
commit0e7984a79354135f265d2342608953104d15db2e (patch)
tree6b8e59e6ca893cb05baff374c78accc4e284dfad
parentc77ac11acc10efc23acfa3d81e1deaac11cb724f (diff)
add check for unclean tree
-rw-r--r--.git-annex/uuid.log1
-rw-r--r--Command.hs2
-rw-r--r--Command/Unannex.hs6
-rw-r--r--GitRepo.hs17
4 files changed, 20 insertions, 6 deletions
diff --git a/.git-annex/uuid.log b/.git-annex/uuid.log
deleted file mode 100644
index 8cd9452b6..000000000
--- a/.git-annex/uuid.log
+++ /dev/null
@@ -1 +0,0 @@
-1ac368a4-19e2-11e0-8c0f-8fcd42cf5a8d test repo
diff --git a/Command.hs b/Command.hs
index 0bbc6088c..601b58464 100644
--- a/Command.hs
+++ b/Command.hs
@@ -147,7 +147,7 @@ withStrings a params = return $ map a params
withFilesToBeCommitted :: CommandSeekStrings
withFilesToBeCommitted a params = do
repo <- Annex.gitRepo
- tocommit <- liftIO $ runPreserveOrder (Git.stagedFiles repo) params
+ tocommit <- liftIO $ runPreserveOrder (Git.stagedFilesNotDeleted repo) params
tocommit' <- filterFiles tocommit
return $ map a tocommit'
withFilesUnlocked :: CommandSeekBackendFiles
diff --git a/Command/Unannex.hs b/Command/Unannex.hs
index 3810cca1c..c663b29ab 100644
--- a/Command/Unannex.hs
+++ b/Command/Unannex.hs
@@ -8,6 +8,7 @@
module Command.Unannex where
import Control.Monad.State (liftIO)
+import Control.Monad (unless)
import System.Directory
import Command
@@ -32,6 +33,11 @@ start file = isAnnexed file $ \(key, backend) -> do
ishere <- inAnnex key
if ishere
then do
+ g <- Annex.gitRepo
+ staged <- liftIO $ Git.stagedFiles g [Git.workTree g]
+ unless (null staged) $
+ error "This command cannot be run when there are already files staged for commit."
+
showStart "unannex" file
return $ Just $ perform file key backend
else return Nothing
diff --git a/GitRepo.hs b/GitRepo.hs
index 4e69544d4..031a9cbe2 100644
--- a/GitRepo.hs
+++ b/GitRepo.hs
@@ -38,6 +38,7 @@ module GitRepo (
inRepo,
notInRepo,
stagedFiles,
+ stagedFilesNotDeleted,
changedUnstagedFiles,
checkAttr,
decodeGitFile,
@@ -243,12 +244,20 @@ notInRepo :: Repo -> [FilePath] -> IO [FilePath]
notInRepo repo l = pipeNullSplit repo $
["ls-files", "--others", "--exclude-standard", "-z", "--"] ++ l
+{- Returns a list of all files that are staged for commit. -}
+stagedFiles :: Repo -> [FilePath] -> IO [FilePath]
+stagedFiles repo l = stagedFiles' repo l []
+
{- Returns a list of the files, staged for commit, that are being added,
- moved, or changed (but not deleted), from the specified locations. -}
-stagedFiles :: Repo -> [FilePath] -> IO [FilePath]
-stagedFiles repo l = pipeNullSplit repo $
- ["diff", "--cached", "--name-only", "--diff-filter=ACMRT", "-z",
- "--"] ++ l
+stagedFilesNotDeleted :: Repo -> [FilePath] -> IO [FilePath]
+stagedFilesNotDeleted repo l = stagedFiles' repo l ["--diff-filter=ACMRT"]
+
+stagedFiles' :: Repo -> [FilePath] -> [String] -> IO [FilePath]
+stagedFiles' repo l middle = pipeNullSplit repo $ start ++ middle ++ end
+ where
+ start = ["diff", "--cached", "--name-only", "-z"]
+ end = ["--"] ++ l
{- Returns a list of files that have unstaged changes. -}
changedUnstagedFiles :: Repo -> [FilePath] -> IO [FilePath]