refactor
This commit is contained in:
parent
4c5a9965c1
commit
5e87389f40
1 changed files with 18 additions and 12 deletions
|
@ -587,11 +587,9 @@ checkSecureHashes key
|
||||||
, return True
|
, return True
|
||||||
)
|
)
|
||||||
|
|
||||||
newtype Restage = Restage Bool
|
|
||||||
|
|
||||||
{- Populates a pointer file with the content of a key. -}
|
{- Populates a pointer file with the content of a key. -}
|
||||||
populatePointerFile :: Restage -> Key -> FilePath -> FilePath -> Annex ()
|
populatePointerFile :: Restage -> Key -> FilePath -> FilePath -> Annex ()
|
||||||
populatePointerFile (Restage restage) k obj f = go =<< liftIO (isPointerFile f)
|
populatePointerFile restage k obj f = go =<< liftIO (isPointerFile f)
|
||||||
where
|
where
|
||||||
go (Just k') | k == k' = do
|
go (Just k') | k == k' = do
|
||||||
destmode <- liftIO $ catchMaybeIO $ fileMode <$> getFileStatus f
|
destmode <- liftIO $ catchMaybeIO $ fileMode <$> getFileStatus f
|
||||||
|
@ -599,15 +597,26 @@ populatePointerFile (Restage restage) k obj f = go =<< liftIO (isPointerFile f)
|
||||||
ifM (linkOrCopy k obj f destmode)
|
ifM (linkOrCopy k obj f destmode)
|
||||||
( do
|
( do
|
||||||
thawContent f
|
thawContent f
|
||||||
-- The pointer file is re-staged,
|
restagePointerFile restage k f destmode
|
||||||
-- so git won't think it's been modified.
|
|
||||||
when restage $ do
|
|
||||||
pointersha <- hashPointerFile k
|
|
||||||
stagePointerFile f destmode pointersha
|
|
||||||
, liftIO $ writePointerFile f k destmode
|
, liftIO $ writePointerFile f k destmode
|
||||||
)
|
)
|
||||||
go _ = return ()
|
go _ = return ()
|
||||||
|
|
||||||
|
newtype Restage = Restage Bool
|
||||||
|
|
||||||
|
{- Re-stages a pointer file. This is used after updating a worktree file
|
||||||
|
- when content is added/removed, to prevent git from treating the worktree
|
||||||
|
- file as modified.
|
||||||
|
-
|
||||||
|
- If the index is known to be locked (eg, git add has run git-annex),
|
||||||
|
- the staging would fail, and Restage False will prevent it.
|
||||||
|
-}
|
||||||
|
restagePointerFile :: Restage -> Key -> FilePath -> Maybe FileMode -> Annex ()
|
||||||
|
restagePointerFile (Restage False) _ _ _ = return ()
|
||||||
|
restagePointerFile (Restage True) k f mode = do
|
||||||
|
pointersha <- hashPointerFile k
|
||||||
|
stagePointerFile f mode pointersha
|
||||||
|
|
||||||
data LinkAnnexResult = LinkAnnexOk | LinkAnnexFailed | LinkAnnexNoop
|
data LinkAnnexResult = LinkAnnexOk | LinkAnnexFailed | LinkAnnexNoop
|
||||||
|
|
||||||
{- Populates the annex object file by hard linking or copying a source
|
{- Populates the annex object file by hard linking or copying a source
|
||||||
|
@ -847,10 +856,7 @@ removeAnnex (ContentRemovalLock key) = withObjectLoc key remove removedirect
|
||||||
secureErase file
|
secureErase file
|
||||||
liftIO $ nukeFile file
|
liftIO $ nukeFile file
|
||||||
liftIO $ writePointerFile file key mode
|
liftIO $ writePointerFile file key mode
|
||||||
-- Re-stage the pointer, so git won't think it's
|
restagePointerFile (Restage True) key file mode
|
||||||
-- been modified.
|
|
||||||
pointersha <- hashPointerFile key
|
|
||||||
stagePointerFile file mode pointersha
|
|
||||||
-- Modified file, so leave it alone.
|
-- Modified file, so leave it alone.
|
||||||
-- If it was a hard link to the annex object,
|
-- If it was a hard link to the annex object,
|
||||||
-- that object might have been frozen as part of the
|
-- that object might have been frozen as part of the
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue