avoid moving if src and dest are the same

This commit is contained in:
Joey Hess 2011-01-26 15:59:10 -04:00
parent 268cb35e64
commit 7b2da21ab7

View file

@ -71,8 +71,9 @@ remoteHasKey remote key present = do
-} -}
toStart :: Git.Repo -> Bool -> CommandStartString toStart :: Git.Repo -> Bool -> CommandStartString
toStart dest move file = isAnnexed file $ \(key, _) -> do toStart dest move file = isAnnexed file $ \(key, _) -> do
g <- Annex.gitRepo
ishere <- inAnnex key ishere <- inAnnex key
if not ishere if not ishere || g == dest
then return Nothing -- not here, so nothing to do then return Nothing -- not here, so nothing to do
else do else do
showAction move file showAction move file
@ -108,8 +109,9 @@ toCleanup dest move key = do
-} -}
fromStart :: Git.Repo -> Bool -> CommandStartString fromStart :: Git.Repo -> Bool -> CommandStartString
fromStart src move file = isAnnexed file $ \(key, _) -> do fromStart src move file = isAnnexed file $ \(key, _) -> do
g <- Annex.gitRepo
(trusted, untrusted, _) <- Remotes.keyPossibilities key (trusted, untrusted, _) <- Remotes.keyPossibilities key
if null $ filter (\r -> Remotes.same r src) (trusted ++ untrusted) if (g == src) || (null $ filter (\r -> Remotes.same r src) (trusted ++ untrusted))
then return Nothing then return Nothing
else do else do
showAction move file showAction move file