Skip to content

pr: stop merged output after the last line without a page trailer - #15673

Open
jayhemnani9910 wants to merge 2 commits into
uutils:mainfrom
jayhemnani9910:pr-merge-omit-blank-rows
Open

jayhemnani9910 wants to merge 2 commits into
uutils:mainfrom
jayhemnani9910:pr-merge-omit-blank-rows

Conversation

@jayhemnani9910

@jayhemnani9910 jayhemnani9910 commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

With -m and no page trailer (-t, -T, -F), pr pads the merged columns with empty rows up to the page length:

$ printf 'a\nb\n' > one; printf 'c\nd\n' > two
$ pr -m -t one two | wc -l
GNU 9.12: 2     uutils: 56
$ pr -m -F one two | wc -l
GNU 9.12: 7     uutils: 58

This is the symptom in #14334, which no longer shows for a single file on main but still does with -m. Single-file mode already stops at the first empty row in this case; write_columns now does the same for merged files. With a header and trailer the page is still padded, as GNU does.

New test test_merge_stops_after_last_line_without_header checks the exact output of -m -J with -t, -T and -F (fails on main). The pr tests pass (86), clippy is clean. 45 -m invocations (-t, -T, -F, -f, -l, -d, -n, -o, -J, three pairs of files with even and uneven lengths, with and without header) now print the same number of lines as GNU 9.12; apart from the column separator issues in #12313 the text matches GNU up to tab/space padding. #13540 rewrites merge mode and may cover this too.

Copilot AI balanced review requested due to automatic review settings October 23, 2026 06:12

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.

@github-actions

Copy link
Copy Markdown

Binary size comparison:

Individual binary size comparison VS main (threshold: >=5% AND >=4 KB).

Total size of compared binaries: 155.04 MB (-308 KB, -0.19%)

Significant per-binary changes:
  date     2.61 MB ->    2.30 MB  (-316 KB, -11.81%)

Comment thread src/uu/pr/src/pr.rs Outdated
// page trailer to pad for.
if merge
&& row.iter().all(Option::is_none)
&& (feed_line_present || !options.display_header_and_trailer)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

same condition as the break below, could you please put it in a variable like no_trailer?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done in 8df7385: no_trailer is set once before the loop and both breaks use it.

@sylvestre

Copy link
Copy Markdown
Contributor

please don't compare with 9.7, it is old, you should compare with 9.12

Comment thread tests/by-util/test_pr.rs Outdated
let (at, mut ucmd) = at_and_ucmd!();
at.write("one", "a\nb\n");
at.write("two", "c\nd\n");
let result = ucmd.args(&["-m", flag, "one", "two"]).succeeds();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

please check the exact stdout rather than only the line count

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done in 8df7385: the test now compares the whole stdout for -t, -T and -F (with -D X for a fixed header). It uses -J: without it the merged columns are padded with spaces where GNU uses tabs, which is separate from this fix (#12313).

With -m and -t, -T or -F, the merged files were padded with empty rows to the full page length, so two two-line files gave 56 lines; GNU pr prints the two lines.
@jayhemnani9910
jayhemnani9910 force-pushed the pr-merge-omit-blank-rows branch from 28f7bb0 to 8df7385 Compare October 25, 2026 07:55
Copilot AI balanced review requested due to automatic review settings October 25, 2026 07:55

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.

@jayhemnani9910

Copy link
Copy Markdown
Contributor Author

Rebased on main (it conflicted with #15671 in test_pr.rs) and checked against GNU 9.12 instead of 9.7: the same 2 and 7 lines for the examples, and 45 -m invocations now print the same number of lines as 9.12. Description updated.

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.

3 participants