Skip to content

Commit

Permalink
multi hard link regression fix
Browse files Browse the repository at this point in the history
  • Loading branch information
matrixhead committed Jun 19, 2024
1 parent a968980 commit c2fe2b7
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
18 changes: 16 additions & 2 deletions src/uu/ls/src/ls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3414,7 +3414,14 @@ fn apply_style_based_on_metadata(
) -> String {
let path_indicator = ls_colors.indicator_for_path_with_metadata(&path.p_buf, md_option);
let is_zeroed = ls_colors.zeroed_indicators.contains(&path_indicator);
match ls_colors.style_for_indicator(path_indicator) {
let style = if path_indicator == Indicator::RegularFile {
ls_colors
.style_for_str(&name)

Check failure on line 3419 in src/uu/ls/src/ls.rs

View workflow job for this annotation

GitHub Actions / Style and Lint (ubuntu-22.04, unix)

ERROR: `cargo clippy`: this expression creates a reference which is immediately dereferenced by the compiler (file:'src/uu/ls/src/ls.rs', line:3419)
.or_else(|| ls_colors.style_for_indicator(path_indicator))
} else {
ls_colors.style_for_indicator(path_indicator)
};
match style {
Some(style) => style_manager.apply_style(style, name, ls_colors, is_zeroed),
None => name.to_owned(),
}
Expand All @@ -3438,7 +3445,14 @@ fn color_name(
// There is a DirEntry, we don't need to get the metadata for the color
let de_indicator = ls_colors.indicator_for(de);
let is_zeroed = ls_colors.zeroed_indicators.contains(&de_indicator);
return match ls_colors.style_for_indicator(de_indicator) {
let style = if de_indicator == Indicator::RegularFile {
ls_colors
.style_for_str(&name)
.or_else(|| ls_colors.style_for_indicator(de_indicator))
} else {
ls_colors.style_for_indicator(de_indicator)
};
return match style {
Some(style) => style_manager.apply_style(style, &name, ls_colors, is_zeroed),
None => name,
};
Expand Down
7 changes: 6 additions & 1 deletion util/build-gnu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -350,4 +350,9 @@ sed -i -e "s|Try 'md5sum --help' for more information.\\\n||" tests/cksum/md5su
sed -i -E '65,79{s/\^\[\[([1-9]m)/^[[0\1/g; s/\^\[\[m/^[[0m/g}' tests/ls/color-norm.sh
# It says in the test itself that having more than one reset is a bug, so we
# don't need to replicate that behavior.
sed -i -E '73,75{s/(\^\[\[0m)+/\^\[\[0m/g}' tests/ls/color-norm.sh
sed -i -E '73,75{s/(\^\[\[0m)+/\^\[\[0m/g}' tests/ls/color-norm.sh

# GNU's ls seems to output color codes in the order given in the environment
# variable, but our ls seems to output them in a predefined order. Nevertheless,
# the order doesn't matter, so it's okay.
sed -i '25s/44;37/37;44/' tests/ls/multihardlink.sh

0 comments on commit c2fe2b7

Please sign in to comment.