I have discovered that what is meant by Any files that are gitignored will not be included in the import, but will be left on the remote.
in the import doc is Any files that are [locally] gitignored [relative to the repo's root] will not be included in the import
. This is to say that when importing, only .gitignore
paths from the root repo are used to exclude paths in the imported tree as if the tree were imported relative to root, regardless if a subtree is specified. This means that the repo gitignores must include ignores as desired to import the correct files from an import tree.
This makes it challenging to import special remotes into subtrees. Ignores must be written to match the trees' roots but this might lead to clobbering of paths/names which overlap with other trees or the main repo.
Therefore I suggest that imports to a subtree respect ignores as if the files in the tree were already adjusted to their new destination. I suspect that annex is listing the tree, comparing the list to ignores, then importing what doesn't match. So, instead, this would involve listing, moving the list to its subtree path, then comparing to ignores.
A similar argument could be made for attributes in general.
I haven't done the testing on import attributes (namely largefiles
), but I would want these to respect subtree paths as well.
Testing Notes
I made various .gitignore files in a fresh repo with a tree at ../tree
relative to fresh repo.
The tree had files a
-g
.
The ignores all began from this template:
# -- Import into ROOT
# -- tree ignore
a
# -- root ignore
b
# -- root ignore in root
root-ignore/c
# -- relative ignore in relative
d
# -- root ignore in relative
root-ignore/e
# -- relative ignore in root
f
# -- tree ignore relative to root
root-ignore/g
Then I commented out certain lines for each location. E.g. only try ignoring a
and root-ignore/g
in the tree, b
, root-ignore/c
in root, and f
in root.
Regardless of import or ignore, only b
and f
were ignored pertaining to the root .gitignore
matching these files in the tree, even when the tree was imported to subtree rel-ignore
or root-ignore
.
As far as I can see, this works correctly already.
So the .gitignore of
foo/*.c
applied when importing fromd
into afoo
subdirectory, with the.c
file not being imported, and other files being imported. When I import fromd
into a different subdirectory, the .gitignore does not match, and those files are imported:The above shows this does happen. Also I can confirm it by inspection of the code, particularly
notIgnoredImportLocation
adds the ImportSubTree location to the filepath.Based on my inspection of the code, it already does.
So, I suspect I am either misunderstanding what you are trying to do, or you are confused. In either case, it would be helpful if you show a complete example of what you're trying to do.