forked from qt-creator/qt-creator
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>
This commit is contained in:
committed by
Orgad Shaneh
parent
32af4d9e70
commit
c0c5773345
@@ -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);
|
||||
|
@@ -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);
|
||||
|
@@ -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)
|
||||
|
Reference in New Issue
Block a user