git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[QGIT4 PATCH] Add --no-color option to several calls to git

From
YSYaacov Akiba Slama <ya@slamail.org>
Date
Oct 17, 2007, 17:54 UTC
Message-ID
<1192643649-18908-1-git-send-email-ya@slamail.org>

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 <ya@slamail.org>
---
 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
Next: Marco Costalba
Message 1 of 3 in “Add --no-color option to several calls to git”
  1. Add --no-color option to several calls to gitYaacov Akiba Slama, Oct 17, 2007
  2. Marco CostalbaOct 17, 2007
  3. Yaacov Akiba SlamaOct 18, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.