improve smudge --clean behavior on outside work tree files
smudge: When passed a file located outside the working tree, eg by git diff, avoid erroring out. This commit was sponsored by Ewen McNeill on Patreon.
This commit is contained in:
parent
ac27c29490
commit
71cc9cfaa2
3 changed files with 20 additions and 5 deletions
|
@ -14,6 +14,8 @@ git-annex (7.20181106) UNRELEASED; urgency=medium
|
||||||
be clearer about what the problem is and how to resolve it.
|
be clearer about what the problem is and how to resolve it.
|
||||||
* export, sync --content: Avoid unnecessarily trying to upload files
|
* export, sync --content: Avoid unnecessarily trying to upload files
|
||||||
to an exporttree remote that already contains the 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 <id@joeyh.name> Tue, 06 Nov 2018 12:44:27 -0400
|
-- Joey Hess <id@joeyh.name> Tue, 06 Nov 2018 12:44:27 -0400
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,7 @@ import Logs.Location
|
||||||
import qualified Database.Keys
|
import qualified Database.Keys
|
||||||
import qualified Git.BuildVersion
|
import qualified Git.BuildVersion
|
||||||
import Git.FilePath
|
import Git.FilePath
|
||||||
|
import qualified Git
|
||||||
import qualified Git.Ref
|
import qualified Git.Ref
|
||||||
import Backend
|
import Backend
|
||||||
|
|
||||||
|
@ -77,11 +78,14 @@ smudge file = do
|
||||||
clean :: FilePath -> CommandStart
|
clean :: FilePath -> CommandStart
|
||||||
clean file = do
|
clean file = do
|
||||||
b <- liftIO $ B.hGetContents stdin
|
b <- liftIO $ B.hGetContents stdin
|
||||||
case parseLinkOrPointer b of
|
ifM fileoutsiderepo
|
||||||
Just k -> do
|
( liftIO $ B.hPut stdout b
|
||||||
getMoveRaceRecovery k file
|
, case parseLinkOrPointer b of
|
||||||
liftIO $ B.hPut stdout b
|
Just k -> do
|
||||||
Nothing -> go b =<< catKeyFile file
|
getMoveRaceRecovery k file
|
||||||
|
liftIO $ B.hPut stdout b
|
||||||
|
Nothing -> go b =<< catKeyFile file
|
||||||
|
)
|
||||||
stop
|
stop
|
||||||
where
|
where
|
||||||
go b oldkey = ifM (shouldAnnex file oldkey)
|
go b oldkey = ifM (shouldAnnex file oldkey)
|
||||||
|
@ -130,6 +134,13 @@ clean file = do
|
||||||
, hardlinkFileTmp = False
|
, 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
|
-- New files are annexed as configured by annex.largefiles, with a default
|
||||||
-- of annexing them.
|
-- of annexing them.
|
||||||
--
|
--
|
||||||
|
|
|
@ -22,3 +22,5 @@ $ git diff ../file1.txt ../file2.txt
|
||||||
### What version of git-annex are you using? On what operating system?
|
### What version of git-annex are you using? On what operating system?
|
||||||
|
|
||||||
6.20180913-1~bpo9+1 on Debian Stretch + backports.
|
6.20180913-1~bpo9+1 on Debian Stretch + backports.
|
||||||
|
|
||||||
|
> [[fixed|done]] --[[Joey]]
|
||||||
|
|
Loading…
Reference in a new issue