forked from qt-creator/qt-creator
Git: Standardize error message handling
Change-Id: I5574abf0acf7ed430f5f7f3b89ebcbddb31f3016 Reviewed-by: Orgad Shaneh <orgads@gmail.com> Reviewed-by: Tobias Hunger <tobias.hunger@digia.com>
This commit is contained in:
committed by
Orgad Shaneh
parent
c24361901c
commit
7da9ad56c8
@@ -913,6 +913,25 @@ static inline QStringList statusArguments()
|
|||||||
<< QLatin1String("status");
|
<< QLatin1String("status");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline void msgCannotRun(const QString &message, QString *errorMessage)
|
||||||
|
{
|
||||||
|
if (errorMessage)
|
||||||
|
*errorMessage = message;
|
||||||
|
else
|
||||||
|
outputWindow()->appendError(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void msgCannotRun(const QStringList &args, const QString &workingDirectory,
|
||||||
|
const QByteArray &error, QString *errorMessage)
|
||||||
|
{
|
||||||
|
const QString message = GitClient::tr("Cannot run \"%1 %2\" in \"%2\": %3")
|
||||||
|
.arg(QLatin1String("git ") + args.join(QLatin1String(" ")),
|
||||||
|
QDir::toNativeSeparators(workingDirectory),
|
||||||
|
commandOutputFromLocal8Bit(error));
|
||||||
|
|
||||||
|
msgCannotRun(message, errorMessage);
|
||||||
|
}
|
||||||
|
|
||||||
// ---------------- GitClient
|
// ---------------- GitClient
|
||||||
|
|
||||||
const char *GitClient::stashNamePrefix = "stash@{";
|
const char *GitClient::stashNamePrefix = "stash@{";
|
||||||
@@ -1535,13 +1554,7 @@ bool GitClient::synchronousCheckout(const QString &workingDirectory,
|
|||||||
const QString output = commandOutputFromLocal8Bit(outputText);
|
const QString output = commandOutputFromLocal8Bit(outputText);
|
||||||
outputWindow()->append(output);
|
outputWindow()->append(output);
|
||||||
if (!rc) {
|
if (!rc) {
|
||||||
const QString stdErr = commandOutputFromLocal8Bit(errorText);
|
msgCannotRun(arguments, workingDirectory, errorText, errorMessage);
|
||||||
//: Meaning of the arguments: %1: Branch, %2: Repository, %3: Error message
|
|
||||||
const QString msg = tr("Cannot checkout \"%1\" of \"%2\": %3").arg(ref, workingDirectory, stdErr);
|
|
||||||
if (errorMessage)
|
|
||||||
*errorMessage = msg;
|
|
||||||
else
|
|
||||||
outputWindow()->appendError(msg);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
updateSubmodulesIfNeeded(workingDirectory, true);
|
updateSubmodulesIfNeeded(workingDirectory, true);
|
||||||
@@ -1585,13 +1598,9 @@ bool GitClient::synchronousLog(const QString &workingDirectory, const QStringLis
|
|||||||
else
|
else
|
||||||
*output = commandOutputFromLocal8Bit(outputText);
|
*output = commandOutputFromLocal8Bit(outputText);
|
||||||
} else {
|
} else {
|
||||||
const QString errorMessage = tr("Cannot obtain log of \"%1\": %2").
|
msgCannotRun(tr("Cannot obtain log of \"%1\": %2")
|
||||||
arg(QDir::toNativeSeparators(workingDirectory),
|
.arg(QDir::toNativeSeparators(workingDirectory),
|
||||||
commandOutputFromLocal8Bit(errorText));
|
commandOutputFromLocal8Bit(errorText)), errorMessageIn);
|
||||||
if (errorMessageIn)
|
|
||||||
*errorMessageIn = errorMessage;
|
|
||||||
else
|
|
||||||
outputWindow()->appendError(errorMessage);
|
|
||||||
}
|
}
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
@@ -1610,10 +1619,9 @@ bool GitClient::synchronousAdd(const QString &workingDirectory,
|
|||||||
arguments.append(files);
|
arguments.append(files);
|
||||||
const bool rc = fullySynchronousGit(workingDirectory, arguments, &outputText, &errorText);
|
const bool rc = fullySynchronousGit(workingDirectory, arguments, &outputText, &errorText);
|
||||||
if (!rc) {
|
if (!rc) {
|
||||||
const QString errorMessage = tr("Cannot add %n file(s) to \"%1\": %2", 0, files.size()).
|
msgCannotRun(tr("Cannot add %n file(s) to \"%1\": %2", 0, files.size())
|
||||||
arg(QDir::toNativeSeparators(workingDirectory),
|
.arg(QDir::toNativeSeparators(workingDirectory),
|
||||||
commandOutputFromLocal8Bit(errorText));
|
commandOutputFromLocal8Bit(errorText)), 0);
|
||||||
outputWindow()->appendError(errorMessage);
|
|
||||||
}
|
}
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
@@ -1631,9 +1639,9 @@ bool GitClient::synchronousDelete(const QString &workingDirectory,
|
|||||||
arguments.append(files);
|
arguments.append(files);
|
||||||
const bool rc = fullySynchronousGit(workingDirectory, arguments, &outputText, &errorText);
|
const bool rc = fullySynchronousGit(workingDirectory, arguments, &outputText, &errorText);
|
||||||
if (!rc) {
|
if (!rc) {
|
||||||
const QString errorMessage = tr("Cannot remove %n file(s) from \"%1\": %2", 0, files.size()).
|
msgCannotRun(tr("Cannot remove %n file(s) from \"%1\": %2", 0, files.size())
|
||||||
arg(QDir::toNativeSeparators(workingDirectory), commandOutputFromLocal8Bit(errorText));
|
.arg(QDir::toNativeSeparators(workingDirectory),
|
||||||
outputWindow()->appendError(errorMessage);
|
commandOutputFromLocal8Bit(errorText)), 0);
|
||||||
}
|
}
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
@@ -1650,9 +1658,8 @@ bool GitClient::synchronousMove(const QString &workingDirectory,
|
|||||||
arguments << (to);
|
arguments << (to);
|
||||||
const bool rc = fullySynchronousGit(workingDirectory, arguments, &outputText, &errorText);
|
const bool rc = fullySynchronousGit(workingDirectory, arguments, &outputText, &errorText);
|
||||||
if (!rc) {
|
if (!rc) {
|
||||||
const QString errorMessage = tr("Cannot move from \"%1\" to \"%2\": %3").
|
msgCannotRun(tr("Cannot move from \"%1\" to \"%2\": %3")
|
||||||
arg(from, to, commandOutputFromLocal8Bit(errorText));
|
.arg(from, to, commandOutputFromLocal8Bit(errorText)), 0);
|
||||||
outputWindow()->appendError(errorMessage);
|
|
||||||
}
|
}
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
@@ -1677,15 +1684,14 @@ bool GitClient::synchronousReset(const QString &workingDirectory,
|
|||||||
// or "Unstaged changes after reset" (git 1.7.0).
|
// or "Unstaged changes after reset" (git 1.7.0).
|
||||||
if (!rc && (!output.contains(QLatin1String("modified"))
|
if (!rc && (!output.contains(QLatin1String("modified"))
|
||||||
&& !output.contains(QLatin1String("Unstaged changes after reset")))) {
|
&& !output.contains(QLatin1String("Unstaged changes after reset")))) {
|
||||||
const QString stdErr = commandOutputFromLocal8Bit(errorText);
|
if (files.isEmpty()) {
|
||||||
const QString msg = files.isEmpty() ?
|
msgCannotRun(arguments, workingDirectory, errorText, errorMessage);
|
||||||
tr("Cannot reset \"%1\": %2").arg(QDir::toNativeSeparators(workingDirectory), stdErr) :
|
} else {
|
||||||
tr("Cannot reset %n file(s) in \"%1\": %2", 0, files.size()).
|
msgCannotRun(tr("Cannot reset %n file(s) in \"%1\": %2", 0, files.size())
|
||||||
arg(QDir::toNativeSeparators(workingDirectory), stdErr);
|
.arg(QDir::toNativeSeparators(workingDirectory),
|
||||||
if (errorMessage)
|
commandOutputFromLocal8Bit(errorText)),
|
||||||
*errorMessage = msg;
|
errorMessage);
|
||||||
else
|
}
|
||||||
outputWindow()->appendError(msg);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@@ -1736,12 +1742,10 @@ bool GitClient::synchronousCheckoutFiles(const QString &workingDirectory,
|
|||||||
const QString fileArg = files.join(QLatin1String(", "));
|
const QString fileArg = files.join(QLatin1String(", "));
|
||||||
//: Meaning of the arguments: %1: revision, %2: files, %3: repository,
|
//: Meaning of the arguments: %1: revision, %2: files, %3: repository,
|
||||||
//: %4: Error message
|
//: %4: Error message
|
||||||
const QString msg = tr("Cannot checkout \"%1\" of %2 in \"%3\": %4").
|
msgCannotRun(tr("Cannot checkout \"%1\" of %2 in \"%3\": %4")
|
||||||
arg(revision, fileArg, workingDirectory, commandOutputFromLocal8Bit(errorText));
|
.arg(revision, fileArg, workingDirectory,
|
||||||
if (errorMessage)
|
commandOutputFromLocal8Bit(errorText)),
|
||||||
*errorMessage = msg;
|
errorMessage);
|
||||||
else
|
|
||||||
outputWindow()->appendError(msg);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@@ -1791,12 +1795,7 @@ bool GitClient::synchronousRevListCmd(const QString &workingDirectory, const QSt
|
|||||||
|
|
||||||
const bool rc = fullySynchronousGit(workingDirectory, args, &outputTextData, &errorText);
|
const bool rc = fullySynchronousGit(workingDirectory, args, &outputTextData, &errorText);
|
||||||
if (!rc) {
|
if (!rc) {
|
||||||
if (errorMessage)
|
msgCannotRun(args, workingDirectory, errorText, errorMessage);
|
||||||
*errorMessage = commandOutputFromLocal8Bit(errorText);
|
|
||||||
else
|
|
||||||
outputWindow()->appendError(tr("Cannot execute \"git %1\" in \"%2\": %3").arg(
|
|
||||||
args.join(QLatin1String(" ")), workingDirectory,
|
|
||||||
commandOutputFromLocal8Bit(errorText)));
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
*output = commandOutputFromLocal8Bit(outputTextData);
|
*output = commandOutputFromLocal8Bit(outputTextData);
|
||||||
@@ -1874,12 +1873,6 @@ QString GitClient::synchronousCurrentLocalBranch(const QString &workingDirectory
|
|||||||
return QString();
|
return QString();
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline QString msgCannotRun(const QString &command, const QString &workingDirectory, const QString &why)
|
|
||||||
{
|
|
||||||
return GitClient::tr("Cannot run \"%1\" in \"%2\": %3")
|
|
||||||
.arg(command, QDir::toNativeSeparators(workingDirectory), why);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool GitClient::synchronousHeadRefs(const QString &workingDirectory, QStringList *output,
|
bool GitClient::synchronousHeadRefs(const QString &workingDirectory, QStringList *output,
|
||||||
QString *errorMessage)
|
QString *errorMessage)
|
||||||
{
|
{
|
||||||
@@ -1890,12 +1883,7 @@ bool GitClient::synchronousHeadRefs(const QString &workingDirectory, QStringList
|
|||||||
QByteArray errorText;
|
QByteArray errorText;
|
||||||
const bool rc = fullySynchronousGit(workingDirectory, args, &outputText, &errorText);
|
const bool rc = fullySynchronousGit(workingDirectory, args, &outputText, &errorText);
|
||||||
if (!rc) {
|
if (!rc) {
|
||||||
QString message = msgCannotRun(QLatin1String("git show-ref --head"), workingDirectory, commandOutputFromLocal8Bit(errorText));
|
msgCannotRun(args, workingDirectory, errorText, errorMessage);
|
||||||
|
|
||||||
if (errorMessage)
|
|
||||||
*errorMessage = message;
|
|
||||||
else
|
|
||||||
outputWindow()->appendError(message);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1982,12 +1970,9 @@ QString GitClient::synchronousTopRevision(const QString &workingDirectory, QStri
|
|||||||
}
|
}
|
||||||
QString revision = commandOutputFromLocal8Bit(outputTextData);
|
QString revision = commandOutputFromLocal8Bit(outputTextData);
|
||||||
revision.remove(QLatin1Char('\n'));
|
revision.remove(QLatin1Char('\n'));
|
||||||
if (revision.isEmpty() && !errorMessage.isEmpty()) {
|
if (revision.isEmpty() && !errorMessage.isEmpty())
|
||||||
if (errorMessageIn)
|
msgCannotRun(errorMessage, errorMessageIn);
|
||||||
*errorMessageIn = errorMessage;
|
|
||||||
else
|
|
||||||
outputWindow()->appendError(errorMessage);
|
|
||||||
}
|
|
||||||
return revision;
|
return revision;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2152,17 +2137,10 @@ bool GitClient::executeSynchronousStash(const QString &workingDirectory,
|
|||||||
arguments << QLatin1String("save") << message;
|
arguments << QLatin1String("save") << message;
|
||||||
const bool rc = fullySynchronousGit(workingDirectory, arguments, &outputText, &errorText,
|
const bool rc = fullySynchronousGit(workingDirectory, arguments, &outputText, &errorText,
|
||||||
VcsBasePlugin::ExpectRepoChanges);
|
VcsBasePlugin::ExpectRepoChanges);
|
||||||
if (!rc) {
|
if (!rc)
|
||||||
const QString msg = tr("Cannot stash in \"%1\": %2").
|
msgCannotRun(arguments, workingDirectory, errorText, errorMessage);
|
||||||
arg(QDir::toNativeSeparators(workingDirectory),
|
|
||||||
commandOutputFromLocal8Bit(errorText));
|
return rc;
|
||||||
if (errorMessage)
|
|
||||||
*errorMessage = msg;
|
|
||||||
else
|
|
||||||
outputWindow()->appendError(msg);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Resolve a stash name from message
|
// Resolve a stash name from message
|
||||||
@@ -2186,11 +2164,8 @@ bool GitClient::stashNameFromMessage(const QString &workingDirectory,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
//: Look-up of a stash via its descriptive message failed.
|
//: Look-up of a stash via its descriptive message failed.
|
||||||
const QString msg = tr("Cannot resolve stash message \"%1\" in \"%2\".").arg(message, workingDirectory);
|
msgCannotRun(tr("Cannot resolve stash message \"%1\" in \"%2\".")
|
||||||
if (errorMessage)
|
.arg(message, workingDirectory), errorMessage);
|
||||||
*errorMessage = msg;
|
|
||||||
else
|
|
||||||
outputWindow()->appendError(msg);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2202,26 +2177,24 @@ bool GitClient::synchronousBranchCmd(const QString &workingDirectory, QStringLis
|
|||||||
QByteArray errorText;
|
QByteArray errorText;
|
||||||
const bool rc = fullySynchronousGit(workingDirectory, branchArgs, &outputText, &errorText);
|
const bool rc = fullySynchronousGit(workingDirectory, branchArgs, &outputText, &errorText);
|
||||||
*output = commandOutputFromLocal8Bit(outputText);
|
*output = commandOutputFromLocal8Bit(outputText);
|
||||||
if (!rc && errorMessage) {
|
if (!rc)
|
||||||
*errorMessage = msgCannotRun(QLatin1String("git branch"), workingDirectory,
|
msgCannotRun(branchArgs, workingDirectory, errorText, errorMessage);
|
||||||
commandOutputFromLocal8Bit(errorText));
|
|
||||||
}
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GitClient::synchronousTagCmd(const QString &workingDirectory, QStringList tagArgs, QString *output, QString *errorMessage)
|
bool GitClient::synchronousTagCmd(const QString &workingDirectory, QStringList tagArgs,
|
||||||
|
QString *output, QString *errorMessage)
|
||||||
{
|
{
|
||||||
tagArgs.push_front(QLatin1String("tag"));
|
tagArgs.push_front(QLatin1String("tag"));
|
||||||
QByteArray outputText;
|
QByteArray outputText;
|
||||||
QByteArray errorText;
|
QByteArray errorText;
|
||||||
const bool rc = fullySynchronousGit(workingDirectory, tagArgs, &outputText, &errorText);
|
const bool rc = fullySynchronousGit(workingDirectory, tagArgs, &outputText, &errorText);
|
||||||
*output = commandOutputFromLocal8Bit(outputText);
|
*output = commandOutputFromLocal8Bit(outputText);
|
||||||
if (!rc) {
|
if (!rc)
|
||||||
*errorMessage = msgCannotRun(QLatin1String("git tag"), workingDirectory,
|
msgCannotRun(tagArgs, workingDirectory, errorText, errorMessage);
|
||||||
commandOutputFromLocal8Bit(errorText));
|
|
||||||
return false;
|
return rc;
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GitClient::synchronousForEachRefCmd(const QString &workingDirectory, QStringList args,
|
bool GitClient::synchronousForEachRefCmd(const QString &workingDirectory, QStringList args,
|
||||||
@@ -2232,17 +2205,10 @@ bool GitClient::synchronousForEachRefCmd(const QString &workingDirectory, QStrin
|
|||||||
QByteArray errorText;
|
QByteArray errorText;
|
||||||
const bool rc = fullySynchronousGit(workingDirectory, args, &outputText, &errorText);
|
const bool rc = fullySynchronousGit(workingDirectory, args, &outputText, &errorText);
|
||||||
*output = commandOutputFromLocal8Bit(outputText);
|
*output = commandOutputFromLocal8Bit(outputText);
|
||||||
if (!rc) {
|
if (!rc)
|
||||||
QString error = msgCannotRun(QLatin1String("git for-each-ref"), workingDirectory,
|
msgCannotRun(args, workingDirectory, errorText, errorMessage);
|
||||||
commandOutputFromLocal8Bit(errorText));
|
|
||||||
if (errorMessage)
|
|
||||||
*errorMessage = error;
|
|
||||||
else
|
|
||||||
outputWindow()->appendError(error);
|
|
||||||
|
|
||||||
return false;
|
return rc;
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GitClient::synchronousRemoteCmd(const QString &workingDirectory, QStringList remoteArgs,
|
bool GitClient::synchronousRemoteCmd(const QString &workingDirectory, QStringList remoteArgs,
|
||||||
@@ -2253,7 +2219,7 @@ bool GitClient::synchronousRemoteCmd(const QString &workingDirectory, QStringLis
|
|||||||
QByteArray errorText;
|
QByteArray errorText;
|
||||||
const bool rc = fullySynchronousGit(workingDirectory, remoteArgs, &outputText, &errorText);
|
const bool rc = fullySynchronousGit(workingDirectory, remoteArgs, &outputText, &errorText);
|
||||||
if (!rc) {
|
if (!rc) {
|
||||||
*errorMessage = msgCannotRun(QLatin1String("git remote"), workingDirectory, commandOutputFromLocal8Bit(errorText));
|
msgCannotRun(remoteArgs, workingDirectory, errorText, errorMessage);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
*output = commandOutputFromLocal8Bit(outputText);
|
*output = commandOutputFromLocal8Bit(outputText);
|
||||||
@@ -2268,10 +2234,7 @@ QMap<QString,QString> GitClient::synchronousRemotesList(const QString &workingDi
|
|||||||
QString error;
|
QString error;
|
||||||
QStringList args(QLatin1String("-v"));
|
QStringList args(QLatin1String("-v"));
|
||||||
if (!synchronousRemoteCmd(workingDirectory, args, &output, &error)) {
|
if (!synchronousRemoteCmd(workingDirectory, args, &output, &error)) {
|
||||||
if (errorMessage)
|
msgCannotRun(error, errorMessage);
|
||||||
*errorMessage = error;
|
|
||||||
else
|
|
||||||
outputWindow()->appendError(error);
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
QStringList remotes = output.split(QLatin1String("\n"));
|
QStringList remotes = output.split(QLatin1String("\n"));
|
||||||
@@ -2299,15 +2262,9 @@ QStringList GitClient::synchronousSubmoduleStatus(const QString &workingDirector
|
|||||||
// get submodule status
|
// get submodule status
|
||||||
arguments << QLatin1String("submodule") << QLatin1String("status");
|
arguments << QLatin1String("submodule") << QLatin1String("status");
|
||||||
if (!fullySynchronousGit(workingDirectory, arguments, &outputTextData, &errorText)) {
|
if (!fullySynchronousGit(workingDirectory, arguments, &outputTextData, &errorText)) {
|
||||||
QString error = tr("Cannot retrieve submodule status of \"%1\": %2")
|
msgCannotRun(tr("Cannot retrieve submodule status of \"%1\": %2")
|
||||||
.arg(QDir::toNativeSeparators(workingDirectory),
|
.arg(QDir::toNativeSeparators(workingDirectory),
|
||||||
commandOutputFromLocal8Bit(errorText));
|
commandOutputFromLocal8Bit(errorText)), errorMessage);
|
||||||
|
|
||||||
if (errorMessage)
|
|
||||||
*errorMessage = error;
|
|
||||||
else
|
|
||||||
outputWindow()->appendError(error);
|
|
||||||
|
|
||||||
return QStringList();
|
return QStringList();
|
||||||
}
|
}
|
||||||
return commandOutputLinesFromLocal8Bit(outputTextData);
|
return commandOutputLinesFromLocal8Bit(outputTextData);
|
||||||
@@ -2382,12 +2339,11 @@ bool GitClient::synchronousShow(const QString &workingDirectory, const QString &
|
|||||||
QByteArray outputText;
|
QByteArray outputText;
|
||||||
QByteArray errorText;
|
QByteArray errorText;
|
||||||
const bool rc = fullySynchronousGit(workingDirectory, args, &outputText, &errorText);
|
const bool rc = fullySynchronousGit(workingDirectory, args, &outputText, &errorText);
|
||||||
if (!rc) {
|
if (rc)
|
||||||
*errorMessage = msgCannotRun(QLatin1String("git show"), workingDirectory, commandOutputFromLocal8Bit(errorText));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
*output = commandOutputFromLocal8Bit(outputText);
|
*output = commandOutputFromLocal8Bit(outputText);
|
||||||
return true;
|
else
|
||||||
|
msgCannotRun(QStringList(QLatin1String("show")), workingDirectory, errorText, errorMessage);
|
||||||
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Retrieve list of files to be cleaned
|
// Retrieve list of files to be cleaned
|
||||||
@@ -2399,7 +2355,8 @@ bool GitClient::cleanList(const QString &workingDirectory, const QString &flag,
|
|||||||
QByteArray errorText;
|
QByteArray errorText;
|
||||||
const bool rc = fullySynchronousGit(workingDirectory, args, &outputText, &errorText);
|
const bool rc = fullySynchronousGit(workingDirectory, args, &outputText, &errorText);
|
||||||
if (!rc) {
|
if (!rc) {
|
||||||
*errorMessage = msgCannotRun(QLatin1String("git clean"), workingDirectory, commandOutputFromLocal8Bit(errorText));
|
msgCannotRun(QStringList(QLatin1String("clean")), workingDirectory,
|
||||||
|
errorText, errorMessage);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// Filter files that git would remove
|
// Filter files that git would remove
|
||||||
@@ -3376,9 +3333,8 @@ bool GitClient::synchronousSetTrackingBranch(const QString &workingDirectory,
|
|||||||
arguments << QLatin1String("--set-upstream") << branch << tracking;
|
arguments << QLatin1String("--set-upstream") << branch << tracking;
|
||||||
const bool rc = fullySynchronousGit(workingDirectory, arguments, &outputText, &errorText);
|
const bool rc = fullySynchronousGit(workingDirectory, arguments, &outputText, &errorText);
|
||||||
if (!rc) {
|
if (!rc) {
|
||||||
const QString errorMessage = tr("Cannot set tracking branch: %1")
|
msgCannotRun(tr("Cannot set tracking branch: %1")
|
||||||
.arg(commandOutputFromLocal8Bit(errorText));
|
.arg(commandOutputFromLocal8Bit(errorText)), 0);
|
||||||
outputWindow()->appendError(errorMessage);
|
|
||||||
}
|
}
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
@@ -3585,24 +3541,14 @@ bool GitClient::synchronousStashRestore(const QString &workingDirectory,
|
|||||||
QByteArray errorText;
|
QByteArray errorText;
|
||||||
const bool rc = fullySynchronousGit(workingDirectory, arguments, &outputText, &errorText,
|
const bool rc = fullySynchronousGit(workingDirectory, arguments, &outputText, &errorText,
|
||||||
VcsBasePlugin::ExpectRepoChanges);
|
VcsBasePlugin::ExpectRepoChanges);
|
||||||
if (!rc) {
|
if (rc) {
|
||||||
const QString stdErr = commandOutputFromLocal8Bit(errorText);
|
const QString output = commandOutputFromLocal8Bit(outputText);
|
||||||
const QString nativeWorkingDir = QDir::toNativeSeparators(workingDirectory);
|
|
||||||
const QString msg = branch.isEmpty() ?
|
|
||||||
tr("Cannot restore stash \"%1\": %2").
|
|
||||||
arg(nativeWorkingDir, stdErr) :
|
|
||||||
tr("Cannot restore stash \"%1\" to branch \"%2\": %3").
|
|
||||||
arg(nativeWorkingDir, branch, stdErr);
|
|
||||||
if (errorMessage)
|
|
||||||
*errorMessage = msg;
|
|
||||||
else
|
|
||||||
outputWindow()->appendError(msg);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
QString output = commandOutputFromLocal8Bit(outputText);
|
|
||||||
if (!output.isEmpty())
|
if (!output.isEmpty())
|
||||||
outputWindow()->append(output);
|
outputWindow()->append(output);
|
||||||
return true;
|
} else {
|
||||||
|
msgCannotRun(arguments, workingDirectory, errorText, errorMessage);
|
||||||
|
}
|
||||||
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GitClient::synchronousStashRemove(const QString &workingDirectory,
|
bool GitClient::synchronousStashRemove(const QString &workingDirectory,
|
||||||
@@ -3617,24 +3563,14 @@ bool GitClient::synchronousStashRemove(const QString &workingDirectory,
|
|||||||
QByteArray outputText;
|
QByteArray outputText;
|
||||||
QByteArray errorText;
|
QByteArray errorText;
|
||||||
const bool rc = fullySynchronousGit(workingDirectory, arguments, &outputText, &errorText);
|
const bool rc = fullySynchronousGit(workingDirectory, arguments, &outputText, &errorText);
|
||||||
if (!rc) {
|
if (rc) {
|
||||||
const QString stdErr = commandOutputFromLocal8Bit(errorText);
|
const QString output = commandOutputFromLocal8Bit(outputText);
|
||||||
const QString nativeWorkingDir = QDir::toNativeSeparators(workingDirectory);
|
|
||||||
const QString msg = stash.isEmpty() ?
|
|
||||||
tr("Cannot remove stashes of \"%1\": %2").
|
|
||||||
arg(nativeWorkingDir, stdErr) :
|
|
||||||
tr("Cannot remove stash \"%1\" of \"%2\": %3").
|
|
||||||
arg(stash, nativeWorkingDir, stdErr);
|
|
||||||
if (errorMessage)
|
|
||||||
*errorMessage = msg;
|
|
||||||
else
|
|
||||||
outputWindow()->appendError(msg);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
QString output = commandOutputFromLocal8Bit(outputText);
|
|
||||||
if (!output.isEmpty())
|
if (!output.isEmpty())
|
||||||
outputWindow()->append(output);
|
outputWindow()->append(output);
|
||||||
return true;
|
} else {
|
||||||
|
msgCannotRun(arguments, workingDirectory, errorText, errorMessage);
|
||||||
|
}
|
||||||
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GitClient::branchList(const QString &workingDirectory)
|
void GitClient::branchList(const QString &workingDirectory)
|
||||||
@@ -3662,13 +3598,7 @@ bool GitClient::synchronousStashList(const QString &workingDirectory,
|
|||||||
QByteArray errorText;
|
QByteArray errorText;
|
||||||
const bool rc = fullySynchronousGit(workingDirectory, arguments, &outputText, &errorText);
|
const bool rc = fullySynchronousGit(workingDirectory, arguments, &outputText, &errorText);
|
||||||
if (!rc) {
|
if (!rc) {
|
||||||
const QString msg = tr("Cannot retrieve stash list of \"%1\": %2").
|
msgCannotRun(arguments, workingDirectory, errorText, errorMessage);
|
||||||
arg(QDir::toNativeSeparators(workingDirectory),
|
|
||||||
commandOutputFromLocal8Bit(errorText));
|
|
||||||
if (errorMessage)
|
|
||||||
*errorMessage = msg;
|
|
||||||
else
|
|
||||||
outputWindow()->appendError(msg);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Stash stash;
|
Stash stash;
|
||||||
@@ -3794,11 +3724,9 @@ unsigned GitClient::synchronousGitVersion(QString *errorMessage) const
|
|||||||
&outputText, &errorText,
|
&outputText, &errorText,
|
||||||
VcsBasePlugin::SuppressCommandLogging);
|
VcsBasePlugin::SuppressCommandLogging);
|
||||||
if (!rc) {
|
if (!rc) {
|
||||||
const QString msg = tr("Cannot determine git version: %1").arg(commandOutputFromLocal8Bit(errorText));
|
msgCannotRun(tr("Cannot determine Git version: %1")
|
||||||
if (errorMessage)
|
.arg(commandOutputFromLocal8Bit(errorText)),
|
||||||
*errorMessage = msg;
|
errorMessage);
|
||||||
else
|
|
||||||
outputWindow()->appendError(msg);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
// cut 'git version 1.6.5.1.sha'
|
// cut 'git version 1.6.5.1.sha'
|
||||||
|
|||||||
Reference in New Issue
Block a user