summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/cli.rs4
-rw-r--r--src/rewrite.rs3
-rw-r--r--src/tests/integration_test_utils.rs1
-rwxr-xr-xtests/test_color_only_output_matches_git_on_full_repo_history3
-rwxr-xr-xtests/test_deprecated_options26
5 files changed, 25 insertions, 12 deletions
diff --git a/src/cli.rs b/src/cli.rs
index d8b4e5be..52c58efc 100644
--- a/src/cli.rs
+++ b/src/cli.rs
@@ -330,6 +330,10 @@ pub struct Opt {
/// --file-decoration '' --hunk-decoration ''`.
pub color_only: bool,
+ #[structopt(long = "no-gitconfig")]
+ /// Do not take settings from git config files. See GIT CONFIG section.
+ pub no_gitconfig: bool,
+
#[structopt(long = "keep-plus-minus-markers")]
/// Prefix added/removed lines with a +/- character, respectively, exactly as git does. The
/// default behavior is to output a space character in place of these markers.
diff --git a/src/rewrite.rs b/src/rewrite.rs
index fc03cdea..38223ebd 100644
--- a/src/rewrite.rs
+++ b/src/rewrite.rs
@@ -43,6 +43,9 @@ fn _rewrite_options_to_honor_git_config(
git_config: &mut Option<git2::Config>,
arg_matches: Option<&clap::ArgMatches>,
) {
+ if opt.no_gitconfig {
+ return;
+ }
// --preset must be set first
set_delta_options__option_string!([("preset", preset)], opt, git_config, arg_matches);
set_delta_options__bool!(
diff --git a/src/tests/integration_test_utils.rs b/src/tests/integration_test_utils.rs
index 5737b4d0..940c9d44 100644
--- a/src/tests/integration_test_utils.rs
+++ b/src/tests/integration_test_utils.rs
@@ -14,6 +14,7 @@ pub mod integration_test_utils {
pub fn get_command_line_options() -> cli::Opt {
let mut opt = cli::Opt::from_iter(Vec::<OsString>::new());
opt.syntax_theme = None; // TODO: Why does opt.syntax_theme have the value Some("")?
+ opt.no_gitconfig = true;
opt
}
diff --git a/tests/test_color_only_output_matches_git_on_full_repo_history b/tests/test_color_only_output_matches_git_on_full_repo_history
index c4513f75..c654863c 100755
--- a/tests/test_color_only_output_matches_git_on_full_repo_history
+++ b/tests/test_color_only_output_matches_git_on_full_repo_history
@@ -1,3 +1,4 @@
#!/bin/bash
+DELTA="./target/release/delta --no-gitconfig --color-only"
GIT_ARGS="log --patch --stat --numstat"
-diff -u <(git $GIT_ARGS | perl -pe 's/\e\[[0-9;]*[mK]//g') <(git $GIT_ARGS | ./target/release/delta --color-only | perl -pe 's/\e\[[0-9;]*[mK]//g')
+diff -u <(git $GIT_ARGS | perl -pe 's/\e\[[0-9;]*[mK]//g') <(git $GIT_ARGS | $DELTA | perl -pe 's/\e\[[0-9;]*[mK]//g')
diff --git a/tests/test_deprecated_options b/tests/test_deprecated_options
index daf62581..2b058dc9 100755
--- a/tests/test_deprecated_options
+++ b/tests/test_deprecated_options
@@ -1,23 +1,27 @@
+#!/bin/bash
+
+DELTA="./target/release/delta --no-gitconfig"
+
foreground_color=red
for decoration_attr in box underline plain; do
- git show | ./target/release/delta --commit-style $decoration_attr
- git show | ./target/release/delta --file-style $decoration_attr
- git show | ./target/release/delta --hunk-style $decoration_attr
+ git show | $DELTA --commit-style $decoration_attr
+ git show | $DELTA --file-style $decoration_attr
+ git show | $DELTA --hunk-style $decoration_attr
- git show | ./target/release/delta --commit-color $foreground_color
- git show | ./target/release/delta --file-color $foreground_color
- git show | ./target/release/delta --hunk-color $foreground_color
+ git show | $DELTA --commit-color $foreground_color
+ git show | $DELTA --file-color $foreground_color
+ git show | $DELTA --hunk-color $foreground_color
- git show | ./target/release/delta --commit-color $foreground_color --commit-style $decoration_attr
- git show | ./target/release/delta --file-color $foreground_color --file-style $decoration_attr
- git show | ./target/release/delta --hunk-color $foreground_color --hunk-style $decoration_attr
+ git show | $DELTA --commit-color $foreground_color --commit-style $decoration_attr
+ git show | $DELTA --file-color $foreground_color --file-style $decoration_attr
+ git show | $DELTA --hunk-color $foreground_color --hunk-style $decoration_attr
done
background_color=blue
for option in --minus-color --plus-color --minus-emph-color --plus-emph-color; do
- git show | ./target/release/delta $option $background_color
+ git show | $DELTA $option $background_color
done
-git show | ./target/release/delta --theme=GitHub --highlight-removed
+git show | $DELTA --theme=GitHub --highlight-removed