From 7e2f5edd68bc2b41148c4a0deb8f5fe792de23dc Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Mon, 3 Jan 2022 14:21:50 -0400 Subject: [PATCH] avoid exporting non-annexed symlinks So that importing does not replace them with plain files. This works similarly to how the previous handling of submodules and matchers did, except that annexed symlinks still get exported as plain files of course, it's only non-annexed symlinks that it does not make sense to export. When symlinks have previously been exported, updating the export will unexport them after upgrading to this commit. Sponsored-by: Kevin Mueller on Patreon --- CHANGELOG | 8 ++++++ Command/Export.hs | 26 ++++++++++++++----- ...replaces_symlinks_by_plain_text_files.mdwn | 2 ++ 3 files changed, 29 insertions(+), 7 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index a1c1032eef..235b49aacc 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,11 @@ +git-annex (8.20211232) UNRELEASED; urgency=medium + + * export: When a non-annexed symlink is in the tree to be exported, skip it. + * import: When the previously exported tree contained a non-annexed symlink, + preserve it in the imported tree so it does not get deleted. + + -- Joey Hess Mon, 03 Jan 2022 14:01:14 -0400 + git-annex (8.20211231) upstream; urgency=medium * Improved support for using git-annex in a read-only repository, diff --git a/Command/Export.hs b/Command/Export.hs index bb848f42f1..6efbaf1002 100644 --- a/Command/Export.hs +++ b/Command/Export.hs @@ -479,7 +479,8 @@ removeEmptyDirectories r db loc ks newtype ExportFiltered t = ExportFiltered t -- | Filters the tree to annexed files that are preferred content of the --- remote, and also including non-annexed files, but not submodules. +-- remote, and also including non-annexed files, but not submodules or +-- non-annexed symlinks. -- -- A log is written with tree items that were filtered out, so they can -- be added back in when importing from the remote. @@ -505,17 +506,28 @@ filterExport r tree = logExportExcluded (uuid r) $ \logwriter -> do case toTreeItemType mode of -- Don't export submodule entries. Just TreeSubmodule -> excluded - _ -> case mmatcher of - Nothing -> return (Just ti) - Just matcher -> catKey sha >>= \case - Just k -> checkmatcher matcher k - -- Always export non-annexed files. - Nothing -> return (Just ti) + Just TreeSymlink -> checkkey True + _ -> checkkey False where excluded = do () <- liftIO $ logwriter ti return Nothing + checkkey issymlink = + case mmatcher of + Nothing + | issymlink -> catKey sha >>= \case + Just _ -> return (Just ti) + Nothing + | issymlink -> excluded + | otherwise -> return (Just ti) + | otherwise -> return (Just ti) + Just matcher -> catKey sha >>= \case + Just k -> checkmatcher matcher k + Nothing + | issymlink -> excluded + | otherwise -> return (Just ti) + checkmatcher matcher k = do let mi = MatchingInfo $ ProvidedInfo { providedFilePath = Just $ diff --git a/doc/bugs/adb_replaces_symlinks_by_plain_text_files.mdwn b/doc/bugs/adb_replaces_symlinks_by_plain_text_files.mdwn index e6bf632ddc..5e663589fb 100644 --- a/doc/bugs/adb_replaces_symlinks_by_plain_text_files.mdwn +++ b/doc/bugs/adb_replaces_symlinks_by_plain_text_files.mdwn @@ -26,3 +26,5 @@ Don't do anything if they are the same. Replace symlink by actual file if they differ. [[!meta title="export then import replaces non-annex symlinks by plain text files"]] + +> [[fixed|done]] by skipping syminks. --[[Joey]]