Skip to main content



      Home
Home » Eclipse Projects » EGit / JGit » Sparse Checkout support
Sparse Checkout support [message #1794114] Thu, 23 August 2018 16:18 Go to next message
Eclipse UserFriend
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 04:24 Go to previous messageGo to next message
Eclipse UserFriend
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 08:08 Go to previous messageGo to next message
Eclipse UserFriend
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 08:10] by Moderator

Re: Sparse Checkout support [message #1794276 is a reply to message #1794263] Tue, 28 August 2018 08:08 Go to previous messageGo to next message
Eclipse UserFriend
No Message Body

[Updated on: Tue, 28 August 2018 08:10] by Moderator

Re: Sparse Checkout support [message #1844902 is a reply to message #1794114] Wed, 29 September 2021 07:53 Go to previous messageGo to next message
Eclipse UserFriend
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 15:47 Go to previous message
Eclipse UserFriend
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: Fri May 23 02:15:00 EDT 2025

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

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

Back to the top