0

Simple git command i try to execute with java ProcessBuilder , working find when i run it in linux with results returned. this is the command :

git -C /home/mlxx log -1 "72xxxxxxxxe700d6bbe06" --pretty=format:"%s"

when i try to execute it in java

ProcessBuilder pb = new ProcessBuilder()
                    .command("git","-C","/home/mlxx","log","1","72xxxxxxxxe700d6bbe06","--pretty=format:\"%s\"").directory("/bin/bash");

The int exit = p.waitFor(); returns 128 error code

now according to this link : Start GitLog with Java Process Builder which face the same problem

i tried to do :

ProcessBuilder pb = new ProcessBuilder()
                        .command("/usr/bin","-c""git","-C","/home/mlxx","log","1","72xxxxxxxxe700d6bbe06","--pretty=format:\"%s\"")

The int exit = p.waitFor(); returns 1 error c0de

what is wrong here ?

other commands working just fine in linux via java?

1 Answer 1

1

You are specifying /bin/bash as the process's working directory:

[...] .directory("/bin/bash");

This is an executable file and not a valid directory.

You can leave it off entirely, since you already specify the directory git should operate on with its -C option.

Sign up to request clarification or add additional context in comments.

1 Comment

it was stype mistake i fixed it to /usr/bin but i wtill have the erro

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.