Skip to content

Cloning a repository which contains any LFS-managed file with an ampersand character in its file name fails on windows when using native git-lfs #228

@alxflam-work

Description

@alxflam-work

Version

7.0.0

Operating System

Windows

Bug description

  • Clone a repository which contains an LFS-managed file with an ampersand character in its file name
  • Clone with native git-lfs, not with JGit built-in LFS support
  • Here's a minimal reproducible example repo: https://github.com/alxflam-work/egit-clone-lfs.git
  • The clone fails on windows, as windows CMD treats ampersand as a special character (command chaining operator)

Actual behavior

  • The file name with the ampersand character is passed unescaped to CMD and therefore the native git-lfs smudge command receives not the complete file path (everything after the ampersand is treated as a separate command)
  • The command invocation therefore fails with:

org.eclipse.jgit.api.errors.FilterFailedException: Execution of filter command 'git-lfs smudge -- 'some&lfs.txt'' on file 'some&lfs.txt' failed with return code '1', message on stderr: 'Downloading 'some (44 B) 'lfs.txt'' is not recognized as an internal or external command, operable program or batch file. '

Expected behavior

  • JGit escapes file names containing & with ^ on windows when invoking the native git-lfs (or potentially other tools)
  • For the given example not some&lfs.txt is passed but some^&lfs.txt
  • Clone succeeds

Relevant log output

IOException: org.eclipse.jgit.api.errors.FilterFailedException: Execution of filter command 'git-lfs smudge -- 'some&lfs.txt'' on file 'some&lfs.txt' failed with return code '1', message on stderr: 'Downloading 'some (44 B)
'lfs.txt'' is not recognized as an internal or external command, operable program or batch file
	at org.eclipse.jgit.dircache.DirCacheCheckout.runExternalFilterCommand(DirCacheCheckout.java:1549)
	at org.eclipse.jgit.dircache.DirCacheCheckout.getContent(DirCacheCheckout.java:1508)
	at org.eclipse.jgit.dircache.DirCacheCheckout.getContent(DirCacheCheckout.java:1437)
	at org.eclipse.jgit.dircache.Checkout.checkout(Checkout.java:195)
	at org.eclipse.jgit.dircache.DirCacheCheckout.doCheckout(DirCacheCheckout.java:577)
	at org.eclipse.jgit.dircache.DirCacheCheckout.checkout(DirCacheCheckout.java:480)
	at org.eclipse.jgit.api.CloneCommand.checkout(CloneCommand.java:397)
	at org.eclipse.jgit.api.CloneCommand.call(CloneCommand.java:216)

Other information

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions