unannex improvements
Added files don't have to be committed before they can be unannexed. unannex no longer commits existing staged changes unannex of the last file in a directory now works, before it failed because git rm deleted the directory out from under it,
This commit is contained in:
parent
3f5f28b487
commit
14e9b87d44
2 changed files with 14 additions and 18 deletions
|
@ -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
|
||||
|
|
2
debian/changelog
vendored
2
debian/changelog
vendored
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in a new issue