diff options
author | Joey Hess <joey@kitenet.net> | 2014-02-26 14:14:39 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2014-02-26 14:14:39 -0400 |
commit | 0f78a1c58ba2d4152b5671e0c055ef6f37f44425 (patch) | |
tree | ab50d91c1cae5e08825cb4adffa3f6b388cb0148 /Git/Destroyer.hs | |
parent | 9ddd4a8fa822dfddf4adc07972146230815381cd (diff) | |
download | git-repair-0f78a1c58ba2d4152b5671e0c055ef6f37f44425.tar.gz |
avoid swapping file with itself when different file selectors select same file
Diffstat (limited to 'Git/Destroyer.hs')
-rw-r--r-- | Git/Destroyer.hs | 9 |
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 |