Search code examples
gitgit-p4git-lfs

git-p4 and config git-p4.largeFileExtensions


I am attempting to convert a Perforce repository to a git one, using git-p4 (using git for Windows). I have many images, and would like to use LFS for them. However, I can't seem to get the git-p4.largeFileExtensions config setting to work properly with multiple extensions. If I execute the following:

git config       git-p4.largeFileSystem     GitLFS
git config       git-p4.largeFileExtensions png
git config --add git-p4.largeFileExtensions jpg
git p4 clone --verbose //depot/project@all .

I get (if I use more than two, all pairs report a similar warning):

WARNING: These git config values clash:
  git config "git-p4.largefileextensions" = "png"
  git config "git-p4.largefileextensions" = "jpg"

The .git/config file is what I would expect, a multivalue entry for largeFileExtensions:

[git-p4]
        largeFileSystem = GitLFS
        largeFileExtensions = png
        largeFileExtensions = jpg

The however .gitattributes file created looks like:

#
# Git LFS (see https://git-lfs.github.com/)
#
*.png
jpg filter=lfs -text

Am I doing something wrong, or does the largeFileExtensions attribute formatted differently?


Solution

  • This appears to be a problem with git for Windows outputting incorrect line endings for Windows. If I run:

    git config --get-all git-p4.largeFileExtensions
    

    it will give me:

    png\r
    jpg\r
    

    In the git-p4.py script, it uses split(os.linesep) to split the output from the command line. On Windows, os.linesep = '\r\n', and thus the lines don't get split. If I change the script to use splitlines() instead, then it still gives the clash warnings, however, it seems as though the tracking is now correct.