summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoey Hess <joey@kitenet.net>2014-02-26 14:14:39 -0400
committerJoey Hess <joey@kitenet.net>2014-02-26 14:14:39 -0400
commit0f78a1c58ba2d4152b5671e0c055ef6f37f44425 (patch)
treeab50d91c1cae5e08825cb4adffa3f6b388cb0148
parent9ddd4a8fa822dfddf4adc07972146230815381cd (diff)
downloadgit-repair-0f78a1c58ba2d4152b5671e0c055ef6f37f44425.tar.gz
avoid swapping file with itself when different file selectors select same file
-rw-r--r--Git/Destroyer.hs9
1 files changed, 4 insertions, 5 deletions
diff --git a/Git/Destroyer.hs b/Git/Destroyer.hs
index 8827976..955e313 100644
--- a/Git/Destroyer.hs
+++ b/Git/Destroyer.hs
@@ -129,11 +129,10 @@ applyDamage ds r = do
ScrambleFileMode s mode ->
withfile s $ \f ->
setFileMode f mode
- SwapFiles a b
- | a == b -> noop
- | otherwise ->
- withfile a $ \fa ->
- withfile b $ \fb ->
+ SwapFiles a b ->
+ withfile a $ \fa ->
+ withfile b $ \fb ->
+ unless (fa == fb) $
withTmpFile "swap" $ \tmp _ -> do
moveFile fa tmp
moveFile fb fa