aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/git
diff options
context:
space:
mode:
authorOrgad Shaneh <orgad.shaneh@audiocodes.com>2020-06-13 23:15:29 +0300
committerOrgad Shaneh <orgads@gmail.com>2020-07-19 03:59:45 +0000
commitc0c5773345480df8cec8d6959f89ae255eeb7d8a (patch)
tree8ea9325bf9060f0b069398074da386b8e11762f2 /src/plugins/git
parent32af4d9e70b8a5f16a48fe85dba59b4a47a2af90 (diff)
Git: Add new files with --intent-to-add
Sometimes the file is modified after adding it, either by Qt Creator itself or by the user. Running Diff on such a file may look strange. Instead of showing the entire file, it shows the diff since it was added with its initial content. Fixes: QTCREATORBUG-23441 Change-Id: I712cc574053f39753250685aec148d2b6d7db192 Reviewed-by: André Hartmann <aha_1980@gmx.de>
Diffstat (limited to 'src/plugins/git')
-rw-r--r--src/plugins/git/gitclient.cpp11
-rw-r--r--src/plugins/git/gitclient.h3
-rw-r--r--src/plugins/git/gitplugin.cpp2
3 files changed, 10 insertions, 6 deletions
diff --git a/src/plugins/git/gitclient.cpp b/src/plugins/git/gitclient.cpp
index 70f34604ae..79b0ea657b 100644
--- a/src/plugins/git/gitclient.cpp
+++ b/src/plugins/git/gitclient.cpp
@@ -1438,10 +1438,13 @@ bool GitClient::synchronousLog(const QString &workingDirectory, const QStringLis
}
}
-bool GitClient::synchronousAdd(const QString &workingDirectory, const QStringList &files)
+bool GitClient::synchronousAdd(const QString &workingDirectory,
+ const QStringList &files,
+ const QStringList &extraOptions)
{
- return vcsFullySynchronousExec(workingDirectory, QStringList({"add"}) + files).result
- == SynchronousProcessResponse::Finished;
+ QStringList args{"add"};
+ args += extraOptions + files;
+ return vcsFullySynchronousExec(workingDirectory, args).result == SynchronousProcessResponse::Finished;
}
bool GitClient::synchronousDelete(const QString &workingDirectory,
@@ -2890,7 +2893,7 @@ bool GitClient::addAndCommit(const QString &repositoryDirectory,
filesToReset.removeAll(file);
filesToAdd.append(file);
} else if (state == AddedFile && checked) {
- QTC_ASSERT(false, continue); // these should be untracked!
+ filesToAdd.append(file);
} else if (state == DeletedFile && checked) {
filesToReset.removeAll(file);
filesToRemove.append(file);
diff --git a/src/plugins/git/gitclient.h b/src/plugins/git/gitclient.h
index 925e7dc56c..9588bec366 100644
--- a/src/plugins/git/gitclient.h
+++ b/src/plugins/git/gitclient.h
@@ -185,7 +185,8 @@ public:
bool synchronousLog(const QString &workingDirectory, const QStringList &arguments,
QString *output, QString *errorMessage = nullptr,
unsigned flags = 0);
- bool synchronousAdd(const QString &workingDirectory, const QStringList &files);
+ bool synchronousAdd(const QString &workingDirectory, const QStringList &files,
+ const QStringList &extraOptions = {});
bool synchronousDelete(const QString &workingDirectory,
bool force,
const QStringList &files);
diff --git a/src/plugins/git/gitplugin.cpp b/src/plugins/git/gitplugin.cpp
index aa1d36d13b..bb7de09818 100644
--- a/src/plugins/git/gitplugin.cpp
+++ b/src/plugins/git/gitplugin.cpp
@@ -1859,7 +1859,7 @@ bool GitPluginPrivate::vcsOpen(const QString & /*fileName*/)
bool GitPluginPrivate::vcsAdd(const QString & fileName)
{
const QFileInfo fi(fileName);
- return m_gitClient.synchronousAdd(fi.absolutePath(), {fi.fileName()});
+ return m_gitClient.synchronousAdd(fi.absolutePath(), {fi.fileName()}, {"--intent-to-add"});
}
bool GitPluginPrivate::vcsDelete(const QString & fileName)