Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EGit / JGit » JGIT with LFS: Archive does not has actual files(JGIT archive command does not create zip with actual LFS files)
icon5.gif  JGIT with LFS: Archive does not has actual files [message #1748717] Sun, 27 November 2016 19:00 Go to next message
Afroz Shaik is currently offline Afroz ShaikFriend
Messages: 3
Registered: November 2016
Junior Member
JGIT/LFS Team,

We are using JGIT in our project. We recently observed that there is LFS support so I am evaluating this.

I have been able to install GIT LFS locally and configured LFS to track some files. I also committed .gitattributes file.

A. I was able to checkout a commit/branch and can confirm I am able to extract LFS files via JGIT [with a caveat though]. I did not have to change any code in our previous checkout code.

However when I am trying to build a zip file at the same commit, I am ONLY getting pointer files.

Am I missing something?

The git core "archive" command does in fact seem to insert the final object pointed by pointer file.

B. I also want to know if I need to have GIT LFS client installed for JGIT LFS to work. This is because my "jgit checkout" only works if GIT LFS client is installed. Is there some config I need to point to make it work without GIT LFS client.

Let us say I am using a GIT server where it stores objects in a special file store, what is config needed to make it look into this file store.

Are there any examples I can use. Any help is appreciated.

Thanks so much in advance.

I do not get any error.

Best Regards
Afroz Shaik

---------------------

String repoDir = "C:/Users/a0216021/gerrit/test/lfstest/.git";
String lfsarchive = "C:/Users/a0216021/gerrit/test/lfsarchive/";
String outputFile = lfsarchive + File.separator + "lfstest.zip";
ArchiveFormats.registerAll();

try (FileOutputStream out = new FileOutputStream(outputFile)) {
String commitId = "0dd5ce1f29541cd520b0ac810f88cbfc2d93c5a4";
log.info("generateArchive method Repo Dir: {}", repoDir);

//an existing repository
File repoDirObj = new File(repoDir);
try (Repository myRepo = new FileRepositoryBuilder()
.setGitDir(repoDirObj)
.readEnvironment()
.findGitDir().build()) {

git = new Git(myRepo);
ObjectId objectId = myRepo.resolve(commitId);
if (objectId != null) {
log.info("Resolved commitId: {} ", objectId.getName());
}


git.archive().setTree(objectId).setFormat("zip")
.setOutputStream(out).call();

}
}
ArchiveFormats.unregisterAll();

[Updated on: Mon, 28 November 2016 20:02]

Report message to a moderator

Re: JGIT with LFS: Archive does not has actual files [message #1748810 is a reply to message #1748717] Mon, 28 November 2016 23:31 Go to previous messageGo to next message
Afroz Shaik is currently offline Afroz ShaikFriend
Messages: 3
Registered: November 2016
Junior Member
It appears v4.5 is expecting LFS client to be installed.

Will I be able to remove GIT LFS client dependency with v4.6?

how about configuring where LFS objects are [vs default of .git/lfs/objects]...

I see some new code is being written to address this in v4.6.0-SNAPSHOT.

is there a tentative ETA on v4.6 release?
Re: JGIT with LFS: Archive does not has actual files [message #1749137 is a reply to message #1748810] Fri, 02 December 2016 08:59 Go to previous messageGo to next message
Matthias Sohn is currently offline Matthias SohnFriend
Messages: 962
Registered: July 2009
Senior Member
Yes 4.5 requires git lfs and native git to be available on the PATH seen by JGit.

We are working on built-in LFS filters in JGit, a couple of changes are in review
https://git.eclipse.org/r/#/q/is:open+topic:lfs
Not sure if this will be finished for 4.6.

In local clone JGit follows the filesystem layout defined by git-lfs to ensure interoperability.

4.6 is planned to be released before Christmas.
Re: JGIT with LFS: Archive does not has actual files [message #1749182 is a reply to message #1749137] Fri, 02 December 2016 18:29 Go to previous message
Afroz Shaik is currently offline Afroz ShaikFriend
Messages: 3
Registered: November 2016
Junior Member
Thank you so much for your response.

I appreciate it. We will wait for 100% java based solution.

We have a very unique usecase where we use JGIT as a client on a LFS server.

So will there be any way to set LFS root programmatically so we can do git checkout and commit operations that will use LFS?

Looking at v4.6.0-SNAPSHOT, root is configurable in LFS.java.

https://github.com/eclipse/jgit/blob/master/org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/Lfs.java

Will it work in theory if we set Set LFS object store for repo as "root" in LFS.java?

From what I am seeing We need to register filters. But I do not know how to connect LFS.java to Git or Repository object. Can you please share info if you have or can support it in your roadmap?

We only use JGIT Client for automation on a server and this will help in performance significantly our usecases without having to use JGIT server operations.

Thanks again in advance for the information.

Best Regards
Afroz Shaik

Previous Topic:Key binding for "Commit and Push" and "Commit" in "Git Staging" view?
Next Topic:Will egit create a "generic" local branch name if the remote branch name is very long?
Goto Forum:
  


Current Time: Wed Nov 22 20:31:30 GMT 2017

Powered by FUDForum. Page generated in 0.02218 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software