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: 1268
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 messageGo to next 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

Re: Sparse Checkout support [message #1844902 is a reply to message #1794114] Wed, 29 September 2021 11:53 Go to previous messageGo to next message
Dmitry Mogilevets is currently offline Dmitry MogilevetsFriend
Messages: 1
Registered: September 2021
Junior Member
Can you please tell me if you plan to add support for sparse checkout? And if it is planned, when?
Re: Sparse Checkout support [message #1858076 is a reply to message #1844902] Tue, 14 March 2023 19:47 Go to previous message
Chris Papademetrious is currently offline Chris PapademetriousFriend
Messages: 1
Registered: March 2023
Junior Member
We would also very much like to see sparse checkouts supported in JGit!

We are using Oxygen XML Author for technical writing. It provides an integrated Git client that uses JGit internally. Our various Git repos contain between 60k to 100k files, and many JGit operations are painfully slow with the full repository.
Previous Topic:Remove From View option - Keyboard shortcut
Next Topic:JGit initialization to a shared folder path fails in java 11
Goto Forum:
  


Current Time: Thu Apr 25 22:32:14 GMT 2024

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

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

Back to the top