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

Skip --no-ext-diff in log #167

Merged
merged 1 commit into from
Feb 7, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 21 additions & 9 deletions src/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -287,14 +287,23 @@ impl Cmd {
}
}

fn should_omit_arg(cmd: &OsStr, arg: &OsStr, val: Option<&&OsStr>) -> bool {
if GIT.as_ref().is_ok_and(|git| cmd == git) && arg == "-c" {
return val.is_some_and(|flag| {
let flag = flag.as_encoded_bytes();
flag.starts_with(b"core.useBuiltinFSMonitor") || flag.starts_with(b"protocol.version")
});
/// Returns the number of arguments to skip.
fn skip_args(cmd: &OsStr, cur: &OsStr, next: Option<&&OsStr>) -> usize {
if GIT.as_ref().is_ok_and(|git| cmd == git) {
if cur == "-c" {
if let Some(flag) = next {
let flag = flag.as_encoded_bytes();
if flag.starts_with(b"core.useBuiltinFSMonitor")
|| flag.starts_with(b"protocol.version")
{
return 2;
}
}
} else if cur == "--no-ext-diff" {
return 1;
}
};
false
0
}

/// Simplified Command Debug output, with args truncated if they're too long.
Expand All @@ -313,8 +322,11 @@ impl std::fmt::Display for Cmd {

let mut len = 0;
while let Some(arg) = args.next() {
if should_omit_arg(program, arg, args.peek()) {
args.next();
let skip = skip_args(program, arg, args.peek());
if skip > 0 {
for _ in 1..skip {
args.next();
}
continue;
}
write!(f, " {}", arg.to_string_lossy().dimmed())?;
Expand Down
Loading