return result;
}
bool hasdir = false;
+ bool shouldadd = false;
+ bool shouldremove = false;
foreach (const KFileItem &item, items) {
if (item.isDir()) {
kDebug() << "Items include directory" << item;
hasdir = true;
break;
} else {
+ const QByteArray gitfile = getGitFile(item, m_directory);
+ unsigned int gitstatusflags = 0;
+ const int gitresult = git_status_file(&gitstatusflags, m_gitrepo, gitfile.constData());
+ if (gitresult != GIT_OK) {
+ kWarning() << "Could not get status" << gitfile << FileViewGitPlugin::getGitError();
+ gitstatusflags = 0;
+ }
+ if (gitstatusflags & GIT_STATUS_INDEX_NEW || gitstatusflags & GIT_STATUS_CONFLICTED
+ || gitstatusflags == GIT_STATUS_CURRENT) {
+ shouldremove = true;
+ }
+ // NOTE: git_index_add_bypath() force-adds ignored files
+ if (gitstatusflags & GIT_STATUS_WT_NEW || gitstatusflags & GIT_STATUS_INDEX_DELETED
+ || gitstatusflags & GIT_STATUS_IGNORED) {
+ shouldadd = true;
+ }
m_actionitems.append(item);
}
}
result.append(m_commitaction);
}
} else {
- result.append(m_addaction);
- result.append(m_removeaction);
+ if (shouldadd) {
+ result.append(m_addaction);
+ }
+ if (shouldremove) {
+ result.append(m_removeaction);
+ }
}
return result;
}
{
m_changedfiles->setText(changedfiles.join(QLatin1String("\n")));
if (m_diffdocument) {
- // by not re-setting the text the cursor position and selection is preserved
+ // by not re-setting the text the cursor position and selection are preserved
if (m_diffdocument->text() != diff) {
// NOTE: can't set the text in read-only mode
m_diffdocument->setReadWrite(true);