diff options
author | Joey Hess <joey@kitenet.net> | 2014-06-09 18:01:30 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2014-06-09 19:40:28 -0400 |
commit | 7ce9a3793d91c210343a1e5ea60053dccab5a12c (patch) | |
tree | 5a5c262770118d790b0851e4ff6f1df4fddfaa39 /Git/Branch.hs | |
parent | 3eeba159f25cd53773c48d131cae796b366a43a4 (diff) |
avoid bad commits after interrupted direct mode sync (or merge)
It was possible for a interrupted sync or merge in direct mode to
leave the work tree out of sync with the last recorded commit.
This would result in the next commit seeing files missing from the work
tree, and committing their removal.
Now, a direct mode merge happens not only in a throwaway work tree, but using
a temporary index file, and without any commits or index changes
being made until the real work tree has been updated. If the merge is
interrupted, the work tree may have some updated files, but worst case a
commit will redundantly commit changes that come from the merge.
This commit was sponsored by Tony Cantor.
Diffstat (limited to 'Git/Branch.hs')
-rw-r--r-- | Git/Branch.hs | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/Git/Branch.hs b/Git/Branch.hs index d182ceb39..7c7e44d75 100644 --- a/Git/Branch.hs +++ b/Git/Branch.hs @@ -52,7 +52,22 @@ changed origbranch newbranch repo diffs = pipeReadStrict [ Param "log" , Param (fromRef origbranch ++ ".." ++ fromRef newbranch) - , Params "--oneline -n1" + , Param "-n1" + , Param "--pretty=%H" + ] repo + +{- Check if it's possible to fast-forward from the old + - ref to the new ref. + - + - This requires there to be a path from the old to the new. -} +fastForwardable :: Ref -> Ref -> Repo -> IO Bool +fastForwardable old new repo = not . null <$> + pipeReadStrict + [ Param "log" + , Param $ fromRef old ++ ".." ++ fromRef new + , Param "-n1" + , Param "--pretty=%H" + , Param "--ancestry-path" ] repo {- Given a set of refs that are all known to have commits not @@ -74,7 +89,7 @@ fastForward branch (first:rest) repo = where no_ff = return False do_ff to = do - run [Param "update-ref", Param $ fromRef branch, Param $ fromRef to] repo + update branch to repo return True findbest c [] = return $ Just c findbest c (r:rs) |