From a0c7b208cc268c2c4c5a75968e834c37d4c08c12 Mon Sep 17 00:00:00 2001 From: Orgad Shaneh Date: Mon, 30 Jun 2014 22:15:12 +0300 Subject: Git: Factor source directory resolving to a function Change-Id: Ica2f6ad01052fb7130397740fcf2396de7cbbf9d Reviewed-by: Tobias Hunger --- src/plugins/git/giteditor.cpp | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) (limited to 'src/plugins/git/giteditor.cpp') diff --git a/src/plugins/git/giteditor.cpp b/src/plugins/git/giteditor.cpp index 468c541238..edde549c24 100644 --- a/src/plugins/git/giteditor.cpp +++ b/src/plugins/git/giteditor.cpp @@ -206,15 +206,13 @@ void GitEditor::commandFinishedGotoLine(bool ok, int exitCode, const QVariant &v void GitEditor::checkoutChange() { - const QFileInfo fi(source()); - const QString workingDirectory = fi.isDir() ? fi.absoluteFilePath() : fi.absolutePath(); - GitPlugin::instance()->gitClient()->stashAndCheckout(workingDirectory, m_currentChange); + GitPlugin::instance()->gitClient()->stashAndCheckout( + sourceWorkingDirectory(), m_currentChange); } void GitEditor::resetChange() { - const QFileInfo fi(source()); - const QString workingDir = fi.isDir() ? fi.absoluteFilePath() : fi.absolutePath(); + const QString workingDir = sourceWorkingDirectory(); GitClient *client = GitPlugin::instance()->gitClient(); if (client->gitStatus(workingDir, StatusMode(NoUntracked | NoSubmodules)) @@ -232,16 +230,14 @@ void GitEditor::resetChange() void GitEditor::cherryPickChange() { - const QFileInfo fi(source()); - const QString workingDirectory = fi.isDir() ? fi.absoluteFilePath() : fi.absolutePath(); - GitPlugin::instance()->gitClient()->synchronousCherryPick(workingDirectory, m_currentChange); + GitPlugin::instance()->gitClient()->synchronousCherryPick( + sourceWorkingDirectory(), m_currentChange); } void GitEditor::revertChange() { - const QFileInfo fi(source()); - const QString workingDirectory = fi.isDir() ? fi.absoluteFilePath() : fi.absolutePath(); - GitPlugin::instance()->gitClient()->synchronousRevert(workingDirectory, m_currentChange); + GitPlugin::instance()->gitClient()->synchronousRevert( + sourceWorkingDirectory(), m_currentChange); } void GitEditor::stageDiffChunk() @@ -402,5 +398,11 @@ QString GitEditor::fileNameForLine(int line) const return source(); } +QString GitEditor::sourceWorkingDirectory() const +{ + const QFileInfo fi(source()); + return fi.isDir() ? fi.absoluteFilePath() : fi.absolutePath(); +} + } // namespace Internal } // namespace Git -- cgit v1.2.1