avoid update-index race
This commit was supported by the NSF-funded DataLad project.
This commit is contained in:
parent
82c5dd8a01
commit
54d49eeac8
7 changed files with 91 additions and 46 deletions
|
@ -1,6 +1,6 @@
|
|||
{- git-update-index library
|
||||
-
|
||||
- Copyright 2011-2013 Joey Hess <id@joeyh.name>
|
||||
- Copyright 2011-2018 Joey Hess <id@joeyh.name>
|
||||
-
|
||||
- Licensed under the GNU GPL version 3 or higher.
|
||||
-}
|
||||
|
@ -21,6 +21,7 @@ module Git.UpdateIndex (
|
|||
unstageFile,
|
||||
stageSymlink,
|
||||
stageDiffTreeItem,
|
||||
refreshIndex,
|
||||
) where
|
||||
|
||||
import Common
|
||||
|
@ -123,3 +124,23 @@ stageDiffTreeItem d = case toTreeItemType (Diff.dstmode d) of
|
|||
|
||||
indexPath :: TopFilePath -> InternalGitPath
|
||||
indexPath = toInternalGitPath . getTopFilePath
|
||||
|
||||
{- Refreshes the index, by checking file stat information. -}
|
||||
refreshIndex :: Repo -> ((FilePath -> IO ()) -> IO ()) -> IO Bool
|
||||
refreshIndex repo feeder = do
|
||||
(Just h, _, _, p) <- createProcess (gitCreateProcess params repo)
|
||||
{ std_in = CreatePipe }
|
||||
feeder $ \f -> do
|
||||
hPutStr h f
|
||||
hPutStr h "\0"
|
||||
hFlush h
|
||||
hClose h
|
||||
checkSuccessProcess p
|
||||
where
|
||||
params =
|
||||
[ Param "update-index"
|
||||
, Param "-q"
|
||||
, Param "--refresh"
|
||||
, Param "-z"
|
||||
, Param "--stdin"
|
||||
]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue