]> dgit.raspbian.org Git - git-annex.git/commitdiff
avoid exporting non-annexed symlinks
authorJoey Hess <joeyh@joeyh.name>
Mon, 3 Jan 2022 18:21:50 +0000 (14:21 -0400)
committerJoey Hess <joeyh@joeyh.name>
Mon, 3 Jan 2022 18:21:50 +0000 (14:21 -0400)
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
Command/Export.hs
doc/bugs/adb_replaces_symlinks_by_plain_text_files.mdwn

index a1c1032eefcfeceb1eef2be762ed1d10e3ca3989..235b49aaccc5dc0a3cd9604427d2cff169bd992e 100644 (file)
--- 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 <id@joeyh.name>  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,
index bb848f42f13db680fafe2efbb035c1f0f45be755..6efbaf10025c78ff1ac612b2e07c80ced5ad885f 100644 (file)
@@ -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 $
index e6bf632ddceaf9545ab2bd70e3eef44b0ab982da..5e663589fbb32d7e03d0fd0ceb6f334d36994835 100644 (file)
@@ -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]]