Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EGit / JGit » Sparse Checkout support
Sparse Checkout support [message #1794114] Thu, 23 August 2018 20:18 Go to next message
Denis M is currently offline Denis MFriend
Messages: 3
Registered: August 2018
Junior Member
Hello,

I tried replicating these commands and I am not seeing same results when using git command or JGit API.

git init
git remote add -f origin REMOTE_SERVER
git config core.sparsecheckout true
echo "FOLDER_NAME/*"> .git/info/sparse-checkout // Created file must have ANSI encoding
git pull origin master

Using command line I'm getting only FOLDER_NAME retrieved.

I tried doing same in code and folder not being retrieved.

try (Git git = Git.init().setDirectory(localPath).call()) {
StoredConfig config = git.getRepository().getConfig();

config.setString("remote", "origin", "url", "REMOTE_SERVER");
config.setBoolean("core", null, "sparsecheckout", true);

config.save();

Path file = Paths.get(localPath.getAbsolutePath() + "/.git/info/sparse-checkout");
Files.write(file, Arrays.asList("FOLDER_NAME/*"), Charset.forName("ISO-8859-1"));

PullResult result = git.pull()
.setRemote("origin")
.setRemoteBranchName("master")
.call();

} catch (IllegalStateException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (GitAPIException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Re: Sparse Checkout support [message #1794263 is a reply to message #1794114] Tue, 28 August 2018 08:24 Go to previous messageGo to next message
Matthias Sohn is currently offline Matthias SohnFriend
Messages: 1039
Registered: July 2009
Senior Member
See https://bugs.eclipse.org/bugs/show_bug.cgi?id=383772
Stephen Lawson was working on an implementation
https://git.eclipse.org/r/#/c/110964/
but it seems this stalled
Re: Sparse Checkout support [message #1794275 is a reply to message #1794263] Tue, 28 August 2018 12:08 Go to previous messageGo to next message
Denis M is currently offline Denis MFriend
Messages: 3
Registered: August 2018
Junior Member
I found another way to solve this problem.


String url = "SERVER";
String hash = "origin/master";
String subPath = "SERVER_DIRECTORY";

Git gitRepo = Git.cloneRepository().setURI(url).setDirectory(localPath).setNoCheckout(true).call();

gitRepo.checkout().setName("master").setStartPoint(hash).addPath(subPath).call();
gitRepo.getRepository().close();

[Updated on: Tue, 28 August 2018 12:10]

Report message to a moderator

Re: Sparse Checkout support [message #1794276 is a reply to message #1794263] Tue, 28 August 2018 12:08 Go to previous message
Denis M is currently offline Denis MFriend
Messages: 3
Registered: August 2018
Junior Member
No Message Body

[Updated on: Tue, 28 August 2018 12:10]

Report message to a moderator

Previous Topic:Wanna use 'org.eclipse.egit.github.core' in a project
Next Topic:Create bare Jgit repo with public ssh key auth
Goto Forum:
  


Current Time: Fri Nov 16 06:18:41 GMT 2018

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

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

Back to the top