ProcessBuilder: Git repository does not download









up vote
0
down vote

favorite












I'm using ProcessBuilder to download from Git. This is my current code:



Process process = null;
try
String command = "git", "clone", gitLink;
ProcessBuilder processBuilder = new ProcessBuilder(command);
processBuilder.directory(new File(gitPath));
process = processBuilder.start();

System.out.println("n*** Console output is:");
InputStream processStdOutput = process.getInputStream();
Reader r = new InputStreamReader(processStdOutput);
BufferedReader br = new BufferedReader(r);
String line;
while ((line = br.readLine()) != null) System.out.println("t" + line);

process.getOutputStream().close();
catch (IOException e) e.printStackTrace();
finally if (process != null) process.destroy();


So, gitLink would be an actual link to the repository I want to download, and gitPath is where it will be downloaded to on my PC. gitPath seems to work, as I tested it by executing command ls. gitLink, however, shows up nothing. I get the Git repository for a second (in the correct gitPath folder), and then it vanishes. Also, when I use the actual link for Git repository instead of the variable gitLink, it works perfectly. For some reason it doesn't like the variable gitLink.



That's the code that works:



String command = "git", "clone", "https://some-rep.git";


Other things beng equal.










share|improve this question

















  • 1




    So print the command before you execute it. If it's not the same as the one that works, then there is the problem. If it is the same as the one that works, then the problem isn't in your java code but elsewhere .
    – Erwin Bolwidt
    Nov 11 at 10:57






  • 1




    Okay, just figured the issue... Apparently, extra spaces at the end of the link are not treated well by ProcessBuilder. Thx tho!
    – Daniil Gannota
    Nov 11 at 11:03















up vote
0
down vote

favorite












I'm using ProcessBuilder to download from Git. This is my current code:



Process process = null;
try
String command = "git", "clone", gitLink;
ProcessBuilder processBuilder = new ProcessBuilder(command);
processBuilder.directory(new File(gitPath));
process = processBuilder.start();

System.out.println("n*** Console output is:");
InputStream processStdOutput = process.getInputStream();
Reader r = new InputStreamReader(processStdOutput);
BufferedReader br = new BufferedReader(r);
String line;
while ((line = br.readLine()) != null) System.out.println("t" + line);

process.getOutputStream().close();
catch (IOException e) e.printStackTrace();
finally if (process != null) process.destroy();


So, gitLink would be an actual link to the repository I want to download, and gitPath is where it will be downloaded to on my PC. gitPath seems to work, as I tested it by executing command ls. gitLink, however, shows up nothing. I get the Git repository for a second (in the correct gitPath folder), and then it vanishes. Also, when I use the actual link for Git repository instead of the variable gitLink, it works perfectly. For some reason it doesn't like the variable gitLink.



That's the code that works:



String command = "git", "clone", "https://some-rep.git";


Other things beng equal.










share|improve this question

















  • 1




    So print the command before you execute it. If it's not the same as the one that works, then there is the problem. If it is the same as the one that works, then the problem isn't in your java code but elsewhere .
    – Erwin Bolwidt
    Nov 11 at 10:57






  • 1




    Okay, just figured the issue... Apparently, extra spaces at the end of the link are not treated well by ProcessBuilder. Thx tho!
    – Daniil Gannota
    Nov 11 at 11:03













up vote
0
down vote

favorite









up vote
0
down vote

favorite











I'm using ProcessBuilder to download from Git. This is my current code:



Process process = null;
try
String command = "git", "clone", gitLink;
ProcessBuilder processBuilder = new ProcessBuilder(command);
processBuilder.directory(new File(gitPath));
process = processBuilder.start();

System.out.println("n*** Console output is:");
InputStream processStdOutput = process.getInputStream();
Reader r = new InputStreamReader(processStdOutput);
BufferedReader br = new BufferedReader(r);
String line;
while ((line = br.readLine()) != null) System.out.println("t" + line);

process.getOutputStream().close();
catch (IOException e) e.printStackTrace();
finally if (process != null) process.destroy();


So, gitLink would be an actual link to the repository I want to download, and gitPath is where it will be downloaded to on my PC. gitPath seems to work, as I tested it by executing command ls. gitLink, however, shows up nothing. I get the Git repository for a second (in the correct gitPath folder), and then it vanishes. Also, when I use the actual link for Git repository instead of the variable gitLink, it works perfectly. For some reason it doesn't like the variable gitLink.



That's the code that works:



String command = "git", "clone", "https://some-rep.git";


Other things beng equal.










share|improve this question













I'm using ProcessBuilder to download from Git. This is my current code:



Process process = null;
try
String command = "git", "clone", gitLink;
ProcessBuilder processBuilder = new ProcessBuilder(command);
processBuilder.directory(new File(gitPath));
process = processBuilder.start();

System.out.println("n*** Console output is:");
InputStream processStdOutput = process.getInputStream();
Reader r = new InputStreamReader(processStdOutput);
BufferedReader br = new BufferedReader(r);
String line;
while ((line = br.readLine()) != null) System.out.println("t" + line);

process.getOutputStream().close();
catch (IOException e) e.printStackTrace();
finally if (process != null) process.destroy();


So, gitLink would be an actual link to the repository I want to download, and gitPath is where it will be downloaded to on my PC. gitPath seems to work, as I tested it by executing command ls. gitLink, however, shows up nothing. I get the Git repository for a second (in the correct gitPath folder), and then it vanishes. Also, when I use the actual link for Git repository instead of the variable gitLink, it works perfectly. For some reason it doesn't like the variable gitLink.



That's the code that works:



String command = "git", "clone", "https://some-rep.git";


Other things beng equal.







java git github






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 11 at 10:52









Daniil Gannota

164




164







  • 1




    So print the command before you execute it. If it's not the same as the one that works, then there is the problem. If it is the same as the one that works, then the problem isn't in your java code but elsewhere .
    – Erwin Bolwidt
    Nov 11 at 10:57






  • 1




    Okay, just figured the issue... Apparently, extra spaces at the end of the link are not treated well by ProcessBuilder. Thx tho!
    – Daniil Gannota
    Nov 11 at 11:03













  • 1




    So print the command before you execute it. If it's not the same as the one that works, then there is the problem. If it is the same as the one that works, then the problem isn't in your java code but elsewhere .
    – Erwin Bolwidt
    Nov 11 at 10:57






  • 1




    Okay, just figured the issue... Apparently, extra spaces at the end of the link are not treated well by ProcessBuilder. Thx tho!
    – Daniil Gannota
    Nov 11 at 11:03








1




1




So print the command before you execute it. If it's not the same as the one that works, then there is the problem. If it is the same as the one that works, then the problem isn't in your java code but elsewhere .
– Erwin Bolwidt
Nov 11 at 10:57




So print the command before you execute it. If it's not the same as the one that works, then there is the problem. If it is the same as the one that works, then the problem isn't in your java code but elsewhere .
– Erwin Bolwidt
Nov 11 at 10:57




1




1




Okay, just figured the issue... Apparently, extra spaces at the end of the link are not treated well by ProcessBuilder. Thx tho!
– Daniil Gannota
Nov 11 at 11:03





Okay, just figured the issue... Apparently, extra spaces at the end of the link are not treated well by ProcessBuilder. Thx tho!
– Daniil Gannota
Nov 11 at 11:03


















active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53248000%2fprocessbuilder-git-repository-does-not-download%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown






























active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53248000%2fprocessbuilder-git-repository-does-not-download%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







這個網誌中的熱門文章

Barbados

How to read a connectionString WITH PROVIDER in .NET Core?

Node.js Script on GitHub Pages or Amazon S3