Fix bug that caused typechanged symlinks to be assumed to be unlocked files, so they were added to the annex by the pre-commit hook.

This commit is contained in:
Joey Hess 2013-08-22 13:57:07 -04:00
parent 2fc7092095
commit 412dcb8017
4 changed files with 19 additions and 6 deletions

View file

@ -12,6 +12,7 @@ module Annex.CatFile (
catFileHandle,
catKey,
catKeyFile,
catKeyFileHEAD,
) where
import qualified Data.ByteString.Lazy as L
@ -87,6 +88,9 @@ catKey ref = do
-}
catKeyFile :: FilePath -> Annex (Maybe Key)
catKeyFile f = ifM (Annex.getState Annex.daemon)
( catKey $ Ref $ "HEAD:./" ++ f
( catKeyFileHEAD f
, catKey $ Ref $ ":./" ++ f
)
catKeyFileHEAD :: FilePath -> Annex (Maybe Key)
catKeyFileHEAD f = catKey $ Ref $ "HEAD:./" ++ f

15
Seek.hs
View file

@ -26,6 +26,7 @@ import qualified Option
import Config
import Logs.Location
import Logs.Unused
import Annex.CatFile
seekHelper :: ([FilePath] -> Git.Repo -> IO ([FilePath], IO Bool)) -> [FilePath] -> Annex [FilePath]
seekHelper a params = do
@ -86,12 +87,16 @@ withFilesUnlocked = withFilesUnlocked' LsFiles.typeChanged
withFilesUnlockedToBeCommitted :: (FilePath -> CommandStart) -> CommandSeek
withFilesUnlockedToBeCommitted = withFilesUnlocked' LsFiles.typeChangedStaged
{- Unlocked files have changed type from a symlink to a regular file.
-
- Furthermore, unlocked files used to be a git-annex symlink,
- not some other sort of symlink.
-}
withFilesUnlocked' :: ([FilePath] -> Git.Repo -> IO ([FilePath], IO Bool)) -> (FilePath -> CommandStart) -> CommandSeek
withFilesUnlocked' typechanged a params = do
-- unlocked files have changed type from a symlink to a regular file
typechangedfiles <- seekHelper typechanged params
let unlockedfiles = liftIO $ filterM notSymlink typechangedfiles
prepFiltered a unlockedfiles
withFilesUnlocked' typechanged a params = prepFiltered a unlockedfiles
where
check f = liftIO (notSymlink f) <&&> isJust <$> catKeyFileHEAD f
unlockedfiles = filterM check =<< seekHelper typechanged params
{- Finds files that may be modified. -}
withFilesMaybeModified :: (FilePath -> CommandStart) -> CommandSeek

2
debian/changelog vendored
View file

@ -12,6 +12,8 @@ git-annex (4.20130816) UNRELEASED; urgency=low
* Unescape characters in 'file://...' URIs. (Thanks, guilhem for the patch.)
* Better error message when trying to use a git remote that has annex.ignore
set.
* Fix bug that caused typechanged symlinks to be assumed to be unlocked
files, so they were added to the annex by the pre-commit hook.
-- Joey Hess <joeyh@debian.org> Thu, 15 Aug 2013 15:47:52 +0200

View file

@ -36,3 +36,5 @@ Ubuntu 12.04 LTS
# End of transcript or log.
"""]]
> [[fixed|done]] --[[Joey]]