| 1 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::collectionsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/::{HashMaprust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/HashMap#, HashSetrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/HashSet#, VecDequerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/vec_deque/VecDeque#}; |
| 2 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::convertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/::TryIntorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/TryInto#; |
| 3 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/::Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#; |
| 4 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/::FromStrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/traits/FromStr#; |
| 5 | |
| 6 | use batrust-analyzer cargo bat 0.26.1 crate/::assetsrust-analyzer cargo bat 0.26.1 assets/::HighlightingAssetsrust-analyzer cargo bat 0.26.1 assets/HighlightingAssets#; |
| 7 | use consolerust-analyzer cargo console 0.15.7 crate/::Termrust-analyzer cargo console 0.15.7 term/Term#; |
| 8 | |
| 9 | use craterust-analyzer cargo git-delta 0.19.2 crate/::clirust-analyzer cargo git-delta 0.19.2 cli/; |
| 10 | use craterust-analyzer cargo git-delta 0.19.2 crate/::configrust-analyzer cargo git-delta 0.19.2 config/; |
| 11 | use craterust-analyzer cargo git-delta 0.19.2 crate/::envrust-analyzer cargo git-delta 0.19.2 env/::DeltaEnvrust-analyzer cargo git-delta 0.19.2 env/DeltaEnv#; |
| 12 | use craterust-analyzer cargo git-delta 0.19.2 crate/::errorsrust-analyzer cargo git-delta 0.19.2 errors/::*; |
| 13 | use craterust-analyzer cargo git-delta 0.19.2 crate/::fatalrust-analyzer cargo git-delta 0.19.2 fatal().; |
| 14 | use craterust-analyzer cargo git-delta 0.19.2 crate/::featuresrust-analyzer cargo git-delta 0.19.2 features/; |
| 15 | use craterust-analyzer cargo git-delta 0.19.2 crate/::git_configrust-analyzer cargo git-delta 0.19.2 git_config/::GitConfigrust-analyzer cargo git-delta 0.19.2 git_config/GitConfig#; |
| 16 | use craterust-analyzer cargo git-delta 0.19.2 crate/::optionsrust-analyzer cargo git-delta 0.19.2 options/::option_valuerust-analyzer cargo git-delta 0.19.2 options/option_value/::{OptionValuerust-analyzer cargo git-delta 0.19.2 options/option_value/OptionValue#, ProvenancedOptionValuerust-analyzer cargo git-delta 0.19.2 options/option_value/ProvenancedOptionValue#}; |
| 17 | use craterust-analyzer cargo git-delta 0.19.2 crate/::optionsrust-analyzer cargo git-delta 0.19.2 options/::themerust-analyzer cargo git-delta 0.19.2 options/theme/; |
| 18 | use craterust-analyzer cargo git-delta 0.19.2 crate/::utilsrust-analyzer cargo git-delta 0.19.2 utils/::batrust-analyzer cargo git-delta 0.19.2 utils/bat/::outputrust-analyzer cargo git-delta 0.19.2 utils/bat/output/::PagingModerust-analyzer cargo git-delta 0.19.2 utils/bat/output/PagingMode#; |
| 19 | |
| 20 | macro_rules! set_optionsrust-analyzer cargo git-delta 0.19.2 options/set/set_options! { |
| 21 | ([$( $field_ident:ident ),* ], |
| 22 | $opt:expr, $builtin_features:expr, $git_config:expr, $arg_matches:expr, $expected_option_name_map:expr, $check_names:expr) => { |
| 23 | let mut option_names = HashSet::new(); |
| 24 | $( |
| 25 | let field_name = stringify!($field_ident); |
| 26 | let option_name = &$expected_option_name_map[field_name]; |
| 27 | if !$crate::config::user_supplied_option(&field_name, $arg_matches) { |
| 28 | if let Some(value) = $crate::options::get::get_option_value( |
| 29 | option_name, |
| 30 | &$builtin_features, |
| 31 | $opt, |
| 32 | $git_config |
| 33 | ) { |
| 34 | $opt.$field_ident = value; |
| 35 | } |
| 36 | } |
| 37 | if $check_names { |
| 38 | option_names.insert(option_name.as_str()); |
| 39 | } |
| 40 | )* |
| 41 | if $check_names { |
| 42 | option_names.extend(&[ |
| 43 | "24-bit-color", |
| 44 | "diff-highlight", // Does not exist as a flag on config |
| 45 | "diff-so-fancy", // Does not exist as a flag on config |
| 46 | "detect-dark-light", // Does not exist as a flag on config |
| 47 | "features", // Processed differently |
| 48 | // Set prior to the rest |
| 49 | "no-gitconfig", |
| 50 | "dark", |
| 51 | "light", |
| 52 | "syntax-theme", |
| 53 | ]); |
| 54 | let expected_option_names: HashSet<_> = $expected_option_name_map |
| 55 | .values() |
| 56 | .map(String::as_str) |
| 57 | .collect(); |
| 58 | |
| 59 | if option_names != expected_option_names { |
| 60 | $crate::config::delta_unreachable( |
| 61 | &format!("Error processing options.\nUnhandled names: {:?}\nInvalid names: {:?}.\n", |
| 62 | &expected_option_names - &option_names, |
| 63 | &option_names - &expected_option_names)); |
| 64 | } |
| 65 | } |
| 66 | } |
| 67 | } |
| 68 | |
| 69 | pub fn set_optionsrust-analyzer cargo git-delta 0.19.2 options/set/set_options().( |
| 70 | opt: &mut clirust-analyzer cargo git-delta 0.19.2 cli/::Optrust-analyzer cargo git-delta 0.19.2 cli/Opt#, |
| 71 | git_config: &mut Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<GitConfigrust-analyzer cargo git-delta 0.19.2 git_config/GitConfig#>, |
| 72 | arg_matches: &claprust-analyzer cargo clap 4.5.60 crate/::ArgMatchesrust-analyzer cargo clap_builder 4.5.60 parser/matches/arg_matches/ArgMatches#, |
| 73 | assets: HighlightingAssetsrust-analyzer cargo bat 0.26.1 assets/HighlightingAssets#, |
| 74 | ) { |
| 75 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(git_config) = git_config { |
| 76 | if opt.no_gitconfigrust-analyzer cargo git-delta 0.19.2 cli/Opt#no_gitconfig. { |
| 77 | git_config.enabledrust-analyzer cargo git-delta 0.19.2 git_config/GitConfig#enabled. = false; |
| 78 | } |
| 79 | } |
| 80 | opt.navigaterust-analyzer cargo git-delta 0.19.2 cli/Opt#navigate. = opt.navigaterust-analyzer cargo git-delta 0.19.2 cli/Opt#navigate. || opt.envrust-analyzer cargo git-delta 0.19.2 cli/Opt#env..navigaterust-analyzer cargo git-delta 0.19.2 env/DeltaEnv#navigate..is_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_some().(); |
| 81 | if opt.syntax_themerust-analyzer cargo git-delta 0.19.2 cli/Opt#syntax_theme..is_nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_none().() { |
| 82 | opt.syntax_themerust-analyzer cargo git-delta 0.19.2 cli/Opt#syntax_theme..clone_fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][Clone]clone_from().(&opt.envrust-analyzer cargo git-delta 0.19.2 cli/Opt#env..bat_themerust-analyzer cargo git-delta 0.19.2 env/DeltaEnv#bat_theme.); |
| 83 | } |
| 84 | |
| 85 | let option_names = clirust-analyzer cargo git-delta 0.19.2 cli/::Optrust-analyzer cargo git-delta 0.19.2 cli/Opt#::get_argument_and_option_namesrust-analyzer cargo git-delta 0.19.2 cli/impl#[Opt]get_argument_and_option_names().(); |
| 86 | |
| 87 | // Set features |
| 88 | let mut builtin_features = featuresrust-analyzer cargo git-delta 0.19.2 features/::make_builtin_featuresrust-analyzer cargo git-delta 0.19.2 features/make_builtin_features().(); |
| 89 | |
| 90 | // --color-only is used for interactive.diffFilter (git add -p) and side-by-side cannot be used |
| 91 | // there (does not emit lines in 1-1 correspondence with raw git output). See #274. |
| 92 | if configrust-analyzer cargo git-delta 0.19.2 config/::user_supplied_optionrust-analyzer cargo git-delta 0.19.2 config/user_supplied_option().("color_only", arg_matches) { |
| 93 | builtin_features.removerust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]remove().("side-by-side"); |
| 94 | } |
| 95 | |
| 96 | let features = gather_featuresrust-analyzer cargo git-delta 0.19.2 options/set/gather_features().(opt, &builtin_features, git_config); |
| 97 | opt.featuresrust-analyzer cargo git-delta 0.19.2 cli/Opt#features. = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(features.joinrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc slice/impl#[`[T]`]join().(" ")); |
| 98 | |
| 99 | // Set light, dark, and syntax-theme. |
| 100 | set__light__dark__syntax_theme__optionsrust-analyzer cargo git-delta 0.19.2 options/set/set__light__dark__syntax_theme__options().(opt, git_config, arg_matches, &option_names); |
| 101 | |
| 102 | // HACK: make minus-line styles have syntax-highlighting iff side-by-side. |
| 103 | if features.containsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]contains().(&"side-by-side".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()) { |
| 104 | let prefix = "normal "; |
| 105 | if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().configrust-analyzer cargo git-delta 0.19.2 config/::user_supplied_optionrust-analyzer cargo git-delta 0.19.2 config/user_supplied_option().("minus_style", arg_matches) |
| 106 | && opt.minus_stylerust-analyzer cargo git-delta 0.19.2 cli/Opt#minus_style..starts_withrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]starts_with().(prefix) |
| 107 | { |
| 108 | opt.minus_stylerust-analyzer cargo git-delta 0.19.2 cli/Opt#minus_style. = formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("syntax {}", &opt.minus_stylerust-analyzer cargo git-delta 0.19.2 cli/Opt#minus_style.[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`Index<I>`]index().prefix.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]len().()..]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`Index<I>`]index().); |
| 109 | } |
| 110 | if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().configrust-analyzer cargo git-delta 0.19.2 config/::user_supplied_optionrust-analyzer cargo git-delta 0.19.2 config/user_supplied_option().("minus_emph_style", arg_matches) |
| 111 | && opt.minus_emph_stylerust-analyzer cargo git-delta 0.19.2 cli/Opt#minus_emph_style..starts_withrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]starts_with().(prefix) |
| 112 | { |
| 113 | opt.minus_emph_stylerust-analyzer cargo git-delta 0.19.2 cli/Opt#minus_emph_style. = formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("syntax {}", &opt.minus_emph_stylerust-analyzer cargo git-delta 0.19.2 cli/Opt#minus_emph_style.[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`Index<I>`]index().prefix.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]len().()..]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`Index<I>`]index().); |
| 114 | } |
| 115 | } |
| 116 | |
| 117 | // Handle options which default to an arbitrary git config value. |
| 118 | // TODO: incorporate this logic into the set_options macro. |
| 119 | if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().configrust-analyzer cargo git-delta 0.19.2 config/::user_supplied_optionrust-analyzer cargo git-delta 0.19.2 config/user_supplied_option().("whitespace_error_style", arg_matches) { |
| 120 | opt.whitespace_error_stylerust-analyzer cargo git-delta 0.19.2 cli/Opt#whitespace_error_style. = if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(git_config) = git_config { |
| 121 | git_config.getrust-analyzer cargo git-delta 0.19.2 git_config/impl#[GitConfig]get().::<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>("color.diff.whitespace") |
| 122 | } else { |
| 123 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# |
| 124 | } |
| 125 | .unwrap_or_elserust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or_else().(|| "magenta reverse".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()) |
| 126 | } |
| 127 | |
| 128 | set_optionsrust-analyzer cargo git-delta 0.19.2 options/set/set_options!!( |
| 129 | [ |
| 130 | blame_code_stylerust-analyzer cargo git-delta 0.19.2 cli/Opt#blame_code_style., |
| 131 | blame_formatrust-analyzer cargo git-delta 0.19.2 cli/Opt#blame_format., |
| 132 | blame_separator_formatrust-analyzer cargo git-delta 0.19.2 cli/Opt#blame_separator_format., |
| 133 | blame_paletterust-analyzer cargo git-delta 0.19.2 cli/Opt#blame_palette., |
| 134 | blame_separator_stylerust-analyzer cargo git-delta 0.19.2 cli/Opt#blame_separator_style., |
| 135 | blame_timestamp_formatrust-analyzer cargo git-delta 0.19.2 cli/Opt#blame_timestamp_format., |
| 136 | blame_timestamp_output_formatrust-analyzer cargo git-delta 0.19.2 cli/Opt#blame_timestamp_output_format., |
| 137 | color_onlyrust-analyzer cargo git-delta 0.19.2 cli/Opt#color_only., |
| 138 | configrust-analyzer cargo git-delta 0.19.2 cli/Opt#config., |
| 139 | commit_decoration_stylerust-analyzer cargo git-delta 0.19.2 cli/Opt#commit_decoration_style., |
| 140 | commit_regexrust-analyzer cargo git-delta 0.19.2 cli/Opt#commit_regex., |
| 141 | commit_stylerust-analyzer cargo git-delta 0.19.2 cli/Opt#commit_style., |
| 142 | default_languagerust-analyzer cargo git-delta 0.19.2 cli/Opt#default_language., |
| 143 | diff_argsrust-analyzer cargo git-delta 0.19.2 cli/Opt#diff_args., |
| 144 | diff_stat_align_widthrust-analyzer cargo git-delta 0.19.2 cli/Opt#diff_stat_align_width., |
| 145 | file_added_labelrust-analyzer cargo git-delta 0.19.2 cli/Opt#file_added_label., |
| 146 | file_copied_labelrust-analyzer cargo git-delta 0.19.2 cli/Opt#file_copied_label., |
| 147 | file_decoration_stylerust-analyzer cargo git-delta 0.19.2 cli/Opt#file_decoration_style., |
| 148 | file_modified_labelrust-analyzer cargo git-delta 0.19.2 cli/Opt#file_modified_label., |
| 149 | file_removed_labelrust-analyzer cargo git-delta 0.19.2 cli/Opt#file_removed_label., |
| 150 | file_renamed_labelrust-analyzer cargo git-delta 0.19.2 cli/Opt#file_renamed_label., |
| 151 | file_regex_replacementrust-analyzer cargo git-delta 0.19.2 cli/Opt#file_regex_replacement., |
| 152 | right_arrowrust-analyzer cargo git-delta 0.19.2 cli/Opt#right_arrow., |
| 153 | hunk_labelrust-analyzer cargo git-delta 0.19.2 cli/Opt#hunk_label., |
| 154 | file_stylerust-analyzer cargo git-delta 0.19.2 cli/Opt#file_style., |
| 155 | grep_context_line_stylerust-analyzer cargo git-delta 0.19.2 cli/Opt#grep_context_line_style., |
| 156 | grep_file_stylerust-analyzer cargo git-delta 0.19.2 cli/Opt#grep_file_style., |
| 157 | grep_header_decoration_stylerust-analyzer cargo git-delta 0.19.2 cli/Opt#grep_header_decoration_style., |
| 158 | grep_header_file_stylerust-analyzer cargo git-delta 0.19.2 cli/Opt#grep_header_file_style., |
| 159 | grep_output_typerust-analyzer cargo git-delta 0.19.2 cli/Opt#grep_output_type., |
| 160 | grep_line_number_stylerust-analyzer cargo git-delta 0.19.2 cli/Opt#grep_line_number_style., |
| 161 | grep_match_line_stylerust-analyzer cargo git-delta 0.19.2 cli/Opt#grep_match_line_style., |
| 162 | grep_match_word_stylerust-analyzer cargo git-delta 0.19.2 cli/Opt#grep_match_word_style., |
| 163 | grep_separator_symbolrust-analyzer cargo git-delta 0.19.2 cli/Opt#grep_separator_symbol., |
| 164 | hunk_header_decoration_stylerust-analyzer cargo git-delta 0.19.2 cli/Opt#hunk_header_decoration_style., |
| 165 | hunk_header_file_stylerust-analyzer cargo git-delta 0.19.2 cli/Opt#hunk_header_file_style., |
| 166 | hunk_header_line_number_stylerust-analyzer cargo git-delta 0.19.2 cli/Opt#hunk_header_line_number_style., |
| 167 | hunk_header_stylerust-analyzer cargo git-delta 0.19.2 cli/Opt#hunk_header_style., |
| 168 | hyperlinksrust-analyzer cargo git-delta 0.19.2 cli/Opt#hyperlinks., |
| 169 | hyperlinks_commit_link_formatrust-analyzer cargo git-delta 0.19.2 cli/Opt#hyperlinks_commit_link_format., |
| 170 | hyperlinks_file_link_formatrust-analyzer cargo git-delta 0.19.2 cli/Opt#hyperlinks_file_link_format., |
| 171 | inline_hint_stylerust-analyzer cargo git-delta 0.19.2 cli/Opt#inline_hint_style., |
| 172 | inspect_raw_linesrust-analyzer cargo git-delta 0.19.2 cli/Opt#inspect_raw_lines., |
| 173 | keep_plus_minus_markersrust-analyzer cargo git-delta 0.19.2 cli/Opt#keep_plus_minus_markers., |
| 174 | line_buffer_sizerust-analyzer cargo git-delta 0.19.2 cli/Opt#line_buffer_size., |
| 175 | map_stylesrust-analyzer cargo git-delta 0.19.2 cli/Opt#map_styles., |
| 176 | max_line_distancerust-analyzer cargo git-delta 0.19.2 cli/Opt#max_line_distance., |
| 177 | max_line_lengthrust-analyzer cargo git-delta 0.19.2 cli/Opt#max_line_length., |
| 178 | max_syntax_lengthrust-analyzer cargo git-delta 0.19.2 cli/Opt#max_syntax_length., |
| 179 | // Hack: minus-style must come before minus-*emph-style because the latter default |
| 180 | // dynamically to the value of the former. |
| 181 | merge_conflict_begin_symbolrust-analyzer cargo git-delta 0.19.2 cli/Opt#merge_conflict_begin_symbol., |
| 182 | merge_conflict_end_symbolrust-analyzer cargo git-delta 0.19.2 cli/Opt#merge_conflict_end_symbol., |
| 183 | merge_conflict_ours_diff_header_decoration_stylerust-analyzer cargo git-delta 0.19.2 cli/Opt#merge_conflict_ours_diff_header_decoration_style., |
| 184 | merge_conflict_ours_diff_header_stylerust-analyzer cargo git-delta 0.19.2 cli/Opt#merge_conflict_ours_diff_header_style., |
| 185 | merge_conflict_theirs_diff_header_decoration_stylerust-analyzer cargo git-delta 0.19.2 cli/Opt#merge_conflict_theirs_diff_header_decoration_style., |
| 186 | merge_conflict_theirs_diff_header_stylerust-analyzer cargo git-delta 0.19.2 cli/Opt#merge_conflict_theirs_diff_header_style., |
| 187 | minus_stylerust-analyzer cargo git-delta 0.19.2 cli/Opt#minus_style., |
| 188 | minus_emph_stylerust-analyzer cargo git-delta 0.19.2 cli/Opt#minus_emph_style., |
| 189 | minus_empty_line_marker_stylerust-analyzer cargo git-delta 0.19.2 cli/Opt#minus_empty_line_marker_style., |
| 190 | minus_non_emph_stylerust-analyzer cargo git-delta 0.19.2 cli/Opt#minus_non_emph_style., |
| 191 | minus_non_emph_stylerust-analyzer cargo git-delta 0.19.2 cli/Opt#minus_non_emph_style., |
| 192 | navigaterust-analyzer cargo git-delta 0.19.2 cli/Opt#navigate., |
| 193 | navigate_regexrust-analyzer cargo git-delta 0.19.2 cli/Opt#navigate_regex., |
| 194 | line_fill_methodrust-analyzer cargo git-delta 0.19.2 cli/Opt#line_fill_method., |
| 195 | line_numbersrust-analyzer cargo git-delta 0.19.2 cli/Opt#line_numbers., |
| 196 | line_numbers_left_formatrust-analyzer cargo git-delta 0.19.2 cli/Opt#line_numbers_left_format., |
| 197 | line_numbers_left_stylerust-analyzer cargo git-delta 0.19.2 cli/Opt#line_numbers_left_style., |
| 198 | line_numbers_minus_stylerust-analyzer cargo git-delta 0.19.2 cli/Opt#line_numbers_minus_style., |
| 199 | line_numbers_plus_stylerust-analyzer cargo git-delta 0.19.2 cli/Opt#line_numbers_plus_style., |
| 200 | line_numbers_right_formatrust-analyzer cargo git-delta 0.19.2 cli/Opt#line_numbers_right_format., |
| 201 | line_numbers_right_stylerust-analyzer cargo git-delta 0.19.2 cli/Opt#line_numbers_right_style., |
| 202 | line_numbers_zero_stylerust-analyzer cargo git-delta 0.19.2 cli/Opt#line_numbers_zero_style., |
| 203 | pagerrust-analyzer cargo git-delta 0.19.2 cli/Opt#pager., |
| 204 | paging_moderust-analyzer cargo git-delta 0.19.2 cli/Opt#paging_mode., |
| 205 | parse_ansirust-analyzer cargo git-delta 0.19.2 cli/Opt#parse_ansi., |
| 206 | // Hack: plus-style must come before plus-*emph-style because the latter default |
| 207 | // dynamically to the value of the former. |
| 208 | plus_stylerust-analyzer cargo git-delta 0.19.2 cli/Opt#plus_style., |
| 209 | plus_emph_stylerust-analyzer cargo git-delta 0.19.2 cli/Opt#plus_emph_style., |
| 210 | plus_empty_line_marker_stylerust-analyzer cargo git-delta 0.19.2 cli/Opt#plus_empty_line_marker_style., |
| 211 | plus_non_emph_stylerust-analyzer cargo git-delta 0.19.2 cli/Opt#plus_non_emph_style., |
| 212 | rawrust-analyzer cargo git-delta 0.19.2 cli/Opt#raw., |
| 213 | relative_pathsrust-analyzer cargo git-delta 0.19.2 cli/Opt#relative_paths., |
| 214 | show_colorsrust-analyzer cargo git-delta 0.19.2 cli/Opt#show_colors., |
| 215 | show_themesrust-analyzer cargo git-delta 0.19.2 cli/Opt#show_themes., |
| 216 | side_by_siderust-analyzer cargo git-delta 0.19.2 cli/Opt#side_by_side., |
| 217 | wrap_max_linesrust-analyzer cargo git-delta 0.19.2 cli/Opt#wrap_max_lines., |
| 218 | wrap_right_prefix_symbolrust-analyzer cargo git-delta 0.19.2 cli/Opt#wrap_right_prefix_symbol., |
| 219 | wrap_right_percentrust-analyzer cargo git-delta 0.19.2 cli/Opt#wrap_right_percent., |
| 220 | wrap_right_symbolrust-analyzer cargo git-delta 0.19.2 cli/Opt#wrap_right_symbol., |
| 221 | wrap_left_symbolrust-analyzer cargo git-delta 0.19.2 cli/Opt#wrap_left_symbol., |
| 222 | tab_widthrust-analyzer cargo git-delta 0.19.2 cli/Opt#tab_width., |
| 223 | tokenization_regexrust-analyzer cargo git-delta 0.19.2 cli/Opt#tokenization_regex., |
| 224 | true_colorrust-analyzer cargo git-delta 0.19.2 cli/Opt#true_color., |
| 225 | whitespace_error_stylerust-analyzer cargo git-delta 0.19.2 cli/Opt#whitespace_error_style., |
| 226 | widthrust-analyzer cargo git-delta 0.19.2 cli/Opt#width., |
| 227 | zero_stylerust-analyzer cargo git-delta 0.19.2 cli/Opt#zero_style. |
| 228 | ], |
| 229 | opt, |
| 230 | builtin_features, |
| 231 | git_config, |
| 232 | arg_matches, |
| 233 | &option_names, |
| 234 | true |
| 235 | ); |
| 236 | |
| 237 | // Setting ComputedValues |
| 238 | set_widths_and_isattyrust-analyzer cargo git-delta 0.19.2 options/set/set_widths_and_isatty().(opt); |
| 239 | set_true_colorrust-analyzer cargo git-delta 0.19.2 options/set/set_true_color().(opt); |
| 240 | themerust-analyzer cargo git-delta 0.19.2 options/theme/::set__color_mode__syntax_theme__syntax_setrust-analyzer cargo git-delta 0.19.2 options/theme/set__color_mode__syntax_theme__syntax_set().(opt, assets); |
| 241 | opt.computedrust-analyzer cargo git-delta 0.19.2 cli/Opt#computed..inspect_raw_linesrust-analyzer cargo git-delta 0.19.2 cli/ComputedValues#inspect_raw_lines. = |
| 242 | clirust-analyzer cargo git-delta 0.19.2 cli/::InspectRawLinesrust-analyzer cargo git-delta 0.19.2 cli/InspectRawLines#::from_strrust-analyzer cargo git-delta 0.19.2 options/set/impl#[`cli::InspectRawLines`][FromStr]from_str().(&opt.inspect_raw_linesrust-analyzer cargo git-delta 0.19.2 cli/Opt#inspect_raw_lines.).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 243 | opt.computedrust-analyzer cargo git-delta 0.19.2 cli/Opt#computed..paging_moderust-analyzer cargo git-delta 0.19.2 cli/ComputedValues#paging_mode. = parse_paging_moderust-analyzer cargo git-delta 0.19.2 options/set/parse_paging_mode().(&opt.paging_moderust-analyzer cargo git-delta 0.19.2 cli/Opt#paging_mode.); |
| 244 | |
| 245 | // --color-only is used for interactive.diffFilter (git add -p). side-by-side, and |
| 246 | // **-decoration-style cannot be used there (does not emit lines in 1-1 correspondence with raw git output). |
| 247 | // See #274. |
| 248 | if opt.color_onlyrust-analyzer cargo git-delta 0.19.2 cli/Opt#color_only. { |
| 249 | opt.side_by_siderust-analyzer cargo git-delta 0.19.2 cli/Opt#side_by_side. = false; |
| 250 | opt.file_decoration_stylerust-analyzer cargo git-delta 0.19.2 cli/Opt#file_decoration_style. = "none".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(); |
| 251 | opt.commit_decoration_stylerust-analyzer cargo git-delta 0.19.2 cli/Opt#commit_decoration_style. = "none".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(); |
| 252 | opt.hunk_header_decoration_stylerust-analyzer cargo git-delta 0.19.2 cli/Opt#hunk_header_decoration_style. = "none".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(); |
| 253 | } |
| 254 | } |
| 255 | |
| 256 | #[allow(non_snake_case)] |
| 257 | fn set__light__dark__syntax_theme__optionsrust-analyzer cargo git-delta 0.19.2 options/set/set__light__dark__syntax_theme__options().( |
| 258 | opt: &mut clirust-analyzer cargo git-delta 0.19.2 cli/::Optrust-analyzer cargo git-delta 0.19.2 cli/Opt#, |
| 259 | git_config: &mut Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<GitConfigrust-analyzer cargo git-delta 0.19.2 git_config/GitConfig#>, |
| 260 | arg_matches: &claprust-analyzer cargo clap 4.5.60 crate/::ArgMatchesrust-analyzer cargo clap_builder 4.5.60 parser/matches/arg_matches/ArgMatches#, |
| 261 | option_names: &HashMaprust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/HashMap#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>, |
| 262 | ) { |
| 263 | let validate_light_and_dark = |opt: &clirust-analyzer cargo git-delta 0.19.2 cli/::Optrust-analyzer cargo git-delta 0.19.2 cli/Opt#| { |
| 264 | if opt.lightrust-analyzer cargo git-delta 0.19.2 cli/Opt#light. && opt.darkrust-analyzer cargo git-delta 0.19.2 cli/Opt#dark. { |
| 265 | fatalrust-analyzer cargo git-delta 0.19.2 fatal().("--light and --dark cannot be used together."); |
| 266 | } |
| 267 | }; |
| 268 | let empty_builtin_features = HashMaprust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/HashMap#::newrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V>`]new().(); |
| 269 | validate_light_and_dark(opt); |
| 270 | if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().(opt.lightrust-analyzer cargo git-delta 0.19.2 cli/Opt#light. || opt.darkrust-analyzer cargo git-delta 0.19.2 cli/Opt#dark.) { |
| 271 | set_optionsrust-analyzer cargo git-delta 0.19.2 options/set/set_options!!( |
| 272 | [darkrust-analyzer cargo git-delta 0.19.2 cli/Opt#dark., lightrust-analyzer cargo git-delta 0.19.2 cli/Opt#light.], |
| 273 | opt, |
| 274 | &empty_builtin_features, |
| 275 | git_config, |
| 276 | arg_matches, |
| 277 | option_names, |
| 278 | false |
| 279 | ); |
| 280 | } |
| 281 | validate_light_and_dark(opt); |
| 282 | set_optionsrust-analyzer cargo git-delta 0.19.2 options/set/set_options!!( |
| 283 | [syntax_themerust-analyzer cargo git-delta 0.19.2 cli/Opt#syntax_theme.], |
| 284 | opt, |
| 285 | &empty_builtin_features, |
| 286 | git_config, |
| 287 | arg_matches, |
| 288 | option_names, |
| 289 | false |
| 290 | ); |
| 291 | } |
| 292 | |
| 293 | // Features are processed differently from all other options. The role of this function is to |
| 294 | // collect all configuration related to features and summarize it as a single list |
| 295 | // (space-separated string) of enabled features. The list is arranged in order of increasing |
| 296 | // priority in the sense that, when searching for a option value, one starts at the right-hand end |
| 297 | // and moves leftward, examining each feature in turn until a feature that associates a value with |
| 298 | // the option name is encountered. This search is documented in |
| 299 | // `get_option_value::get_option_value`. |
| 300 | // |
| 301 | // The feature list comprises features deriving from the following sources, listed in order of |
| 302 | // decreasing priority: |
| 303 | // |
| 304 | // 1. Suppose the command-line has `--features "a b"`. Then |
| 305 | // - `b`, followed by b's "ordered descendents" |
| 306 | // - `a`, followed by a's "ordered descendents" |
| 307 | // |
| 308 | // 2. Suppose the command line enables two builtin features via `--navigate --diff-so-fancy`. Then |
| 309 | // - `diff-so-fancy` |
| 310 | // - `navigate` |
| 311 | // |
| 312 | // 3. Suppose the main [delta] section has `features = d e`. Then |
| 313 | // - `e`, followed by e's "ordered descendents" |
| 314 | // - `d`, followed by d's "ordered descendents" |
| 315 | // |
| 316 | // 4. Suppose the main [delta] section has `diff-highlight = true` followed by `raw = true`. |
| 317 | // Then |
| 318 | // - `diff-highlight` |
| 319 | // - `raw` |
| 320 | // |
| 321 | // The "ordered descendents" of a feature `f` is a list of features obtained via a pre-order |
| 322 | // traversal of the feature tree rooted at `f`. This tree arises because it is allowed for a |
| 323 | // feature to contain a (key, value) pair that itself enables features. |
| 324 | // |
| 325 | // If a feature has already been included at higher priority, and is encountered again, it is |
| 326 | // ignored. |
| 327 | // |
| 328 | // Thus, for example: |
| 329 | // |
| 330 | // delta --features "my-navigate-settings" --navigate => "navigate my-navigate-settings" |
| 331 | // |
| 332 | // In the following configuration, the feature names indicate their priority, with `a` having |
| 333 | // highest priority: |
| 334 | // |
| 335 | // delta --g --features "d a" |
| 336 | // |
| 337 | // [delta "a"] |
| 338 | // features = c b |
| 339 | // |
| 340 | // [delta "d"] |
| 341 | // features = f e |
| 342 | fn gather_featuresrust-analyzer cargo git-delta 0.19.2 options/set/gather_features().( |
| 343 | opt: &mut clirust-analyzer cargo git-delta 0.19.2 cli/::Optrust-analyzer cargo git-delta 0.19.2 cli/Opt#, |
| 344 | builtin_features: &HashMaprust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/HashMap#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, featuresrust-analyzer cargo git-delta 0.19.2 features/::BuiltinFeaturerust-analyzer cargo git-delta 0.19.2 features/BuiltinFeature#>, |
| 345 | git_config: &Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<GitConfigrust-analyzer cargo git-delta 0.19.2 git_config/GitConfig#>, |
| 346 | ) -> Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#> { |
| 347 | let from_env_var = &opt.envrust-analyzer cargo git-delta 0.19.2 cli/Opt#env..featuresrust-analyzer cargo git-delta 0.19.2 env/DeltaEnv#features.; |
| 348 | let from_args = opt.featuresrust-analyzer cargo git-delta 0.19.2 cli/Opt#features..as_derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_deref().().unwrap_orrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or().(""); |
| 349 | let input_features: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<&str> = match from_env_var.as_derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_deref().() { |
| 350 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(from_env_var) if from_env_var.starts_withrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]starts_with().('+') => from_env_var[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().1..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFrom#]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index(). |
| 351 | .split_whitespacerust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]split_whitespace().() |
| 352 | .chainrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#chain().(split_feature_stringrust-analyzer cargo git-delta 0.19.2 options/set/split_feature_string().(from_args)) |
| 353 | .collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().(), |
| 354 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(from_env_var) => { |
| 355 | opt.featuresrust-analyzer cargo git-delta 0.19.2 cli/Opt#features. = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(from_env_var.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()); |
| 356 | split_feature_stringrust-analyzer cargo git-delta 0.19.2 options/set/split_feature_string().(from_env_var).collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().() |
| 357 | } |
| 358 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# => split_feature_stringrust-analyzer cargo git-delta 0.19.2 options/set/split_feature_string().(from_args).collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().(), |
| 359 | }; |
| 360 | |
| 361 | let mut features = VecDequerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/vec_deque/VecDeque#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/vec_deque/impl#[`VecDeque<T>`]new().(); |
| 362 | |
| 363 | // Gather features from command line. |
| 364 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(git_config) = git_config { |
| 365 | for feature in input_features { |
| 366 | gather_features_recursivelyrust-analyzer cargo git-delta 0.19.2 options/set/gather_features_recursively().(feature, &mut features, builtin_features, opt, git_config); |
| 367 | } |
| 368 | } else { |
| 369 | for feature in input_features { |
| 370 | features.push_frontrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/vec_deque/impl#[`VecDeque<T, A>`]push_front().(feature.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()); |
| 371 | } |
| 372 | } |
| 373 | |
| 374 | // Gather builtin feature flags supplied on command line. |
| 375 | // TODO: Iterate over programmatically-obtained names of builtin features. |
| 376 | if opt.rawrust-analyzer cargo git-delta 0.19.2 cli/Opt#raw. { |
| 377 | gather_builtin_features_recursivelyrust-analyzer cargo git-delta 0.19.2 options/set/gather_builtin_features_recursively().("raw", &mut features, builtin_features, opt); |
| 378 | } |
| 379 | if opt.color_onlyrust-analyzer cargo git-delta 0.19.2 cli/Opt#color_only. { |
| 380 | gather_builtin_features_recursivelyrust-analyzer cargo git-delta 0.19.2 options/set/gather_builtin_features_recursively().("color-only", &mut features, builtin_features, opt); |
| 381 | } |
| 382 | if opt.diff_highlightrust-analyzer cargo git-delta 0.19.2 cli/Opt#diff_highlight. { |
| 383 | gather_builtin_features_recursivelyrust-analyzer cargo git-delta 0.19.2 options/set/gather_builtin_features_recursively().("diff-highlight", &mut features, builtin_features, opt); |
| 384 | } |
| 385 | if opt.diff_so_fancyrust-analyzer cargo git-delta 0.19.2 cli/Opt#diff_so_fancy. { |
| 386 | gather_builtin_features_recursivelyrust-analyzer cargo git-delta 0.19.2 options/set/gather_builtin_features_recursively().("diff-so-fancy", &mut features, builtin_features, opt); |
| 387 | } |
| 388 | if opt.hyperlinksrust-analyzer cargo git-delta 0.19.2 cli/Opt#hyperlinks. { |
| 389 | gather_builtin_features_recursivelyrust-analyzer cargo git-delta 0.19.2 options/set/gather_builtin_features_recursively().("hyperlinks", &mut features, builtin_features, opt); |
| 390 | } |
| 391 | if opt.line_numbersrust-analyzer cargo git-delta 0.19.2 cli/Opt#line_numbers. { |
| 392 | gather_builtin_features_recursivelyrust-analyzer cargo git-delta 0.19.2 options/set/gather_builtin_features_recursively().("line-numbers", &mut features, builtin_features, opt); |
| 393 | } |
| 394 | if opt.navigaterust-analyzer cargo git-delta 0.19.2 cli/Opt#navigate. { |
| 395 | gather_builtin_features_recursivelyrust-analyzer cargo git-delta 0.19.2 options/set/gather_builtin_features_recursively().("navigate", &mut features, builtin_features, opt); |
| 396 | } |
| 397 | if opt.side_by_siderust-analyzer cargo git-delta 0.19.2 cli/Opt#side_by_side. { |
| 398 | gather_builtin_features_recursivelyrust-analyzer cargo git-delta 0.19.2 options/set/gather_builtin_features_recursively().("side-by-side", &mut features, builtin_features, opt); |
| 399 | } |
| 400 | |
| 401 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(git_config) = git_config { |
| 402 | // Gather features from [delta] section if --features was not passed. |
| 403 | if opt.featuresrust-analyzer cargo git-delta 0.19.2 cli/Opt#features..is_nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_none().() { |
| 404 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(feature_string) = git_config.getrust-analyzer cargo git-delta 0.19.2 git_config/impl#[GitConfig]get().::<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>("delta.features") { |
| 405 | for feature in split_feature_stringrust-analyzer cargo git-delta 0.19.2 options/set/split_feature_string().(&feature_string) { |
| 406 | gather_features_recursivelyrust-analyzer cargo git-delta 0.19.2 options/set/gather_features_recursively().( |
| 407 | feature, |
| 408 | &mut features, |
| 409 | builtin_features, |
| 410 | opt, |
| 411 | git_config, |
| 412 | ) |
| 413 | } |
| 414 | } |
| 415 | } |
| 416 | // Always gather builtin feature flags from [delta] section. |
| 417 | gather_builtin_features_from_flags_in_gitconfigrust-analyzer cargo git-delta 0.19.2 options/set/gather_builtin_features_from_flags_in_gitconfig().( |
| 418 | "delta", |
| 419 | &mut features, |
| 420 | builtin_features, |
| 421 | opt, |
| 422 | git_config, |
| 423 | ); |
| 424 | } |
| 425 | |
| 426 | Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>::fromrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/vec_deque/impl#[`Vec<T, A>`][`From<VecDeque<T, A>>`]from().(features) |
| 427 | } |
| 428 | |
| 429 | /// Add to feature list `features` all features in the tree rooted at `feature`. |
| 430 | fn gather_features_recursivelyrust-analyzer cargo git-delta 0.19.2 options/set/gather_features_recursively().( |
| 431 | feature: &str, |
| 432 | features: &mut VecDequerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/vec_deque/VecDeque#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>, |
| 433 | builtin_features: &HashMaprust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/HashMap#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, featuresrust-analyzer cargo git-delta 0.19.2 features/::BuiltinFeaturerust-analyzer cargo git-delta 0.19.2 features/BuiltinFeature#>, |
| 434 | opt: &clirust-analyzer cargo git-delta 0.19.2 cli/::Optrust-analyzer cargo git-delta 0.19.2 cli/Opt#, |
| 435 | git_config: &GitConfigrust-analyzer cargo git-delta 0.19.2 git_config/GitConfig#, |
| 436 | ) { |
| 437 | if builtin_features.contains_keyrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]contains_key().(feature) { |
| 438 | gather_builtin_features_recursivelyrust-analyzer cargo git-delta 0.19.2 options/set/gather_builtin_features_recursively().(feature, features, builtin_features, opt); |
| 439 | } else { |
| 440 | features.push_frontrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/vec_deque/impl#[`VecDeque<T, A>`]push_front().(feature.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()); |
| 441 | } |
| 442 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(child_features) = git_config.getrust-analyzer cargo git-delta 0.19.2 git_config/impl#[GitConfig]get().::<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>(&formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("delta.{feature}.features")) { |
| 443 | for child_feature in split_feature_stringrust-analyzer cargo git-delta 0.19.2 options/set/split_feature_string().(&child_features) { |
| 444 | if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().features.containsrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/vec_deque/impl#[`VecDeque<T, A>`]contains().(&child_feature.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()) { |
| 445 | gather_features_recursivelyrust-analyzer cargo git-delta 0.19.2 options/set/gather_features_recursively().( |
| 446 | child_feature, |
| 447 | features, |
| 448 | builtin_features, |
| 449 | opt, |
| 450 | git_config, |
| 451 | ) |
| 452 | } |
| 453 | } |
| 454 | } |
| 455 | gather_builtin_features_from_flags_in_gitconfigrust-analyzer cargo git-delta 0.19.2 options/set/gather_builtin_features_from_flags_in_gitconfig().( |
| 456 | &formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("delta.{feature}"), |
| 457 | features, |
| 458 | builtin_features, |
| 459 | opt, |
| 460 | git_config, |
| 461 | ); |
| 462 | } |
| 463 | |
| 464 | /// Look for builtin features requested via boolean feature flags (as opposed to via a "features" |
| 465 | /// list) in a custom feature section in git config and add them to the features list. |
| 466 | fn gather_builtin_features_from_flags_in_gitconfigrust-analyzer cargo git-delta 0.19.2 options/set/gather_builtin_features_from_flags_in_gitconfig().( |
| 467 | git_config_key: &str, |
| 468 | features: &mut VecDequerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/vec_deque/VecDeque#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>, |
| 469 | builtin_features: &HashMaprust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/HashMap#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, featuresrust-analyzer cargo git-delta 0.19.2 features/::BuiltinFeaturerust-analyzer cargo git-delta 0.19.2 features/BuiltinFeature#>, |
| 470 | opt: &clirust-analyzer cargo git-delta 0.19.2 cli/::Optrust-analyzer cargo git-delta 0.19.2 cli/Opt#, |
| 471 | git_config: &GitConfigrust-analyzer cargo git-delta 0.19.2 git_config/GitConfig#, |
| 472 | ) { |
| 473 | for child_feature in builtin_features.keysrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]keys().() { |
| 474 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(true) = git_config.getrust-analyzer cargo git-delta 0.19.2 git_config/impl#[GitConfig]get().::<bool>(&formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{git_config_key}.{child_feature}")) { |
| 475 | gather_builtin_features_recursivelyrust-analyzer cargo git-delta 0.19.2 options/set/gather_builtin_features_recursively().(child_feature, features, builtin_features, opt); |
| 476 | } |
| 477 | } |
| 478 | } |
| 479 | |
| 480 | /// Add to feature list `features` all builtin features in the tree rooted at `builtin_feature`. A |
| 481 | /// builtin feature is a named collection of (option-name, value) pairs. This tree arises because |
| 482 | /// those option names might include (a) a "features" list, and (b) boolean feature flags. I.e. the |
| 483 | /// children of a node in the tree are features in (a) and (b). (In both cases the features |
| 484 | /// referenced will be other builtin features, since a builtin feature is determined at compile |
| 485 | /// time and therefore cannot know of the existence of a non-builtin custom features in gitconfig). |
| 486 | fn gather_builtin_features_recursivelyrust-analyzer cargo git-delta 0.19.2 options/set/gather_builtin_features_recursively().( |
| 487 | feature: &str, |
| 488 | features: &mut VecDequerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/vec_deque/VecDeque#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>, |
| 489 | builtin_features: &HashMaprust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/HashMap#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, featuresrust-analyzer cargo git-delta 0.19.2 features/::BuiltinFeaturerust-analyzer cargo git-delta 0.19.2 features/BuiltinFeature#>, |
| 490 | opt: &clirust-analyzer cargo git-delta 0.19.2 cli/::Optrust-analyzer cargo git-delta 0.19.2 cli/Opt#, |
| 491 | ) { |
| 492 | let feature_string = feature.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(); |
| 493 | if features.containsrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/vec_deque/impl#[`VecDeque<T, A>`]contains().(&feature_string) { |
| 494 | return; |
| 495 | } |
| 496 | features.push_frontrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/vec_deque/impl#[`VecDeque<T, A>`]push_front().(feature_string); |
| 497 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(feature_data) = builtin_features.getrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]get().(feature) { |
| 498 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(child_features_fn) = feature_data.getrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]get().("features") { |
| 499 | if let ProvenancedOptionValuerust-analyzer cargo git-delta 0.19.2 options/option_value/ProvenancedOptionValue#::DefaultValuerust-analyzer cargo git-delta 0.19.2 options/option_value/ProvenancedOptionValue#DefaultValue#(OptionValuerust-analyzer cargo git-delta 0.19.2 options/option_value/OptionValue#::Stringrust-analyzer cargo git-delta 0.19.2 options/option_value/OptionValue#String#(features_string)) = |
| 500 | child_features_fn(opt, &Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#) |
| 501 | { |
| 502 | for child_feature in split_feature_stringrust-analyzer cargo git-delta 0.19.2 options/set/split_feature_string().(&features_string) { |
| 503 | gather_builtin_features_recursivelyrust-analyzer cargo git-delta 0.19.2 options/set/gather_builtin_features_recursively().( |
| 504 | child_feature, |
| 505 | features, |
| 506 | builtin_features, |
| 507 | opt, |
| 508 | ); |
| 509 | } |
| 510 | } |
| 511 | } |
| 512 | for child_feature in builtin_features.keysrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]keys().() { |
| 513 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(child_features_fn) = feature_data.getrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]get().(child_feature) { |
| 514 | if let ProvenancedOptionValuerust-analyzer cargo git-delta 0.19.2 options/option_value/ProvenancedOptionValue#::DefaultValuerust-analyzer cargo git-delta 0.19.2 options/option_value/ProvenancedOptionValue#DefaultValue#(OptionValuerust-analyzer cargo git-delta 0.19.2 options/option_value/OptionValue#::Booleanrust-analyzer cargo git-delta 0.19.2 options/option_value/OptionValue#Boolean#(true)) = |
| 515 | child_features_fn(opt, &Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#) |
| 516 | { |
| 517 | gather_builtin_features_recursivelyrust-analyzer cargo git-delta 0.19.2 options/set/gather_builtin_features_recursively().( |
| 518 | child_feature, |
| 519 | features, |
| 520 | builtin_features, |
| 521 | opt, |
| 522 | ); |
| 523 | } |
| 524 | } |
| 525 | } |
| 526 | } |
| 527 | } |
| 528 | |
| 529 | fn split_feature_stringrust-analyzer cargo git-delta 0.19.2 options/set/split_feature_string().(features: &str) -> impl Iteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#<Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item# = &str> { |
| 530 | features.split_whitespacerust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]split_whitespace().().revrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#rev().() |
| 531 | } |
| 532 | |
| 533 | impl FromStrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/traits/FromStr# for clirust-analyzer cargo git-delta 0.19.2 cli/::InspectRawLinesrust-analyzer cargo git-delta 0.19.2 cli/InspectRawLines# { |
| 534 | type Errrust-analyzer cargo git-delta 0.19.2 options/set/impl#[`cli::InspectRawLines`][FromStr]Err# = Errorrust-analyzer cargo anyhow 1.0.102 Error#; |
| 535 | fn from_strrust-analyzer cargo git-delta 0.19.2 options/set/impl#[`cli::InspectRawLines`][FromStr]from_str().(s: &str) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Selfrust-analyzer cargo git-delta 0.19.2 options/set/impl#[`cli::InspectRawLines`][FromStr], Selfrust-analyzer cargo git-delta 0.19.2 options/set/impl#[`cli::InspectRawLines`][FromStr]::Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/traits/FromStr#Err#> { |
| 536 | match s.to_lowercaserust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str]to_lowercase().().as_strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]as_str().() { |
| 537 | "true" => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Selfrust-analyzer cargo git-delta 0.19.2 options/set/impl#[`cli::InspectRawLines`][FromStr]::Truerust-analyzer cargo git-delta 0.19.2 cli/InspectRawLines#True#), |
| 538 | "false" => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Selfrust-analyzer cargo git-delta 0.19.2 options/set/impl#[`cli::InspectRawLines`][FromStr]::Falserust-analyzer cargo git-delta 0.19.2 cli/InspectRawLines#False#), |
| 539 | _ => { |
| 540 | fatalrust-analyzer cargo git-delta 0.19.2 fatal().(formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!( |
| 541 | r#"Invalid value for inspect-raw-lines option: {s}. Valid values are "true", and "false"."#, |
| 542 | )); |
| 543 | } |
| 544 | } |
| 545 | } |
| 546 | } |
| 547 | |
| 548 | fn parse_paging_moderust-analyzer cargo git-delta 0.19.2 options/set/parse_paging_mode().(paging_mode_string: &str) -> PagingModerust-analyzer cargo git-delta 0.19.2 utils/bat/output/PagingMode# { |
| 549 | match paging_mode_string.to_lowercaserust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str]to_lowercase().().as_strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]as_str().() { |
| 550 | "always" => PagingModerust-analyzer cargo git-delta 0.19.2 utils/bat/output/PagingMode#::Alwaysrust-analyzer cargo git-delta 0.19.2 utils/bat/output/PagingMode#Always#, |
| 551 | "never" => PagingModerust-analyzer cargo git-delta 0.19.2 utils/bat/output/PagingMode#::Neverrust-analyzer cargo git-delta 0.19.2 utils/bat/output/PagingMode#Never#, |
| 552 | "auto" => PagingModerust-analyzer cargo git-delta 0.19.2 utils/bat/output/PagingMode#::QuitIfOneScreenrust-analyzer cargo git-delta 0.19.2 utils/bat/output/PagingMode#QuitIfOneScreen#, |
| 553 | _ => { |
| 554 | fatalrust-analyzer cargo git-delta 0.19.2 fatal().(formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!( |
| 555 | "Invalid value for --paging option: {paging_mode_string} (valid values are \"always\", \"never\", and \"auto\")", |
| 556 | )); |
| 557 | } |
| 558 | } |
| 559 | } |
| 560 | |
| 561 | fn parse_width_specifierrust-analyzer cargo git-delta 0.19.2 options/set/parse_width_specifier().(width_arg: &str, terminal_width: usize) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<usize, Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#> { |
| 562 | let width_arg = width_arg.trimrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]trim().(); |
| 563 | |
| 564 | let parse = |width: &str, must_be_negative, subexpression| -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<isize, Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#> { |
| 565 | let remove_spaces = |s: &str| s.charsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]chars().().filterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#filter().(|c| c rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]ne().&' ').collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().::<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>(); |
| 566 | match remove_spaces(width).parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().() { |
| 567 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(val) if must_be_negative && val rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[isize][`PartialOrd<Self>`]gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[isize][`PartialOrd<Self>`]gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[isize][`PartialOrd<Self>`]gt().0 => Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(()), |
| 568 | Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(_) => Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(()), |
| 569 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(ok) => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(ok), |
| 570 | } |
| 571 | .map_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map_err().(|_| { |
| 572 | let pos = if must_be_negative { " negative" } else { "n" }; |
| 573 | let subexpr = if subexpression { |
| 574 | formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!(" (from {width_arg:?})") |
| 575 | } else { |
| 576 | "".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().() |
| 577 | }; |
| 578 | formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{width:?}{subexpr} is not a{pos} integer") |
| 579 | }) |
| 580 | }; |
| 581 | |
| 582 | let width = match width_arg.findrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]find().('-') { |
| 583 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# => parse(width_arg, false, false)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()..try_intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`TryInto<U>`]try_into().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), |
| 584 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(0) => (terminal_width as isize rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[isize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[isize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[isize][`Add<Self>`]add().parse(width_arg, true, false)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().) |
| 585 | .try_intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`TryInto<U>`]try_into().() |
| 586 | .map_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map_err().(|_| { |
| 587 | formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!( |
| 588 | "the current terminal width of {} minus {} is negative", |
| 589 | terminal_width, |
| 590 | &width_arg[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().1..]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()..trimrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]trim().(), |
| 591 | ) |
| 592 | })?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()., |
| 593 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(index) => { |
| 594 | let a = parse(&width_arg[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#index]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()., false, true)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 595 | let b = parse(&width_arg[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().index..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFrom#]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()., true, true)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 596 | (a rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[isize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[isize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[isize][`Add<Self>`]add().b) |
| 597 | .try_intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`TryInto<U>`]try_into().() |
| 598 | .map_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map_err().(|_| formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("expression {width_arg:?} is not positive"))?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch(). |
| 599 | } |
| 600 | }; |
| 601 | |
| 602 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(width) |
| 603 | } |
| 604 | |
| 605 | fn set_widths_and_isattyrust-analyzer cargo git-delta 0.19.2 options/set/set_widths_and_isatty().(opt: &mut clirust-analyzer cargo git-delta 0.19.2 cli/::Optrust-analyzer cargo git-delta 0.19.2 cli/Opt#) { |
| 606 | let term_stdout = Termrust-analyzer cargo console 0.15.7 term/Term#::stdoutrust-analyzer cargo console 0.15.7 term/impl#[Term]stdout().(); |
| 607 | opt.computedrust-analyzer cargo git-delta 0.19.2 cli/Opt#computed..stdout_is_termrust-analyzer cargo git-delta 0.19.2 cli/ComputedValues#stdout_is_term. = term_stdout.is_termrust-analyzer cargo console 0.15.7 term/impl#[Term]is_term().(); |
| 608 | |
| 609 | // If one extra character for e.g. `less --status-column` is required use "-1" |
| 610 | // as an argument, also see #41, #10, #115 and #727. |
| 611 | opt.computedrust-analyzer cargo git-delta 0.19.2 cli/Opt#computed..available_terminal_widthrust-analyzer cargo git-delta 0.19.2 cli/ComputedValues#available_terminal_width. = |
| 612 | craterust-analyzer cargo git-delta 0.19.2 crate/::utilsrust-analyzer cargo git-delta 0.19.2 utils/::workaroundsrust-analyzer cargo git-delta 0.19.2 utils/workarounds/::windows_msys2_width_fixrust-analyzer cargo git-delta 0.19.2 utils/workarounds/windows_msys2_width_fix().(term_stdout.sizerust-analyzer cargo console 0.15.7 term/impl#[Term]size().(), &term_stdout); |
| 613 | |
| 614 | let (decorations_width, background_color_extends_to_terminal_width) = match opt.widthrust-analyzer cargo git-delta 0.19.2 cli/Opt#width..as_derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_deref().() |
| 615 | { |
| 616 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("variable") => (clirust-analyzer cargo git-delta 0.19.2 cli/::Widthrust-analyzer cargo git-delta 0.19.2 cli/Width#::Variablerust-analyzer cargo git-delta 0.19.2 cli/Width#Variable#, false), |
| 617 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(width) => { |
| 618 | let width = parse_width_specifierrust-analyzer cargo git-delta 0.19.2 options/set/parse_width_specifier().(width, opt.computedrust-analyzer cargo git-delta 0.19.2 cli/Opt#computed..available_terminal_widthrust-analyzer cargo git-delta 0.19.2 cli/ComputedValues#available_terminal_width.) |
| 619 | .unwrap_or_elserust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_or_else().(|err| fatalrust-analyzer cargo git-delta 0.19.2 fatal().(formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("Invalid value for width: {err}"))); |
| 620 | (clirust-analyzer cargo git-delta 0.19.2 cli/::Widthrust-analyzer cargo git-delta 0.19.2 cli/Width#::Fixedrust-analyzer cargo git-delta 0.19.2 cli/Width#Fixed#(width), true) |
| 621 | } |
| 622 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# => { |
| 623 | #[cfg(test)] |
| 624 | { |
| 625 | // instead of passing `--width=..` to all tests, set it here: |
| 626 | (clirust-analyzer cargo git-delta 0.19.2 cli/::Widthrust-analyzer cargo git-delta 0.19.2 cli/Width#::Fixedrust-analyzer cargo git-delta 0.19.2 cli/Width#Fixed#(testsrust-analyzer cargo git-delta 0.19.2 options/set/tests/::TERMINAL_WIDTH_IN_TESTSrust-analyzer cargo git-delta 0.19.2 options/set/tests/TERMINAL_WIDTH_IN_TESTS.), true) |
| 627 | } |
| 628 | #[cfg(not(test))] |
| 629 | { |
| 630 | ( |
| 631 | clirust-analyzer cargo git-delta 0.19.2 cli/::Widthrust-analyzer cargo git-delta 0.19.2 cli/Width#::Fixedrust-analyzer cargo git-delta 0.19.2 cli/Width#Fixed#(opt.computed.available_terminal_width), |
| 632 | true, |
| 633 | ) |
| 634 | } |
| 635 | } |
| 636 | }; |
| 637 | opt.computedrust-analyzer cargo git-delta 0.19.2 cli/Opt#computed..decorations_widthrust-analyzer cargo git-delta 0.19.2 cli/ComputedValues#decorations_width. = decorations_width; |
| 638 | opt.computedrust-analyzer cargo git-delta 0.19.2 cli/Opt#computed..background_color_extends_to_terminal_widthrust-analyzer cargo git-delta 0.19.2 cli/ComputedValues#background_color_extends_to_terminal_width. = |
| 639 | background_color_extends_to_terminal_width; |
| 640 | } |
| 641 | |
| 642 | fn set_true_colorrust-analyzer cargo git-delta 0.19.2 options/set/set_true_color().(opt: &mut clirust-analyzer cargo git-delta 0.19.2 cli/::Optrust-analyzer cargo git-delta 0.19.2 cli/Opt#) { |
| 643 | if opt.true_colorrust-analyzer cargo git-delta 0.19.2 cli/Opt#true_color. rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`PartialEq<&str>`]eq().==rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`PartialEq<&str>`]eq(). rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`PartialEq<&str>`]eq()."auto" { |
| 644 | // It's equal to its default, so the user might be using the deprecated |
| 645 | // --24-bit-color option. |
| 646 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(_24_bit_color) = opt._24_bit_colorrust-analyzer cargo git-delta 0.19.2 cli/Opt#_24_bit_color..as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_ref().() { |
| 647 | opt.true_colorrust-analyzer cargo git-delta 0.19.2 cli/Opt#true_color..clone_fromrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][Clone]clone_from().(_24_bit_color); |
| 648 | } |
| 649 | } |
| 650 | |
| 651 | opt.computedrust-analyzer cargo git-delta 0.19.2 cli/Opt#computed..true_colorrust-analyzer cargo git-delta 0.19.2 cli/ComputedValues#true_color. = match opt.true_colorrust-analyzer cargo git-delta 0.19.2 cli/Opt#true_color..as_refrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`AsRef<str>`]as_ref().() { |
| 652 | "always" => true, |
| 653 | "never" => false, |
| 654 | "auto" => is_truecolor_terminalrust-analyzer cargo git-delta 0.19.2 options/set/is_truecolor_terminal().(&opt.envrust-analyzer cargo git-delta 0.19.2 cli/Opt#env.), |
| 655 | _ => { |
| 656 | fatalrust-analyzer cargo git-delta 0.19.2 fatal().(formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!( |
| 657 | "Invalid value for --true-color option: {} (valid values are \"always\", \"never\", and \"auto\")", |
| 658 | opt.true_colorrust-analyzer cargo git-delta 0.19.2 cli/Opt#true_color. |
| 659 | )); |
| 660 | } |
| 661 | }; |
| 662 | } |
| 663 | |
| 664 | fn is_truecolor_terminalrust-analyzer cargo git-delta 0.19.2 options/set/is_truecolor_terminal().(env: &DeltaEnvrust-analyzer cargo git-delta 0.19.2 env/DeltaEnv#) -> bool { |
| 665 | env.colortermrust-analyzer cargo git-delta 0.19.2 env/DeltaEnv#colorterm. |
| 666 | .as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_ref().() |
| 667 | .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|colorterm| colorterm rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq()."truecolor" || colorterm rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq()."24bit") |
| 668 | .unwrap_orrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or().(false) |
| 669 | } |
| 670 | |
| 671 | #[cfg(test)] |
| 672 | pub mod testsrust-analyzer cargo git-delta 0.19.2 options/set/tests/ { |
| 673 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::fsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/::remove_filerust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/remove_file().; |
| 674 | |
| 675 | use craterust-analyzer cargo git-delta 0.19.2 crate/::clirust-analyzer cargo git-delta 0.19.2 cli/; |
| 676 | use craterust-analyzer cargo git-delta 0.19.2 crate/::testsrust-analyzer cargo git-delta 0.19.2 tests/::integration_test_utilsrust-analyzer cargo git-delta 0.19.2 tests/integration_test_utils/; |
| 677 | use craterust-analyzer cargo git-delta 0.19.2 crate/::utilsrust-analyzer cargo git-delta 0.19.2 utils/::batrust-analyzer cargo git-delta 0.19.2 utils/bat/::outputrust-analyzer cargo git-delta 0.19.2 utils/bat/output/::PagingModerust-analyzer cargo git-delta 0.19.2 utils/bat/output/PagingMode#; |
| 678 | |
| 679 | pub const TERMINAL_WIDTH_IN_TESTSrust-analyzer cargo git-delta 0.19.2 options/set/tests/TERMINAL_WIDTH_IN_TESTS.: usize = 43; |
| 680 | |
| 681 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 682 | fn test_options_can_be_set_in_git_configrust-analyzer cargo git-delta 0.19.2 options/set/tests/test_options_can_be_set_in_git_config().() { |
| 683 | // In general the values here are not the default values. However there are some exceptions |
| 684 | // since e.g. color-only = true (non-default) forces side-by-side = false (default). |
| 685 | let git_config_contents = b" |
| 686 | [delta] |
| 687 | color-only = false |
| 688 | commit-decoration-style = black black |
| 689 | commit-style = black black |
| 690 | dark = false |
| 691 | default-language = rs |
| 692 | diff-highlight = true |
| 693 | diff-so-fancy = true |
| 694 | features = xxxyyyzzz |
| 695 | file-added-label = xxxyyyzzz |
| 696 | file-decoration-style = black black |
| 697 | file-modified-label = xxxyyyzzz |
| 698 | file-removed-label = xxxyyyzzz |
| 699 | file-renamed-label = xxxyyyzzz |
| 700 | file-transformation = s/foo/bar/ |
| 701 | right-arrow = xxxyyyzzz |
| 702 | file-style = black black |
| 703 | hunk-header-decoration-style = black black |
| 704 | hunk-header-style = black black |
| 705 | keep-plus-minus-markers = true |
| 706 | light = true |
| 707 | line-numbers = true |
| 708 | line-numbers-left-format = xxxyyyzzz |
| 709 | line-numbers-left-style = black black |
| 710 | line-numbers-minus-style = black black |
| 711 | line-numbers-plus-style = black black |
| 712 | line-numbers-right-format = xxxyyyzzz |
| 713 | line-numbers-right-style = black black |
| 714 | line-numbers-zero-style = black black |
| 715 | max-line-distance = 77 |
| 716 | max-line-length = 77 |
| 717 | minus-emph-style = black black |
| 718 | minus-empty-line-marker-style = black black |
| 719 | minus-non-emph-style = black black |
| 720 | minus-style = black black |
| 721 | navigate = true |
| 722 | navigate-regex = xxxyyyzzz |
| 723 | paging = never |
| 724 | plus-emph-style = black black |
| 725 | plus-empty-line-marker-style = black black |
| 726 | plus-non-emph-style = black black |
| 727 | plus-style = black black |
| 728 | raw = true |
| 729 | side-by-side = true |
| 730 | syntax-theme = xxxyyyzzz |
| 731 | tabs = 77 |
| 732 | true-color = never |
| 733 | whitespace-error-style = black black |
| 734 | width = 77 |
| 735 | word-diff-regex = xxxyyyzzz |
| 736 | zero-style = black black |
| 737 | # no-gitconfig |
| 738 | "; |
| 739 | let git_config_path = "delta__test_options_can_be_set_in_git_config.gitconfig"; |
| 740 | |
| 741 | let opt = integration_test_utilsrust-analyzer cargo git-delta 0.19.2 tests/integration_test_utils/::make_options_from_args_and_git_configrust-analyzer cargo git-delta 0.19.2 tests/integration_test_utils/make_options_from_args_and_git_config().( |
| 742 | &[], |
| 743 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(git_config_contents), |
| 744 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(git_config_path), |
| 745 | ); |
| 746 | |
| 747 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(opt.true_colorrust-analyzer cargo git-delta 0.19.2 cli/Opt#true_color., "never"); |
| 748 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().opt.color_onlyrust-analyzer cargo git-delta 0.19.2 cli/Opt#color_only.); |
| 749 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(opt.commit_decoration_stylerust-analyzer cargo git-delta 0.19.2 cli/Opt#commit_decoration_style., "black black"); |
| 750 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(opt.commit_stylerust-analyzer cargo git-delta 0.19.2 cli/Opt#commit_style., "black black"); |
| 751 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().opt.darkrust-analyzer cargo git-delta 0.19.2 cli/Opt#dark.); |
| 752 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(opt.default_languagerust-analyzer cargo git-delta 0.19.2 cli/Opt#default_language., "rs".to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().()); |
| 753 | // TODO: should set_options not be called on any feature flags? |
| 754 | // assert_eq!(opt.diff_highlight, true); |
| 755 | // assert_eq!(opt.diff_so_fancy, true); |
| 756 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(opt |
| 757 | .featuresrust-analyzer cargo git-delta 0.19.2 cli/Opt#features. |
| 758 | .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().() |
| 759 | .split_whitespacerust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]split_whitespace().() |
| 760 | .anyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#any().(|s| s == "xxxyyyzzz")); |
| 761 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(opt.file_added_labelrust-analyzer cargo git-delta 0.19.2 cli/Opt#file_added_label., "xxxyyyzzz"); |
| 762 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(opt.file_decoration_stylerust-analyzer cargo git-delta 0.19.2 cli/Opt#file_decoration_style., "black black"); |
| 763 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(opt.file_modified_labelrust-analyzer cargo git-delta 0.19.2 cli/Opt#file_modified_label., "xxxyyyzzz"); |
| 764 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(opt.file_removed_labelrust-analyzer cargo git-delta 0.19.2 cli/Opt#file_removed_label., "xxxyyyzzz"); |
| 765 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(opt.file_renamed_labelrust-analyzer cargo git-delta 0.19.2 cli/Opt#file_renamed_label., "xxxyyyzzz"); |
| 766 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(opt.right_arrowrust-analyzer cargo git-delta 0.19.2 cli/Opt#right_arrow., "xxxyyyzzz"); |
| 767 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(opt.file_stylerust-analyzer cargo git-delta 0.19.2 cli/Opt#file_style., "black black"); |
| 768 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(opt.file_regex_replacementrust-analyzer cargo git-delta 0.19.2 cli/Opt#file_regex_replacement., Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("s/foo/bar/".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().())); |
| 769 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(opt.hunk_header_decoration_stylerust-analyzer cargo git-delta 0.19.2 cli/Opt#hunk_header_decoration_style., "black black"); |
| 770 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(opt.hunk_header_stylerust-analyzer cargo git-delta 0.19.2 cli/Opt#hunk_header_style., "black black"); |
| 771 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(opt.keep_plus_minus_markersrust-analyzer cargo git-delta 0.19.2 cli/Opt#keep_plus_minus_markers.); |
| 772 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(opt.lightrust-analyzer cargo git-delta 0.19.2 cli/Opt#light.); |
| 773 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(opt.line_numbersrust-analyzer cargo git-delta 0.19.2 cli/Opt#line_numbers.); |
| 774 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(opt.line_numbers_left_formatrust-analyzer cargo git-delta 0.19.2 cli/Opt#line_numbers_left_format., "xxxyyyzzz"); |
| 775 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(opt.line_numbers_left_stylerust-analyzer cargo git-delta 0.19.2 cli/Opt#line_numbers_left_style., "black black"); |
| 776 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(opt.line_numbers_minus_stylerust-analyzer cargo git-delta 0.19.2 cli/Opt#line_numbers_minus_style., "black black"); |
| 777 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(opt.line_numbers_plus_stylerust-analyzer cargo git-delta 0.19.2 cli/Opt#line_numbers_plus_style., "black black"); |
| 778 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(opt.line_numbers_right_formatrust-analyzer cargo git-delta 0.19.2 cli/Opt#line_numbers_right_format., "xxxyyyzzz"); |
| 779 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(opt.line_numbers_right_stylerust-analyzer cargo git-delta 0.19.2 cli/Opt#line_numbers_right_style., "black black"); |
| 780 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(opt.line_numbers_zero_stylerust-analyzer cargo git-delta 0.19.2 cli/Opt#line_numbers_zero_style., "black black"); |
| 781 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(opt.max_line_distancerust-analyzer cargo git-delta 0.19.2 cli/Opt#max_line_distance., 77.0); |
| 782 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(opt.max_line_lengthrust-analyzer cargo git-delta 0.19.2 cli/Opt#max_line_length., 77); |
| 783 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(opt.minus_emph_stylerust-analyzer cargo git-delta 0.19.2 cli/Opt#minus_emph_style., "black black"); |
| 784 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(opt.minus_empty_line_marker_stylerust-analyzer cargo git-delta 0.19.2 cli/Opt#minus_empty_line_marker_style., "black black"); |
| 785 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(opt.minus_non_emph_stylerust-analyzer cargo git-delta 0.19.2 cli/Opt#minus_non_emph_style., "black black"); |
| 786 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(opt.minus_stylerust-analyzer cargo git-delta 0.19.2 cli/Opt#minus_style., "black black"); |
| 787 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(opt.navigaterust-analyzer cargo git-delta 0.19.2 cli/Opt#navigate.); |
| 788 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(opt.navigate_regexrust-analyzer cargo git-delta 0.19.2 cli/Opt#navigate_regex., Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("xxxyyyzzz".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().())); |
| 789 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(opt.paging_moderust-analyzer cargo git-delta 0.19.2 cli/Opt#paging_mode., "never"); |
| 790 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(opt.plus_emph_stylerust-analyzer cargo git-delta 0.19.2 cli/Opt#plus_emph_style., "black black"); |
| 791 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(opt.plus_empty_line_marker_stylerust-analyzer cargo git-delta 0.19.2 cli/Opt#plus_empty_line_marker_style., "black black"); |
| 792 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(opt.plus_non_emph_stylerust-analyzer cargo git-delta 0.19.2 cli/Opt#plus_non_emph_style., "black black"); |
| 793 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(opt.plus_stylerust-analyzer cargo git-delta 0.19.2 cli/Opt#plus_style., "black black"); |
| 794 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(opt.rawrust-analyzer cargo git-delta 0.19.2 cli/Opt#raw.); |
| 795 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(opt.side_by_siderust-analyzer cargo git-delta 0.19.2 cli/Opt#side_by_side.); |
| 796 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(opt.syntax_themerust-analyzer cargo git-delta 0.19.2 cli/Opt#syntax_theme., Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("xxxyyyzzz".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().())); |
| 797 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(opt.tab_widthrust-analyzer cargo git-delta 0.19.2 cli/Opt#tab_width., 77); |
| 798 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(opt.true_colorrust-analyzer cargo git-delta 0.19.2 cli/Opt#true_color., "never"); |
| 799 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(opt.whitespace_error_stylerust-analyzer cargo git-delta 0.19.2 cli/Opt#whitespace_error_style., "black black"); |
| 800 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(opt.widthrust-analyzer cargo git-delta 0.19.2 cli/Opt#width., Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("77".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().())); |
| 801 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(opt.tokenization_regexrust-analyzer cargo git-delta 0.19.2 cli/Opt#tokenization_regex., "xxxyyyzzz"); |
| 802 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(opt.zero_stylerust-analyzer cargo git-delta 0.19.2 cli/Opt#zero_style., "black black"); |
| 803 | |
| 804 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(opt.computedrust-analyzer cargo git-delta 0.19.2 cli/Opt#computed..paging_moderust-analyzer cargo git-delta 0.19.2 cli/ComputedValues#paging_mode., PagingModerust-analyzer cargo git-delta 0.19.2 utils/bat/output/PagingMode#::Neverrust-analyzer cargo git-delta 0.19.2 utils/bat/output/PagingMode#Never#); |
| 805 | |
| 806 | remove_filerust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/remove_file().(git_config_path).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 807 | } |
| 808 | |
| 809 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 810 | fn test_width_in_git_config_is_honoredrust-analyzer cargo git-delta 0.19.2 options/set/tests/test_width_in_git_config_is_honored().() { |
| 811 | let git_config_contents = b" |
| 812 | [delta] |
| 813 | features = my-width-feature |
| 814 | |
| 815 | [delta \"my-width-feature\"] |
| 816 | width = variable |
| 817 | "; |
| 818 | let git_config_path = "delta__test_width_in_git_config_is_honored.gitconfig"; |
| 819 | |
| 820 | let opt = integration_test_utilsrust-analyzer cargo git-delta 0.19.2 tests/integration_test_utils/::make_options_from_args_and_git_configrust-analyzer cargo git-delta 0.19.2 tests/integration_test_utils/make_options_from_args_and_git_config().( |
| 821 | &[], |
| 822 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(git_config_contents), |
| 823 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(git_config_path), |
| 824 | ); |
| 825 | |
| 826 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(opt.computedrust-analyzer cargo git-delta 0.19.2 cli/Opt#computed..decorations_widthrust-analyzer cargo git-delta 0.19.2 cli/ComputedValues#decorations_width., clirust-analyzer cargo git-delta 0.19.2 cli/::Widthrust-analyzer cargo git-delta 0.19.2 cli/Width#::Variablerust-analyzer cargo git-delta 0.19.2 cli/Width#Variable#); |
| 827 | |
| 828 | remove_filerust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/remove_file().(git_config_path).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 829 | } |
| 830 | |
| 831 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 832 | fn test_parse_width_specifierrust-analyzer cargo git-delta 0.19.2 options/set/tests/test_parse_width_specifier().() { |
| 833 | use superrust-analyzer cargo git-delta 0.19.2 options/set/::parse_width_specifierrust-analyzer cargo git-delta 0.19.2 options/set/parse_width_specifier().; |
| 834 | let term_width = 12; |
| 835 | |
| 836 | let assert_failure_containing = |x, errmsg| { |
| 837 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(parse_width_specifierrust-analyzer cargo git-delta 0.19.2 options/set/parse_width_specifier().(x, term_width) |
| 838 | .unwrap_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_err().() |
| 839 | .containsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]contains().(errmsg)); |
| 840 | }; |
| 841 | |
| 842 | assert_failure_containing("", "is not an integer"); |
| 843 | assert_failure_containing("foo", "is not an integer"); |
| 844 | assert_failure_containing("123foo", "is not an integer"); |
| 845 | assert_failure_containing("+12bar", "is not an integer"); |
| 846 | assert_failure_containing("-456bar", "is not a negative integer"); |
| 847 | |
| 848 | assert_failure_containing("-13", "minus 13 is negative"); |
| 849 | assert_failure_containing(" - 13 ", "minus 13 is negative"); |
| 850 | assert_failure_containing("12-13", "expression"); |
| 851 | assert_failure_containing(" 12 - 13 ", "expression \"12 - 13\" is not"); |
| 852 | assert_failure_containing("12+foo", "is not an integer"); |
| 853 | assert_failure_containing( |
| 854 | " 12 - bar ", |
| 855 | "\"- bar\" (from \"12 - bar\") is not a negative integer", |
| 856 | ); |
| 857 | |
| 858 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(parse_width_specifierrust-analyzer cargo git-delta 0.19.2 options/set/parse_width_specifier().("1", term_width).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), 1); |
| 859 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(parse_width_specifierrust-analyzer cargo git-delta 0.19.2 options/set/parse_width_specifier().(" 1 ", term_width).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), 1); |
| 860 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(parse_width_specifierrust-analyzer cargo git-delta 0.19.2 options/set/parse_width_specifier().("-2", term_width).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), 10); |
| 861 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(parse_width_specifierrust-analyzer cargo git-delta 0.19.2 options/set/parse_width_specifier().(" - 2", term_width).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), 10); |
| 862 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(parse_width_specifierrust-analyzer cargo git-delta 0.19.2 options/set/parse_width_specifier().("-12", term_width).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), 0); |
| 863 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(parse_width_specifierrust-analyzer cargo git-delta 0.19.2 options/set/parse_width_specifier().(" - 12 ", term_width).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), 0); |
| 864 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(parse_width_specifierrust-analyzer cargo git-delta 0.19.2 options/set/parse_width_specifier().(" 2 - 2 ", term_width).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), 0); |
| 865 | } |
| 866 | } |