Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

git cannot treat grouped pattern produced by bfg --convert-to-git-lfs #143

Closed
hirose31 opened this issue Apr 15, 2016 · 2 comments
Closed

Comments

@hirose31
Copy link

hirose31 commented Apr 15, 2016

bfg --convert-to-git-lfs '*.{zip,mp4}' adds below to .gitattributes.

*.{zip,mp4} filter=lfs diff=lfs merge=lfs -text

But git command cannot treat this pattern as we expect.

$ cat .gitattributes
*.gz filter=lfs diff=lfs merge=lfs -text
*.{zip,mp4} filter=lfs diff=lfs merge=lfs -text

$ echo blah > foo.gz
$ echo blah > bar.zip
$ echo blah > baz.mp4
$ echo blah > 'qux.{zip,mp4}'

$ git add -A .
$ git commit -m blah
[master c434cbe] blah
 4 files changed, 8 insertions(+)
 create mode 100644 bar.zip
 create mode 100644 baz.mp4
 create mode 100644 foo.gz
 create mode 100644 qux.{zip,mp4}
$ git lfs ls-files
41af286dc0 * foo.gz
41af286dc0 * qux.{zip,mp4}

Suggest: If It is hard to separate grouped pattern, How abount enabling to specify --convert-to-git-lfs option multiple times and take only one pattern?

bfg --convert-to-git-lfs '*.zip' --convert-to-git-lfs '*.mp4'

I'v checked on following environment:

  • git 2.2.1
  • git-lfs 1.2.0
  • bfg 1.12.12
@javabrett
Copy link
Contributor

javabrett commented Apr 15, 2016

This problem is a limitation of glob-processing in Git itself. It is not a BFG or Git LFS-specific problem, or if there is a bug with those, it is if those tools accept and process those globs, but Git itself doesn't understand them, so the filters they add don't work.

Git might say that it treats these types of matches as "shell glob pattern", but I think a lot of the wildcard-processing is hand-coded, see wildmatch.c in the Git source. To improve completeness between what common shell globs support (with or without shopt -s extglob), some work might be required on that code, perhaps referencing some common library.

Here's a test. .gitignore can be used because the rules are the same as for .gitattributes:

$ git init globtest
Initialized empty Git repository in <redacted>
$ cd globtest/
$ touch test.zip test.mp4

$ ls *.{zip,mp4}
test.mp4  test.zip

$ git status
...
Untracked files:
  (use "git add <file>..." to include in what will be committed)

    test.mp4
    test.zip

$ echo "*.{zip,mp4}" >> .gitignore

$ cat .gitignore 
*.{zip,mp4}

$ git status
...
Untracked files:
  (use "git add <file>..." to include in what will be committed)

    .gitignore
    test.mp4
    test.zip

$ echo "*.zip" >> .gitignore

$ git status
...
Untracked files:
  (use "git add <file>..." to include in what will be committed)

    .gitignore
    test.mp4

$ echo "*.mp4" >> .gitignore

$ git status
...
Untracked files:
  (use "git add <file>..." to include in what will be committed)

    .gitignore

The demostrates that whilst ls *.{zip,mp4} might work in bash, Git ignore/attributes is unable to match it in the way you'd like.

@n8gray
Copy link

n8gray commented Jun 2, 2016

To be clear, the BFG documentation for the --convert-to-git-lfs option suggests using this syntax. If it doesn't work the documentation should be changed:

--convert-to-git-lfs
extract files with the specified names (eg '*.{zip,mp4}') into Git LFS

javabrett added a commit to javabrett/bfg-repo-cleaner that referenced this issue Jun 3, 2016
…wild-carded forms that are supported by BFG but not by git/git-lfs. See rtyley#143.

This may also relate to how BFG combines the cleaning-routine and LFS-externalization with the creation of .gitattributes files, ref rtyley#116.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants