fixed reconcileStaged crash when index is locked or in conflict
Eg, when git commit runs the smudge filter.
Commit 428c91606b
introduced the crash,
as write-tree fails in those situations. Now it will work, and git-annex
always gets up-to-date information even in those situations. It does
need to do a bit more work, each time git-annex is run with the index
locked. Although if the index is unmodified from the last time
write-tree succeeded, that work is avoided.
This commit is contained in:
parent
3698e804d4
commit
efae085272
3 changed files with 47 additions and 26 deletions
|
@ -185,8 +185,18 @@ commitAlways :: CommitMode -> String -> Branch -> [Ref] -> Repo -> IO Sha
|
|||
commitAlways commitmode message branch parentrefs repo = fromJust
|
||||
<$> commit commitmode True message branch parentrefs repo
|
||||
|
||||
-- Throws exception if the index is locked, with an error message output by
|
||||
-- git on stderr.
|
||||
writeTree :: Repo -> IO Sha
|
||||
writeTree repo = getSha "write-tree" $ pipeReadStrict [Param "write-tree"] repo
|
||||
writeTree repo = getSha "write-tree" $
|
||||
pipeReadStrict [Param "write-tree"] repo
|
||||
|
||||
-- Avoids error output if the command fails due to eg, the index being locked.
|
||||
writeTreeQuiet :: Repo -> IO (Maybe Sha)
|
||||
writeTreeQuiet repo = extractSha <$> withNullHandle go
|
||||
where
|
||||
go nullh = pipeReadStrict' (\p -> p { std_err = UseHandle nullh })
|
||||
[Param "write-tree"] repo
|
||||
|
||||
commitTree :: CommitMode -> String -> [Ref] -> Ref -> Repo -> IO Sha
|
||||
commitTree commitmode message parentrefs tree repo =
|
||||
|
|
|
@ -70,17 +70,15 @@ pipeReadLazy params repo = assertLocal repo $ do
|
|||
- Nonzero exit status is ignored.
|
||||
-}
|
||||
pipeReadStrict :: [CommandParam] -> Repo -> IO S.ByteString
|
||||
pipeReadStrict = pipeReadStrict' S.hGetContents
|
||||
pipeReadStrict = pipeReadStrict' id
|
||||
|
||||
{- The reader action must be strict. -}
|
||||
pipeReadStrict' :: (Handle -> IO a) -> [CommandParam] -> Repo -> IO a
|
||||
pipeReadStrict' reader params repo = assertLocal repo $ withCreateProcess p go
|
||||
pipeReadStrict' :: (CreateProcess -> CreateProcess) -> [CommandParam] -> Repo -> IO S.ByteString
|
||||
pipeReadStrict' fp params repo = assertLocal repo $ withCreateProcess p go
|
||||
where
|
||||
p = (gitCreateProcess params repo)
|
||||
{ std_out = CreatePipe }
|
||||
p = fp (gitCreateProcess params repo) { std_out = CreatePipe }
|
||||
|
||||
go _ (Just outh) _ pid = do
|
||||
output <- reader outh
|
||||
output <- S.hGetContents outh
|
||||
hClose outh
|
||||
void $ waitForProcess pid
|
||||
return output
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue