diff --git a/gemini/cloud/git/checkoutcreator.cpp b/gemini/cloud/git/checkoutcreator.cpp index b6004b1..42e038e 100644 --- gemini/cloud/git/checkoutcreator.cpp +++ gemini/cloud/git/checkoutcreator.cpp @@ -243,7 +243,7 @@ QString CheckoutCreator::createClone(QString userVisibleName, QString url, QStri git_repository *repo = NULL; int error = git_clone(&repo, url.toLatin1(), checkoutLocation.toLatin1(), &clone_opts); - if(error != 0) { const git_error* err = giterr_last(); qDebug() << "Kapow, error code from git2 was" << error << "which is described as" << err->message; return QString(); } + if(error != 0) { const git_error* err = git_error_last(); qDebug() << "Kapow, error code from git2 was" << error << "which is described as" << err->message; return QString(); } return checkoutLocation; } diff --git a/gemini/cloud/git/gitcontroller.cpp b/gemini/cloud/git/gitcontroller.cpp index 9bbf058..8fc6984 100644 --- gemini/cloud/git/gitcontroller.cpp +++ gemini/cloud/git/gitcontroller.cpp @@ -168,75 +168,75 @@ void GitOpsThread::performPush() { git_repository* repository; int error = git_repository_open(&repository, QString("%1/.git").arg(d->gitDir).toLatin1()); - if(error != 0) { const git_error* err = giterr_last(); qDebug() << "Push 1, error code from git2 was" << error << "which is described as" << err->message; return; } + if(error != 0) { const git_error* err = git_error_last(); qDebug() << "Push 1, error code from git2 was" << error << "which is described as" << err->message; return; } // Get the current index git_index* index; error = git_repository_index(&index, repository); - if(error != 0) { const git_error* err = giterr_last(); qDebug() << "Push 2, error code from git2 was" << error << "which is described as" << err->message; return; } + if(error != 0) { const git_error* err = git_error_last(); qDebug() << "Push 2, error code from git2 was" << error << "which is described as" << err->message; return; } // refresh it, and add the file error = git_index_read(index, true); - if(error != 0) { const git_error* err = giterr_last(); qDebug() << "Push 3, error code from git2 was" << error << "which is described as" << err->message; return; } + if(error != 0) { const git_error* err = git_error_last(); qDebug() << "Push 3, error code from git2 was" << error << "which is described as" << err->message; return; } #ifdef Q_OS_WIN QString relative = d->currentFile.mid(d->gitDir.length() + 9); // That is, 1 for the leading slash, and 8 for the file:/// #else QString relative = d->currentFile.mid(d->gitDir.length() + 8); // That is, 1 for the leading slash, and 8 for the file:// #endif error = git_index_add_bypath(index, relative.toLocal8Bit()); - if(error != 0) { const git_error* err = giterr_last(); qDebug() << "Push 4, error code from git2 was" << error << "which is described as" << err->message; return; } + if(error != 0) { const git_error* err = git_error_last(); qDebug() << "Push 4, error code from git2 was" << error << "which is described as" << err->message; return; } error = git_index_write(index); - if(error != 0) { const git_error* err = giterr_last(); qDebug() << "Push 5, error code from git2 was" << error << "which is described as" << err->message; return; } + if(error != 0) { const git_error* err = git_error_last(); qDebug() << "Push 5, error code from git2 was" << error << "which is described as" << err->message; return; } // convert the index to a tree, so we can use that to create the commit git_tree* tree; git_oid tree_id; error = git_index_write_tree(&tree_id, index); - if(error != 0) { const git_error* err = giterr_last(); qDebug() << "Push 6, error code from git2 was" << error << "which is described as" << err->message; return; } + if(error != 0) { const git_error* err = git_error_last(); qDebug() << "Push 6, error code from git2 was" << error << "which is described as" << err->message; return; } error = git_tree_lookup(&tree, repository, &tree_id); - if(error != 0) { const git_error* err = giterr_last(); qDebug() << "Push 7, error code from git2 was" << error << "which is described as" << err->message; return; } + if(error != 0) { const git_error* err = git_error_last(); qDebug() << "Push 7, error code from git2 was" << error << "which is described as" << err->message; return; } // get where we want to parent things to git_oid obj; error = git_reference_name_to_id(&obj, repository, "HEAD"); - if(error != 0) { const git_error* err = giterr_last(); qDebug() << "Push 8, error code from git2 was" << error << "which is described as" << err->message; return; } + if(error != 0) { const git_error* err = git_error_last(); qDebug() << "Push 8, error code from git2 was" << error << "which is described as" << err->message; return; } git_commit *parent = NULL; error = git_commit_lookup(&parent, repository, &obj); - if(error != 0) { const git_error* err = giterr_last(); qDebug() << "Push 9, error code from git2 was" << error << "which is described as" << err->message; return; } + if(error != 0) { const git_error* err = git_error_last(); qDebug() << "Push 9, error code from git2 was" << error << "which is described as" << err->message; return; } // create the commit git_oid oid; error = git_commit_create_v(&oid, repository, "HEAD", d->signature, d->signature, "UTF-8", d->message.toLatin1(), tree, 1, parent); - if(error != 0) { const git_error* err = giterr_last(); qDebug() << "Push 10, error code from git2 was" << error << "which is described as" << err->message; return; } + if(error != 0) { const git_error* err = git_error_last(); qDebug() << "Push 10, error code from git2 was" << error << "which is described as" << err->message; return; } error = git_repository_state_cleanup(repository); - if(error != 0) { const git_error* err = giterr_last(); qDebug() << "Push 11, error code from git2 was" << error << "which is described as" << err->message; return; } + if(error != 0) { const git_error* err = git_error_last(); qDebug() << "Push 11, error code from git2 was" << error << "which is described as" << err->message; return; } // Find the current branch's upstream remote git_reference *current_branch; error = git_repository_head(¤t_branch, repository); - if(error != 0) { const git_error* err = giterr_last(); qDebug() << "Push 12, error code from git2 was" << error << "which is described as" << err->message; return; } + if(error != 0) { const git_error* err = git_error_last(); qDebug() << "Push 12, error code from git2 was" << error << "which is described as" << err->message; return; } git_reference *upstream; error = git_branch_upstream(&upstream, current_branch); - if(error != 0) { const git_error* err = giterr_last(); qDebug() << "Push 13, error code from git2 was" << error << "which is described as" << err->message; return; } + if(error != 0) { const git_error* err = git_error_last(); qDebug() << "Push 13, error code from git2 was" << error << "which is described as" << err->message; return; } // Now find the name of the remote git_buf remote_name = {0,0,0}; error = git_branch_remote_name(&remote_name, repository, git_reference_name(upstream)); - if(error != 0) { const git_error* err = giterr_last(); qDebug() << "Push 14, error code from git2 was" << error << "which is described as" << err->message; return; } + if(error != 0) { const git_error* err = git_error_last(); qDebug() << "Push 14, error code from git2 was" << error << "which is described as" << err->message; return; } QString remoteName = QString::fromUtf8(remote_name.ptr); - git_buf_free(&remote_name); + git_buf_dispose(&remote_name); // And the upstream and local branch names... const char *branch_name; error = git_branch_name(&branch_name, upstream); - if(error != 0) { const git_error* err = giterr_last(); qDebug() << "Push 15, error code from git2 was" << error << "which is described as" << err->message; return; } + if(error != 0) { const git_error* err = git_error_last(); qDebug() << "Push 15, error code from git2 was" << error << "which is described as" << err->message; return; } QString upstreamBranchName = QString::fromUtf8(branch_name); upstreamBranchName.remove(0, remoteName.length() + 1); error = git_branch_name(&branch_name, current_branch); - if(error != 0) { const git_error* err = giterr_last(); qDebug() << "Push 16, error code from git2 was" << error << "which is described as" << err->message; return; } + if(error != 0) { const git_error* err = git_error_last(); qDebug() << "Push 16, error code from git2 was" << error << "which is described as" << err->message; return; } QString branchName = QString::fromUtf8(branch_name); git_remote_callbacks remoteCallbacks = GIT_REMOTE_CALLBACKS_INIT; @@ -245,7 +245,7 @@ void GitOpsThread::performPush() remoteCallbacks.credentials = &Private::acquireCredentialsCallback; git_remote* remote; error = git_remote_lookup(&remote, repository, "origin"); - if(error != 0) { const git_error* err = giterr_last(); qDebug() << "Push 17, error code from git2 was" << error << "which is described as" << err->message; return; } + if(error != 0) { const git_error* err = git_error_last(); qDebug() << "Push 17, error code from git2 was" << error << "which is described as" << err->message; return; } char tempPath[512] = "refs/heads/"; char tempPath2[512] = "refs/heads/"; @@ -258,11 +258,11 @@ void GitOpsThread::performPush() git_push_options pushOptions; error = git_push_init_options(&pushOptions, GIT_PUSH_OPTIONS_VERSION); - if(error != 0) { const git_error* err = giterr_last(); qDebug() << "Push 18, error code from git2 was" << error << "which is described as" << err->message; return; } + if(error != 0) { const git_error* err = git_error_last(); qDebug() << "Push 18, error code from git2 was" << error << "which is described as" << err->message; return; } pushOptions.callbacks = remoteCallbacks; error = git_remote_push(remote, &uploadrefs, &pushOptions); - if(error != 0) { const git_error* err = giterr_last(); qDebug() << "Push 19, error code from git2 was" << error << "which is described as" << err->message; return; } + if(error != 0) { const git_error* err = git_error_last(); qDebug() << "Push 19, error code from git2 was" << error << "which is described as" << err->message; return; } emit pushCompleted(); } @@ -271,21 +271,21 @@ void GitOpsThread::performPull() { git_repository* repository; int error = git_repository_open(&repository, QString("%1/.git").arg(d->gitDir).toLatin1()); - if(error != 0) { const git_error* err = giterr_last(); qDebug() << "Kapow, error code from git2 was" << error << "which is described as" << err->message; return; } + if(error != 0) { const git_error* err = git_error_last(); qDebug() << "Kapow, error code from git2 was" << error << "which is described as" << err->message; return; } // Find the current branch's upstream remote git_reference *current_branch; error = git_repository_head(¤t_branch, repository); - if(error != 0) { const git_error* err = giterr_last(); qDebug() << "Kapow, error code from git2 was" << error << "which is described as" << err->message; return; } + if(error != 0) { const git_error* err = git_error_last(); qDebug() << "Kapow, error code from git2 was" << error << "which is described as" << err->message; return; } git_reference *upstream; error = git_branch_upstream(&upstream, current_branch); - if(error != 0) { const git_error* err = giterr_last(); qDebug() << "Kapow, error code from git2 was" << error << "which is described as" << err->message; return; } + if(error != 0) { const git_error* err = git_error_last(); qDebug() << "Kapow, error code from git2 was" << error << "which is described as" << err->message; return; } // Now find the name of the remote git_buf remote_name = {0,0,0}; error = git_branch_remote_name(&remote_name, repository, git_reference_name(upstream)); - if(error != 0) { const git_error* err = giterr_last(); qDebug() << "Kapow, error code from git2 was" << error << "which is described as" << err->message; return; } + if(error != 0) { const git_error* err = git_error_last(); qDebug() << "Kapow, error code from git2 was" << error << "which is described as" << err->message; return; } // Finally set the credentials on it that we're given, and fetch it git_remote_callbacks remoteCallbacks = GIT_REMOTE_CALLBACKS_INIT; @@ -294,15 +294,15 @@ void GitOpsThread::performPull() remoteCallbacks.credentials = &Private::acquireCredentialsCallback; git_remote* remote; error = git_remote_lookup(&remote, repository, remote_name.ptr); - git_buf_free(&remote_name); - if(error != 0) { const git_error* err = giterr_last(); qDebug() << "Kapow, error code from git2 was" << error << "which is described as" << err->message; return; } + git_buf_dispose(&remote_name); + if(error != 0) { const git_error* err = git_error_last(); qDebug() << "Kapow, error code from git2 was" << error << "which is described as" << err->message; return; } git_fetch_options fetch_options = GIT_FETCH_OPTIONS_INIT; fetch_options.callbacks = remoteCallbacks; error = git_remote_fetch(remote, NULL, &fetch_options, NULL); - if(error != 0) { const git_error* err = giterr_last(); qDebug() << "Kapow, error code from git2 was" << error << "which is described as" << err->message; return; } + if(error != 0) { const git_error* err = git_error_last(); qDebug() << "Kapow, error code from git2 was" << error << "which is described as" << err->message; return; } error = git_branch_upstream(&upstream, current_branch); - if(error != 0) { const git_error* err = giterr_last(); qDebug() << "Kapow, error code from git2 was" << error << "which is described as" << err->message; return; } + if(error != 0) { const git_error* err = git_error_last(); qDebug() << "Kapow, error code from git2 was" << error << "which is described as" << err->message; return; } // Let's check and see what sort of merge we should be doing... git_merge_analysis_t analysis; @@ -480,19 +480,19 @@ public: { git_config* configActual; int error = git_config_open_default(&configActual); - if(error != 0) { const git_error* err = giterr_last(); qDebug() << "Kapow, error code from git2 was" << error << "which is described as" << err->message; return false; } + if(error != 0) { const git_error* err = git_error_last(); qDebug() << "Kapow, error code from git2 was" << error << "which is described as" << err->message; return false; } git_config* config; error = git_config_snapshot(&config, configActual); - if(error != 0) { const git_error* err = giterr_last(); qDebug() << "Kapow, error code from git2 was" << error << "which is described as" << err->message; return false; } + if(error != 0) { const git_error* err = git_error_last(); qDebug() << "Kapow, error code from git2 was" << error << "which is described as" << err->message; return false; } const char* name; error = git_config_get_string(&name, config, "user.name"); - if(error != 0) { const git_error* err = giterr_last(); qDebug() << "Kapow, error code from git2 was" << error << "which is described as" << err->message; return false; } + if(error != 0) { const git_error* err = git_error_last(); qDebug() << "Kapow, error code from git2 was" << error << "which is described as" << err->message; return false; } const char* email; error = git_config_get_string(&email, config, "user.email"); - if(error != 0) { const git_error* err = giterr_last(); qDebug() << "Kapow, error code from git2 was" << error << "which is described as" << err->message; return false; } + if(error != 0) { const git_error* err = git_error_last(); qDebug() << "Kapow, error code from git2 was" << error << "which is described as" << err->message; return false; } userName = QString::fromLocal8Bit(name); userEmail = QString::fromLocal8Bit(email); @@ -512,7 +512,7 @@ public: } userName = newName; error = git_config_set_string(config, "user.name", newName.toLocal8Bit()); - if(error != 0) { const git_error* err = giterr_last(); qDebug() << "Kapow, error code from git2 was" << error << "which is described as" << err->message; return false; } + if(error != 0) { const git_error* err = git_error_last(); qDebug() << "Kapow, error code from git2 was" << error << "which is described as" << err->message; return false; } } if(userEmail.isEmpty()) { bool ok; @@ -529,7 +529,7 @@ public: } userEmail = newEmail; error = git_config_set_string(config, "user.email", newEmail.toLocal8Bit()); - if(error != 0) { const git_error* err = giterr_last(); qDebug() << "Kapow, error code from git2 was" << error << "which is described as" << err->message; return false; } + if(error != 0) { const git_error* err = git_error_last(); qDebug() << "Kapow, error code from git2 was" << error << "which is described as" << err->message; return false; } } git_config_free(config); @@ -538,7 +538,7 @@ public: return false; } error = git_signature_now(&signature, userName.toLocal8Bit(), userEmail.toLocal8Bit()); - if(error != 0) { const git_error* err = giterr_last(); qDebug() << "Kapow, error code from git2 was" << error << "which is described as" << err->message; return false; } + if(error != 0) { const git_error* err = git_error_last(); qDebug() << "Kapow, error code from git2 was" << error << "which is described as" << err->message; return false; } return true; } diff --git a/gemini/cloud/git/gitlogmodel.cpp b/gemini/cloud/git/gitlogmodel.cpp index 7496519..d29c91c 100644 --- gemini/cloud/git/gitlogmodel.cpp +++ gemini/cloud/git/gitlogmodel.cpp @@ -134,19 +134,19 @@ void GitLogModel::refreshLog() git_repository* repository; int error = git_repository_open(&repository, QString("%1/.git").arg(d->repoDir).toLatin1()); - if(error != 0) { const git_error* err = giterr_last(); qDebug() << "Kapow, error code from git2 was" << error << "which is described as" << err->message; return; } + if(error != 0) { const git_error* err = git_error_last(); qDebug() << "Kapow, error code from git2 was" << error << "which is described as" << err->message; return; } git_revwalk *walker; error = git_revwalk_new(&walker, repository); - if(error != 0) { const git_error* err = giterr_last(); qDebug() << "Kapow, error code from git2 was" << error << "which is described as" << err->message; return; } + if(error != 0) { const git_error* err = git_error_last(); qDebug() << "Kapow, error code from git2 was" << error << "which is described as" << err->message; return; } error = git_revwalk_push_range(walker, "HEAD~100..HEAD"); - if(error != 0) { const git_error* err = giterr_last(); qDebug() << "Kapow, error code from git2 was" << error << "which is described as" << err->message; return; } + if(error != 0) { const git_error* err = git_error_last(); qDebug() << "Kapow, error code from git2 was" << error << "which is described as" << err->message; return; } git_oid oid; git_commit *commit = NULL; while (git_revwalk_next(&oid, walker) == 0) { error = git_commit_lookup(&commit, repository, &oid); - if(error != 0) { const git_error* err = giterr_last(); qDebug() << "Kapow, error code from git2 was" << error << "which is described as" << err->message; return; } + if(error != 0) { const git_error* err = git_error_last(); qDebug() << "Kapow, error code from git2 was" << error << "which is described as" << err->message; return; } const git_signature *author = git_commit_author(commit);