Skip to content

ls: fix --dired offsets after a directory with no listed entries - #15840

Open
Guilherme-M-Mateus wants to merge 1 commit into
uutils:mainfrom
Guilherme-M-Mateus:ls-dired-empty-dir
Open

Guilherme-M-Mateus wants to merge 1 commit into
uutils:mainfrom
Guilherme-M-Mateus:ls-dired-empty-dir

Conversation

@Guilherme-M-Mateus

Copy link
Copy Markdown
Contributor

Fixes #15800

TextOutput::write_dir_header() reset dired.padding to 0 before each heading after the first. When the previous directory listed no entry (empty, or only dot files without -a), padding still held that directory's heading and total line, so those bytes were lost and every later //DIRED// / //SUBDIRED// offset was too small. The padding is now kept; line_offset and padding are only ever used as a sum, and when the previous directory had entries padding is already 0, so other listings are unchanged.

Added test_ls_dired_offsets_after_empty_dir, covering several operands and -R with an empty and a dot-only directory. It fails before this change and passes after; all test_ls tests pass.

AI-assisted (Claude Code); I reviewed the change.

🤖 Generated with Claude Code

After a directory that lists no entry, its heading and "total" line were
dropped from the --dired byte count, shifting every later offset.

Fixes uutils#15800

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

GNU testsuite comparison:

GNU test failed: tests/tail/truncate. tests/tail/truncate is passing on 'main'. Maybe you have to rebase?

This branch has not been deployed

No deployments
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.

ls: --dired offsets too small after an empty directory

1 participant