diff --git a/CHANGELOG b/CHANGELOG index fcbadc1cf1..3a50cd4495 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -14,6 +14,8 @@ git-annex (7.20181106) UNRELEASED; urgency=medium be clearer about what the problem is and how to resolve it. * export, sync --content: Avoid unnecessarily trying to upload files to an exporttree remote that already contains the files. + * smudge: When passed a file located outside the working tree, eg by git + diff, avoid erroring out. -- Joey Hess Tue, 06 Nov 2018 12:44:27 -0400 diff --git a/Command/Smudge.hs b/Command/Smudge.hs index a526f997f1..1a6b7a64fc 100644 --- a/Command/Smudge.hs +++ b/Command/Smudge.hs @@ -18,6 +18,7 @@ import Logs.Location import qualified Database.Keys import qualified Git.BuildVersion import Git.FilePath +import qualified Git import qualified Git.Ref import Backend @@ -77,11 +78,14 @@ smudge file = do clean :: FilePath -> CommandStart clean file = do b <- liftIO $ B.hGetContents stdin - case parseLinkOrPointer b of - Just k -> do - getMoveRaceRecovery k file - liftIO $ B.hPut stdout b - Nothing -> go b =<< catKeyFile file + ifM fileoutsiderepo + ( liftIO $ B.hPut stdout b + , case parseLinkOrPointer b of + Just k -> do + getMoveRaceRecovery k file + liftIO $ B.hPut stdout b + Nothing -> go b =<< catKeyFile file + ) stop where go b oldkey = ifM (shouldAnnex file oldkey) @@ -130,6 +134,13 @@ clean file = do , hardlinkFileTmp = False } + -- git diff can run the clean filter on files outside the + -- repository; can't annex those + fileoutsiderepo = do + repopath <- liftIO . absPath =<< fromRepo Git.repoPath + filepath <- liftIO $ absPath file + return $ not $ dirContains repopath filepath + -- New files are annexed as configured by annex.largefiles, with a default -- of annexing them. -- diff --git a/doc/bugs/v6_smudge_filter_breaks_git_diff_for_files_outside_the_repository.mdwn b/doc/bugs/v6_smudge_filter_breaks_git_diff_for_files_outside_the_repository.mdwn index 313869aa54..54e70ea0fb 100644 --- a/doc/bugs/v6_smudge_filter_breaks_git_diff_for_files_outside_the_repository.mdwn +++ b/doc/bugs/v6_smudge_filter_breaks_git_diff_for_files_outside_the_repository.mdwn @@ -22,3 +22,5 @@ $ git diff ../file1.txt ../file2.txt ### What version of git-annex are you using? On what operating system? 6.20180913-1~bpo9+1 on Debian Stretch + backports. + +> [[fixed|done]] --[[Joey]]