mirror of
https://bitbucket.org/smil3y/kde-workspace.git
synced 2025-02-23 18:32:50 +00:00
dolphin: return GIT_EUSER when dialog was not accepted
otherwise the error claims no callback was set Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
db61f4bf93
commit
f2a35aba1f
3 changed files with 34 additions and 31 deletions
|
@ -173,7 +173,7 @@ bool FileViewGitPlugin::beginRetrieval(const QString &directory)
|
|||
// NOTE: git_repository_open_ext() will look for .git in parent directories
|
||||
const int gitresult = git_repository_open_ext(&m_gitrepo, directorybytes.constData(), 0 , "/");
|
||||
if (gitresult != GIT_OK) {
|
||||
const QByteArray giterror = FileViewGitPlugin::getGitError();
|
||||
const QByteArray giterror = FileViewGitPlugin::getGitError(gitresult);
|
||||
kWarning() << "Could not open" << directory << giterror;
|
||||
emit errorMessage(QString::fromLocal8Bit(giterror.constData(), giterror.size()));
|
||||
return false;
|
||||
|
@ -201,7 +201,7 @@ KVersionControlPlugin::ItemVersion FileViewGitPlugin::itemVersion(const KFileIte
|
|||
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();
|
||||
kWarning() << "Could not get status" << gitfile << FileViewGitPlugin::getGitError(gitresult);
|
||||
return KVersionControlPlugin::UnversionedVersion;
|
||||
}
|
||||
if (gitstatusflags & GIT_STATUS_INDEX_NEW || gitstatusflags & GIT_STATUS_WT_NEW) {
|
||||
|
@ -270,7 +270,7 @@ QStringList FileViewGitPlugin::changedGitFiles() const
|
|||
git_status_options gitstatusoptions;
|
||||
int gitresult = git_status_options_init(&gitstatusoptions, GIT_STATUS_OPTIONS_VERSION);
|
||||
if (gitresult != GIT_OK) {
|
||||
const QByteArray giterror = FileViewGitPlugin::getGitError();
|
||||
const QByteArray giterror = FileViewGitPlugin::getGitError(gitresult);
|
||||
kWarning() << "Could not initialize status options" << m_directory << giterror;
|
||||
return result;
|
||||
}
|
||||
|
@ -282,7 +282,7 @@ QStringList FileViewGitPlugin::changedGitFiles() const
|
|||
// NOTE: the callback is called only for paths the status of which has changed
|
||||
gitresult = git_status_foreach_ext(m_gitrepo, &gitstatusoptions, FileViewGitPlugin::gitStatusCallback, &gitstatuspayload);
|
||||
if (gitresult != GIT_OK) {
|
||||
const QByteArray giterror = FileViewGitPlugin::getGitError();
|
||||
const QByteArray giterror = FileViewGitPlugin::getGitError(gitresult);
|
||||
kWarning() << "Could not get repository status" << m_directory << giterror;
|
||||
return result;
|
||||
}
|
||||
|
@ -364,7 +364,7 @@ int FileViewGitPlugin::gitCredentialCallback(git_credential **out,
|
|||
kpassworddialog.setKeepPassword(true);
|
||||
}
|
||||
if (kpassworddialog.exec() != QDialog::Accepted) {
|
||||
return 1;
|
||||
return GIT_EUSER;
|
||||
}
|
||||
const QByteArray gituser = kpassworddialog.username().toUtf8();
|
||||
const QByteArray gitpass = kpassworddialog.password().toUtf8();
|
||||
|
@ -391,7 +391,7 @@ int FileViewGitPlugin::gitCredentialCallback(git_credential **out,
|
|||
kpassworddialog.addCommentLine(i18n("URL:"), kpassworddialogcomment);
|
||||
kpassworddialog.setUsername(kpassworddialoguser);
|
||||
if (kpassworddialog.exec() != QDialog::Accepted) {
|
||||
return 1;
|
||||
return GIT_EUSER;
|
||||
}
|
||||
const QByteArray gituser = kpassworddialog.username().toUtf8();
|
||||
return git_credential_username_new(out, gituser.constData());
|
||||
|
@ -399,8 +399,11 @@ int FileViewGitPlugin::gitCredentialCallback(git_credential **out,
|
|||
return 1;
|
||||
}
|
||||
|
||||
QByteArray FileViewGitPlugin::getGitError()
|
||||
QByteArray FileViewGitPlugin::getGitError(const int gitresult)
|
||||
{
|
||||
if (gitresult == GIT_EUSER) {
|
||||
return i18n("Canceled by user").toLocal8Bit();
|
||||
}
|
||||
const git_error* giterror = git_error_last();
|
||||
if (!giterror) {
|
||||
return QByteArray();
|
||||
|
@ -414,7 +417,7 @@ void FileViewGitPlugin::slotAdd()
|
|||
git_index* gitindex = nullptr;
|
||||
int gitresult = git_repository_index(&gitindex, m_gitrepo);
|
||||
if (gitresult != GIT_OK) {
|
||||
const QByteArray giterror = FileViewGitPlugin::getGitError();
|
||||
const QByteArray giterror = FileViewGitPlugin::getGitError(gitresult);
|
||||
kWarning() << "Could not get repository index" << m_directory << giterror;
|
||||
emit errorMessage(QString::fromLocal8Bit(giterror.constData(), giterror.size()));
|
||||
return;
|
||||
|
@ -425,7 +428,7 @@ void FileViewGitPlugin::slotAdd()
|
|||
emit infoMessage(i18n("Adding: %1", QFile::decodeName(gitfile)));
|
||||
gitresult = git_index_add_bypath(gitindex, gitfile.constData());
|
||||
if (gitresult != GIT_OK) {
|
||||
const QByteArray giterror = FileViewGitPlugin::getGitError();
|
||||
const QByteArray giterror = FileViewGitPlugin::getGitError(gitresult);
|
||||
kWarning() << "Could not add path to repository" << m_directory << giterror;
|
||||
emit errorMessage(QString::fromLocal8Bit(giterror.constData(), giterror.size()));
|
||||
git_index_free(gitindex);
|
||||
|
@ -436,7 +439,7 @@ void FileViewGitPlugin::slotAdd()
|
|||
emit infoMessage(i18n("Writing changes"));
|
||||
gitresult = git_index_write(gitindex);
|
||||
if (gitresult != GIT_OK) {
|
||||
const QByteArray giterror = FileViewGitPlugin::getGitError();
|
||||
const QByteArray giterror = FileViewGitPlugin::getGitError(gitresult);
|
||||
kWarning() << "Could not write changes to repository" << m_directory << giterror;
|
||||
emit errorMessage(QString::fromLocal8Bit(giterror.constData(), giterror.size()));
|
||||
git_index_free(gitindex);
|
||||
|
@ -462,7 +465,7 @@ void FileViewGitPlugin::slotRemove()
|
|||
git_index* gitindex = nullptr;
|
||||
int gitresult = git_repository_index(&gitindex, m_gitrepo);
|
||||
if (gitresult != GIT_OK) {
|
||||
const QByteArray giterror = FileViewGitPlugin::getGitError();
|
||||
const QByteArray giterror = FileViewGitPlugin::getGitError(gitresult);
|
||||
kWarning() << "Could not get repository index" << m_directory << giterror;
|
||||
emit errorMessage(QString::fromLocal8Bit(giterror.constData(), giterror.size()));
|
||||
return;
|
||||
|
@ -473,7 +476,7 @@ void FileViewGitPlugin::slotRemove()
|
|||
emit infoMessage(i18n("Removing: %1", QFile::decodeName(gitfile)));
|
||||
gitresult = git_index_remove_bypath(gitindex, gitfile.constData());
|
||||
if (gitresult != GIT_OK) {
|
||||
const QByteArray giterror = FileViewGitPlugin::getGitError();
|
||||
const QByteArray giterror = FileViewGitPlugin::getGitError(gitresult);
|
||||
kWarning() << "Could not remove path from repository" << m_directory << giterror;
|
||||
emit errorMessage(QString::fromLocal8Bit(giterror.constData(), giterror.size()));
|
||||
git_index_free(gitindex);
|
||||
|
@ -484,7 +487,7 @@ void FileViewGitPlugin::slotRemove()
|
|||
emit infoMessage(i18n("Writing changes"));
|
||||
gitresult = git_index_write(gitindex);
|
||||
if (gitresult != GIT_OK) {
|
||||
const QByteArray giterror = FileViewGitPlugin::getGitError();
|
||||
const QByteArray giterror = FileViewGitPlugin::getGitError(gitresult);
|
||||
kWarning() << "Could not write index changes to repository" << m_directory << giterror;
|
||||
emit errorMessage(QString::fromLocal8Bit(giterror.constData(), giterror.size()));
|
||||
git_index_free(gitindex);
|
||||
|
@ -521,7 +524,7 @@ void FileViewGitPlugin::slotCommit()
|
|||
git_index* gitindex = nullptr;
|
||||
int gitresult = git_repository_index(&gitindex, m_gitrepo);
|
||||
if (gitresult != GIT_OK) {
|
||||
const QByteArray giterror = FileViewGitPlugin::getGitError();
|
||||
const QByteArray giterror = FileViewGitPlugin::getGitError(gitresult);
|
||||
kWarning() << "Could not get repository index" << m_directory << giterror;
|
||||
emit errorMessage(QString::fromLocal8Bit(giterror.constData(), giterror.size()));
|
||||
return;
|
||||
|
@ -533,7 +536,7 @@ void FileViewGitPlugin::slotCommit()
|
|||
gitupdatearray.count = 1;
|
||||
gitresult = git_index_update_all(gitindex, &gitupdatearray, NULL, NULL);
|
||||
if (gitresult != GIT_OK) {
|
||||
const QByteArray giterror = FileViewGitPlugin::getGitError();
|
||||
const QByteArray giterror = FileViewGitPlugin::getGitError(gitresult);
|
||||
kWarning() << "Could not update index" << m_directory << giterror;
|
||||
emit errorMessage(QString::fromLocal8Bit(giterror.constData(), giterror.size()));
|
||||
git_index_free(gitindex);
|
||||
|
@ -544,7 +547,7 @@ void FileViewGitPlugin::slotCommit()
|
|||
git_object *gitparent = nullptr;
|
||||
gitresult = git_revparse_single(&gitparent, m_gitrepo, gitspec);
|
||||
if (gitresult != GIT_OK) {
|
||||
const QByteArray giterror = FileViewGitPlugin::getGitError();
|
||||
const QByteArray giterror = FileViewGitPlugin::getGitError(gitresult);
|
||||
kWarning() << "Could not parse revision" << m_directory << giterror;
|
||||
emit errorMessage(QString::fromLocal8Bit(giterror.constData(), giterror.size()));
|
||||
git_index_free(gitindex);
|
||||
|
@ -555,7 +558,7 @@ void FileViewGitPlugin::slotCommit()
|
|||
git_oid gittreeobjectid;
|
||||
gitresult = git_index_write_tree(&gittreeobjectid, gitindex);
|
||||
if (gitresult != GIT_OK) {
|
||||
const QByteArray giterror = FileViewGitPlugin::getGitError();
|
||||
const QByteArray giterror = FileViewGitPlugin::getGitError(gitresult);
|
||||
kWarning() << "Could not write tree changes to repository" << m_directory << giterror;
|
||||
emit errorMessage(QString::fromLocal8Bit(giterror.constData(), giterror.size()));
|
||||
git_object_free(gitparent);
|
||||
|
@ -564,7 +567,7 @@ void FileViewGitPlugin::slotCommit()
|
|||
}
|
||||
gitresult = git_index_write(gitindex);
|
||||
if (gitresult != GIT_OK) {
|
||||
const QByteArray giterror = FileViewGitPlugin::getGitError();
|
||||
const QByteArray giterror = FileViewGitPlugin::getGitError(gitresult);
|
||||
kWarning() << "Could not write index changes to repository" << m_directory << giterror;
|
||||
emit errorMessage(QString::fromLocal8Bit(giterror.constData(), giterror.size()));
|
||||
git_object_free(gitparent);
|
||||
|
@ -576,7 +579,7 @@ void FileViewGitPlugin::slotCommit()
|
|||
git_tree *gittree = nullptr;
|
||||
gitresult = git_tree_lookup(&gittree, m_gitrepo, &gittreeobjectid);
|
||||
if (gitresult != GIT_OK) {
|
||||
const QByteArray giterror = FileViewGitPlugin::getGitError();
|
||||
const QByteArray giterror = FileViewGitPlugin::getGitError(gitresult);
|
||||
kWarning() << "Could not lookup tree" << m_directory << giterror;
|
||||
emit errorMessage(QString::fromLocal8Bit(giterror.constData(), giterror.size()));
|
||||
git_object_free(gitparent);
|
||||
|
@ -588,7 +591,7 @@ void FileViewGitPlugin::slotCommit()
|
|||
git_signature* gitsignature = nullptr;
|
||||
gitresult = git_signature_default(&gitsignature, m_gitrepo);
|
||||
if (gitresult != GIT_OK) {
|
||||
const QByteArray giterror = FileViewGitPlugin::getGitError();
|
||||
const QByteArray giterror = FileViewGitPlugin::getGitError(gitresult);
|
||||
kWarning() << "Could not get signature" << m_directory << giterror;
|
||||
emit errorMessage(QString::fromLocal8Bit(giterror.constData(), giterror.size()));
|
||||
git_tree_free(gittree);
|
||||
|
@ -607,7 +610,7 @@ void FileViewGitPlugin::slotCommit()
|
|||
gitparent ? 1 : 0, gitparent
|
||||
);
|
||||
if (gitresult != GIT_OK) {
|
||||
const QByteArray giterror = FileViewGitPlugin::getGitError();
|
||||
const QByteArray giterror = FileViewGitPlugin::getGitError(gitresult);
|
||||
kWarning() << "Could not commit" << m_directory << giterror;
|
||||
emit errorMessage(QString::fromLocal8Bit(giterror.constData(), giterror.size()));
|
||||
git_signature_free(gitsignature);
|
||||
|
@ -633,7 +636,7 @@ void FileViewGitPlugin::slotPush()
|
|||
git_push_options gitpushoptions;
|
||||
int gitresult = git_push_options_init(&gitpushoptions, GIT_PUSH_OPTIONS_VERSION);
|
||||
if (gitresult != GIT_OK) {
|
||||
const QByteArray giterror = FileViewGitPlugin::getGitError();
|
||||
const QByteArray giterror = FileViewGitPlugin::getGitError(gitresult);
|
||||
kWarning() << "Could not initialize push options" << m_directory << giterror;
|
||||
emit errorMessage(QString::fromLocal8Bit(giterror.constData(), giterror.size()));
|
||||
return;
|
||||
|
@ -650,7 +653,7 @@ void FileViewGitPlugin::slotPush()
|
|||
git_strarray gitremotes;
|
||||
gitresult = git_remote_list(&gitremotes, m_gitrepo);
|
||||
if (gitresult != GIT_OK) {
|
||||
const QByteArray giterror = FileViewGitPlugin::getGitError();
|
||||
const QByteArray giterror = FileViewGitPlugin::getGitError(gitresult);
|
||||
kWarning() << "Could not list remotes" << m_directory << giterror;
|
||||
emit errorMessage(QString::fromLocal8Bit(giterror.constData(), giterror.size()));
|
||||
return;
|
||||
|
@ -661,7 +664,7 @@ void FileViewGitPlugin::slotPush()
|
|||
git_remote* gitremote = nullptr;
|
||||
gitresult = git_remote_lookup(&gitremote, m_gitrepo, gitremotes.strings[i]);
|
||||
if (gitresult != GIT_OK) {
|
||||
const QByteArray giterror = FileViewGitPlugin::getGitError();
|
||||
const QByteArray giterror = FileViewGitPlugin::getGitError(gitresult);
|
||||
kWarning() << "Could not lookup remote" << m_directory << giterror;
|
||||
emit errorMessage(QString::fromLocal8Bit(giterror.constData(), giterror.size()));
|
||||
return;
|
||||
|
@ -669,7 +672,7 @@ void FileViewGitPlugin::slotPush()
|
|||
|
||||
gitresult = git_remote_push(gitremote, NULL, &gitpushoptions);
|
||||
if (gitresult != GIT_OK) {
|
||||
const QByteArray giterror = FileViewGitPlugin::getGitError();
|
||||
const QByteArray giterror = FileViewGitPlugin::getGitError(gitresult);
|
||||
kWarning() << "Could not push remote" << m_directory << giterror;
|
||||
emit errorMessage(QString::fromLocal8Bit(giterror.constData(), giterror.size()));
|
||||
git_remote_free(gitremote);
|
||||
|
@ -690,7 +693,7 @@ void FileViewGitPlugin::slotPull()
|
|||
git_fetch_options gitfetchoptions;
|
||||
int gitresult = git_fetch_options_init(&gitfetchoptions, GIT_FETCH_OPTIONS_VERSION);
|
||||
if (gitresult != GIT_OK) {
|
||||
const QByteArray giterror = FileViewGitPlugin::getGitError();
|
||||
const QByteArray giterror = FileViewGitPlugin::getGitError(gitresult);
|
||||
kWarning() << "Could not initialize fetch options" << m_directory << giterror;
|
||||
emit errorMessage(QString::fromLocal8Bit(giterror.constData(), giterror.size()));
|
||||
return;
|
||||
|
@ -707,7 +710,7 @@ void FileViewGitPlugin::slotPull()
|
|||
git_strarray gitremotes;
|
||||
gitresult = git_remote_list(&gitremotes, m_gitrepo);
|
||||
if (gitresult != GIT_OK) {
|
||||
const QByteArray giterror = FileViewGitPlugin::getGitError();
|
||||
const QByteArray giterror = FileViewGitPlugin::getGitError(gitresult);
|
||||
kWarning() << "Could not list remotes" << m_directory << giterror;
|
||||
emit errorMessage(QString::fromLocal8Bit(giterror.constData(), giterror.size()));
|
||||
return;
|
||||
|
@ -718,7 +721,7 @@ void FileViewGitPlugin::slotPull()
|
|||
git_remote* gitremote = nullptr;
|
||||
gitresult = git_remote_lookup(&gitremote, m_gitrepo, gitremotes.strings[i]);
|
||||
if (gitresult != GIT_OK) {
|
||||
const QByteArray giterror = FileViewGitPlugin::getGitError();
|
||||
const QByteArray giterror = FileViewGitPlugin::getGitError(gitresult);
|
||||
kWarning() << "Could not lookup remote" << m_directory << giterror;
|
||||
emit errorMessage(QString::fromLocal8Bit(giterror.constData(), giterror.size()));
|
||||
return;
|
||||
|
@ -726,7 +729,7 @@ void FileViewGitPlugin::slotPull()
|
|||
|
||||
gitresult = git_remote_fetch(gitremote, NULL, &gitfetchoptions, NULL);
|
||||
if (gitresult != GIT_OK) {
|
||||
const QByteArray giterror = FileViewGitPlugin::getGitError();
|
||||
const QByteArray giterror = FileViewGitPlugin::getGitError(gitresult);
|
||||
kWarning() << "Could not fetch remote" << m_directory << giterror;
|
||||
emit errorMessage(QString::fromLocal8Bit(giterror.constData(), giterror.size()));
|
||||
git_remote_free(gitremote);
|
||||
|
|
|
@ -50,7 +50,7 @@ public:
|
|||
const char *url, const char *username_from_url, unsigned int allowed_types,
|
||||
void *payload);
|
||||
|
||||
static QByteArray getGitError();
|
||||
static QByteArray getGitError(const int gitresult);
|
||||
|
||||
private Q_SLOTS:
|
||||
void slotAdd();
|
||||
|
|
|
@ -54,7 +54,7 @@ QByteArray GitCommitDialog::message() const
|
|||
git_buf gitbuffer = GIT_BUF_INIT;
|
||||
int gitresult = git_message_prettify(&gitbuffer, gitmessage.constData(), 1, '#');
|
||||
if (gitresult != GIT_OK) {
|
||||
kWarning() << "Could not prettify message" << gitmessage << FileViewGitPlugin::getGitError();
|
||||
kWarning() << "Could not prettify message" << gitmessage << FileViewGitPlugin::getGitError(gitresult);
|
||||
return gitmessage;
|
||||
}
|
||||
const QByteArray gitprettymessage(gitbuffer.ptr, gitbuffer.size);
|
||||
|
|
Loading…
Add table
Reference in a new issue