From 048980a97bf703ca8dbfbeba070619d4e3222463 Mon Sep 17 00:00:00 2001 From: Martin Marmsoler Date: Wed, 7 Sep 2022 09:43:06 +0200 Subject: [PATCH 01/40] Reason: --- .gitignore | 1 + .gitmodules | 2 +- dep/CMakeLists.txt | 4 ++ dep/git/git | 2 +- dep/libgit2/CMakeLists.txt | 6 ++- dep/libgit2/libgit2 | 2 +- dep/libgit2/rebaseGittyupLibgit2.sh | 27 +++++++++++ dep/openssl/openssl | 2 +- src/dialogs/SubmoduleTableModel.cpp | 2 +- src/git/Branch.cpp | 2 +- src/git/Buffer.cpp | 9 +++- src/git/Buffer.h | 5 +- src/git/CMakeLists.txt | 15 +++++- src/git/Config.cpp | 4 +- src/git/Filter.cpp | 72 ++++++++++++++++------------- src/git/Id.cpp | 8 ++-- src/git/Object.cpp | 5 +- src/git/Patch.cpp | 8 ++-- src/git/Remote.cpp | 35 +++++++------- src/git/Remote.h | 8 ++-- src/git/Repository.cpp | 20 ++++++-- src/git/Repository.h | 1 + src/git/Submodule.cpp | 18 ++------ src/git/Submodule.h | 11 +---- src/index/CMakeLists.txt | 10 ++-- src/index/Index.cpp | 4 +- src/ui/RepoView.cpp | 16 +++---- test/dep/zip | 2 +- 28 files changed, 180 insertions(+), 121 deletions(-) create mode 100644 dep/libgit2/rebaseGittyupLibgit2.sh diff --git a/.gitignore b/.gitignore index ca6f9e259..0c9af2b06 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,7 @@ build .vscode/ CMakeLists.txt.user cmake-build-debug/ +build* cmake-build-release/ build .idea/ diff --git a/.gitmodules b/.gitmodules index 2ee39c1a4..c04026aee 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,6 +1,6 @@ [submodule "dep/libgit2/libgit2"] path = dep/libgit2/libgit2 - url = https://github.com/stinb/libgit2.git + url = https://github.com/Murmele/libgit2.git [submodule "dep/libssh2/libssh2"] path = dep/libssh2/libssh2 url = https://github.com/libssh2/libssh2.git diff --git a/dep/CMakeLists.txt b/dep/CMakeLists.txt index 54cb4ae42..3d3a527ac 100644 --- a/dep/CMakeLists.txt +++ b/dep/CMakeLists.txt @@ -3,6 +3,10 @@ find_package(PkgConfig) 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) add_subdirectory(cmark) add_subdirectory(lua) diff --git a/dep/git/git b/dep/git/git index 4c53a8c20..61a22ddaf 160000 --- a/dep/git/git +++ b/dep/git/git @@ -1 +1 @@ -Subproject commit 4c53a8c20f8984adb226293a3ffd7b88c3f4ac1a +Subproject commit 61a22ddaf0626111193a17ac12f366bd6d167dff diff --git a/dep/libgit2/CMakeLists.txt b/dep/libgit2/CMakeLists.txt index dc3a232d6..c8c48896e 100644 --- a/dep/libgit2/CMakeLists.txt +++ b/dep/libgit2/CMakeLists.txt @@ -36,4 +36,8 @@ if(NOT USE_SYSTEM_LIBGIT2) add_subdirectory(libgit2) target_include_directories( git2 INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/libgit2/include) -endif() +# 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() \ No newline at end of file diff --git a/dep/libgit2/libgit2 b/dep/libgit2/libgit2 index 7861f401e..59e41acbc 160000 --- a/dep/libgit2/libgit2 +++ b/dep/libgit2/libgit2 @@ -1 +1 @@ -Subproject commit 7861f401ea25e1ceaf7323c1585de4d633e0ec39 +Subproject commit 59e41acbcc7993ae9013f2729d60437ec56f9ed8 diff --git a/dep/libgit2/rebaseGittyupLibgit2.sh b/dep/libgit2/rebaseGittyupLibgit2.sh new file mode 100644 index 000000000..f9d08a0c5 --- /dev/null +++ b/dep/libgit2/rebaseGittyupLibgit2.sh @@ -0,0 +1,27 @@ +declare -a branches=("fetch_annotated_tags" "blame_abort" "disableRenameDetection" "checkout_deletion_notification" "diff_checkout" "fix_push_callback_issues" "disable_mmap" "context_line_accessor´" "disableRenameDetection" "submodule" "hash" "callback_connect_disconnect" "blame_buffer" "libgit2_includes_public") + +cd libgit2 + +git remote remove origin +git remote remove upstream +git remote add origin https://github.com/Murmele/libgit2.git +git remote add upstream https://github.com/libgit2/libgit2.git + +git fetch --all + +for branch in ${branches[@]}; do + echo $branch + git checkout -B $branch "origin/$branch" + git rebase upstream/main +done + +git checkout Gittyup +git reset --hard upstream/main + +for branch in ${branches[@]}; do + git merge --no-edit $branch +done + +git push --force origin + +echo "Script finished. Check if all branches are rebased correctly and push them to origin!" diff --git a/dep/openssl/openssl b/dep/openssl/openssl index 3f499b24f..29708a562 160000 --- a/dep/openssl/openssl +++ b/dep/openssl/openssl @@ -1 +1 @@ -Subproject commit 3f499b24f3bcd66db022074f7e8b4f6ee266a3ae +Subproject commit 29708a562a1887a91de0fa6ca668c71871accde9 diff --git a/src/dialogs/SubmoduleTableModel.cpp b/src/dialogs/SubmoduleTableModel.cpp index ea3df094a..61d08c524 100644 --- a/src/dialogs/SubmoduleTableModel.cpp +++ b/src/dialogs/SubmoduleTableModel.cpp @@ -126,7 +126,7 @@ bool SubmoduleTableModel::setData(const QModelIndex &index, QMessageBox::Warning, tr("Deinitialize Submodule?"), text, QMessageBox::Cancel, qobject_cast(parent())); - if (GIT_SUBMODULE_STATUS_IS_WD_DIRTY(submodule.status())) + 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/Branch.cpp b/src/git/Branch.cpp index 68e5cd0f6..360ea5336 100644 --- a/src/git/Branch.cpp +++ b/src/git/Branch.cpp @@ -83,7 +83,7 @@ Remote Branch::remote() const { return up.isValid() ? up.remote() : Remote(); } - git_buf buf = GIT_BUF_INIT_CONST(nullptr, 0); + git_buf buf = GIT_BUF_INIT; git_repository *repo = git_reference_owner(d.data()); if (git_branch_remote_name(&buf, repo, qualifiedName().toUtf8())) return Remote(); diff --git a/src/git/Buffer.cpp b/src/git/Buffer.cpp index 6b1f4fc02..4a77b85bb 100644 --- a/src/git/Buffer.cpp +++ b/src/git/Buffer.cpp @@ -8,12 +8,17 @@ // #include "Buffer.h" +#include "git2/blob.h" namespace git { Buffer::Buffer(const char *data, int size) - : d(GIT_BUF_INIT_CONST(data, size)) {} + : data(data), size(size) +{} -bool Buffer::isBinary() const { return git_buf_is_binary(&d); } +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 45c00c124..13eea87f0 100644 --- a/src/git/Buffer.h +++ b/src/git/Buffer.h @@ -10,8 +10,6 @@ #ifndef BUFFER_H #define BUFFER_H -#include "git2/buffer.h" - namespace git { class Buffer { @@ -21,7 +19,8 @@ class Buffer { bool isBinary() const; private: - git_buf d; + const char* data; + const int size; }; } // namespace git diff --git a/src/git/CMakeLists.txt b/src/git/CMakeLists.txt index c9553149b..5b772cf89 100644 --- a/src/git/CMakeLists.txt +++ b/src/git/CMakeLists.txt @@ -27,6 +27,19 @@ add_library( TagRef.cpp Tree.cpp) -target_link_libraries(git git2 Qt5::Core Qt5::Network util) +target_link_libraries(git + git2 + ${LIBGIT2_DEPENDENCY_OBJECTS} + ${LIBGIT2_SYSTEM_LIBS} + $ + $ + Qt5::Core + Qt5::Network +) + +# needed also by the plugin target so it must be public +target_include_directories(git PUBLIC + ${LIBGIT2_INCLUDES} + ) set_target_properties(git PROPERTIES AUTOMOC ON) diff --git a/src/git/Config.cpp b/src/git/Config.cpp index 8f4e7cd98..eaf9eb711 100644 --- a/src/git/Config.cpp +++ b/src/git/Config.cpp @@ -102,7 +102,7 @@ QString Config::value(const QString &key, return defaultValue; } - git_buf buf = GIT_BUF_INIT_CONST(nullptr, 0); + git_buf buf = GIT_BUF_INIT; git_config_get_string_buf(&buf, d.data(), key.toUtf8()); QString value = QString::fromUtf8(buf.ptr, buf.size); git_buf_dispose(&buf); @@ -182,7 +182,7 @@ QString Config::globalPath() { config.remove("global.force"); } - git_buf buf = GIT_BUF_INIT_CONST(nullptr, 0); + git_buf buf = GIT_BUF_INIT; git_config_find_global(&buf); QString path = QString::fromUtf8(buf.ptr, buf.size); git_buf_dispose(&buf); diff --git a/src/git/Filter.cpp b/src/git/Filter.cpp index cfa03d8d5..7da37c772 100644 --- a/src/git/Filter.cpp +++ b/src/git/Filter.cpp @@ -38,38 +38,44 @@ struct FilterInfo { QString quote(const QString &path) { return QString("\"%1\"").arg(path); } -int apply(git_filter *self, void **payload, git_buf *to, const git_buf *from, - const git_filter_source *src) { - FilterInfo *info = reinterpret_cast(self); - git_filter_mode_t mode = git_filter_source_mode(src); - QString command = (mode == GIT_FILTER_SMUDGE) ? info->smudge : info->clean; - - // Substitute path. - command.replace("%f", quote(git_filter_source_path(src))); - - QString bash = Command::bashPath(); - if (bash.isEmpty()) - return info->required ? GIT_EUSER : GIT_PASSTHROUGH; - - QProcess process; - git_repository *repo = git_filter_source_repo(src); - process.setWorkingDirectory(git_repository_workdir(repo)); - - process.start(bash, {"-c", command}); - if (!process.waitForStarted()) - return info->required ? GIT_EUSER : GIT_PASSTHROUGH; - - process.write(from->ptr, from->size); - process.closeWriteChannel(); - - if (!process.waitForFinished() || process.exitCode()) { - git_error_set_str(GIT_ERROR_FILTER, process.readAllStandardError()); - return info->required ? GIT_EUSER : GIT_PASSTHROUGH; - } - - QByteArray data = process.readAll(); - git_buf_set(to, data.constData(), data.length()); - return 0; +int stream( + git_writestream **out, + git_filter *self, + void **payload, + const git_filter_source *src, + git_writestream *next) +{ + return -1; +// FilterInfo *info = reinterpret_cast(self); +// git_filter_mode_t mode = git_filter_source_mode(src); +// QString command = (mode == GIT_FILTER_SMUDGE) ? info->smudge : info->clean; + +// // Substitute path. +// command.replace("%f", quote(git_filter_source_path(src))); + +// QString bash = Command::bashPath(); +// if (bash.isEmpty()) +// return info->required ? GIT_EUSER : GIT_PASSTHROUGH; + +// QProcess process; +// git_repository *repo = git_filter_source_repo(src); +// process.setWorkingDirectory(git_repository_workdir(repo)); + +// process.start(bash, {"-c", command}); +// if (!process.waitForStarted()) +// return info->required ? GIT_EUSER : GIT_PASSTHROUGH; + +// process.write(from->ptr, from->size); +// process.closeWriteChannel(); + +// if (!process.waitForFinished() || process.exitCode()) { +// git_error_set_str(GIT_ERROR_FILTER, process.readAllStandardError()); +// return info->required ? GIT_EUSER : GIT_PASSTHROUGH; +// } + +// QByteArray data = process.readAll(); +// git_buf_set(to, data.constData(), data.length()); +// return 0; } } // namespace @@ -101,7 +107,7 @@ void Filter::init() { info.name = key.toUtf8(); info.attributes = kFilterFmt.arg(key).toUtf8(); - info.filter.apply = &apply; + info.filter.stream = &stream; info.filter.attributes = info.attributes.constData(); git_filter_register(info.name.constData(), &info.filter, GIT_FILTER_DRIVER_PRIORITY); diff --git a/src/git/Id.cpp b/src/git/Id.cpp index 97de9472a..611afe3fc 100644 --- a/src/git/Id.cpp +++ b/src/git/Id.cpp @@ -15,11 +15,11 @@ namespace git { namespace { -const Id kInvalidId = QByteArray(GIT_OID_RAWSZ, -1); +const Id kInvalidId = QByteArray(GIT_OID_SHA1_SIZE, -1); } // namespace -Id::Id() { memset(d.id, 0, GIT_OID_RAWSZ); } +Id::Id() { memset(d.id, 0, GIT_OID_SHA1_SIZE); } Id::Id(const QByteArray &id) { git_oid_fromraw(&d, reinterpret_cast(id.constData())); @@ -31,7 +31,7 @@ Id::Id(const git_oid *id) { if (id) { git_oid_cpy(&d, id); } else { - memset(d.id, 0, GIT_OID_RAWSZ); + memset(d.id, 0, GIT_OID_SHA1_SIZE); } } @@ -45,7 +45,7 @@ QString Id::toString() const { return toByteArray().toHex(); } QByteArray Id::toByteArray() const { const char *data = reinterpret_cast(d.id); - return QByteArray::fromRawData(data, GIT_OID_RAWSZ); + return QByteArray::fromRawData(data, GIT_OID_SHA1_SIZE); } bool Id::operator<(const Id &rhs) const { return (git_oid_cmp(&d, rhs) < 0); } diff --git a/src/git/Object.cpp b/src/git/Object.cpp index d7344ae3f..b091d8210 100644 --- a/src/git/Object.cpp +++ b/src/git/Object.cpp @@ -25,8 +25,9 @@ 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 { - git_buf buf = GIT_BUF_INIT_CONST(0, 0); +QString Object::shortId() const +{ + git_buf buf = GIT_BUF_INIT; git_object_short_id(&buf, d.data()); QByteArray result(buf.ptr, buf.size); git_buf_dispose(&buf); diff --git a/src/git/Patch.cpp b/src/git/Patch.cpp index 913104e4c..e00288491 100644 --- a/src/git/Patch.cpp +++ b/src/git/Patch.cpp @@ -325,11 +325,9 @@ QByteArray Patch::generateResult(QList> &image, if (!filters.isValid()) return result; - // Apply filters. - git_buf out = GIT_BUF_INIT_CONST(nullptr, 0); - git_buf raw = GIT_BUF_INIT_CONST(result.constData(), result.length()); - (&out, filters, &raw); - git_buf_dispose(&raw); + // 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 dfd1013ba..487ed82d4 100644 --- a/src/git/Remote.cpp +++ b/src/git/Remote.cpp @@ -243,18 +243,16 @@ class ConfigFile { } // namespace -int Remote::Callbacks::connect(git_remote *remote, void *payload) { +void Remote::Callbacks::connected(git_remote *remote, void *payload) { Remote::Callbacks *cbs = reinterpret_cast(payload); cbs->mRemote = remote; - return 0; } -int Remote::Callbacks::disconnect(git_remote *remote, void *payload) { +void Remote::Callbacks::about_to_disconnect(git_remote *remote, void *payload) { Q_UNUSED(remote) Remote::Callbacks *cbs = reinterpret_cast(payload); cbs->mRemote = nullptr; - return 0; } int Remote::Callbacks::sideband(const char *str, int len, void *payload) { @@ -457,12 +455,15 @@ int Remote::Callbacks::update(const char *name, const git_oid *a, return 0; } -int Remote::Callbacks::url(git_buf *out, const char *url, int direction, - void *payload) { +int Remote::Callbacks::remoteReady( + git_remote* remote, + int direction, + void *payload) +{ Q_UNUSED(direction) Remote::Callbacks *cbs = reinterpret_cast(payload); - QString resolved(url); + QString resolved(git_remote_url(remote)); if (!cbs->url(resolved)) return -1; @@ -494,7 +495,7 @@ int Remote::Callbacks::url(git_buf *out, const char *url, int direction, } resolved = resolvedUrl.toString(); - git_buf_set(out, resolved.toUtf8(), resolved.length()); + git_remote_set_instance_url(remote, resolved.toUtf8()); return 0; } @@ -532,14 +533,14 @@ void Remote::setUrl(const QString &url) { Result Remote::fetch(Callbacks *callbacks, bool tags, bool prune) { git_fetch_options opts = GIT_FETCH_OPTIONS_INIT; - opts.callbacks.connect = &Remote::Callbacks::connect; - opts.callbacks.disconnect = &Remote::Callbacks::disconnect; + opts.callbacks.connected = &Remote::Callbacks::connected; + opts.callbacks.about_to_disconnect = &Remote::Callbacks::about_to_disconnect; opts.callbacks.sideband_progress = &Remote::Callbacks::sideband; opts.callbacks.credentials = &Remote::Callbacks::credentials; opts.callbacks.certificate_check = &Remote::Callbacks::certificate; opts.callbacks.transfer_progress = &Remote::Callbacks::transfer; opts.callbacks.update_tips = &Remote::Callbacks::update; - opts.callbacks.resolve_url = &Remote::Callbacks::url; + opts.callbacks.remote_ready = &Remote::Callbacks::remoteReady; opts.callbacks.payload = callbacks; QByteArray proxy = proxyUrl(url(), opts.proxy_opts.type); @@ -559,14 +560,14 @@ Result Remote::fetch(Callbacks *callbacks, bool tags, bool prune) { Result Remote::push(Callbacks *callbacks, const QStringList &refspecs) { git_push_options opts = GIT_PUSH_OPTIONS_INIT; - opts.callbacks.connect = &Remote::Callbacks::connect; - opts.callbacks.disconnect = &Remote::Callbacks::disconnect; + opts.callbacks.connected = &Remote::Callbacks::connected; + opts.callbacks.about_to_disconnect = &Remote::Callbacks::about_to_disconnect; opts.callbacks.sideband_progress = &Remote::Callbacks::sideband; opts.callbacks.credentials = &Remote::Callbacks::credentials; opts.callbacks.certificate_check = &Remote::Callbacks::certificate; opts.callbacks.transfer_progress = &Remote::Callbacks::transfer; opts.callbacks.update_tips = &Remote::Callbacks::update; - opts.callbacks.resolve_url = &Remote::Callbacks::url; + opts.callbacks.remote_ready = &Remote::Callbacks::remoteReady; opts.callbacks.pack_progress = &pack_progress; opts.callbacks.push_transfer_progress = &push_transfer_progress; opts.callbacks.push_update_reference = &push_update_reference; @@ -617,14 +618,14 @@ Result Remote::clone(Callbacks *callbacks, const QString &url, const QString &path, bool bare) { git_repository *repo = nullptr; git_clone_options opts = GIT_CLONE_OPTIONS_INIT; - opts.fetch_opts.callbacks.connect = &Remote::Callbacks::connect; - opts.fetch_opts.callbacks.disconnect = &Remote::Callbacks::disconnect; + opts.fetch_opts.callbacks.connected = &Remote::Callbacks::connected; + 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; opts.fetch_opts.callbacks.transfer_progress = &Remote::Callbacks::transfer; opts.fetch_opts.callbacks.update_tips = &Remote::Callbacks::update; - opts.fetch_opts.callbacks.resolve_url = &Remote::Callbacks::url; + opts.fetch_opts.callbacks.remote_ready = &Remote::Callbacks::remoteReady; opts.fetch_opts.callbacks.payload = callbacks; opts.bare = bare; diff --git a/src/git/Remote.h b/src/git/Remote.h index 953c31a2d..d8e82cdf6 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 int connect(git_remote *remote, void *payload); + static void connected(git_remote *remote, void *payload); - static int 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,7 +110,9 @@ class Remote { static int update(const char *name, const git_oid *a, const git_oid *b, void *payload); - static int url(git_buf *out, const char *url, 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 3004501d2..4fe259bb4 100644 --- a/src/git/Repository.cpp +++ b/src/git/Repository.cpp @@ -175,8 +175,9 @@ Id Repository::workdirId(const QString &path) const { return id; } -QString Repository::message() const { - git_buf buf = GIT_BUF_INIT_CONST(nullptr, 0); +QString Repository::message() const +{ + git_buf buf = GIT_BUF_INIT; git_repository_message(&buf, d->repo); return QString::fromUtf8(buf.ptr, buf.size); } @@ -334,7 +335,7 @@ Diff Repository::diffIndexToWorkdir(const Index &index, Diff::Callbacks *callbacks, bool ignoreWhitespace) const { git_diff_options opts = GIT_DIFF_OPTIONS_INIT; - opts.flags |= (GIT_DIFF_DISABLE_MMAP | GIT_DIFF_INCLUDE_TYPECHANGE); + opts.flags |= GIT_DIFF_INCLUDE_TYPECHANGE; // GIT_DIFF_DISABLE_MMAP flag really needed? if (!appConfig().value("untracked.hide", false)) opts.flags |= GIT_DIFF_INCLUDE_UNTRACKED | GIT_DIFF_RECURSE_UNTRACKED_DIRS; @@ -706,7 +707,18 @@ Submodule Repository::lookupSubmodule(const QString &name) const { return Submodule(submodule); } -Remote Repository::addRemote(const QString &name, const QString &url) { +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; +} + +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 0abb27794..e4f102f79 100644 --- a/src/git/Repository.h +++ b/src/git/Repository.h @@ -166,6 +166,7 @@ class Repository { void invalidateSubmoduleCache(); QList submodules() const; Submodule lookupSubmodule(const QString &path) 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 f31e642c4..35d05329a 100644 --- a/src/git/Submodule.cpp +++ b/src/git/Submodule.cpp @@ -80,25 +80,17 @@ Id Submodule::indexId() const { return git_submodule_index_id(d.data()); } Id Submodule::workdirId() const { return git_submodule_wd_id(d.data()); } -int Submodule::status() const { - unsigned int status = 0; - if (git_submodule_status(&status, d.data(), GIT_SUBMODULE_IGNORE_UNSPECIFIED)) - return -1; - - return status; -} - -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.connect = &Remote::Callbacks::connect; - opts.fetch_opts.callbacks.disconnect = &Remote::Callbacks::disconnect; + opts.fetch_opts.callbacks.connected = &Remote::Callbacks::connected; + 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; opts.fetch_opts.callbacks.transfer_progress = &Remote::Callbacks::transfer; opts.fetch_opts.callbacks.update_tips = &Remote::Callbacks::update; - opts.fetch_opts.callbacks.resolve_url = &Remote::Callbacks::url; + opts.fetch_opts.callbacks.remote_ready = &Remote::Callbacks::remoteReady; opts.fetch_opts.callbacks.payload = callbacks; if (checkout_force) diff --git a/src/git/Submodule.h b/src/git/Submodule.h index 71eda035b..44205378d 100644 --- a/src/git/Submodule.h +++ b/src/git/Submodule.h @@ -44,16 +44,7 @@ class Submodule { Id indexId() const; Id workdirId() const; - /*! - * \brief status - * Return the status of the submodule as a combination of flags described in - * https://libgit2.org/libgit2/index.html#HEAD/type/git_submodule_status_t - * \return current status - */ - int status() 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 26b911754..e9ab0385a 100644 --- a/src/index/CMakeLists.txt +++ b/src/index/CMakeLists.txt @@ -12,11 +12,13 @@ target_link_libraries( set_target_properties(index PROPERTIES AUTOMOC ON) -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) target_link_libraries(indexer index) diff --git a/src/index/Index.cpp b/src/index/Index.cpp index d48ad5d8d..cbe0fe607 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_RAWSZ)); + 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_RAWSZ); + 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 b9ee24368..32ef6b710 100644 --- a/src/ui/RepoView.cpp +++ b/src/ui/RepoView.cpp @@ -1047,13 +1047,13 @@ 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(submodule.status())) - 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; })); @@ -2385,7 +2385,7 @@ RepoView::submoduleResetInfoList(const git::Repository &repo, // Only reset modified submodules QList modules; foreach (const git::Submodule &submodule, submodules) { - int status = submodule.status(); + int status = repo.submoduleStatus(submodule.name()); if (status & (GIT_SUBMODULE_STATUS_WD_MODIFIED | GIT_SUBMODULE_STATUS_WD_WD_MODIFIED | diff --git a/test/dep/zip b/test/dep/zip index 96825016e..fefb8d6ac 160000 --- a/test/dep/zip +++ b/test/dep/zip @@ -1 +1 @@ -Subproject commit 96825016edb6e63698ec2314349daeae345ad2fe +Subproject commit fefb8d6acc78b5f63d5a78b86a4900e694bd2862 From b8f76e1746274ba3c4606d1f60810a0ad7916f26 Mon Sep 17 00:00:00 2001 From: kas Date: Wed, 7 Sep 2022 14:16:46 +0200 Subject: [PATCH 02/40] Update build.yml and CMakeLists.txt --- .github/workflows/build.yml | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index fa2771ab8..aebee74b4 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -160,11 +160,10 @@ jobs: qt_arch_check_only: win64_msvc2017_64 openssl_arch: VC-WIN64A msvc_arch: x64 - cmake_flags: "-DUSE_BUNDLED_ZLIB=1" cmake_env: CMAKE_RC_FLAGS: "/C 1252" - CC: clang - CXX: clang++ + CC: cl + CXX: cl pack: 1 - name: win32 @@ -175,13 +174,10 @@ jobs: qt_arch_check_only: win32_msvc2017 openssl_arch: VC-WIN32 msvc_arch: x86 - cmake_flags: "-DUSE_BUNDLED_ZLIB=1" cmake_env: CMAKE_RC_FLAGS: "/C 1252" - CC: clang - CXX: clang++ - CMAKE_C_FLAGS: -m32 - CMAKE_CXX_FLAGS: -m32 + CC: cl + CXX: cl pack: 1 steps: From 29121347ede78ffba285a70b0cee673990e3abdb Mon Sep 17 00:00:00 2001 From: Martin Marmsoler Date: Tue, 13 Sep 2022 15:27:35 +0200 Subject: [PATCH 03/40] Reason: --- src/conf/CMakeLists.txt | 2 +- src/git/CMakeLists.txt | 6 +++--- src/util/CMakeLists.txt | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/conf/CMakeLists.txt b/src/conf/CMakeLists.txt index bbb0f2ce2..9a525e000 100644 --- a/src/conf/CMakeLists.txt +++ b/src/conf/CMakeLists.txt @@ -1,7 +1,7 @@ add_library(conf ConfFile.cpp Settings.cpp Setting.cpp RecentRepositories.cpp RecentRepository.cpp) -target_link_libraries(conf lua Qt5::Core util translation) +target_link_libraries(conf lua Qt5::Core translation gittyupUtil) # SRC_ definitions point to the source directly target_compile_definitions( diff --git a/src/git/CMakeLists.txt b/src/git/CMakeLists.txt index 5b772cf89..3c7c67359 100644 --- a/src/git/CMakeLists.txt +++ b/src/git/CMakeLists.txt @@ -28,11 +28,11 @@ add_library( Tree.cpp) target_link_libraries(git - git2 + $ + $ # util of libgit2 + gittyupUtil ${LIBGIT2_DEPENDENCY_OBJECTS} ${LIBGIT2_SYSTEM_LIBS} - $ - $ Qt5::Core Qt5::Network ) diff --git a/src/util/CMakeLists.txt b/src/util/CMakeLists.txt index 4d039839f..01ae27f9f 100644 --- a/src/util/CMakeLists.txt +++ b/src/util/CMakeLists.txt @@ -3,4 +3,4 @@ add_library(util Path.cpp Debug.h Debug.cpp) target_link_libraries(util Qt5::Core) target_include_directories(util INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}) -set_target_properties(util PROPERTIES AUTOMOC ON) +set_target_properties(gittyupUtil PROPERTIES AUTOMOC ON) From 4651f48bd86ae67ce19cb36ddc586a9aa9b18667 Mon Sep 17 00:00:00 2001 From: Martin Marmsoler Date: Thu, 22 Sep 2022 16:21:44 +0200 Subject: [PATCH 04/40] initial approach to reactivate filter apply --- src/git/Filter.cpp | 69 +++++++++++++++++++++++++--------------------- 1 file changed, 38 insertions(+), 31 deletions(-) diff --git a/src/git/Filter.cpp b/src/git/Filter.cpp index 7da37c772..7a70ff3a3 100644 --- a/src/git/Filter.cpp +++ b/src/git/Filter.cpp @@ -12,8 +12,10 @@ #include "Config.h" #include "git2/errors.h" #include "git2/filter.h" +#include "str.h" #include "git2/repository.h" #include "git2/sys/filter.h" +#include "git2_util.h" #include #include @@ -38,44 +40,49 @@ struct FilterInfo { QString quote(const QString &path) { return QString("\"%1\"").arg(path); } -int stream( - git_writestream **out, - git_filter *self, - void **payload, - const git_filter_source *src, - git_writestream *next) -{ - return -1; -// FilterInfo *info = reinterpret_cast(self); -// git_filter_mode_t mode = git_filter_source_mode(src); -// QString command = (mode == GIT_FILTER_SMUDGE) ? info->smudge : info->clean; +int apply(git_filter *self, void **payload, git_str *to, const git_str *from, + const git_filter_source *src) { + FilterInfo *info = reinterpret_cast(self); + git_filter_mode_t mode = git_filter_source_mode(src); + QString command = (mode == GIT_FILTER_SMUDGE) ? info->smudge : info->clean; + + // Substitute path. + command.replace("%f", quote(git_filter_source_path(src))); -// // Substitute path. -// command.replace("%f", quote(git_filter_source_path(src))); + QString bash = Command::bashPath(); + if (bash.isEmpty()) + return info->required ? GIT_EUSER : GIT_PASSTHROUGH; -// QString bash = Command::bashPath(); -// if (bash.isEmpty()) -// return info->required ? GIT_EUSER : GIT_PASSTHROUGH; + QProcess process; + git_repository *repo = git_filter_source_repo(src); + process.setWorkingDirectory(git_repository_workdir(repo)); -// QProcess process; -// git_repository *repo = git_filter_source_repo(src); -// process.setWorkingDirectory(git_repository_workdir(repo)); + process.start(bash, {"-c", command}); + if (!process.waitForStarted()) + return info->required ? GIT_EUSER : GIT_PASSTHROUGH; -// process.start(bash, {"-c", command}); -// if (!process.waitForStarted()) -// return info->required ? GIT_EUSER : GIT_PASSTHROUGH; + process.write(from->ptr, from->size); + process.closeWriteChannel(); -// process.write(from->ptr, from->size); -// process.closeWriteChannel(); + if (!process.waitForFinished() || process.exitCode()) { + git_error_set_str(GIT_ERROR_FILTER, process.readAllStandardError()); + return info->required ? GIT_EUSER : GIT_PASSTHROUGH; + } -// if (!process.waitForFinished() || process.exitCode()) { -// git_error_set_str(GIT_ERROR_FILTER, process.readAllStandardError()); -// return info->required ? GIT_EUSER : GIT_PASSTHROUGH; -// } + QByteArray data = process.readAll(); + git_str_set(to, data.constData(), data.length()); + return 0; +} -// QByteArray data = process.readAll(); -// git_buf_set(to, data.constData(), data.length()); -// return 0; +int stream( + git_writestream **out, + git_filter *self, + void **payload, + const git_filter_source *src, + git_writestream *next) +{ + return git_filter_buffered_stream_new(out, + self, apply, NULL, payload, src, next); } } // namespace From 361aee985666074a904a047f4a8a97b4bea6de35 Mon Sep 17 00:00:00 2001 From: Martin Marmsoler Date: Thu, 17 Nov 2022 11:21:05 +0100 Subject: [PATCH 05/40] implement filter with streams --- src/git/Filter.cpp | 117 +++++++++++++++++++++++++++++---------------- 1 file changed, 75 insertions(+), 42 deletions(-) diff --git a/src/git/Filter.cpp b/src/git/Filter.cpp index 7a70ff3a3..6166b7b37 100644 --- a/src/git/Filter.cpp +++ b/src/git/Filter.cpp @@ -40,49 +40,82 @@ struct FilterInfo { QString quote(const QString &path) { return QString("\"%1\"").arg(path); } -int apply(git_filter *self, void **payload, git_str *to, const git_str *from, - const git_filter_source *src) { - FilterInfo *info = reinterpret_cast(self); - git_filter_mode_t mode = git_filter_source_mode(src); - QString command = (mode == GIT_FILTER_SMUDGE) ? info->smudge : info->clean; - - // Substitute path. - command.replace("%f", quote(git_filter_source_path(src))); - - QString bash = Command::bashPath(); - if (bash.isEmpty()) - return info->required ? GIT_EUSER : GIT_PASSTHROUGH; - - QProcess process; - git_repository *repo = git_filter_source_repo(src); - process.setWorkingDirectory(git_repository_workdir(repo)); - - process.start(bash, {"-c", command}); - if (!process.waitForStarted()) - return info->required ? GIT_EUSER : GIT_PASSTHROUGH; - - process.write(from->ptr, from->size); - process.closeWriteChannel(); - - if (!process.waitForFinished() || process.exitCode()) { - git_error_set_str(GIT_ERROR_FILTER, process.readAllStandardError()); - return info->required ? GIT_EUSER : GIT_PASSTHROUGH; - } - - QByteArray data = process.readAll(); - git_str_set(to, data.constData(), data.length()); - return 0; +int apply(const git_filter *self, QByteArray &to, const char *from, + const size_t from_length, const git_filter_source *src) { + const FilterInfo *info = reinterpret_cast(self); + git_filter_mode_t mode = git_filter_source_mode(src); + QString command = (mode == GIT_FILTER_SMUDGE) ? info->smudge : info->clean; + + // Substitute path. + command.replace("%f", quote(git_filter_source_path(src))); + + QString bash = Command::bashPath(); + if (bash.isEmpty()) + return info->required ? GIT_EUSER : GIT_PASSTHROUGH; + + QProcess process; + git_repository *repo = git_filter_source_repo(src); + process.setWorkingDirectory(git_repository_workdir(repo)); + + process.start(bash, {"-c", command}); + if (!process.waitForStarted()) + return info->required ? GIT_EUSER : GIT_PASSTHROUGH; + + process.write(from); + process.closeWriteChannel(); + + if (!process.waitForFinished() || process.exitCode()) { + git_error_set_str(GIT_ERROR_FILTER, process.readAllStandardError()); + return info->required ? GIT_EUSER : GIT_PASSTHROUGH; + } + + to = process.readAll(); + return 0; } -int stream( - git_writestream **out, - git_filter *self, - void **payload, - const git_filter_source *src, - git_writestream *next) -{ - return git_filter_buffered_stream_new(out, - self, apply, NULL, payload, src, next); +struct Stream { + git_writestream parent; // must be the first. No pointer! + git_writestream *next; + git_filter_mode_t mode; + const git_filter *filter; + const git_filter_source *filter_source; +}; + +static void stream_free(git_writestream *stream) { git__free(stream); } + +static int stream_close(git_writestream *s) { + struct Stream *stream = (struct Stream *)s; + stream->next->close(stream->next); + return 0; +} + +static int stream_write(git_writestream *s, const char *buffer, size_t len) { + + struct Stream *stream = (struct Stream *)s; + QByteArray to; + apply(stream->filter, to, buffer, len, stream->filter_source); + stream->next->write(stream->next, to.data(), to.length()); + return 0; +} + +// Called for every new stream +static int stream_init(git_writestream **out, git_filter *self, void **payload, + const git_filter_source *src, git_writestream *next) { + + struct Stream *stream = + static_cast(git__calloc(1, sizeof(struct Stream))); + if (!stream) + return -1; + + stream->parent.write = stream_write; + stream->parent.close = stream_close; + stream->parent.free = stream_free; + stream->next = next; + stream->filter_source = src; + stream->filter = self; + + *out = (git_writestream *)stream; + return 0; } } // namespace @@ -114,7 +147,7 @@ void Filter::init() { info.name = key.toUtf8(); info.attributes = kFilterFmt.arg(key).toUtf8(); - info.filter.stream = &stream; + info.filter.stream = stream_init; info.filter.attributes = info.attributes.constData(); git_filter_register(info.name.constData(), &info.filter, GIT_FILTER_DRIVER_PRIORITY); From ba200becb40ec8043c8de0c09926ba605b8acafe Mon Sep 17 00:00:00 2001 From: Martin Marmsoler Date: Thu, 17 Nov 2022 11:37:27 +0100 Subject: [PATCH 06/40] fix build --- dep/libgit2/CMakeLists.txt | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/dep/libgit2/CMakeLists.txt b/dep/libgit2/CMakeLists.txt index c8c48896e..1e129d6f1 100644 --- a/dep/libgit2/CMakeLists.txt +++ b/dep/libgit2/CMakeLists.txt @@ -34,10 +34,8 @@ endif() if(NOT USE_SYSTEM_LIBGIT2) add_subdirectory(libgit2) - target_include_directories( - git2 INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/libgit2/include) -# 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() \ No newline at end of file + # 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() From d1d01e9532d40888312b39a0e14d8aa9aa735c54 Mon Sep 17 00:00:00 2001 From: Martin Marmsoler Date: Thu, 17 Nov 2022 11:37:59 +0100 Subject: [PATCH 07/40] Reason: --- dep/CMakeLists.txt | 12 +++++++++--- dep/libgit2/CMakeLists.txt | 14 ++++++++++---- src/dialogs/SubmoduleTableModel.cpp | 3 ++- src/git/Buffer.cpp | 9 ++------- src/git/Buffer.h | 2 +- src/git/CMakeLists.txt | 10 ++++------ 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 | 22 +++++++++++----------- 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 +++++++++-------- 18 files changed, 75 insertions(+), 70 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/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/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 e00288491..53818abc5 100644 --- a/src/git/Patch.cpp +++ b/src/git/Patch.cpp @@ -325,9 +325,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 487ed82d4..15a6953be 100644 --- a/src/git/Remote.cpp +++ b/src/git/Remote.cpp @@ -455,11 +455,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); @@ -619,7 +616,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 d8e82cdf6..8530eecdf 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 4fe259bb4..c2e9f05be 100644 --- a/src/git/Repository.cpp +++ b/src/git/Repository.cpp @@ -175,8 +175,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); @@ -707,18 +706,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 e4f102f79..bec16b1ab 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 35d05329a..67e5a0e50 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 e9ab0385a..1393259d2 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 cbe0fe607..efcf2543a 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 32ef6b710..fcdb72766 100644 --- a/src/ui/RepoView.cpp +++ b/src/ui/RepoView.cpp @@ -1047,13 +1047,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; })); @@ -2385,7 +2386,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 | From 3b803a1b619b324f96d93e905b67f728cc50ab71 Mon Sep 17 00:00:00 2001 From: kas Date: Thu, 17 Nov 2022 19:17:45 +0100 Subject: [PATCH 08/40] Fix build (at least on Windows using Clang) --- dep/CMakeLists.txt | 10 ---------- dep/libgit2/CMakeLists.txt | 16 +++++----------- src/git/CMakeLists.txt | 16 ++++------------ src/git/Filter.cpp | 6 ++---- 4 files changed, 11 insertions(+), 37 deletions(-) diff --git a/dep/CMakeLists.txt b/dep/CMakeLists.txt index 104d62caf..54cb4ae42 100644 --- a/dep/CMakeLists.txt +++ b/dep/CMakeLists.txt @@ -3,16 +3,6 @@ find_package(PkgConfig) 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) add_subdirectory(cmark) add_subdirectory(lua) diff --git a/dep/libgit2/CMakeLists.txt b/dep/libgit2/CMakeLists.txt index 36bf8f350..473a21e9f 100644 --- a/dep/libgit2/CMakeLists.txt +++ b/dep/libgit2/CMakeLists.txt @@ -2,7 +2,7 @@ set(BUILD_SHARED_LIBS OFF CACHE BOOL "" FORCE) -set(BUILD_CLAR +set(BUILD_TESTS OFF CACHE BOOL "" FORCE) set(STATIC_CRT @@ -34,14 +34,8 @@ 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) + + # Include the generated experimental.h + target_include_directories( + libgit2 INTERFACE ${PROJECT_BINARY_DIR}/dep/libgit2/libgit2/include/git2) endif() diff --git a/src/git/CMakeLists.txt b/src/git/CMakeLists.txt index 2ae3cd049..1416df857 100644 --- a/src/git/CMakeLists.txt +++ b/src/git/CMakeLists.txt @@ -27,17 +27,9 @@ add_library( TagRef.cpp Tree.cpp) -target_link_libraries( - git - $ - $ # util of libgit2 - gittyupUtil - ${LIBGIT2_DEPENDENCY_OBJECTS} - ${LIBGIT2_SYSTEM_LIBS} - Qt5::Core - Qt5::Network) - -# needed also by the plugin target so it must be public -target_include_directories(git PUBLIC ${LIBGIT2_INCLUDES}) +# we need both libgit2package and libgit2 otherwise we can't find the header +# files +target_link_libraries(git libgit2package libgit2 gittyupUtil Qt5::Core + Qt5::Network) set_target_properties(git PROPERTIES AUTOMOC ON) diff --git a/src/git/Filter.cpp b/src/git/Filter.cpp index 6166b7b37..a0937e0c8 100644 --- a/src/git/Filter.cpp +++ b/src/git/Filter.cpp @@ -12,10 +12,8 @@ #include "Config.h" #include "git2/errors.h" #include "git2/filter.h" -#include "str.h" #include "git2/repository.h" #include "git2/sys/filter.h" -#include "git2_util.h" #include #include @@ -81,7 +79,7 @@ struct Stream { const git_filter_source *filter_source; }; -static void stream_free(git_writestream *stream) { git__free(stream); } +static void stream_free(git_writestream *stream) { free(stream); } static int stream_close(git_writestream *s) { struct Stream *stream = (struct Stream *)s; @@ -103,7 +101,7 @@ static int stream_init(git_writestream **out, git_filter *self, void **payload, const git_filter_source *src, git_writestream *next) { struct Stream *stream = - static_cast(git__calloc(1, sizeof(struct Stream))); + static_cast(calloc(1, sizeof(struct Stream))); if (!stream) return -1; From ac6451b63c690075645088f20fdc25bcaa64d860 Mon Sep 17 00:00:00 2001 From: Martin Marmsoler Date: Sat, 10 Dec 2022 17:23:48 +0100 Subject: [PATCH 09/40] comment out for now --- test/SshConfig.cpp | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/test/SshConfig.cpp b/test/SshConfig.cpp index d01cfea5f..13e7c1b18 100644 --- a/test/SshConfig.cpp +++ b/test/SshConfig.cpp @@ -39,16 +39,10 @@ private slots: private: static QString transformUrl(const QString &url, const QString config) { auto callbacks = Callbacks(url, config); - git_buf buf; - buf.asize = 0; - buf.size = 0; - buf.ptr = nullptr; - Callbacks::url(&buf, url.toUtf8().data(), 0, &callbacks); - - QString res = QString::fromUtf8(buf.ptr, (int)buf.size); - git_buf_dispose(&buf); - return res; + //git::Remote remote(); + //Callbacks::remoteReady(*remote, 0, &callbacks); + return ""; // remote.url(); } }; From a63dd8826b76900cdecc28ff8d9e99b518bcd428 Mon Sep 17 00:00:00 2001 From: Martin Marmsoler Date: Thu, 12 Jan 2023 08:21:13 +0100 Subject: [PATCH 10/40] format --- test/SshConfig.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/SshConfig.cpp b/test/SshConfig.cpp index 13e7c1b18..bf828a124 100644 --- a/test/SshConfig.cpp +++ b/test/SshConfig.cpp @@ -40,9 +40,9 @@ private slots: static QString transformUrl(const QString &url, const QString config) { auto callbacks = Callbacks(url, config); - //git::Remote remote(); - //Callbacks::remoteReady(*remote, 0, &callbacks); - return ""; // remote.url(); + // git::Remote remote(); + // Callbacks::remoteReady(*remote, 0, &callbacks); + return ""; // remote.url(); } }; From 7b534093f06b9f954c6af0a35f459dbe0e917b46 Mon Sep 17 00:00:00 2001 From: Martin Marmsoler Date: Sat, 22 Jul 2023 18:37:04 +0200 Subject: [PATCH 11/40] fix test --- test/SshConfig.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/test/SshConfig.cpp b/test/SshConfig.cpp index bf828a124..9d2528a30 100644 --- a/test/SshConfig.cpp +++ b/test/SshConfig.cpp @@ -10,6 +10,7 @@ #include "Test.h" #include "git/Remote.h" #include "git2/buffer.h" +#include "git2/remote.h" #include "qtestcase.h" class Callbacks : public git::Remote::Callbacks { @@ -39,10 +40,16 @@ private slots: private: static QString transformUrl(const QString &url, const QString config) { auto callbacks = Callbacks(url, config); - - // git::Remote remote(); - // Callbacks::remoteReady(*remote, 0, &callbacks); - return ""; // remote.url(); + git_remote *remote{nullptr}; + git_remote_create(&remote, nullptr, "test", url.toUtf8()); + + if (!remote) + return QStringLiteral("Remote nullptr"); + Callbacks::remoteReady(remote, 0, &callbacks); + const char *urlNew = git_remote_url(remote); + QString u = QString::fromUtf8(urlNew); + git_remote_free(remote); + return u; } }; From 7faf33f4b4686b52b61de61d39ce134263d01fea Mon Sep 17 00:00:00 2001 From: Martin Marmsoler Date: Sat, 22 Jul 2023 18:48:38 +0200 Subject: [PATCH 12/40] rename to util Reason: because in libgit2 there is also a util target --- src/util/CMakeLists.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/util/CMakeLists.txt b/src/util/CMakeLists.txt index 01ae27f9f..55dc85568 100644 --- a/src/util/CMakeLists.txt +++ b/src/util/CMakeLists.txt @@ -1,6 +1,6 @@ -add_library(util Path.cpp Debug.h Debug.cpp) +add_library(gittyupUtil Path.cpp Debug.h Debug.cpp) -target_link_libraries(util Qt5::Core) -target_include_directories(util INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}) +target_link_libraries(gittyupUtil Qt5::Core) +target_include_directories(gittyupUtil INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}) set_target_properties(gittyupUtil PROPERTIES AUTOMOC ON) From d3432ca8dd347f2dd59c34d0854effc1a54ede79 Mon Sep 17 00:00:00 2001 From: Martin Marmsoler Date: Sat, 22 Jul 2023 20:47:04 +0200 Subject: [PATCH 13/40] abort script if any error occurs --- dep/libgit2/rebaseGittyupLibgit2.sh | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/dep/libgit2/rebaseGittyupLibgit2.sh b/dep/libgit2/rebaseGittyupLibgit2.sh index f9d08a0c5..ee02d140c 100644 --- a/dep/libgit2/rebaseGittyupLibgit2.sh +++ b/dep/libgit2/rebaseGittyupLibgit2.sh @@ -12,7 +12,17 @@ git fetch --all for branch in ${branches[@]}; do echo $branch git checkout -B $branch "origin/$branch" + RESULT=$? + if [ $RESULT -gt 0 ]; then + echo "Unable to checkout branch: $branch : Exitcode: $RESULT" + exit 1 + fi git rebase upstream/main + RESULT=$? + if [ $RESULT -gt 0 ]; then + echo "Unable to rebase branch: $branch : Exitcode: $RESULT" + exit 1 + fi done git checkout Gittyup @@ -20,6 +30,11 @@ git reset --hard upstream/main for branch in ${branches[@]}; do git merge --no-edit $branch + RESULT=$? + if [ $RESULT -gt 0 ]; then + echo "Unable to merge branch: $branch : Exitcode: $RESULT" + exit 1 + fi done git push --force origin From 0d9b9f00032ff14b5f0773232c62d698e757ba05 Mon Sep 17 00:00:00 2001 From: Martin Marmsoler Date: Sun, 27 Aug 2023 16:07:25 +0200 Subject: [PATCH 14/40] format --- src/git/Repository.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/git/Repository.cpp b/src/git/Repository.cpp index c2e9f05be..ceb58e427 100644 --- a/src/git/Repository.cpp +++ b/src/git/Repository.cpp @@ -334,7 +334,8 @@ 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_TYPECHANGE; // GIT_DIFF_DISABLE_MMAP flag really needed? + opts.flags |= + GIT_DIFF_INCLUDE_TYPECHANGE; // GIT_DIFF_DISABLE_MMAP flag really needed? if (!appConfig().value("untracked.hide", false)) opts.flags |= GIT_DIFF_INCLUDE_UNTRACKED | GIT_DIFF_RECURSE_UNTRACKED_DIRS; From 556e6f0b81dc92731724992eb2cf4cb9562daad3 Mon Sep 17 00:00:00 2001 From: Martin Marmsoler Date: Wed, 22 Nov 2023 20:40:10 +0100 Subject: [PATCH 15/40] Check if this helps --- .github/workflows/build.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index aebee74b4..094be091d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -162,8 +162,8 @@ jobs: msvc_arch: x64 cmake_env: CMAKE_RC_FLAGS: "/C 1252" - CC: cl - CXX: cl + CC: clang + CXX: clang++ pack: 1 - name: win32 @@ -176,8 +176,8 @@ jobs: msvc_arch: x86 cmake_env: CMAKE_RC_FLAGS: "/C 1252" - CC: cl - CXX: cl + CC: clang + CXX: clang++ pack: 1 steps: From d188e240ae86f619ac5e2a1d29518d7c08fe2879 Mon Sep 17 00:00:00 2001 From: Martin Marmsoler Date: Tue, 11 Jun 2024 11:26:42 +0200 Subject: [PATCH 16/40] update libgit2 blame_buffer not required anymore because upstream changes are made so this one is not required anymore submodule: not required because different solution used --- dep/libgit2/libgit2 | 2 +- dep/libgit2/rebaseGittyupLibgit2.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) mode change 100644 => 100755 dep/libgit2/rebaseGittyupLibgit2.sh diff --git a/dep/libgit2/libgit2 b/dep/libgit2/libgit2 index 59e41acbc..d4c2f7603 160000 --- a/dep/libgit2/libgit2 +++ b/dep/libgit2/libgit2 @@ -1 +1 @@ -Subproject commit 59e41acbcc7993ae9013f2729d60437ec56f9ed8 +Subproject commit d4c2f7603e297cc972af2ec2d5bdab1cc3b825e0 diff --git a/dep/libgit2/rebaseGittyupLibgit2.sh b/dep/libgit2/rebaseGittyupLibgit2.sh old mode 100644 new mode 100755 index ee02d140c..f57528b03 --- a/dep/libgit2/rebaseGittyupLibgit2.sh +++ b/dep/libgit2/rebaseGittyupLibgit2.sh @@ -1,4 +1,4 @@ -declare -a branches=("fetch_annotated_tags" "blame_abort" "disableRenameDetection" "checkout_deletion_notification" "diff_checkout" "fix_push_callback_issues" "disable_mmap" "context_line_accessor´" "disableRenameDetection" "submodule" "hash" "callback_connect_disconnect" "blame_buffer" "libgit2_includes_public") +declare -a branches=("fetch_annotated_tags" "blame_abort" "disableRenameDetection" "checkout_deletion_notification" "diff_checkout" "fix_push_callback_issues" "disable_mmap" "context_line_accessor´" "disableRenameDetection" "hash" "callback_connect_disconnect" "libgit2_includes_public") cd libgit2 From de360b9e781380c514e43526d0980ce2498c59f2 Mon Sep 17 00:00:00 2001 From: Martin Marmsoler Date: Tue, 11 Jun 2024 12:44:21 +0200 Subject: [PATCH 17/40] fix compilation errors --- src/git/Filter.cpp | 1 + src/git/Remote.cpp | 1 + src/git/Repository.cpp | 1 + 3 files changed, 3 insertions(+) diff --git a/src/git/Filter.cpp b/src/git/Filter.cpp index a0937e0c8..c29f0094d 100644 --- a/src/git/Filter.cpp +++ b/src/git/Filter.cpp @@ -14,6 +14,7 @@ #include "git2/filter.h" #include "git2/repository.h" #include "git2/sys/filter.h" +#include "git2/sys/errors.h" #include #include diff --git a/src/git/Remote.cpp b/src/git/Remote.cpp index 15a6953be..da47bfc04 100644 --- a/src/git/Remote.cpp +++ b/src/git/Remote.cpp @@ -17,6 +17,7 @@ #include "git2/clone.h" #include "git2/remote.h" #include "git2/signature.h" +#include "git2/sys/errors.h" #include "libssh2.h" #include #include diff --git a/src/git/Repository.cpp b/src/git/Repository.cpp index 868208a31..0a2c59d77 100644 --- a/src/git/Repository.cpp +++ b/src/git/Repository.cpp @@ -44,6 +44,7 @@ #include "git2/stash.h" #include "git2/tag.h" #include "git2/sys/repository.h" +#include "git2/sys/errors.h" #include #include #include From f81c694e067900a138c4b78b64fa9c7d3b868965 Mon Sep 17 00:00:00 2001 From: Martin Marmsoler Date: Tue, 11 Jun 2024 13:06:00 +0200 Subject: [PATCH 18/40] fix compilation --- src/git/Repository.cpp | 2 +- src/ui/RemoteCallbacks.cpp | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/git/Repository.cpp b/src/git/Repository.cpp index 0a2c59d77..0610be5a4 100644 --- a/src/git/Repository.cpp +++ b/src/git/Repository.cpp @@ -615,7 +615,7 @@ Commit Repository::commit(const Signature &author, const Signature &committer, return Commit(); // Lookup the parent commit. - QVector parents; + QVector parents; if (Reference ref = head()) { if (Commit commit = ref.target()) parents.append(commit); diff --git a/src/ui/RemoteCallbacks.cpp b/src/ui/RemoteCallbacks.cpp index b5ba06069..af5c59504 100644 --- a/src/ui/RemoteCallbacks.cpp +++ b/src/ui/RemoteCallbacks.cpp @@ -14,6 +14,7 @@ #include "git/Command.h" #include "git/Id.h" #include "git/RevWalk.h" +#include "git2/sys/errors.h" #include "log/LogEntry.h" #include #include From ec66c0e1a7e47473896962150d5a02f54b3860e8 Mon Sep 17 00:00:00 2001 From: Martin Marmsoler Date: Tue, 11 Jun 2024 13:24:04 +0200 Subject: [PATCH 19/40] use system libs --- .github/workflows/build.yml | 2 +- com.github.Murmele.Gittyup.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index bbd6fe6d3..af9806fe3 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -134,7 +134,7 @@ jobs: qt_arch: gcc_64 openssl_arch: linux-x86_64 ld_library_arch: linux-x86-64 - cmake_flags: "-DGENERATE_APPDATA=ON -DCMAKE_INSTALL_PREFIX=/usr -DUSE_SYSTEM_QT=ON -DENABLE_UPDATE_OVER_GUI=OFF" + cmake_flags: "-DGENERATE_APPDATA=ON -DCMAKE_INSTALL_PREFIX=/usr -DUSE_SYSTEM_QT=ON -DENABLE_UPDATE_OVER_GUI=OFF -DUSE_SSH -DUSE_SYSTEM_LIBSSH2 -DUSE_SYSTEM_OPENSSL" pack: 0 cmake_env: {} diff --git a/com.github.Murmele.Gittyup.yml b/com.github.Murmele.Gittyup.yml index 32f8b0f11..64fc008c6 100644 --- a/com.github.Murmele.Gittyup.yml +++ b/com.github.Murmele.Gittyup.yml @@ -67,7 +67,7 @@ modules: - name: Gittyup buildsystem: cmake-ninja - config-opts: [-DCMAKE_BUILD_TYPE=Release, -DFLATPAK=ON, -DGENERATE_APPDATA=ON, -DENABLE_UPDATE_OVER_GUI=OFF, -DUSE_SYSTEM_OPENSSL:BOOL=ON] + config-opts: [-DCMAKE_BUILD_TYPE=Release, -DFLATPAK=ON, -DGENERATE_APPDATA=ON, -DENABLE_UPDATE_OVER_GUI=OFF, -DUSE_SYSTEM_OPENSSL:BOOL=ON, -DUSE_SSH=ON -DUSE_SYSTEM_LIBSSH2=ON] builddir: true sources: - type: git From 682123c12eae6884e7b78cc80ee6f556e737e726 Mon Sep 17 00:00:00 2001 From: Martin Marmsoler Date: Tue, 11 Jun 2024 13:32:16 +0200 Subject: [PATCH 20/40] Update libssh2 and openssl --- dep/libssh2/libssh2 | 2 +- dep/openssl/openssl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dep/libssh2/libssh2 b/dep/libssh2/libssh2 index 6c59eea5a..c149a1272 160000 --- a/dep/libssh2/libssh2 +++ b/dep/libssh2/libssh2 @@ -1 +1 @@ -Subproject commit 6c59eea5a9ea77127ec0fa3d6815c8adc743dba3 +Subproject commit c149a12721b1caa9cf442efd770c61c590e8b568 diff --git a/dep/openssl/openssl b/dep/openssl/openssl index 29708a562..4cdc08318 160000 --- a/dep/openssl/openssl +++ b/dep/openssl/openssl @@ -1 +1 @@ -Subproject commit 29708a562a1887a91de0fa6ca668c71871accde9 +Subproject commit 4cdc083185716c2e5fd4fb790e00589726c757a3 From e60180d480ecaa87a81681464e789e85fa462498 Mon Sep 17 00:00:00 2001 From: Martin Marmsoler Date: Tue, 11 Jun 2024 14:31:53 +0200 Subject: [PATCH 21/40] install libssh2 and use system openssl --- .github/workflows/build.yml | 21 ++++++++++++++------- .gitignore | 2 +- com.github.Murmele.Gittyup.yml | 15 +++++++++++++++ 3 files changed, 30 insertions(+), 8 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index af9806fe3..7188d23fa 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -134,7 +134,7 @@ jobs: qt_arch: gcc_64 openssl_arch: linux-x86_64 ld_library_arch: linux-x86-64 - cmake_flags: "-DGENERATE_APPDATA=ON -DCMAKE_INSTALL_PREFIX=/usr -DUSE_SYSTEM_QT=ON -DENABLE_UPDATE_OVER_GUI=OFF -DUSE_SSH -DUSE_SYSTEM_LIBSSH2 -DUSE_SYSTEM_OPENSSL" + cmake_flags: "-DGENERATE_APPDATA=ON -DCMAKE_INSTALL_PREFIX=/usr -DUSE_SYSTEM_QT=ON -DENABLE_UPDATE_OVER_GUI=OFF -DUSE_SSH=ON -DUSE_SYSTEM_LIBSSH2=ON -DUSE_SYSTEM_OPENSSL=ON" pack: 0 cmake_env: {} @@ -199,6 +199,12 @@ jobs: with: perl-version: '5.30' + - name: Install Libssh2 + if: matrix.env.ninja_platform == 'linux' + run: | + sudo apt-get update + sudo apt-get -y install libssh2-1 + - name: Install Qt uses: jurplel/install-qt-action@v3.3.0 timeout-minutes: 10 @@ -240,12 +246,12 @@ jobs: if: matrix.env.ninja_platform == 'win' uses: ilammy/setup-nasm@v1.2.0 - - name: Build OpenSSL (Linux) - if: matrix.env.ninja_platform == 'linux' - run: | - cd dep/openssl/openssl - ./config -fPIC - make + #- name: Build OpenSSL (Linux) + # if: matrix.env.ninja_platform == 'linux' + # run: | + # cd dep/openssl/openssl + # ./config -fPIC + # make - name: Build OpenSSL (macOS) if: matrix.env.ninja_platform == 'mac' @@ -431,3 +437,4 @@ jobs: branch: gh-pages # The branch the action should deploy to. folder: docs # The folder the action should deploy. ... +... diff --git a/.gitignore b/.gitignore index 1cd62985f..ea9f67e55 100644 --- a/.gitignore +++ b/.gitignore @@ -11,4 +11,4 @@ build .idea/ .venv compile_commands.json -tags \ No newline at end of file +.flatpak-builder diff --git a/com.github.Murmele.Gittyup.yml b/com.github.Murmele.Gittyup.yml index 64fc008c6..6209683a9 100644 --- a/com.github.Murmele.Gittyup.yml +++ b/com.github.Murmele.Gittyup.yml @@ -65,6 +65,21 @@ modules: - install -Dm755 $(which git-upload-archive) ${FLATPAK_DEST}/bin/ - install -Dm755 $(which git-upload-pack) ${FLATPAK_DEST}/bin/ + - name: libssh2 + rm-configure: true + sources: + - type: archive + url: https://www.libssh2.org/download/libssh2-1.11.0.tar.gz + sha256: 3736161e41e2693324deb38c26cfdc3efe6209d634ba4258db1cecff6a5ad461 + x-checker-data: + type: anitya + project-id: 1730 + url-template: https://www.libssh2.org/download/libssh2-$version.tar.gz + - type: script + commands: + - autoreconf -fiv + dest-filename: autogen.sh + - name: Gittyup buildsystem: cmake-ninja config-opts: [-DCMAKE_BUILD_TYPE=Release, -DFLATPAK=ON, -DGENERATE_APPDATA=ON, -DENABLE_UPDATE_OVER_GUI=OFF, -DUSE_SYSTEM_OPENSSL:BOOL=ON, -DUSE_SSH=ON -DUSE_SYSTEM_LIBSSH2=ON] From e7e27c07ea7f5401aa1dbc717127e307a84009e1 Mon Sep 17 00:00:00 2001 From: Martin Marmsoler Date: Tue, 11 Jun 2024 14:32:18 +0200 Subject: [PATCH 22/40] cleanup --- .github/workflows/build.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7188d23fa..5240848c5 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -437,4 +437,3 @@ jobs: branch: gh-pages # The branch the action should deploy to. folder: docs # The folder the action should deploy. ... -... From 126ee9437d5cc5d9dcc7bcff71faf432d47f78f6 Mon Sep 17 00:00:00 2001 From: Martin Marmsoler Date: Tue, 11 Jun 2024 14:37:08 +0200 Subject: [PATCH 23/40] missing colon --- com.github.Murmele.Gittyup.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/com.github.Murmele.Gittyup.yml b/com.github.Murmele.Gittyup.yml index 6209683a9..4e0cdd73a 100644 --- a/com.github.Murmele.Gittyup.yml +++ b/com.github.Murmele.Gittyup.yml @@ -82,7 +82,7 @@ modules: - name: Gittyup buildsystem: cmake-ninja - config-opts: [-DCMAKE_BUILD_TYPE=Release, -DFLATPAK=ON, -DGENERATE_APPDATA=ON, -DENABLE_UPDATE_OVER_GUI=OFF, -DUSE_SYSTEM_OPENSSL:BOOL=ON, -DUSE_SSH=ON -DUSE_SYSTEM_LIBSSH2=ON] + config-opts: [-DCMAKE_BUILD_TYPE=Release, -DFLATPAK=ON, -DGENERATE_APPDATA=ON, -DENABLE_UPDATE_OVER_GUI=OFF, -DUSE_SYSTEM_OPENSSL:BOOL=ON, -DUSE_SSH=ON, -DUSE_SYSTEM_LIBSSH2=ON] builddir: true sources: - type: git From 8169d04aad4dad149ed5fe104ed41112d678fc2d Mon Sep 17 00:00:00 2001 From: Martin Marmsoler Date: Tue, 11 Jun 2024 14:44:08 +0200 Subject: [PATCH 24/40] libssh2 required --- dep/libssh2/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dep/libssh2/CMakeLists.txt b/dep/libssh2/CMakeLists.txt index f43c150e6..58d2b9627 100644 --- a/dep/libssh2/CMakeLists.txt +++ b/dep/libssh2/CMakeLists.txt @@ -1,6 +1,6 @@ if(USE_SYSTEM_LIBSSH2) if(PKG_CONFIG_FOUND) - pkg_check_modules(LIBSSH2 libssh2) + pkg_check_modules(LIBSSH2 REQUIRED libssh2) endif() else() From 4fb03ae99b340bdfdfe37bf2724739726a4250d8 Mon Sep 17 00:00:00 2001 From: Martin Marmsoler Date: Tue, 11 Jun 2024 15:26:51 +0200 Subject: [PATCH 25/40] install dev so that the header is available for compilation --- .github/workflows/build.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5240848c5..66c0c9b22 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -204,6 +204,7 @@ jobs: run: | sudo apt-get update sudo apt-get -y install libssh2-1 + sudo apt-get -y install libssh2-1-dev - name: Install Qt uses: jurplel/install-qt-action@v3.3.0 From 19a76eb1339ce6ad529250932d90dd4e6a860ef0 Mon Sep 17 00:00:00 2001 From: Martin Marmsoler Date: Tue, 11 Jun 2024 16:03:17 +0200 Subject: [PATCH 26/40] cmake flags to enable ssh for libgit2 --- .github/workflows/build.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 66c0c9b22..f2410b092 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -143,6 +143,7 @@ jobs: ninja_platform: mac qt_platform: mac openssl_arch: darwin64-x86_64-cc + cmake_flags: "-DUSE_SSH=ON" cmake_env: {} pack: 1 @@ -154,6 +155,7 @@ jobs: qt_arch_check_only: win64_msvc2017_64 openssl_arch: VC-WIN64A msvc_arch: x64 + cmake_flags: "-DUSE_SSH=ON" cmake_env: CMAKE_RC_FLAGS: "/C 1252" CC: clang @@ -168,6 +170,7 @@ jobs: qt_arch_check_only: win32_msvc2017 openssl_arch: VC-WIN32 msvc_arch: x86 + cmake_flags: "-DUSE_SSH=ON" cmake_env: CMAKE_RC_FLAGS: "/C 1252" CC: clang From 3aabc673fb3ab5d756d14878e63114cbcd84a5b4 Mon Sep 17 00:00:00 2001 From: Martin Marmsoler Date: Tue, 11 Jun 2024 17:13:38 +0200 Subject: [PATCH 27/40] TESTING --- com.github.Murmele.Gittyup.yml | 2 +- dep/libgit2/CMakeLists.txt | 2 +- src/git/Remote.cpp | 2 +- src/index/CMakeLists.txt | 13 ++++++------- 4 files changed, 9 insertions(+), 10 deletions(-) diff --git a/com.github.Murmele.Gittyup.yml b/com.github.Murmele.Gittyup.yml index 4e0cdd73a..d78d0f6d6 100644 --- a/com.github.Murmele.Gittyup.yml +++ b/com.github.Murmele.Gittyup.yml @@ -87,4 +87,4 @@ modules: sources: - type: git url: https://github.com/Murmele/Gittyup.git - tag: gittyup_v1.3.0 + branch: libgit2update diff --git a/dep/libgit2/CMakeLists.txt b/dep/libgit2/CMakeLists.txt index 473a21e9f..3ae4a3aca 100644 --- a/dep/libgit2/CMakeLists.txt +++ b/dep/libgit2/CMakeLists.txt @@ -11,7 +11,7 @@ set(STATIC_CRT # Enabled manually. Don't search for it. set(USE_SSH - OFF + ON CACHE BOOL "" FORCE) if(WIN32) diff --git a/src/git/Remote.cpp b/src/git/Remote.cpp index da47bfc04..24f3c8319 100644 --- a/src/git/Remote.cpp +++ b/src/git/Remote.cpp @@ -18,7 +18,7 @@ #include "git2/remote.h" #include "git2/signature.h" #include "git2/sys/errors.h" -#include "libssh2.h" +#include #include #include #include diff --git a/src/index/CMakeLists.txt b/src/index/CMakeLists.txt index 1393259d2..d4c04f27f 100644 --- a/src/index/CMakeLists.txt +++ b/src/index/CMakeLists.txt @@ -11,14 +11,13 @@ target_link_libraries( Qt5::Concurrent) set_target_properties(index PROPERTIES AUTOMOC ON) +# if(ENABLE_TESTS) +# 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) -endif() +# add_executable(index_test index_test.cpp) +# target_link_libraries(index_test index Qt5::Widgets) +# endif() add_executable(indexer indexer.cpp) target_link_libraries(indexer index) From d6ea21aeafc6fa1d77aa55943cc791c200541e89 Mon Sep 17 00:00:00 2001 From: Martin Marmsoler Date: Tue, 11 Jun 2024 21:56:41 +0200 Subject: [PATCH 28/40] change branch back Reason: to check if it still passes the flatpak build --- com.github.Murmele.Gittyup.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/com.github.Murmele.Gittyup.yml b/com.github.Murmele.Gittyup.yml index d78d0f6d6..4e0cdd73a 100644 --- a/com.github.Murmele.Gittyup.yml +++ b/com.github.Murmele.Gittyup.yml @@ -87,4 +87,4 @@ modules: sources: - type: git url: https://github.com/Murmele/Gittyup.git - branch: libgit2update + tag: gittyup_v1.3.0 From ebf2b603e6068ae20cb2fa6b84b5aca714ece226 Mon Sep 17 00:00:00 2001 From: Martin Marmsoler Date: Tue, 11 Jun 2024 22:23:43 +0200 Subject: [PATCH 29/40] set to off again --- dep/libgit2/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dep/libgit2/CMakeLists.txt b/dep/libgit2/CMakeLists.txt index 3ae4a3aca..ff3f7b6ba 100644 --- a/dep/libgit2/CMakeLists.txt +++ b/dep/libgit2/CMakeLists.txt @@ -11,7 +11,7 @@ set(STATIC_CRT # Enabled manually. Don't search for it. set(USE_SSH - ON + OFF CACHE BOOL "" FORCE) if(WIN32) From 593d791b8496d338800a375fc1b5f125777bdd8a Mon Sep 17 00:00:00 2001 From: Martin Marmsoler Date: Tue, 11 Jun 2024 23:17:29 +0200 Subject: [PATCH 30/40] if stashRef is invalid it should not checked further. Description: In a previous libgit2 version there was an assert and return if the stash is invalid, but in newer once it is not --- src/ui/ReferenceModel.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/ui/ReferenceModel.cpp b/src/ui/ReferenceModel.cpp index 5dbd29b3d..306edb35c 100644 --- a/src/ui/ReferenceModel.cpp +++ b/src/ui/ReferenceModel.cpp @@ -106,7 +106,8 @@ void ReferenceModel::update() { // Add bottom references. const bool stashOnCommit = !mCommit.isValid() || - mRepo.stashRef().annotatedCommit().commit() == mCommit; + (mRepo.stashRef().isValid() && + mRepo.stashRef().annotatedCommit().commit() == mCommit); if ((mKinds & ReferenceView::Stash) && stashOnCommit) { if (git::Reference stash = mRepo.stashRef()) branches.append(stash); @@ -180,8 +181,9 @@ QModelIndex ReferenceModel::firstBranch() { // use the first valid ref after the invalid ref but only // it is not the stash if (ref.refs.count() > 1 && - ref.refs.at(1).annotatedCommit().commit() != - mRepo.stashRef().annotatedCommit().commit()) + (!mRepo.stashRef().isValid() || + ref.refs.at(1).annotatedCommit().commit() != + mRepo.stashRef().annotatedCommit().commit())) return createIndex(1, 0, ReferenceType::Branches); } else if (ref.refs.count() > 0) return createIndex(0, 0, ReferenceType::Branches); From 9250db731c806571c5b90c6d01e9baddd43930e8 Mon Sep 17 00:00:00 2001 From: Martin Marmsoler Date: Wed, 12 Jun 2024 18:54:51 +0200 Subject: [PATCH 31/40] remove USE_SSH variable, because libgit2 contains such an option --- dep/libgit2/CMakeLists.txt | 5 ----- 1 file changed, 5 deletions(-) diff --git a/dep/libgit2/CMakeLists.txt b/dep/libgit2/CMakeLists.txt index ff3f7b6ba..cc68df799 100644 --- a/dep/libgit2/CMakeLists.txt +++ b/dep/libgit2/CMakeLists.txt @@ -9,11 +9,6 @@ set(STATIC_CRT OFF CACHE BOOL "" FORCE) -# Enabled manually. Don't search for it. -set(USE_SSH - OFF - CACHE BOOL "" FORCE) - if(WIN32) # Disable search for OpenSSL. set(USE_OPENSSL From 684d6dd6a6e3043ce310bb2b161f340dfc29a3bf Mon Sep 17 00:00:00 2001 From: Martin Marmsoler Date: Sat, 15 Jun 2024 09:46:28 +0200 Subject: [PATCH 32/40] use default --- .github/workflows/build.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f2410b092..3c74bd63c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -143,7 +143,7 @@ jobs: ninja_platform: mac qt_platform: mac openssl_arch: darwin64-x86_64-cc - cmake_flags: "-DUSE_SSH=ON" + cmake_flags: "-DUSE_SSH=OFF" cmake_env: {} pack: 1 @@ -155,7 +155,7 @@ jobs: qt_arch_check_only: win64_msvc2017_64 openssl_arch: VC-WIN64A msvc_arch: x64 - cmake_flags: "-DUSE_SSH=ON" + cmake_flags: "-DUSE_SSH=OFF" cmake_env: CMAKE_RC_FLAGS: "/C 1252" CC: clang @@ -170,7 +170,7 @@ jobs: qt_arch_check_only: win32_msvc2017 openssl_arch: VC-WIN32 msvc_arch: x86 - cmake_flags: "-DUSE_SSH=ON" + cmake_flags: "-DUSE_SSH=OFF" cmake_env: CMAKE_RC_FLAGS: "/C 1252" CC: clang From 5a074eb582de257734a0eb5a1bfee639d09bfb39 Mon Sep 17 00:00:00 2001 From: Martin Marmsoler Date: Sat, 15 Jun 2024 11:06:15 +0200 Subject: [PATCH 33/40] patch libgit2 to support local build libssh2 --- .github/workflows/build.yml | 6 +++--- dep/libgit2/libgit2 | 2 +- dep/libgit2/rebaseGittyupLibgit2.sh | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 3c74bd63c..4659da6b3 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -143,7 +143,7 @@ jobs: ninja_platform: mac qt_platform: mac openssl_arch: darwin64-x86_64-cc - cmake_flags: "-DUSE_SSH=OFF" + cmake_flags: "-DUSE_SSH:STRING=localbuild" cmake_env: {} pack: 1 @@ -155,7 +155,7 @@ jobs: qt_arch_check_only: win64_msvc2017_64 openssl_arch: VC-WIN64A msvc_arch: x64 - cmake_flags: "-DUSE_SSH=OFF" + cmake_flags: "-DUSE_SSH:STRING=localbuild" cmake_env: CMAKE_RC_FLAGS: "/C 1252" CC: clang @@ -170,7 +170,7 @@ jobs: qt_arch_check_only: win32_msvc2017 openssl_arch: VC-WIN32 msvc_arch: x86 - cmake_flags: "-DUSE_SSH=OFF" + cmake_flags: "-DUSE_SSH:STRING=localbuild" cmake_env: CMAKE_RC_FLAGS: "/C 1252" CC: clang diff --git a/dep/libgit2/libgit2 b/dep/libgit2/libgit2 index d4c2f7603..7d8fceccc 160000 --- a/dep/libgit2/libgit2 +++ b/dep/libgit2/libgit2 @@ -1 +1 @@ -Subproject commit d4c2f7603e297cc972af2ec2d5bdab1cc3b825e0 +Subproject commit 7d8fceccc61c5e74a1d2d4e1ad01f807828b6568 diff --git a/dep/libgit2/rebaseGittyupLibgit2.sh b/dep/libgit2/rebaseGittyupLibgit2.sh index f57528b03..79a3cfbdd 100755 --- a/dep/libgit2/rebaseGittyupLibgit2.sh +++ b/dep/libgit2/rebaseGittyupLibgit2.sh @@ -1,4 +1,4 @@ -declare -a branches=("fetch_annotated_tags" "blame_abort" "disableRenameDetection" "checkout_deletion_notification" "diff_checkout" "fix_push_callback_issues" "disable_mmap" "context_line_accessor´" "disableRenameDetection" "hash" "callback_connect_disconnect" "libgit2_includes_public") +declare -a branches=("fetch_annotated_tags" "blame_abort" "disableRenameDetection" "checkout_deletion_notification" "diff_checkout" "fix_push_callback_issues" "disable_mmap" "context_line_accessor´" "disableRenameDetection" "hash" "callback_connect_disconnect" "libgit2_includes_public", "local_libssh2") cd libgit2 From 7fa1d4bbe1561d2918c56a9f05c90399afc63410 Mon Sep 17 00:00:00 2001 From: Martin Marmsoler Date: Wed, 26 Jun 2024 22:27:12 +0200 Subject: [PATCH 34/40] drop win32 support --- .github/workflows/build.yml | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4659da6b3..ec02e06d9 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -162,21 +162,6 @@ jobs: CXX: clang++ pack: 1 - - name: win32 - os: windows-latest - ninja_platform: win - qt_platform: windows - qt_arch: win32_msvc2019 - qt_arch_check_only: win32_msvc2017 - openssl_arch: VC-WIN32 - msvc_arch: x86 - cmake_flags: "-DUSE_SSH:STRING=localbuild" - cmake_env: - CMAKE_RC_FLAGS: "/C 1252" - CC: clang - CXX: clang++ - pack: 1 - steps: # otherwise the testcases will fail, because signature is invalid - name: Set git name and email @@ -408,7 +393,6 @@ jobs: automatic_release_tag: 'development' files: | **/artifacts/Gittyup win64/Gittyup*.exe - **/artifacts/Gittyup win32/Gittyup*.exe **/artifacts/Gittyup macos/Gittyup*.dmg **/artifacts/GittyupFlatpak/*.flatpak **/artifacts/GittyupAppImage/Gittyup*.AppImage @@ -423,7 +407,6 @@ jobs: automatic_release_tag: ${{ github.ref_name }} files: | **/artifacts/Gittyup win64/Gittyup*.exe - **/artifacts/Gittyup win32/Gittyup*.exe **/artifacts/Gittyup macos/Gittyup*.dmg **/artifacts/GittyupFlatpak/*.flatpak **/artifacts/GittyupAppImage/Gittyup*.AppImage From 895b9df7854b626f874a4e21f44b3321d3bac0e7 Mon Sep 17 00:00:00 2001 From: Martin Marmsoler Date: Wed, 26 Jun 2024 23:17:11 +0200 Subject: [PATCH 35/40] cmake format --- dep/libssh2/CMakeLists.txt | 2 +- src/index/CMakeLists.txt | 10 ++++------ 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/dep/libssh2/CMakeLists.txt b/dep/libssh2/CMakeLists.txt index 58d2b9627..28fc3a90b 100644 --- a/dep/libssh2/CMakeLists.txt +++ b/dep/libssh2/CMakeLists.txt @@ -1,6 +1,6 @@ if(USE_SYSTEM_LIBSSH2) if(PKG_CONFIG_FOUND) - pkg_check_modules(LIBSSH2 REQUIRED libssh2) + pkg_check_modules(LIBSSH2 REQUIRED libssh2) endif() else() diff --git a/src/index/CMakeLists.txt b/src/index/CMakeLists.txt index d4c04f27f..33500502c 100644 --- a/src/index/CMakeLists.txt +++ b/src/index/CMakeLists.txt @@ -11,13 +11,11 @@ target_link_libraries( Qt5::Concurrent) set_target_properties(index PROPERTIES AUTOMOC ON) -# if(ENABLE_TESTS) -# add_executable(lexer_test lexer_test.cpp) -# target_link_libraries(lexer_test index) +# if(ENABLE_TESTS) 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) -# endif() +# add_executable(index_test index_test.cpp) target_link_libraries(index_test +# index Qt5::Widgets) endif() add_executable(indexer indexer.cpp) target_link_libraries(indexer index) From 44456fbb64c5f7d83f1b108225c3851de51aef13 Mon Sep 17 00:00:00 2001 From: Martin Marmsoler Date: Sun, 8 Sep 2024 18:51:42 +0200 Subject: [PATCH 36/40] update openssl to version 3.4 --- dep/openssl/openssl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dep/openssl/openssl b/dep/openssl/openssl index 4cdc08318..b52451785 160000 --- a/dep/openssl/openssl +++ b/dep/openssl/openssl @@ -1 +1 @@ -Subproject commit 4cdc083185716c2e5fd4fb790e00589726c757a3 +Subproject commit b5245178509db0c04c5f74388f9f36ea6a266b4e From 15a05c7c7f4e0d062e1fc52a32e34d0e3ebca733 Mon Sep 17 00:00:00 2001 From: Martin Marmsoler Date: Mon, 4 Nov 2024 14:10:37 +0100 Subject: [PATCH 37/40] use system openssl for macOS --- .github/workflows/build.yml | 21 +-------------------- 1 file changed, 1 insertion(+), 20 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f82bd13d5..2606f3483 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -143,7 +143,7 @@ jobs: ninja_platform: mac qt_platform: mac openssl_arch: darwin64-x86_64-cc - cmake_flags: "-DUSE_SSH:STRING=localbuild" + cmake_flags: "-DUSE_SYSTEM_OPENSSL=ON -DUSE_SSH:STRING=localbuild" cmake_env: {} pack: 1 @@ -235,25 +235,6 @@ jobs: if: matrix.env.ninja_platform == 'win' uses: ilammy/setup-nasm@v1.2.0 - #- name: Build OpenSSL (Linux) - # if: matrix.env.ninja_platform == 'linux' - # run: | - # cd dep/openssl/openssl - # ./config -fPIC - # make - - - name: Build OpenSSL (macOS) - if: matrix.env.ninja_platform == 'mac' - run: | - cd dep/openssl/openssl - - # this is necessary until https://github.com/openssl/openssl/issues/18720 - # is fixed in OpenSSL 1.1.1r - export CFLAGS=-Wno-error=implicit-function-declaration - - ./Configure ${{ matrix.env.openssl_arch }} no-shared - make - - name: Build OpenSSL (Windows) if: matrix.env.ninja_platform == 'win' run: | From 1121015f952054714ba918b39ca62cdf4eefbea3 Mon Sep 17 00:00:00 2001 From: Martin Marmsoler Date: Mon, 4 Nov 2024 15:16:42 +0100 Subject: [PATCH 38/40] use correct openssl version --- pack/CMakeLists.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pack/CMakeLists.txt b/pack/CMakeLists.txt index c9b5f4de4..330d3b40a 100644 --- a/pack/CMakeLists.txt +++ b/pack/CMakeLists.txt @@ -156,12 +156,12 @@ if(NOT APPLE) if(NOT USE_SYSTEM_OPENSSL) if(WIN32) if(CMAKE_SIZEOF_VOID_P EQUAL 8) - set(SSL_LIB_SUFFIX "-1_1-x64.dll") + set(SSL_LIB_SUFFIX "-3_4-x64.dll") else() - set(SSL_LIB_SUFFIX "-1_1.dll") + set(SSL_LIB_SUFFIX "-3_4.dll") endif() else() - set(SSL_LIB_SUFFIX ".so.1.1") + set(SSL_LIB_SUFFIX ".so.3.4") endif() foreach(SSL_LIB_NAME ssl crypto) From 8a5f9f4488adfd9810e221c1d7ec2adaff9c23af Mon Sep 17 00:00:00 2001 From: Martin Marmsoler Date: Thu, 23 Jan 2025 14:21:10 +0100 Subject: [PATCH 39/40] update --- .github/workflows/build.yml | 2 +- CMakeLists.txt | 4 ++++ LICENSE.md | 2 +- pack/CMakeLists.txt | 1 - 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 2606f3483..9fd194bb6 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -139,7 +139,7 @@ jobs: cmake_env: {} - name: macos - os: macos-12 + os: macos-13 ninja_platform: mac qt_platform: mac openssl_arch: darwin64-x86_64-cc diff --git a/CMakeLists.txt b/CMakeLists.txt index 4bd47318e..f140c08fd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -72,6 +72,10 @@ set(LUA_MODULES_PATH "Path to the directory with native Lua modules (only relevant if system-wide Lua installation is used)" ) +if (NOT USE_SYSTEM_LIBSSH2) + set(USE_SSH "localbuild") +endif() + # Require C++17. set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED TRUE) diff --git a/LICENSE.md b/LICENSE.md index 4722beb8b..2d7800c59 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -1,7 +1,7 @@ MIT License Copyright (c) 2018 Scientific Toolworks, Inc. -Copyright (c) 2021-2024 Gittyup contributors +Copyright (c) 2021-2025 Gittyup contributors Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/pack/CMakeLists.txt b/pack/CMakeLists.txt index 330d3b40a..3729d2e0e 100644 --- a/pack/CMakeLists.txt +++ b/pack/CMakeLists.txt @@ -183,7 +183,6 @@ if(NOT APPLE) WORLD_READ WORLD_EXECUTE COMPONENT ${GITTYUP_NAME} - OPTIONAL # if we use the system libssh, we have not built openssl ) endforeach() endif() From 528b237ee2571c35453c5d709faa88eb735f9186 Mon Sep 17 00:00:00 2001 From: Martin Marmsoler Date: Thu, 23 Jan 2025 14:23:28 +0100 Subject: [PATCH 40/40] link libssh2 --- src/ui/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/src/ui/CMakeLists.txt b/src/ui/CMakeLists.txt index 79d96f803..a2e71f78e 100644 --- a/src/ui/CMakeLists.txt +++ b/src/ui/CMakeLists.txt @@ -75,6 +75,7 @@ target_link_libraries( tools update watcher + ${LIBSSH2_LIBRARIES} Qt5::Concurrent Qt5::Network Qt5::Widgets)