Cannot pass arguments to git process
Solved
General and Desktop
-
wrote on 24 Dec 2020, 08:38 last edited by
Hi guys, I'm having problem sending arguments to git process under Linux Ubuntu. This is the code
QProcess process; connect(&process, static_cast<void(QProcess::*)(int, QProcess::ExitStatus)>(&QProcess::finished), this, &my_class::onProcessFinished); const QString git_process_path{"git"}; process.setWorkingDirectory(repo.location_.path()); const QByteArray command = prepare_git_command(); const QStringList list = QStringList() << "config --list";//<<Here, if the arg count is more than one it doesn't work process.start(git_process_path, list);
and slot:
void my_class::onProcessFinished(int exitCode, QProcess::ExitStatus exitStatus) { const QString output{process.readAllStandardOutput()}; }
Basically if I do this:
const QStringList list = QStringList() << "status";//<<Here, if the arg count is one it works process.start(git_process_path, list);
Then it works, but as soon as I have more than one argument, for exaple:
const QStringList list = QStringList() << "config --list";//<<Here, if the arg count is more than one it doesn't work process.start(git_process_path, list);
there is no output.
How to solve it?
Thanks in advance. -
wrote on 24 Dec 2020, 08:42 last edited by Bonnie
That's not the right way to pass multiple arguments.
Why does it use a QStringList if you pass all the arguments in one string?
You should do likeQStringList() << "config" << "--list"
-
@smallC said in Cannot pass arguments to git process:
QProcess process;
Where do you create this object?
2/3