Sparse Checkout support [message #1794114] |
Thu, 23 August 2018 20:18 |
Denis M 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 #1794275 is a reply to message #1794263] |
Tue, 28 August 2018 12:08 |
Denis M 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
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03079 seconds