summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Command/Unannex.hs30
-rw-r--r--debian/changelog2
2 files changed, 14 insertions, 18 deletions
diff --git a/Command/Unannex.hs b/Command/Unannex.hs
index 263ff88b4..aafc189d0 100644
--- a/Command/Unannex.hs
+++ b/Command/Unannex.hs
@@ -23,17 +23,8 @@ def = [command "unannex" paramPaths seek "undo accidential add command"]
seek :: [CommandSeek]
seek = [withFilesInGit $ whenAnnexed start]
-{- The unannex subcommand undoes an add. -}
start :: FilePath -> (Key, Backend Annex) -> CommandStart
start file (key, _) = stopUnless (inAnnex key) $ do
- force <- Annex.getState Annex.force
- unless force $ do
- top <- fromRepo Git.workTree
- staged <- inRepo $ LsFiles.staged [top]
- unless (null staged) $
- error "This command cannot be run when there are already files staged for commit."
- Annex.changeState $ \s -> s { Annex.force = True }
-
showStart "unannex" file
next $ perform file key
@@ -43,9 +34,17 @@ perform file key = next $ cleanup file key
cleanup :: FilePath -> Key -> CommandCleanup
cleanup file key = do
liftIO $ removeFile file
- inRepo $ Git.run "rm" [Params "--quiet --", File file]
- -- git rm deletes empty directories; put them back
- liftIO $ createDirectoryIfMissing True (parentDir file)
+ -- git rm deletes empty directory without --cached
+ inRepo $ Git.run "rm" [Params "--cached --quiet --", File file]
+
+ -- If the file was already committed, it is now staged for removal.
+ -- Commit that removal now, to avoid later confusing the
+ -- pre-commit hook if this file is later added back to
+ -- git as a normal, non-annexed file.
+ whenM (not . null <$> inRepo (LsFiles.staged [file])) $ do
+ inRepo $ Git.run "commit" [
+ Param "-m", Param "content removed from git annex",
+ Param "--", File file]
fast <- Annex.getState Annex.fast
if fast
@@ -58,10 +57,5 @@ cleanup file key = do
else do
fromAnnex key file
logStatus key InfoMissing
-
- -- Commit staged changes at end to avoid confusing the
- -- pre-commit hook if this file is later added back to
- -- git as a normal, non-annexed file.
- Annex.Queue.add "commit" [Param "-m", Param "content removed from git annex"] []
-
+
return True
diff --git a/debian/changelog b/debian/changelog
index 04e911672..1c27ad566 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -7,6 +7,8 @@ git-annex (3.20111204) UNRELEASED; urgency=low
yet added to git. Running the add again will now clean up this situtation.
* Fix caching of decrypted ciphers, which failed when drop had to check
multiple different encrypted special remotes.
+ * unannex: Can be run on files that have been added to the annex, but not
+ yet committed.
-- Joey Hess <joeyh@debian.org> Sun, 04 Dec 2011 12:22:37 -0400