From a8df8a550405ba6f3460e74c1d1b4384e6f68468 Mon Sep 17 00:00:00 2001 From: Ilia Date: Thu, 22 Jun 2023 18:41:46 +0300 Subject: [PATCH] feat: option to disable requiring git repository for git-ignore rules --- changelog/new.txt | 1 + config/full.toml | 4 +++- crates/rustic_core/src/backend/ignore.rs | 6 ++++++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/changelog/new.txt b/changelog/new.txt index 773d01712..17df6fe05 100644 --- a/changelog/new.txt +++ b/changelog/new.txt @@ -9,3 +9,4 @@ New features: - REST backend: Now allows to use custom TLS root certificates. - restore: The restore algorithm has been improved and should now be faster for remote repositories. - restore: Files are now allocated just before being first processed. This allows easier resumed restores. +- New option: `no-require-git` for backup - if enabled, a git repository is not required to apply `git-ignore` rule. diff --git a/config/full.toml b/config/full.toml index 4bf2895a9..f0181f42a 100644 --- a/config/full.toml +++ b/config/full.toml @@ -7,7 +7,7 @@ # Global options: These options are used for all commands. [global] -use-profile = [] +use-profile = [] log-level = "info" # any of "off", "error", "warn", "info", "debug", "trace"; default: "info" log-file = "/path/to/rustic.log" # Default: not set no-progress = false @@ -68,6 +68,7 @@ iglob = [] glob-file = [] iglob-file = [] git-ignore = false +no-require-git = false exclude-if-present = [".nobackup", "CACHEDIR.TAG"] # Default: not set one-file-system = false exclude-larger-than = "100MB" # Default: not set @@ -97,6 +98,7 @@ iglob = [] glob-file = [] iglob-file = [] git-ignore = false +no-require-git = false exclude-if-present = [".nobackup", "CACHEDIR.TAG"] # Default: not set one-file-system = false exclude-larger-than = "100MB" # Default: not set diff --git a/crates/rustic_core/src/backend/ignore.rs b/crates/rustic_core/src/backend/ignore.rs index f9f1df311..e0c65198d 100644 --- a/crates/rustic_core/src/backend/ignore.rs +++ b/crates/rustic_core/src/backend/ignore.rs @@ -96,6 +96,11 @@ pub struct LocalSourceFilterOptions { #[cfg_attr(feature = "merge", merge(strategy = merge::bool::overwrite_false))] git_ignore: bool, + /// Do not require a git repository to apply git-ignore rule + #[cfg_attr(feature = "clap", clap(long, help_heading = "Exclude options"))] + #[cfg_attr(feature = "merge", merge(strategy = merge::bool::overwrite_false))] + no_require_git: bool, + /// Exclude contents of directories containing this filename (can be specified multiple times) #[cfg_attr( feature = "clap", @@ -177,6 +182,7 @@ impl LocalSource { .hidden(false) .ignore(false) .git_ignore(filter_opts.git_ignore) + .require_git(!filter_opts.no_require_git) .sort_by_file_path(Path::cmp) .same_file_system(filter_opts.one_file_system) .max_filesize(filter_opts.exclude_larger_than.map(|s| s.as_u64()))