From 6c02c27e9e5891440dc99565e4dee01618a76d5e Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Thu, 28 Nov 2013 10:54:39 +0100 Subject: Change GitClient::executeGit() to take flags instead of bool. Change-Id: I3cb83914be7e9665f49baf9f563c753c6c3919f1 Reviewed-by: Orgad Shaneh --- src/plugins/git/gitclient.cpp | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'src/plugins/git/gitclient.cpp') diff --git a/src/plugins/git/gitclient.cpp b/src/plugins/git/gitclient.cpp index af2bc36bd1..ac1f8b497c 100644 --- a/src/plugins/git/gitclient.cpp +++ b/src/plugins/git/gitclient.cpp @@ -1537,7 +1537,7 @@ void GitClient::blame(const QString &workingDirectory, arguments << QLatin1String("--") << fileName; if (!revision.isEmpty()) arguments << revision; - executeGit(workingDirectory, arguments, editor, false, false, lineNumber); + executeGit(workingDirectory, arguments, editor, false, 0, lineNumber); } bool GitClient::synchronousCheckout(const QString &workingDirectory, @@ -1567,7 +1567,10 @@ void GitClient::reset(const QString &workingDirectory, const QString &argument, if (!commit.isEmpty()) arguments << commit; - executeGit(workingDirectory, arguments, 0, true, argument == QLatin1String("--hard")); + unsigned flags = 0; + if (argument == QLatin1String("--hard")) + flags |= VcsBasePlugin::ExpectRepoChanges; + executeGit(workingDirectory, arguments, 0, true, flags); } void GitClient::addFile(const QString &workingDirectory, const QString &fileName) @@ -2427,14 +2430,13 @@ VcsBase::Command *GitClient::executeGit(const QString &workingDirectory, const QStringList &arguments, VcsBase::VcsBaseEditorWidget* editor, bool useOutputToWindow, - bool expectChanges, + unsigned additionalFlags, int editorLineNumber) { outputWindow()->appendCommand(workingDirectory, settings()->stringValue(GitSettings::binaryPathKey), arguments); VcsBase::Command *command = createCommand(workingDirectory, editor, useOutputToWindow, editorLineNumber); command->addJob(arguments, settings()->intValue(GitSettings::timeoutKey)); - if (expectChanges) - command->addFlags(VcsBasePlugin::ExpectRepoChanges); + command->addFlags(additionalFlags); command->execute(); return command; } @@ -2563,7 +2565,8 @@ void GitClient::updateSubmodulesIfNeeded(const QString &workingDirectory, bool p QStringList arguments; arguments << QLatin1String("submodule") << QLatin1String("update"); - VcsBase::Command *cmd = executeGit(workingDirectory, arguments, 0, true, true); + VcsBase::Command *cmd = executeGit(workingDirectory, arguments, 0, true, + VcsBasePlugin::ExpectRepoChanges); connect(cmd, SIGNAL(finished(bool,int,QVariant)), this, SLOT(finishSubmoduleUpdate())); } @@ -3510,7 +3513,8 @@ void GitClient::stashPop(const QString &workingDirectory, const QString &stash) arguments << QLatin1String("pop"); if (!stash.isEmpty()) arguments << stash; - VcsBase::Command *cmd = executeGit(workingDirectory, arguments, 0, true, true); + VcsBase::Command *cmd = executeGit(workingDirectory, arguments, 0, true, + VcsBasePlugin::ExpectRepoChanges); new ConflictHandler(cmd, workingDirectory); } -- cgit v1.2.1 From 6ec8838f688d3b41c2e4d450d85a0bb8990d2f38 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Thu, 28 Nov 2013 11:09:44 +0100 Subject: git: Suppress stderr when running diff on Windows. When using autocrlf, warnings "LF will be replaced by CRLF in ..." occur, causing the command window to pop up, which is not desired. Change-Id: I399080a98f9386dbbaff2c90c6d4ba4877d08057 Reviewed-by: Orgad Shaneh Reviewed-by: Tobias Hunger --- src/plugins/git/gitclient.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'src/plugins/git/gitclient.cpp') diff --git a/src/plugins/git/gitclient.cpp b/src/plugins/git/gitclient.cpp index ac1f8b497c..22d8076a3c 100644 --- a/src/plugins/git/gitclient.cpp +++ b/src/plugins/git/gitclient.cpp @@ -83,6 +83,12 @@ static const char decorateOption[] = "--decorate"; namespace Git { namespace Internal { +// Suppress git diff warnings about "LF will be replaced by CRLF..." on Windows. +static inline unsigned diffExecutionFlags() +{ + return Utils::HostOsInfo::isWindowsHost() ? unsigned(VcsBase::VcsBasePlugin::SuppressStdErrInLogWindow) : 0u; +} + using VcsBase::VcsBasePlugin; class GitDiffSwitcher : public QObject @@ -389,6 +395,7 @@ void GitDiffHandler::collectFilesList(const QStringList &additionalArguments) QStringList arguments; arguments << QLatin1String("diff") << QLatin1String("--name-only") << additionalArguments; command->addJob(arguments, m_timeout); + command->addFlags(diffExecutionFlags()); command->execute(); } @@ -1186,6 +1193,7 @@ void GitClient::diff(const QString &workingDirectory, command->addJob(arguments, timeout); } } + command->addFlags(diffExecutionFlags()); command->execute(); } if (newEditor) { @@ -1256,7 +1264,7 @@ void GitClient::diff(const QString &workingDirectory, const QString &fileName) if (!fileName.isEmpty()) cmdArgs << QLatin1String("--") << fileName; - executeGit(workingDirectory, cmdArgs, vcsEditor); + executeGit(workingDirectory, cmdArgs, vcsEditor, false, diffExecutionFlags()); } if (newEditor) { GitDiffSwitcher *switcher = new GitDiffSwitcher(newEditor, this); @@ -1315,7 +1323,7 @@ void GitClient::diffBranch(const QString &workingDirectory, << vcsEditor->configurationWidget()->arguments() << branchName; - executeGit(workingDirectory, cmdArgs, vcsEditor); + executeGit(workingDirectory, cmdArgs, vcsEditor, false, diffExecutionFlags()); } if (newEditor) { GitDiffSwitcher *switcher = new GitDiffSwitcher(newEditor, this); -- cgit v1.2.1