optimize git2 for good measure, and enable them from tauri and cli

This commit is contained in:
Sebastian Thiel 2024-08-13 15:10:47 +02:00
parent c58112f157
commit 84b2db9685
No known key found for this signature in database
GPG Key ID: 9CB5EE7895E8268B
3 changed files with 13 additions and 0 deletions

View File

@ -9,6 +9,7 @@ mod command;
fn main() -> Result<()> {
let args: Args = clap::Parser::parse();
gitbutler_project::configure_git2();
match args.cmd {
args::Subcommands::Branch(vbranch::Platform { cmd }) => {

View File

@ -7,3 +7,14 @@ mod storage;
pub use controller::Controller;
pub use project::{ApiProject, AuthKey, CodePushState, FetchResult, Project, ProjectId};
pub use storage::UpdateRequest;
/// A utility to be used from applications to optimize `git2` configuration.
/// See comments for details.
pub fn configure_git2() {
// Do not re-hash each decoded objects for quite a significant performance gain.
// This delegates object validation to `git fsck`, which seems fair.
git2::opts::strict_hash_verification(false);
// Thus far, no broken object was created, and if that would be the case, tests should catch it.
// These settings are only changed from `main` of applications.
git2::opts::strict_object_creation(false);
}

View File

@ -20,6 +20,7 @@ use tauri::{generate_context, Manager};
use tauri_plugin_log::LogTarget;
fn main() {
gitbutler_project::configure_git2();
let tauri_context = generate_context!();
gitbutler_secret::secret::set_application_namespace(
&tauri_context.config().tauri.bundle.identifier,