[QGIT4 PATCH] Add --no-color option to several calls to git
From: Yaacov Akiba Slama <hidden>
Date: 2016-06-15 22:43:42
Setting "diff.color = true" in the configuration makes the output of several git commands use color codes. The color codes aren't parsed by qgit, so adds the --no-color" option to the calls of these git commmands. Signed-off-by: Yaacov Akiba Slama <redacted> --- src/git.cpp | 18 +++++++++--------- src/git_startup.cpp | 6 +++--- 2 files changed, 12 insertions(+), 12 deletions(-)
diff --git a/src/git.cpp b/src/git.cpp
index 6cb9c7d..ef7d736 100644
--- a/src/git.cpp
+++ b/src/git.cpp@@ -776,18 +776,18 @@ MyProcess* Git::getDiff(SCRef sha, QObject* receiver, SCRef diffToSha, bool comb QString runCmd; if (sha != ZERO_SHA) { - runCmd = "git diff-tree -r --patch-with-stat "; + runCmd = "git diff-tree --no-color -r --patch-with-stat "; runCmd.append(combined ? "-c " : "-C -m "); // TODO rename for combined runCmd.append(diffToSha + " " + sha); // diffToSha could be empty } else - runCmd = "git diff-index -r -m --patch-with-stat HEAD"; + runCmd = "git diff-index --no-color -r -m --patch-with-stat HEAD"; return runAsync(runCmd, receiver); } const QString Git::getWorkDirDiff(SCRef fileName) { - QString runCmd("git diff-index -r -z -m -p --full-index --no-commit-id HEAD"), runOutput; + QString runCmd("git diff-index --no-color -r -z -m -p --full-index --no-commit-id HEAD"), runOutput; if (!fileName.isEmpty()) runCmd.append(" -- " + quote(fileName));
@@ -998,7 +998,7 @@ bool Git::isSameFiles(SCRef tree1Sha, SCRef tree2Sha) { if (isParentOf(tree2Sha, tree1Sha)) return !isTreeModified(tree1Sha); - const QString runCmd("git diff-tree -r " + tree1Sha + " " + tree2Sha); + const QString runCmd("git diff-tree --no-color -r " + tree1Sha + " " + tree2Sha); QString runOutput; if (!run(runCmd, &runOutput)) return false;
@@ -1209,7 +1209,7 @@ const RevFile* Git::getAllMergeFiles(const Rev* r) { if (revsFiles.contains(mySha)) return revsFiles[mySha]; - QString runCmd("git diff-tree -r -m -C " + r->sha()), runOutput; + QString runCmd("git diff-tree --no-color -r -m -C " + r->sha()), runOutput; if (!run(runCmd, &runOutput)) return NULL;
@@ -1230,7 +1230,7 @@ const RevFile* Git::getFiles(SCRef sha, SCRef diffToSha, bool allFiles, SCRef pa if (!diffToSha.isEmpty() && (sha != ZERO_SHA)) { - QString runCmd("git diff-tree -r -m -C "); + QString runCmd("git diff-tree --no-color -r -m -C "); runCmd.append(diffToSha + " " + sha); if (!path.isEmpty()) runCmd.append(" " + path);
@@ -1250,7 +1250,7 @@ const RevFile* Git::getFiles(SCRef sha, SCRef diffToSha, bool allFiles, SCRef pa dbs("ASSERT in Git::getFiles, ZERO_SHA not found"); return NULL; } - QString runCmd("git diff-tree -r -c -C " + sha), runOutput; + QString runCmd("git diff-tree --no-color -r -c -C " + sha), runOutput; if (!run(runCmd, &runOutput)) return NULL;
@@ -1337,7 +1337,7 @@ bool Git::getPatchFilter(SCRef exp, bool isRegExp, ShaSet& shaSet) { if (buf.isEmpty()) return true; - QString runCmd("git diff-tree -r -s --stdin "), runOutput; + QString runCmd("git diff-tree --no-color -r -s --stdin "), runOutput; if (isRegExp) runCmd.append("--pickaxe-regex ");
@@ -1386,7 +1386,7 @@ bool Git::formatPatch(SCList shaList, SCRef dirPath, SCRef remoteDir) { QSettings settings; const QString FPArgs(settings.value(PATCH_ARGS_KEY).toString()); - QString runCmd("git format-patch"); + QString runCmd("git format-patch --no-color"); if (testFlag(NUMBERS_F) && !remote) runCmd.append(" -n");
diff --git a/src/git_startup.cpp b/src/git_startup.cpp
index 95a9474..a281173 100644
--- a/src/git_startup.cpp
+++ b/src/git_startup.cpp@@ -480,7 +480,7 @@ bool Git::startParseProc(SCList initCmd, FileHistory* fh, SCRef buf) { bool Git::startRevList(SCList args, FileHistory* fh) { - const QString baseCmd("git log --log-size --parents --boundary --pretty=raw -z"); + const QString baseCmd("git log --no-color --log-size --parents --boundary --pretty=raw -z"); QStringList initCmd(baseCmd.split(' ')); if (!isMainHistory(fh)) /*
@@ -505,7 +505,7 @@ bool Git::startUnappliedList() { // WARNING: with this command 'git log' could send spurious // revs so we need some filter out logic during loading - QStringList cmd(QString("git log --parents --pretty=raw -z ^HEAD").split(' ')); + QStringList cmd(QString("git log --no-color --parents --pretty=raw -z ^HEAD").split(' ')); cmd << unAppliedShaList; return startParseProc(cmd, revData, QString()); }
@@ -835,7 +835,7 @@ void Git::loadFileNames() { } if (!diffTreeBuf.isEmpty()) { filesLoadingPending = filesLoadingCurSha = ""; - const QString runCmd("git diff-tree -r -C --stdin"); + const QString runCmd("git diff-tree --no-color -r -C --stdin"); runAsync(runCmd, this, diffTreeBuf); } indexTree();
--
1.5.3.4