add warning on add of annex link
Warn when adding a annex symlink or pointer file that uses a key that is not known to the repository, to prevent confusion if the user has copied it from some other repository. This commit was sponsored by Jake Vosloo on Patreon.
This commit is contained in:
parent
9e8eae20e2
commit
92b7b1964d
5 changed files with 36 additions and 14 deletions
|
@ -27,8 +27,6 @@ import Utility.FileMode
|
|||
import Utility.OptParse
|
||||
import qualified Utility.RawFilePath as R
|
||||
|
||||
import System.Log.Logger (debugM)
|
||||
|
||||
cmd :: Command
|
||||
cmd = notBareRepo $
|
||||
withGlobalOptions opts $
|
||||
|
@ -171,16 +169,17 @@ start o si file addunlockedmatcher = do
|
|||
liftIO (catchMaybeIO $ R.getSymbolicLinkStatus file) >>= \case
|
||||
Just s | isSymbolicLink s -> fixuplink key
|
||||
_ -> add
|
||||
fixuplink key = starting "add" (ActionItemWorkTreeFile file) si $ do
|
||||
liftIO $ debugM "add" "adding existing annex symlink to git"
|
||||
liftIO $ removeFile (fromRawFilePath file)
|
||||
addLink (checkGitIgnoreOption o) file key Nothing
|
||||
next $
|
||||
cleanup key =<< inAnnex key
|
||||
fixuppointer key = starting "add" (ActionItemWorkTreeFile file) si $ do
|
||||
liftIO $ debugM "add" "adding pointer file to git"
|
||||
Database.Keys.addAssociatedFile key =<< inRepo (toTopFilePath file)
|
||||
next $ addFile (checkGitIgnoreOption o) file
|
||||
fixuplink key =
|
||||
starting "add" (ActionItemWorkTreeFile file) si $
|
||||
addingExistingLink file key $ do
|
||||
liftIO $ removeFile (fromRawFilePath file)
|
||||
addLink (checkGitIgnoreOption o) file key Nothing
|
||||
next $ cleanup key =<< inAnnex key
|
||||
fixuppointer key =
|
||||
starting "add" (ActionItemWorkTreeFile file) si $
|
||||
addingExistingLink file key $ do
|
||||
Database.Keys.addAssociatedFile key =<< inRepo (toTopFilePath file)
|
||||
next $ addFile (checkGitIgnoreOption o) file
|
||||
|
||||
perform :: AddOptions -> RawFilePath -> AddUnlockedMatcher -> CommandPerform
|
||||
perform o file addunlockedmatcher = withOtherTmp $ \tmpdir -> do
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue