summaryrefslogtreecommitdiffstats
path: root/src/options/set.rs
diff options
context:
space:
mode:
authorDan Davison <dandavison7@gmail.com>2020-08-08 11:36:02 -0400
committerDan Davison <dandavison7@gmail.com>2020-08-08 11:57:29 -0400
commit6669e6ad698e44c51856ab40fe0dc6d87b7cb4b7 (patch)
tree634b6382b515305f869144ff302c093ed4031db3 /src/options/set.rs
parentec2123597cb7cddf8b0d08b472ed963a3f99d488 (diff)
Disable side-by-side when color-only is in effect
Fixes #274
Diffstat (limited to 'src/options/set.rs')
-rw-r--r--src/options/set.rs21
1 files changed, 18 insertions, 3 deletions
diff --git a/src/options/set.rs b/src/options/set.rs
index 7a67ef97..92644a31 100644
--- a/src/options/set.rs
+++ b/src/options/set.rs
@@ -78,7 +78,14 @@ pub fn set_options(
let option_names = cli::Opt::get_option_names();
// Set features
- let builtin_features = features::make_builtin_features();
+ let mut builtin_features = features::make_builtin_features();
+
+ // --color-only is used for interactive.diffFilter (git add -p) and side-by-side cannot be used
+ // there (does not emit lines in 1-1 correspondence with raw git output). See #274.
+ if config::user_supplied_option("color-only", arg_matches) {
+ builtin_features.remove("side-by-side");
+ }
+
let features = gather_features(opt, &builtin_features, git_config);
opt.features = features.join(" ");
@@ -176,6 +183,12 @@ pub fn set_options(
opt.computed.inspect_raw_lines =
cli::InspectRawLines::from_str(&opt.inspect_raw_lines).unwrap();
opt.computed.paging_mode = parse_paging_mode(&opt.paging_mode);
+
+ // --color-only is used for interactive.diffFilter (git add -p) and side-by-side cannot be used
+ // there (does not emit lines in 1-1 correspondence with raw git output). See #274.
+ if opt.color_only {
+ opt.side_by_side = false;
+ }
}
#[allow(non_snake_case)]
@@ -581,10 +594,12 @@ pub mod tests {
#[test]
fn test_options_can_be_set_in_git_config() {
+ // In general the values here are not the default values. However there are some exceptions
+ // since e.g. color-only = true (non-default) forces side-by-side = false (default).
let git_config_contents = b"
[delta]
24-bit-color = never
- color-only = true
+ color-only = false
commit-decoration-style = black black
commit-style = black black
dark = false
@@ -639,7 +654,7 @@ pub mod tests {
);
assert_eq!(opt.true_color, "never");
- assert_eq!(opt.color_only, true);
+ assert_eq!(opt.color_only, false);
assert_eq!(opt.commit_decoration_style, "black black");
assert_eq!(opt.commit_style, "black black");
assert_eq!(opt.dark, false);