Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix diff interactivefilter when decoration option is enabled #367

Merged
merged 3 commits into from Nov 22, 2020
Merged

Fix diff interactivefilter when decoration option is enabled #367

merged 3 commits into from Nov 22, 2020

Conversation

ghost
Copy link

@ghost ghost commented Oct 27, 2020

Fix #320 (comment)

When ***-decoration-style is enabled, it occurs error. So I set them to none while color-only.

Also, I added all configs to test(excluding show-config, show-syntax-theme, or something not related).

"true",
"--line-numbers-minus-style",
"#444444",
],
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apparently, these --line-numbers-*** is not necessary because line-numbers would be disabled. However, I can't make sure if the option's behavior will be changed, so I added anyway.

It's just my opinion.

@@ -192,6 +192,8 @@ pub fn set_options(
// there (does not emit lines in 1-1 correspondence with raw git output). See #274.
if opt.color_only {
opt.side_by_side = false;
opt.file_decoration_style = "none".to_string();
opt.commit_decoration_style = "none".to_string();
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @Ryuta69, thanks for this PR! I have one question: aren't these already set to "none" by the color-only feature? (see the way that feature "inherits" from the raw feature)

Copy link
Author

@ghost ghost Oct 28, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dandavison
Thank you for review!
Oh, is that supposed to be? If so, currently it seems not working when a user supply some options in gitconfig.

In order to give priority to the options in features/** even when a user supply option in gitconfig, I think we must switch the conditions below (Of course only switching them would break some tests such as features::tests::test_main_section_overrides_feature. I still need extra check.)

delta/src/options/get.rs

Lines 54 to 72 in 1ca0615

if let Some(git_config) = git_config {
if let Some(value) = git_config.get::<Self>(&format!("delta.{}", option_name)) {
return Some(value);
}
}
for feature in opt.features.to_lowercase().split_whitespace().rev() {
match Self::get_provenanced_value_for_feature(
option_name,
&feature,
&builtin_features,
opt,
git_config,
) {
Some(GitConfigValue(value)) | Some(DefaultValue(value)) => {
return Some(value.into());
}
None => {}
}
}

Currently, both not working as you suggested.

[delta]
	file-decoration-style = ul
# git diff | delta --color-only
# => It still prints file-decoration-style as ul.

------------

[delta]
	minus-style = blue
# git diff | delta --raw
# => It still prints minus-style as blue.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @Ryuta69, sorry to be slow -- I was meaning to look into what we're discussing here but didn't find time yet. Definitely looking forward to having this PR in the next release.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dandavison
Sure! The first priority is your schedule, and I'll help when you have a time. Again, thank you for this great OSS.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, this sounds like a potential headache -- let's just keep the hard-coded override to "none" that you have, and we can maybe worry in the future about whether the none-value was supposed to be inherited from the feature automatically.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dandavison
I understand, thank you for review.
If I find a way to solve, I'm going to create PR.

Copy link
Owner

@dandavison dandavison left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks @ulwlu!

I pushed one commit a39b58c which removed the true arguments to the boolean flags, and deleted one dup test case. I believe that that "true" was not actually being used as an option value but rather was being interpreted as the first of two possible file name positional args. E.g. gs | delta --light true true "works" but gs | delta --light true true true fails with error: Found argument 'true' which wasn't expected, or isn't valid in this context. Let me know if anything in a39b58c doesn't seem right to you!

@dandavison dandavison merged commit 123e883 into dandavison:master Nov 22, 2020
@ghost
Copy link
Author

ghost commented Nov 22, 2020

@dandavison
Oh! I didn't notice there is that kind of case.
thank you very much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

🐛 git add -p one-to-one correspondence errors
1 participant