summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2013-08-22 13:57:07 -0400
committerGravatar Joey Hess <joey@kitenet.net>2013-08-22 13:57:07 -0400
commitbc684aaac8572aaaa322ccb49a076bcf6d8faf1a (patch)
tree92ff749fef920aeefaf321023bd9fe10e273b9f2
parent274630ac8460425a291ae122f0d5b390a87e5534 (diff)
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.
-rw-r--r--Annex/CatFile.hs6
-rw-r--r--Seek.hs15
-rw-r--r--debian/changelog2
-rw-r--r--doc/bugs/non-annexed_file_changed_to_annexed_on_typechange.mdwn2
4 files changed, 19 insertions, 6 deletions
diff --git a/Annex/CatFile.hs b/Annex/CatFile.hs
index f90e74509..f70800302 100644
--- a/Annex/CatFile.hs
+++ b/Annex/CatFile.hs
@@ -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
diff --git a/Seek.hs b/Seek.hs
index 817687b45..b0a634564 100644
--- a/Seek.hs
+++ b/Seek.hs
@@ -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
diff --git a/debian/changelog b/debian/changelog
index 120dc69dc..a2317ff9f 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -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
diff --git a/doc/bugs/non-annexed_file_changed_to_annexed_on_typechange.mdwn b/doc/bugs/non-annexed_file_changed_to_annexed_on_typechange.mdwn
index 7811ef6bf..1dca84346 100644
--- a/doc/bugs/non-annexed_file_changed_to_annexed_on_typechange.mdwn
+++ b/doc/bugs/non-annexed_file_changed_to_annexed_on_typechange.mdwn
@@ -36,3 +36,5 @@ Ubuntu 12.04 LTS
# End of transcript or log.
"""]]
+
+> [[fixed|done]] --[[Joey]]