1
1
mirror of https://github.com/Byron/gitoxide synced 2025-10-06 01:52:40 +02:00

thanks clippy

This commit is contained in:
Sebastian Thiel
2025-05-02 15:31:34 +02:00
parent 3a5068eb3f
commit dbf65c9564
13 changed files with 83 additions and 51 deletions

View File

@@ -44,8 +44,8 @@ pub fn estimate_hours(
};
let author = &commits[0].1;
let (files, lines) = (!stats.is_empty())
.then(|| {
let (files, lines) = if !stats.is_empty() {
{
commits
.iter()
.map(|t| &t.0)
@@ -60,8 +60,10 @@ pub fn estimate_hours(
}
Err(_) => acc,
})
})
.unwrap_or_default();
}
} else {
Default::default()
};
WorkByEmail {
name: author.name,
email: author.email,

View File

@@ -113,8 +113,8 @@ where
Ok(out)
});
let (stats_progresses, stats_counters) = needs_stats
.then(|| {
let (stats_progresses, stats_counters) = if needs_stats {
{
let mut sp = progress.add_child("extract stats");
sp.init(None, progress::count("commits"));
let sc = sp.counter();
@@ -128,14 +128,16 @@ where
let lc = lp.counter();
(Some((sp, cp, lp)), Some((sc, cc, lc)))
})
.unwrap_or_default();
}
} else {
Default::default()
};
let mut progress = progress.add_child("traverse commit graph");
progress.init(None, progress::count("commits"));
let (tx_tree_id, stat_threads) = needs_stats
.then(|| {
let (tx_tree_id, stat_threads) = if needs_stats {
{
let (tx, threads) = spawn_tree_delta_threads(
scope,
threads,
@@ -144,8 +146,10 @@ where
stats_counters.clone().expect("counters are set"),
);
(Some(tx), threads)
})
.unwrap_or_default();
}
} else {
Default::default()
};
let mut commit_idx = 0_u32;
let mut skipped_merge_commits = 0;
@@ -296,7 +300,7 @@ where
total_hours,
total_hours / HOURS_PER_WORKDAY,
total_commits,
is_shallow.then_some(" (shallow)").unwrap_or_default(),
if is_shallow { " (shallow)" } else { Default::default() },
num_authors
)?;
if file_stats {

View File

@@ -115,17 +115,18 @@ pub fn checkout_exclusive(
progress.done(format!(
"Created {} {} files{} ({})",
files_updated,
no_repo.then_some("empty").unwrap_or_default(),
should_interrupt
.load(Ordering::Relaxed)
.then(|| {
if no_repo { "empty" } else { Default::default() },
if should_interrupt.load(Ordering::Relaxed) {
{
format!(
" of {}",
entries_for_checkout
.saturating_sub(errors.len() + collisions.len() + delayed_paths_unprocessed.len())
)
})
.unwrap_or_default(),
}
} else {
Default::default()
},
gix::progress::bytes()
.unwrap()
.display(bytes_written as usize, None, None)

View File

@@ -237,7 +237,7 @@ pub(crate) mod function {
out,
"{maybe}{suffix} {}{} {status}",
display_path.display(),
disk_kind.is_dir().then_some("/").unwrap_or_default(),
if disk_kind.is_dir() { "/" } else { Default::default() },
status = match entry.status {
Status::Ignored(kind) => {
Cow::Owned(format!(

View File

@@ -94,11 +94,15 @@ fn write_meta(meta: &gix::config::file::Metadata, out: &mut impl std::io::Write)
.as_deref()
.map_or_else(|| "memory".into(), |p| p.display().to_string()),
meta.source,
(meta.level != 0)
.then(|| format!(", include level {}", meta.level))
.unwrap_or_default(),
(meta.trust != gix::sec::Trust::Full)
.then_some(", untrusted")
.unwrap_or_default()
if meta.level != 0 {
format!(", include level {}", meta.level)
} else {
Default::default()
},
if meta.trust != gix::sec::Trust::Full {
", untrusted"
} else {
Default::default()
}
)
}

View File

@@ -70,7 +70,7 @@ fn resources_of_worktree_and_odb_and_check_link() -> crate::Result {
2,
3
)),
format!("{}test a <tmp-path> 0000000000000000000000000000000000000000 100644 <tmp-path> 4c469b6c8c4486fdc9ded9d597d8f6816a455707 100755", (!cfg!(windows)).then_some("GIT_DIFF_PATH_COUNTER=3 GIT_DIFF_PATH_TOTAL=3 GIT_DIR=. ").unwrap_or_default()),
format!("{}test a <tmp-path> 0000000000000000000000000000000000000000 100644 <tmp-path> 4c469b6c8c4486fdc9ded9d597d8f6816a455707 100755", if !cfg!(windows) { "GIT_DIFF_PATH_COUNTER=3 GIT_DIFF_PATH_TOTAL=3 GIT_DIR=. " } else { Default::default() }),
"in this case, there is no rename-to field as last argument, it's based on the resource paths being different"
);
@@ -117,7 +117,7 @@ fn resources_of_worktree_and_odb_and_check_link() -> crate::Result {
0,
1
)),
format!("{}test a <tmp-path> 0000000000000000000000000000000000000000 100644 <tmp-path> 4c469b6c8c4486fdc9ded9d597d8f6816a455707 120000", (!cfg!(windows)).then_some(r#"GIT_DIFF_PATH_COUNTER=1 GIT_DIFF_PATH_TOTAL=1 GIT_DIR=. "#).unwrap_or_default()),
format!("{}test a <tmp-path> 0000000000000000000000000000000000000000 100644 <tmp-path> 4c469b6c8c4486fdc9ded9d597d8f6816a455707 120000", if !cfg!(windows) { r#"GIT_DIFF_PATH_COUNTER=1 GIT_DIFF_PATH_TOTAL=1 GIT_DIR=. "# } else { Default::default() }),
"Also obvious that symlinks are definitely special, but it's what git does as well"
);
@@ -340,9 +340,11 @@ fn source_and_destination_do_not_exist() -> crate::Result {
),
format!(
r#"{}"test" "missing" "/dev/null" "." "." "/dev/null" "." "." "a""#,
(!cfg!(windows))
.then_some(r#"GIT_DIFF_PATH_COUNTER="1" GIT_DIFF_PATH_TOTAL="1" GIT_DIR="." "#)
.unwrap_or_default()
if !cfg!(windows) {
r#"GIT_DIFF_PATH_COUNTER="1" GIT_DIFF_PATH_TOTAL="1" GIT_DIR="." "#
} else {
Default::default()
}
)
);
Ok(())

View File

@@ -251,9 +251,11 @@ impl super::Store {
.collect();
let mut new_slot_map_indices = Vec::new(); // these indices into the slot map still exist there/didn't change
let mut index_paths_to_add = was_uninitialized
.then(|| VecDeque::with_capacity(indices_by_modification_time.len()))
.unwrap_or_default();
let mut index_paths_to_add = if was_uninitialized {
VecDeque::with_capacity(indices_by_modification_time.len())
} else {
Default::default()
};
// Figure out this number based on what we see while handling the existing indices
let mut num_loaded_indices = 0;
@@ -389,9 +391,11 @@ impl super::Store {
generation,
// if there was a prior generation, some indices might already be loaded. But we deal with it by trying to load the next index then,
// until we find one.
next_index_to_load: index_unchanged
.then(|| Arc::clone(&index.next_index_to_load))
.unwrap_or_default(),
next_index_to_load: if index_unchanged {
Arc::clone(&index.next_index_to_load)
} else {
Default::default()
},
loaded_indices: if index_unchanged {
Arc::clone(&index.loaded_indices)
} else {

View File

@@ -141,7 +141,7 @@ mod tests {
];
#[test]
#[cfg_attr(not(windows), ignore)]
#[cfg_attr(not(windows), ignore = "only meaningful on Windows")]
fn find_git_associated_windows_executable() {
for stem in SHOULD_FIND {
let path = super::find_git_associated_windows_executable(stem);
@@ -150,7 +150,7 @@ mod tests {
}
#[test]
#[cfg_attr(not(windows), ignore)]
#[cfg_attr(not(windows), ignore = "only meaningful on Windows")]
fn find_git_associated_windows_executable_no_extra() {
for stem in SHOULD_NOT_FIND {
let path = super::find_git_associated_windows_executable(stem);
@@ -159,7 +159,7 @@ mod tests {
}
#[test]
#[cfg_attr(not(windows), ignore)]
#[cfg_attr(not(windows), ignore = "only meaningful on Windows")]
fn find_git_associated_windows_executable_with_fallback() {
for stem in SHOULD_FIND {
let path = super::find_git_associated_windows_executable_with_fallback(stem);
@@ -168,7 +168,7 @@ mod tests {
}
#[test]
#[cfg_attr(not(windows), ignore)]
#[cfg_attr(not(windows), ignore = "only meaningful on Windows")]
fn find_git_associated_windows_executable_with_fallback_falls_back() {
for stem in SHOULD_NOT_FIND {
let path = super::find_git_associated_windows_executable_with_fallback(stem)

View File

@@ -54,7 +54,11 @@ impl Pattern {
_ => 0,
})
.sum::<isize>();
(count > 0).then_some(count as usize).unwrap_or_default()
if count > 0 {
count as usize
} else {
Default::default()
}
}
let mut path = gix_path::from_bstr(self.path.as_bstr());

View File

@@ -220,7 +220,11 @@ mod v2 {
for keepalive in [false, true] {
let fixture = format!(
"v2/clone-only{}.response",
keepalive.then_some("-with-keepalive").unwrap_or_default()
if keepalive {
"-with-keepalive"
} else {
Default::default()
}
);
let mut provider = mock_reader(&fixture);
let mut reader = provider.as_read_without_sidebands();

View File

@@ -12,7 +12,11 @@ async fn clone() -> crate::Result {
let mut dlg = CloneDelegate::default();
let fixture = format!(
"v1/clone{}.response",
with_keepalive.then_some("-with-keepalive").unwrap_or_default()
if with_keepalive {
"-with-keepalive"
} else {
Default::default()
}
);
crate::fetch(
transport(

View File

@@ -78,9 +78,11 @@ impl SpawnProcessOnDemand {
.expect("valid url"),
path,
ssh_cmd: None,
envs: (version != Protocol::V1)
.then(|| vec![("GIT_PROTOCOL", format!("version={}", version as usize))])
.unwrap_or_default(),
envs: if version != Protocol::V1 {
vec![("GIT_PROTOCOL", format!("version={}", version as usize))]
} else {
Default::default()
},
ssh_disallow_shell: false,
child: None,
connection: None,

View File

@@ -67,10 +67,11 @@ static EXCLUDE_LUT: Lazy<Mutex<Option<gix_worktree::Stack>>> = Lazy::new(|| {
let work_tree = work_tree?.canonicalize().ok()?;
let mut buf = Vec::with_capacity(512);
let case = gix_fs::Capabilities::probe(&work_tree)
.ignore_case
.then_some(gix_worktree::ignore::glob::pattern::Case::Fold)
.unwrap_or_default();
let case = if gix_fs::Capabilities::probe(&work_tree).ignore_case {
gix_worktree::ignore::glob::pattern::Case::Fold
} else {
Default::default()
};
let state = gix_worktree::stack::State::IgnoreStack(gix_worktree::stack::state::Ignore::new(
Default::default(),
gix_worktree::ignore::Search::from_git_dir(&gix_dir, None, &mut buf).ok()?,