From 0f78a1c58ba2d4152b5671e0c055ef6f37f44425 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Wed, 26 Feb 2014 14:14:39 -0400 Subject: avoid swapping file with itself when different file selectors select same file --- Git/Destroyer.hs | 9 ++++----- 1 file 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 -- cgit v1.2.3