Bug 545701 - Jgit ArchiveCommand ignores git attributes (CR/LF and others)
Summary: Jgit ArchiveCommand ignores git attributes (CR/LF and others)
Status: NEW
Alias: None
Product: JGit
Classification: Technology
Component: JGit (show other bugs)
Version: 5.3   Edit
Hardware: All Linux
: P3 normal with 2 votes (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-03-23 09:37 EDT by Ilya Rokhkin CLA
Modified: 2019-05-20 02:25 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ilya Rokhkin CLA 2019-03-23 09:37:44 EDT
We use jgit via gerrit and git archive command seems do not read .git attributes from remote repository before compressing and sending it 

Gerrit version: 2.16.6

What steps will reproduce the problem?
1. ~/tmp/AppShell3 % git archive --format=tar.gz --remote=ssh://gerrit-server:29418/Repo1 V_BRANCH1 | tar zxf -
Bring all files with eol LF
2./tmp/AppShell4 % git archive --format=tar.gz --remote=git@gerrit-server:/git/Repo1 V_BRANCH1 | tar zxf -
Regular git archive via ssh port 22 not related to gerrit, works as expected, brings *.mht file eol CRLF windows style
3.
this is the repository Repo1.gitattributes file
# Declare files that will always have CRLF line endings on checkout.
*.mht eol=crlf

What is the expected output?
To see *.mht files in CRLF eol 

By default git archive reads .gitattributes before compressing and sending archive
Comment 1 Thomas Wolf CLA 2019-05-19 16:30:54 EDT
Yes. See org.eclipse.jgit.archive.TarFormat.putEntry(): this just copies the blob, ignoring any CR/LF conversions or other attributes.[1] It also doesn't implement the export-ignore and export-subst attributes.

Smudge filters probably might not work. Unclear to me how canonical git would handle that...

The same problem also exists in ZipFormat.[2]

[1] https://git.eclipse.org/r/plugins/gitiles/jgit/jgit/+/master/org.eclipse.jgit.archive/src/org/eclipse/jgit/archive/TarFormat.java#138
[2] https://git.eclipse.org/r/plugins/gitiles/jgit/jgit/+/master/org.eclipse.jgit.archive/src/org/eclipse/jgit/archive/ZipFormat.java#122
Comment 2 Thomas Wolf CLA 2019-05-20 02:25:40 EDT
(In reply to Thomas Wolf from comment #1)
> Smudge filters probably might not work. Unclear to me how canonical git
> would handle that...
To clarify: might in particular not work with --remote. The smudge filter might refer to an executable not available on the server.