From b71ad6b458bd30893743600ce93c80865c72884b Mon Sep 17 00:00:00 2001 From: Martin Marmsoler Date: Thu, 17 Nov 2022 11:37:59 +0100 Subject: [PATCH] format --- dep/CMakeLists.txt | 12 +++++++++--- dep/libgit2/CMakeLists.txt | 14 ++++++++++---- src/app/CMakeLists.txt | 8 +------- src/dialogs/SubmoduleTableModel.cpp | 3 ++- src/git/Buffer.cpp | 9 ++------- src/git/Buffer.h | 2 +- src/git/CMakeLists.txt | 10 ++++------ src/git/Diff.cpp | 4 ++-- src/git/Id.cpp | 2 +- src/git/Object.cpp | 3 +-- src/git/Patch.cpp | 7 ++++--- src/git/Remote.cpp | 10 ++++------ src/git/Remote.h | 8 +++----- src/git/Repository.cpp | 26 ++++++++++++++------------ src/git/Repository.h | 2 +- src/git/Submodule.cpp | 7 ++++--- src/git/Submodule.h | 3 ++- src/index/CMakeLists.txt | 10 +++++----- src/index/Index.cpp | 4 ++-- src/ui/RepoView.cpp | 17 +++++++++-------- 20 files changed, 81 insertions(+), 80 deletions(-) diff --git a/dep/CMakeLists.txt b/dep/CMakeLists.txt index 3d3a527ac..104d62caf 100644 --- a/dep/CMakeLists.txt +++ b/dep/CMakeLists.txt @@ -4,9 +4,15 @@ add_subdirectory(openssl) add_subdirectory(libssh2) add_subdirectory(libgit2) # otherwise the zlib is not available in the src/git -set(LIBGIT2_DEPENDENCY_OBJECTS ${LIBGIT2_DEPENDENCY_OBJECTS} PARENT_SCOPE) -set(LIBGIT2_SYSTEM_LIBS ${LIBGIT2_SYSTEM_LIBS} PARENT_SCOPE) -set(LIBGIT2_INCLUDES ${LIBGIT2_INCLUDES} PARENT_SCOPE) +set(LIBGIT2_DEPENDENCY_OBJECTS + ${LIBGIT2_DEPENDENCY_OBJECTS} + PARENT_SCOPE) +set(LIBGIT2_SYSTEM_LIBS + ${LIBGIT2_SYSTEM_LIBS} + PARENT_SCOPE) +set(LIBGIT2_INCLUDES + ${LIBGIT2_INCLUDES} + PARENT_SCOPE) add_subdirectory(cmark) add_subdirectory(lua) diff --git a/dep/libgit2/CMakeLists.txt b/dep/libgit2/CMakeLists.txt index 1e129d6f1..36bf8f350 100644 --- a/dep/libgit2/CMakeLists.txt +++ b/dep/libgit2/CMakeLists.txt @@ -34,8 +34,14 @@ endif() if(NOT USE_SYSTEM_LIBGIT2) add_subdirectory(libgit2) - # otherwise the zlib is not available in the src/git - set(LIBGIT2_DEPENDENCY_OBJECTS ${LIBGIT2_DEPENDENCY_OBJECTS} PARENT_SCOPE) - set(LIBGIT2_SYSTEM_LIBS ${LIBGIT2_SYSTEM_LIBS} PARENT_SCOPE) - set(LIBGIT2_INCLUDES ${LIBGIT2_INCLUDES} PARENT_SCOPE) + # otherwise the zlib is not available in the src/git + set(LIBGIT2_DEPENDENCY_OBJECTS + ${LIBGIT2_DEPENDENCY_OBJECTS} + PARENT_SCOPE) + set(LIBGIT2_SYSTEM_LIBS + ${LIBGIT2_SYSTEM_LIBS} + PARENT_SCOPE) + set(LIBGIT2_INCLUDES + ${LIBGIT2_INCLUDES} + PARENT_SCOPE) endif() diff --git a/src/app/CMakeLists.txt b/src/app/CMakeLists.txt index b5eec88b3..bc1e81128 100755 --- a/src/app/CMakeLists.txt +++ b/src/app/CMakeLists.txt @@ -63,13 +63,7 @@ target_compile_definitions( PRIVATE QT_TRANSLATIONS_DIR="${QT_TRANSLATIONS_DIR}" BUILD_DESCRIPTION="${BUILD_DESCRIPTION}") -target_link_libraries(app - conf - git - ui - update - Qt5::Widgets -) +target_link_libraries(app conf git ui update Qt5::Widgets) set_target_properties(app PROPERTIES AUTOMOC ON) diff --git a/src/dialogs/SubmoduleTableModel.cpp b/src/dialogs/SubmoduleTableModel.cpp index 61d08c524..3c9342f64 100644 --- a/src/dialogs/SubmoduleTableModel.cpp +++ b/src/dialogs/SubmoduleTableModel.cpp @@ -126,7 +126,8 @@ bool SubmoduleTableModel::setData(const QModelIndex &index, QMessageBox::Warning, tr("Deinitialize Submodule?"), text, QMessageBox::Cancel, qobject_cast(parent())); - if (GIT_SUBMODULE_STATUS_IS_WD_DIRTY(mRepo.submoduleStatus(submodule.name()))) + if (GIT_SUBMODULE_STATUS_IS_WD_DIRTY( + mRepo.submoduleStatus(submodule.name()))) mb->setInformativeText( tr("The submodule working directory contains uncommitted " "changes that will be lost if you continue.")); diff --git a/src/git/Buffer.cpp b/src/git/Buffer.cpp index 4a77b85bb..4bd8cff8e 100644 --- a/src/git/Buffer.cpp +++ b/src/git/Buffer.cpp @@ -12,13 +12,8 @@ namespace git { -Buffer::Buffer(const char *data, int size) - : data(data), size(size) -{} +Buffer::Buffer(const char *data, int size) : data(data), size(size) {} -bool Buffer::isBinary() const -{ - return git_blob_data_is_binary(data, size); -} +bool Buffer::isBinary() const { return git_blob_data_is_binary(data, size); } } // namespace git diff --git a/src/git/Buffer.h b/src/git/Buffer.h index 13eea87f0..77c69f174 100644 --- a/src/git/Buffer.h +++ b/src/git/Buffer.h @@ -19,7 +19,7 @@ class Buffer { bool isBinary() const; private: - const char* data; + const char *data; const int size; }; diff --git a/src/git/CMakeLists.txt b/src/git/CMakeLists.txt index 3c7c67359..2ae3cd049 100644 --- a/src/git/CMakeLists.txt +++ b/src/git/CMakeLists.txt @@ -27,19 +27,17 @@ add_library( TagRef.cpp Tree.cpp) -target_link_libraries(git +target_link_libraries( + git $ $ # util of libgit2 gittyupUtil ${LIBGIT2_DEPENDENCY_OBJECTS} ${LIBGIT2_SYSTEM_LIBS} Qt5::Core - Qt5::Network -) + Qt5::Network) # needed also by the plugin target so it must be public -target_include_directories(git PUBLIC - ${LIBGIT2_INCLUDES} - ) +target_include_directories(git PUBLIC ${LIBGIT2_INCLUDES}) set_target_properties(git PROPERTIES AUTOMOC ON) diff --git a/src/git/Diff.cpp b/src/git/Diff.cpp index 4af7ed404..332cc801e 100644 --- a/src/git/Diff.cpp +++ b/src/git/Diff.cpp @@ -108,10 +108,10 @@ QByteArray Diff::print() { QByteArray diff; for (auto file : data.files) { for (auto hunk : file.hunks) { - diff.append(hunk.header.toUtf8()); + diff.append(hunk.header.toUtf8()); for (auto line : hunk.lines) - diff.append(line.toUtf8()); + diff.append(line.toUtf8()); } } qDebug() << QString(diff); diff --git a/src/git/Id.cpp b/src/git/Id.cpp index 611afe3fc..cfb071fe0 100644 --- a/src/git/Id.cpp +++ b/src/git/Id.cpp @@ -31,7 +31,7 @@ Id::Id(const git_oid *id) { if (id) { git_oid_cpy(&d, id); } else { - memset(d.id, 0, GIT_OID_SHA1_SIZE); + memset(d.id, 0, GIT_OID_SHA1_SIZE); } } diff --git a/src/git/Object.cpp b/src/git/Object.cpp index b091d8210..5b9b861fa 100644 --- a/src/git/Object.cpp +++ b/src/git/Object.cpp @@ -25,8 +25,7 @@ git_object_t Object::type() const { return git_object_type(d.data()); } Id Object::id() const { return git_object_id(d.data()); } -QString Object::shortId() const -{ +QString Object::shortId() const { git_buf buf = GIT_BUF_INIT; git_object_short_id(&buf, d.data()); QByteArray result(buf.ptr, buf.size); diff --git a/src/git/Patch.cpp b/src/git/Patch.cpp index a4cd28b43..0c62a439a 100644 --- a/src/git/Patch.cpp +++ b/src/git/Patch.cpp @@ -324,9 +324,10 @@ QByteArray Patch::generateResult(QList> &image, if (!filters.isValid()) return result; - // Apply filters. - git_buf out = GIT_BUF_INIT; - git_filter_list_apply_to_buffer(&out, filters, result.data(), result.length()); + // Apply filters. + git_buf out = GIT_BUF_INIT; + git_filter_list_apply_to_buffer(&out, filters, result.data(), + result.length()); QByteArray filtered(out.ptr, out.size); git_buf_dispose(&out); diff --git a/src/git/Remote.cpp b/src/git/Remote.cpp index f118bc74d..d7b98682a 100644 --- a/src/git/Remote.cpp +++ b/src/git/Remote.cpp @@ -453,11 +453,8 @@ int Remote::Callbacks::update(const char *name, const git_oid *a, return 0; } -int Remote::Callbacks::remoteReady( - git_remote* remote, - int direction, - void *payload) -{ +int Remote::Callbacks::remoteReady(git_remote *remote, int direction, + void *payload) { Q_UNUSED(direction) Remote::Callbacks *cbs = reinterpret_cast(payload); @@ -617,7 +614,8 @@ Result Remote::clone(Callbacks *callbacks, const QString &url, git_repository *repo = nullptr; git_clone_options opts = GIT_CLONE_OPTIONS_INIT; opts.fetch_opts.callbacks.connected = &Remote::Callbacks::connected; - opts.fetch_opts.callbacks.about_to_disconnect = &Remote::Callbacks::about_to_disconnect; + opts.fetch_opts.callbacks.about_to_disconnect = + &Remote::Callbacks::about_to_disconnect; opts.fetch_opts.callbacks.sideband_progress = &Remote::Callbacks::sideband; opts.fetch_opts.callbacks.credentials = &Remote::Callbacks::credentials; opts.fetch_opts.callbacks.certificate_check = &Remote::Callbacks::certificate; diff --git a/src/git/Remote.h b/src/git/Remote.h index b6e1067e7..eacd3d0e7 100644 --- a/src/git/Remote.h +++ b/src/git/Remote.h @@ -93,9 +93,9 @@ class Remote { virtual bool connectToAgent() const { return false; } // static callback wrappers - static void connected(git_remote *remote, void *payload); + static void connected(git_remote *remote, void *payload); - static void about_to_disconnect(git_remote *remote, void *payload); + static void about_to_disconnect(git_remote *remote, void *payload); static int sideband(const char *str, int len, void *payload); @@ -110,9 +110,7 @@ class Remote { static int update(const char *name, const git_oid *a, const git_oid *b, void *payload); - static int remoteReady(git_remote *remote, - int direction, - void *payload); + static int remoteReady(git_remote *remote, int direction, void *payload); protected: // Try to stop the current remote. diff --git a/src/git/Repository.cpp b/src/git/Repository.cpp index 530c265b1..a00064ad7 100644 --- a/src/git/Repository.cpp +++ b/src/git/Repository.cpp @@ -167,8 +167,7 @@ Id Repository::workdirId(const QString &path) const { return id; } -QString Repository::message() const -{ +QString Repository::message() const { git_buf buf = GIT_BUF_INIT; git_repository_message(&buf, d->repo); return QString::fromUtf8(buf.ptr, buf.size); @@ -320,7 +319,9 @@ Diff Repository::diffIndexToWorkdir(const Index &index, Diff::Callbacks *callbacks, bool ignoreWhitespace) const { git_diff_options opts = GIT_DIFF_OPTIONS_INIT; - opts.flags |= (GIT_DIFF_INCLUDE_UNTRACKED | GIT_DIFF_RECURSE_UNTRACKED_DIRS | GIT_DIFF_INCLUDE_TYPECHANGE); // GIT_DIFF_DISABLE_MMAP flag really needed? + opts.flags |= (GIT_DIFF_INCLUDE_UNTRACKED | GIT_DIFF_RECURSE_UNTRACKED_DIRS | + GIT_DIFF_INCLUDE_TYPECHANGE); // GIT_DIFF_DISABLE_MMAP flag + // really needed? if (ignoreWhitespace) opts.flags |= GIT_DIFF_IGNORE_WHITESPACE; @@ -687,18 +688,19 @@ Submodule Repository::lookupSubmodule(const QString &name) const { return Submodule(submodule); } -int Repository::submoduleStatus(const QString& name) const { +int Repository::submoduleStatus(const QString &name) const { - unsigned int status; - // TODO: testing!!!! - int returnValue = git_submodule_status(&status, d->repo, name.toLocal8Bit().data(), GIT_SUBMODULE_IGNORE_UNSPECIFIED); - if (returnValue < 0) - return returnValue; - return status; + unsigned int status; + // TODO: testing!!!! + int returnValue = + git_submodule_status(&status, d->repo, name.toLocal8Bit().data(), + GIT_SUBMODULE_IGNORE_UNSPECIFIED); + if (returnValue < 0) + return returnValue; + return status; } -Remote Repository::addRemote(const QString &name, const QString &url) -{ +Remote Repository::addRemote(const QString &name, const QString &url) { // FIXME: Validate name? emit d->notifier->remoteAboutToBeAdded(name); diff --git a/src/git/Repository.h b/src/git/Repository.h index 662feba1a..74ad171d1 100644 --- a/src/git/Repository.h +++ b/src/git/Repository.h @@ -166,7 +166,7 @@ class Repository { void invalidateSubmoduleCache(); QList submodules() const; Submodule lookupSubmodule(const QString &path) const; - int submoduleStatus(const QString& name) const; + int submoduleStatus(const QString &name) const; // remote Remote addRemote(const QString &name, const QString &url); diff --git a/src/git/Submodule.cpp b/src/git/Submodule.cpp index c623d6dd8..ddc95b1a6 100644 --- a/src/git/Submodule.cpp +++ b/src/git/Submodule.cpp @@ -80,11 +80,12 @@ Id Submodule::indexId() const { return git_submodule_index_id(d.data()); } Id Submodule::workdirId() const { return git_submodule_wd_id(d.data()); } -Result Submodule::update(Remote::Callbacks *callbacks, bool init, bool checkout_force) -{ +Result Submodule::update(Remote::Callbacks *callbacks, bool init, + bool checkout_force) { git_submodule_update_options opts = GIT_SUBMODULE_UPDATE_OPTIONS_INIT; opts.fetch_opts.callbacks.connected = &Remote::Callbacks::connected; - opts.fetch_opts.callbacks.about_to_disconnect = &Remote::Callbacks::about_to_disconnect; + opts.fetch_opts.callbacks.about_to_disconnect = + &Remote::Callbacks::about_to_disconnect; opts.fetch_opts.callbacks.sideband_progress = &Remote::Callbacks::sideband; opts.fetch_opts.callbacks.credentials = &Remote::Callbacks::credentials; opts.fetch_opts.callbacks.certificate_check = &Remote::Callbacks::certificate; diff --git a/src/git/Submodule.h b/src/git/Submodule.h index 44205378d..82531c4e6 100644 --- a/src/git/Submodule.h +++ b/src/git/Submodule.h @@ -44,7 +44,8 @@ class Submodule { Id indexId() const; Id workdirId() const; - Result update(Remote::Callbacks *callbacks, bool init = false, bool checkout_force = false); + Result update(Remote::Callbacks *callbacks, bool init = false, + bool checkout_force = false); Repository open() const; diff --git a/src/index/CMakeLists.txt b/src/index/CMakeLists.txt index c7d2c50dc..ba275b5d6 100644 --- a/src/index/CMakeLists.txt +++ b/src/index/CMakeLists.txt @@ -12,12 +12,12 @@ target_link_libraries( set_target_properties(index PROPERTIES AUTOMOC ON) -if (BUILD_GITTYUP_TEST) - add_executable(lexer_test lexer_test.cpp) - target_link_libraries(lexer_test index) +if(BUILD_GITTYUP_TEST) + add_executable(lexer_test lexer_test.cpp) + target_link_libraries(lexer_test index) - add_executable(index_test index_test.cpp) - target_link_libraries(index_test index Qt5::Widgets) + add_executable(index_test index_test.cpp) + target_link_libraries(index_test index Qt5::Widgets) endif() add_executable(indexer indexer.cpp) diff --git a/src/index/Index.cpp b/src/index/Index.cpp index 39da8c7b6..b593cbc6a 100644 --- a/src/index/Index.cpp +++ b/src/index/Index.cpp @@ -67,7 +67,7 @@ void Index::reset() { QFile idFile(dir.filePath(kIdFile)); if (idFile.open(QIODevice::ReadOnly)) { while (idFile.bytesAvailable() > 0) - mIds.append(idFile.read(GIT_OID_SHA1)); + mIds.append(idFile.read(GIT_OID_SHA1)); } // Read dictionary. @@ -140,7 +140,7 @@ bool Index::write(PostingMap map) { // Write id file. foreach (const git::Id &id, mIds) - idFile.write(id.toByteArray(), GIT_OID_SHA1); + idFile.write(id.toByteArray(), GIT_OID_SHA1); // Merge new entries into existing postings file. // Write dictionary and postings files in lockstep. diff --git a/src/ui/RepoView.cpp b/src/ui/RepoView.cpp index a145fbbf5..e22a7ea59 100644 --- a/src/ui/RepoView.cpp +++ b/src/ui/RepoView.cpp @@ -1044,13 +1044,14 @@ QFuture RepoView::fetch(const git::Remote &rmt, bool tags, QtConcurrent::run([this, remote, tags, submodules, prune] { git::Result result = git::Remote(remote).fetch(mCallbacks, tags, prune); - if (result && submodules) { - // Scan for unmodified submodules on the fetch thread. - foreach (const git::Submodule &submodule, mRepo.submodules()) { - if (GIT_SUBMODULE_STATUS_IS_UNMODIFIED(mRepo.submoduleStatus(submodule.name()))) - submodules->append(submodule.name()); - } - } + if (result && submodules) { + // Scan for unmodified submodules on the fetch thread. + foreach (const git::Submodule &submodule, mRepo.submodules()) { + if (GIT_SUBMODULE_STATUS_IS_UNMODIFIED( + mRepo.submoduleStatus(submodule.name()))) + submodules->append(submodule.name()); + } + } return result; })); @@ -2362,7 +2363,7 @@ RepoView::submoduleResetInfoList(const git::Repository &repo, // Only reset modified submodules QList modules; foreach (const git::Submodule &submodule, submodules) { - int status = repo.submoduleStatus(submodule.name()); + int status = repo.submoduleStatus(submodule.name()); if (status & (GIT_SUBMODULE_STATUS_WD_MODIFIED | GIT_SUBMODULE_STATUS_WD_WD_MODIFIED |