Don't try to import .git directories from special remotes
Because git does not support storing git repositories inside a git repository.
This commit is contained in:
parent
500f72ec3d
commit
082e1f1738
4 changed files with 32 additions and 1 deletions
|
@ -16,6 +16,7 @@ module Annex.Import (
|
||||||
downloadImport,
|
downloadImport,
|
||||||
filterImportableContents,
|
filterImportableContents,
|
||||||
makeImportMatcher,
|
makeImportMatcher,
|
||||||
|
listImportableContents,
|
||||||
) where
|
) where
|
||||||
|
|
||||||
import Annex.Common
|
import Annex.Common
|
||||||
|
@ -54,6 +55,7 @@ import qualified Logs.ContentIdentifier as CIDLog
|
||||||
import Control.Concurrent.STM
|
import Control.Concurrent.STM
|
||||||
import qualified Data.Map.Strict as M
|
import qualified Data.Map.Strict as M
|
||||||
import qualified Data.Set as S
|
import qualified Data.Set as S
|
||||||
|
import qualified System.FilePath.Posix as Posix
|
||||||
|
|
||||||
{- Configures how to build an import tree. -}
|
{- Configures how to build an import tree. -}
|
||||||
data ImportTreeConfig
|
data ImportTreeConfig
|
||||||
|
@ -480,3 +482,22 @@ filterImportableContents r matcher importable
|
||||||
<*> mapM (go dbhandle) (importableHistory ic)
|
<*> mapM (go dbhandle) (importableHistory ic)
|
||||||
|
|
||||||
match dbhandle (loc, (_cid, sz)) = shouldImport dbhandle matcher loc sz
|
match dbhandle (loc, (_cid, sz)) = shouldImport dbhandle matcher loc sz
|
||||||
|
|
||||||
|
{- Gets the ImportableContents from the remote.
|
||||||
|
-
|
||||||
|
- Filters out any paths that include a ".git" component, because git does
|
||||||
|
- not allow storing ".git" in a git repository. While it is possible to
|
||||||
|
- write a git tree that contains that, git will complain and refuse to
|
||||||
|
- check it out.
|
||||||
|
-}
|
||||||
|
listImportableContents :: Remote -> Annex (Maybe (ImportableContents (ContentIdentifier, ByteSize)))
|
||||||
|
listImportableContents r = fmap removegitspecial
|
||||||
|
<$> Remote.listImportableContents (Remote.importActions r)
|
||||||
|
where
|
||||||
|
removegitspecial ic = ImportableContents
|
||||||
|
{ importableContents =
|
||||||
|
filter (not . gitspecial . fst) (importableContents ic)
|
||||||
|
, importableHistory =
|
||||||
|
map removegitspecial (importableHistory ic)
|
||||||
|
}
|
||||||
|
gitspecial l = ".git" `elem` Posix.splitDirectories (fromImportLocation l)
|
||||||
|
|
|
@ -11,6 +11,8 @@ git-annex (7.20190508) UNRELEASED; urgency=medium
|
||||||
unwanted files are not imported. But, some preferred content
|
unwanted files are not imported. But, some preferred content
|
||||||
expressions can't be checked before files are imported, and trying to
|
expressions can't be checked before files are imported, and trying to
|
||||||
import with such an expression will fail.
|
import with such an expression will fail.
|
||||||
|
* Don't try to import .git directories from special remotes, because
|
||||||
|
git does not support storing git repositories inside a git repository.
|
||||||
* Improve shape of commit tree when importing from unversioned special
|
* Improve shape of commit tree when importing from unversioned special
|
||||||
remotes.
|
remotes.
|
||||||
* init: When the repository already has a description, don't change it.
|
* init: When the repository already has a description, don't change it.
|
||||||
|
|
|
@ -291,7 +291,7 @@ seekRemote remote branch msubdir = do
|
||||||
listContents :: Remote -> TVar (Maybe (ImportableContents (ContentIdentifier, Remote.ByteSize))) -> CommandStart
|
listContents :: Remote -> TVar (Maybe (ImportableContents (ContentIdentifier, Remote.ByteSize))) -> CommandStart
|
||||||
listContents remote tvar = do
|
listContents remote tvar = do
|
||||||
showStart' "list" (Just (Remote.name remote))
|
showStart' "list" (Just (Remote.name remote))
|
||||||
next $ Remote.listImportableContents (Remote.importActions remote) >>= \case
|
next $ listImportableContents remote >>= \case
|
||||||
Nothing -> giveup $ "Unable to list contents of " ++ Remote.name remote
|
Nothing -> giveup $ "Unable to list contents of " ++ Remote.name remote
|
||||||
Just importable -> do
|
Just importable -> do
|
||||||
importable' <- makeImportMatcher remote >>= \case
|
importable' <- makeImportMatcher remote >>= \case
|
||||||
|
|
|
@ -19,6 +19,14 @@ The solution is certianly to
|
||||||
1. filter out .git when importing
|
1. filter out .git when importing
|
||||||
2. avoid deleting .git when exporting
|
2. avoid deleting .git when exporting
|
||||||
|
|
||||||
|
As long as the export tracking branch did not contain .git,
|
||||||
|
an export will harm no .git directories, because an exporttree
|
||||||
|
remote uses removeExportDirectoryWhenEmpty, not removeExportDirectory,
|
||||||
|
so will not delete non-empty directories. And other than deleting
|
||||||
|
directories, exporting only deletes files that are removed in the git
|
||||||
|
diff between two trees; if neither tree contained .git, the diff won't
|
||||||
|
contain it either, and so if importing skips .git, this will be ok.
|
||||||
|
|
||||||
--[[Joey]]
|
--[[Joey]]
|
||||||
|
|
||||||
> [[fixed|done]] --[[Joey]]
|
> [[fixed|done]] --[[Joey]]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue