diff options
author | Joey Hess <joey@kitenet.net> | 2013-08-26 00:14:19 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2013-08-26 00:19:19 -0400 |
commit | 499a3e6da79d752dab0b4c62c0f0e17db82aa2d6 (patch) | |
tree | 2ed50c5f63ca5d3337fc3ea1cabace53b86deed3 /Command | |
parent | 6cbeda715d64c7da440844414b7f91a88f1a175a (diff) |
fix reversion in unused
The reversion was that, if a file was git rm'd, but still in branches, it
would not be seen as used. Looking at both the added and the removed (or
changed) files from the diff-index is a cheap way to fix that.
Diffstat (limited to 'Command')
-rw-r--r-- | Command/Unused.hs | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/Command/Unused.hs b/Command/Unused.hs index 907e7bd07..b38c254ff 100644 --- a/Command/Unused.hs +++ b/Command/Unused.hs @@ -273,12 +273,15 @@ withKeysReferencedInGitRef :: (Key -> Annex ()) -> Git.Ref -> Annex () withKeysReferencedInGitRef a ref = do showAction $ "checking " ++ Git.Ref.describe ref (ts, clean) <- inRepo $ DiffTree.diffIndex ref - -- if 'dstsha' is 0{40}, the key will be Nothing - forM_ ts $ catObject . DiffTree.dstsha >=> - encodeW8 . L.unpack *>=> - fileKey . takeFileName *>=> - maybe noop a + forM_ ts $ \t -> + mapM_ (`process` t) [DiffTree.dstsha, DiffTree.srcsha] liftIO $ void clean + where + -- the key will be Nothing for the nullSha + process getsha = catObject . getsha >=> + encodeW8 . L.unpack *>=> + fileKey . takeFileName *>=> + maybe noop a {- Looks in the specified directory for bad/tmp keys, and returns a list - of those that might still have value, or might be stale and removable. |