+
Skip to content

.gitattributes filters with foldernames do not work outside main folder #37

@calebrottman

Description

@calebrottman

git supports .gitattributes filters with folder names and wildcards (i.e. subpath/**/*.raw filter=bigstore. However, if you are not in the main path and do a git bigstore push, it will silently fail.

This is because in the current version, a fnmatch is called with the base filename and wildcard here.
If you are in the folder subpath that contains the file foo.raw, fnmatch will fail because it is comparing subpath/**/*.raw to foo.raw.

This issue should be fixed by replacing the line:

-            if fnmatch.fnmatch(filename, wildcard):
+            full_filename = os.path.join(os.getcwd(), filename)
+            rel_filename = os.path.relpath(full_filename, toplevel_dir)
+            if fnmatch.fnmatch(rel_filename, wildcard):

(I figured this change was too small to do a separate pull request).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载