diff --git a/CMakeLists.txt b/CMakeLists.txt index 4a566204d..9e278427e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,7 +17,6 @@ option(NO_MARBLE "disable the marble widget" OFF) option(NO_DOCS "disable the docs" OFF) option(NO_PRINTING "disable the printing support" OFF) option(NO_USERMANUAL "don't include a viewer for the user manual" OFF) -option(USE_LIBGIT23_API "allow building with libgit2 master" OFF) option(FORCE_LIBSSH "force linking with libssh to workaround libgit2 bug" ON) option(SUBSURFACE_MOBILE "build the QtQuick version for mobile device" OFF) option(FBSUPPORT "allow posting to Facebook" ON) @@ -89,40 +88,37 @@ endif() if(LIBGIT2_FROM_PKGCONFIG) pkg_config_library(LIBGIT2 libgit2 REQUIRED) set(LIBGIT2_LIBRARIES "") - if(USE_LIBGIT23_API) - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DUSE_LIBGIT23_API") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DUSE_LIBGIT23_API") - if(ANDROID) - # for Android we need to force a static link against ssl and crypto - # this is a bit hacky, but it seems to work - set(LIBGIT2_LIBRARIES ${LIBGIT2_LIBRARIES} ${LIBGIT2_LIBRARY_DIRS}/libssl.a ${LIBGIT2_LIBRARY_DIRS}/libcrypto.a) - endif() - if(FORCE_LIBSSH) - pkg_config_library(LIBSSH2 libssh2 REQUIRED) - set(LIBGIT2_LIBRARIES ${LIBGIT2_LIBRARIES} ${LIBSSH2_LIBRARIES}) - endif() + if(ANDROID) + # for Android we need to force a static link against ssl and crypto + # this is a bit hacky, but it seems to work + set(LIBGIT2_LIBRARIES ${LIBGIT2_LIBRARIES} ${LIBGIT2_LIBRARY_DIRS}/libssl.a ${LIBGIT2_LIBRARY_DIRS}/libcrypto.a) + endif() + if(FORCE_LIBSSH) + pkg_config_library(LIBSSH2 libssh2 REQUIRED) + set(LIBGIT2_LIBRARIES ${LIBGIT2_LIBRARIES} ${LIBSSH2_LIBRARIES}) endif() else() find_package(LIBGIT2 REQUIRED) include_directories(${LIBGIT2_INCLUDE_DIR}) - if(USE_LIBGIT23_API) - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DUSE_LIBGIT23_API") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DUSE_LIBGIT23_API") - if(FORCE_LIBSSH) - find_package(Libssh2 QUIET CONFIG) - if ("${LIBSSH2_VERSION}" STRGREATER "1.6.1") - set(LIBSSH2_LIBRARIES Libssh2::libssh2) - endif() - if(!LIBSSH2_FOUND OR "${LIBSSH2_FOUND}" STREQUAL "") - pkg_config_library(LIBSSH2 libssh2 REQUIRED) - endif() + if(FORCE_LIBSSH) + find_package(Libssh2 QUIET CONFIG) + find_package(Libssh2 REQUIRED) + if ("${LIBSSH2_VERSION}" STRGREATER "1.6.1") + set(LIBSSH2_LIBRARIES Libssh2::libssh2) endif() - find_package(libcurl QUIET) - if(!LIBCURL_FOUND OR "${LIBCURL_FOUND}" STREQUAL "") - pkg_config_library(LIBCURL libcurl REQUIRED) + get_cmake_property(_variableNames VARIABLES) + foreach (_variableName ${_variableNames}) + message(STATUS "${_variableName}=${${_variableName}}") + endforeach() + if(!Libssh2_FOUND OR "${Libssh2_FOUND}" STREQUAL "") + pkg_config_library(LIBSSH2 libssh2 REQUIRED) endif() - set(LIBGIT2_LIBRARIES ${LIBGIT2_LIBRARIES} -L${LIBSSH2_LIBRARY_DIRS} ${LIBSSH2_LIBRARIES} ${LIBCURL_LIBRARIES}) endif() + find_package(libcurl QUIET) + if(!LIBCURL_FOUND OR "${LIBCURL_FOUND}" STREQUAL "") + pkg_config_library(LIBCURL libcurl REQUIRED) + endif() + set(LIBGIT2_LIBRARIES ${LIBGIT2_LIBRARIES} -L${LIBSSH2_LIBRARY_DIRS} ${LIBSSH2_LIBRARIES} ${LIBCURL_LIBRARIES}) endif() if(LIBDC_FROM_PKGCONFIG) @@ -311,6 +307,10 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") set(MACOSX_BUNDLE_GUI_IDENTIFIER "org.subsurface-divelog") set(MACOSX_BUNDLE_BUNDLE_NAME "Subsurface") endif() + + # on the Mac with Homebrew, libzip ends up with odd include dirs + include_directories(${LIBZIP_INCLUDE_DIRS}) + find_library(APP_SERVICES_LIBRARY ApplicationServices) find_library(HID_LIB HidApi) set(SUBSURFACE_LINK_LIBRARIES ${SUBSURFACE_LINK_LIBRARIES} ${HID_LIB}) diff --git a/desktop-widgets/mainwindow.cpp b/desktop-widgets/mainwindow.cpp index 93cd2d408..62b72441f 100644 --- a/desktop-widgets/mainwindow.cpp +++ b/desktop-widgets/mainwindow.cpp @@ -197,13 +197,7 @@ MainWindow::MainWindow() : QMainWindow(), plannerDetails->printPlan()->hide(); ui.menuFile->removeAction(ui.actionPrint); #endif -#ifndef USE_LIBGIT23_API - ui.menuFile->removeAction(ui.actionCloudstorageopen); - ui.menuFile->removeAction(ui.actionCloudstoragesave); - qDebug() << "disabled / made invisible the cloud storage stuff"; -#else enableDisableCloudActions(); -#endif GpsLocation *locationProvider = new GpsLocation(&report_message, this); if (!locationProvider->hasLocationsSource()) { @@ -314,10 +308,8 @@ void MainWindow::on_actionDiveSiteEdit_triggered() { void MainWindow::enableDisableCloudActions() { -#ifdef USE_LIBGIT23_API ui.actionCloudstorageopen->setEnabled(prefs.cloud_verification_status == CS_VERIFIED); ui.actionCloudstoragesave->setEnabled(prefs.cloud_verification_status == CS_VERIFIED); -#endif } PlannerDetails *MainWindow::plannerDetails() const { diff --git a/packaging/android/build.sh b/packaging/android/build.sh index b03bfef19..a7771bc1a 100644 --- a/packaging/android/build.sh +++ b/packaging/android/build.sh @@ -294,7 +294,6 @@ cmake $MOBILE_CMAKE \ -DFORCE_LIBSSH=ON \ -DLIBDC_FROM_PKGCONFIG=ON \ -DLIBGIT2_FROM_PKGCONFIG=ON \ - -DUSE_LIBGIT23_API=ON \ -DNO_MARBLE=ON \ -DNO_PRINTING=ON \ -DNO_USERMANUAL=ON \ diff --git a/packaging/windows/mxe-based-build.sh b/packaging/windows/mxe-based-build.sh index 16440560e..ea34b6c66 100755 --- a/packaging/windows/mxe-based-build.sh +++ b/packaging/windows/mxe-based-build.sh @@ -346,7 +346,6 @@ else -DCMAKE_BUILD_TYPE=$RELEASE \ -DQT_TRANSLATION_DIR="$BASEDIR"/mxe/usr/i686-w64-mingw32.shared/qt5/translations \ -DMAKENSIS=i686-w64-mingw32.shared-makensis \ - -DUSE_LIBGIT23_API=1 \ -DLIBDIVECOMPUTER_INCLUDE_DIR="$BASEDIR"/mxe/usr/i686-w64-mingw32.shared/include \ -DLIBDIVECOMPUTER_LIBRARIES="$BASEDIR"/mxe/usr/i686-w64-mingw32.shared/lib/libdivecomputer.dll.a \ -DMARBLE_INCLUDE_DIR="$BASEDIR"/mxe/usr/i686-w64-mingw32.shared/include \ diff --git a/scripts/build.sh b/scripts/build.sh index d18993d61..1ea0e3ef0 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -180,8 +180,7 @@ cmake -DCMAKE_BUILD_TYPE=Debug .. \ -DLIBDIVECOMPUTER_LIBRARIES=$INSTALL_ROOT/lib/libdivecomputer.a \ -DMARBLE_INCLUDE_DIR=$INSTALL_ROOT/include \ -DMARBLE_LIBRARIES=$INSTALL_ROOT/lib/libssrfmarblewidget.$SH_LIB_EXT \ - -DNO_PRINTING=OFF \ - -DUSE_LIBGIT23_API=1 + -DNO_PRINTING=OFF if [ $PLATFORM = Darwin ] ; then rm -rf Subsurface.app diff --git a/subsurface-core/git-access.c b/subsurface-core/git-access.c index 607789f98..79e52b5a4 100644 --- a/subsurface-core/git-access.c +++ b/subsurface-core/git-access.c @@ -17,34 +17,6 @@ #include "git-access.h" #include "gettext.h" -/* - * The libgit2 people are incompetent at making libraries. They randomly change - * the interfaces, often just renaming things without any sane way to know which - * version you should check for etc etc. It's a disgrace. - */ -#if !LIBGIT2_VER_MAJOR && LIBGIT2_VER_MINOR < 22 - #define git_remote_lookup(res, repo, name) git_remote_load(res, repo, name) - #if LIBGIT2_VER_MINOR <= 20 - #define git_remote_fetch(remote, refspecs, signature, reflog) git_remote_fetch(remote) - #else - #define git_remote_fetch(remote, refspecs, signature, reflog) git_remote_fetch(remote, signature, reflog) - #endif -#endif - -#if !USE_LIBGIT23_API && !LIBGIT2_VER_MAJOR && LIBGIT2_VER_MINOR == 22 - #define git_remote_push(remote,refspecs,opts) git_remote_push(remote,refspecs,opts,NULL,NULL) - #define git_reference_set_target(out,ref,id,log_message) git_reference_set_target(out,ref,id,NULL,log_message) - #define git_reset(repo,target,reset_type,checkout_opts) git_reset(repo,target,reset_type,checkout_opts,NULL,NULL) -#endif - -/* - * api break introduced in libgit2 master after 0.22 - let's guess this is the v0.23 API - */ -#if USE_LIBGIT23_API || (!LIBGIT2_VER_MAJOR && LIBGIT2_VER_MINOR >= 23) - #define git_branch_create(out, repo, branch_name, target, force, signature, log_message) \ - git_branch_create(out, repo, branch_name, target, force) -#endif - bool is_subsurface_cloud = false; int (*update_progress_cb)(int) = NULL; @@ -181,7 +153,6 @@ static int reset_to_remote(git_repository *repo, git_reference *local, const git return 0; } -#if USE_LIBGIT23_API int credential_ssh_cb(git_cred **out, const char *url, const char *username_from_url, @@ -225,8 +196,6 @@ int certificate_check_cb(git_cert *cert, int valid, const char *host, void *payl return valid; } -#endif - static int update_remote(git_repository *repo, git_remote *origin, git_reference *local, git_reference *remote, enum remote_transport rt) { git_push_options opts = GIT_PUSH_OPTIONS_INIT; @@ -239,14 +208,13 @@ static int update_remote(git_repository *repo, git_remote *origin, git_reference refspec.count = 1; refspec.strings = (char **)&name; -#if USE_LIBGIT23_API opts.callbacks.push_transfer_progress = &push_transfer_progress_cb; if (rt == RT_SSH) opts.callbacks.credentials = credential_ssh_cb; else if (rt == RT_HTTPS) opts.callbacks.credentials = credential_https_cb; opts.callbacks.certificate_check = certificate_check_cb; -#endif + if (git_remote_push(origin, &refspec, &opts)) { if (is_subsurface_cloud) return report_error(translate("gettextFromC", "Could not update Subsurface cloud storage, try again later")); @@ -274,11 +242,7 @@ static int try_to_git_merge(git_repository *repo, git_reference *local, git_refe } git_merge_init_options(&merge_options, GIT_MERGE_OPTIONS_VERSION); -#ifdef USE_LIBGIT23_API merge_options.tree_flags = GIT_MERGE_TREE_FIND_RENAMES; -#else - merge_options.flags = GIT_MERGE_TREE_FIND_RENAMES; -#endif merge_options.file_favor = GIT_MERGE_FILE_FAVOR_UNION; merge_options.rename_threshold = 100; if (git_commit_lookup(&local_commit, repo, local_id)) { @@ -475,7 +439,6 @@ static int check_remote_status(git_repository *repo, git_remote *origin, const c * let's push our branch */ git_strarray refspec; git_reference_list(&refspec, repo); -#if USE_LIBGIT23_API git_push_options opts = GIT_PUSH_OPTIONS_INIT; opts.callbacks.transfer_progress = &transfer_progress_cb; if (rt == RT_SSH) @@ -484,9 +447,6 @@ static int check_remote_status(git_repository *repo, git_remote *origin, const c opts.callbacks.credentials = credential_https_cb; opts.callbacks.certificate_check = certificate_check_cb; error = git_remote_push(origin, &refspec, &opts); -#else - error = git_remote_push(origin, &refspec, NULL); -#endif } else { error = try_to_update(repo, origin, local_ref, remote_ref, remote, branch, rt); git_reference_free(remote_ref); @@ -535,7 +495,6 @@ int sync_with_remote(git_repository *repo, const char *remote, const char *branc } if (verbose) fprintf(stderr, "git storage: fetch remote\n"); -#if USE_LIBGIT23_API git_fetch_options opts = GIT_FETCH_OPTIONS_INIT; opts.callbacks.transfer_progress = &transfer_progress_cb; if (rt == RT_SSH) @@ -544,9 +503,6 @@ int sync_with_remote(git_repository *repo, const char *remote, const char *branc opts.callbacks.credentials = credential_https_cb; opts.callbacks.certificate_check = certificate_check_cb; error = git_remote_fetch(origin, NULL, &opts, NULL); -#else - error = git_remote_fetch(origin, NULL, NULL, NULL); -#endif // NOTE! A fetch error is not fatal, we just report it if (error) { if (is_subsurface_cloud) @@ -654,7 +610,6 @@ static git_repository *create_local_repo(const char *localdir, const char *remot if (verbose) fprintf(stderr, "git storage: create_local_repo\n"); -#if USE_LIBGIT23_API opts.fetch_opts.callbacks.transfer_progress = &transfer_progress_cb; if (rt == RT_SSH) opts.fetch_opts.callbacks.credentials = credential_ssh_cb; @@ -662,7 +617,7 @@ static git_repository *create_local_repo(const char *localdir, const char *remot opts.fetch_opts.callbacks.credentials = credential_https_cb; opts.repository_cb = repository_create_cb; opts.fetch_opts.callbacks.certificate_check = certificate_check_cb; -#endif + opts.checkout_branch = branch; if (rt == RT_HTTPS && !canReachCloudServer()) return 0; diff --git a/subsurface-core/save-git.c b/subsurface-core/save-git.c index e4bf1a5cd..9bdf9dfd0 100644 --- a/subsurface-core/save-git.c +++ b/subsurface-core/save-git.c @@ -18,35 +18,6 @@ #include "version.h" #include "qthelperfromc.h" -/* - * handle libgit2 revision 0.20 and earlier - */ -#if !LIBGIT2_VER_MAJOR && LIBGIT2_VER_MINOR <= 20 && !defined(USE_LIBGIT21_API) - #define GIT_CHECKOUT_OPTIONS_INIT GIT_CHECKOUT_OPTS_INIT - #define git_checkout_options git_checkout_opts - #define git_branch_create(out,repo,branch_name,target,force,sig,msg) \ - git_branch_create(out,repo,branch_name,target,force) - #define git_reference_set_target(out,ref,target,signature,log_message) \ - git_reference_set_target(out,ref,target) -#endif -/* - * api break in libgit2 revision 0.22 - */ -#if !LIBGIT2_VER_MAJOR && LIBGIT2_VER_MINOR < 22 - #define git_treebuilder_new(out, repo, source) git_treebuilder_create(out, source) -#else - #define git_treebuilder_write(id, repo, bld) git_treebuilder_write(id, bld) -#endif -/* - * api break introduced in libgit2 master after 0.22 - let's guess this is the v0.23 API - */ -#if USE_LIBGIT23_API || (!LIBGIT2_VER_MAJOR && LIBGIT2_VER_MINOR >= 23) - #define git_branch_create(out, repo, branch_name, target, force, signature, log_message) \ - git_branch_create(out, repo, branch_name, target, force) - #define git_reference_set_target(out, ref, id, author, log_message) \ - git_reference_set_target(out, ref, id, log_message) -#endif - #define VA_BUF(b, fmt) do { va_list args; va_start(args, fmt); put_vformat(b, fmt, args); va_end(args); } while (0) static void cond_put_format(int cond, struct membuffer *b, const char *fmt, ...) @@ -1143,7 +1114,7 @@ static int create_new_commit(git_repository *repo, const char *remote, const cha } if (!ref) { - if (git_branch_create(&ref, repo, branch, commit, 0, author, "Create branch")) + if (git_branch_create(&ref, repo, branch, commit, 0)) return report_error("Failed to create branch '%s'", branch); } /* @@ -1162,7 +1133,7 @@ static int create_new_commit(git_repository *repo, const char *remote, const cha } } - if (git_reference_set_target(&ref, ref, &commit_id, author, "Subsurface save event")) + if (git_reference_set_target(&ref, ref, &commit_id, "Subsurface save event")) return report_error("Failed to update branch '%s'", branch); set_git_id(&commit_id); @@ -1187,7 +1158,7 @@ static int write_git_tree(git_repository *repo, struct dir *tree, git_oid *resul }; /* .. write out the resulting treebuilder */ - ret = git_treebuilder_write(result, repo, tree->files); + ret = git_treebuilder_write(result, tree->files); /* .. and free the now useless treebuilder */ git_treebuilder_free(tree->files);