mirror of
https://github.com/RGBCube/serenity
synced 2025-05-14 09:14:58 +00:00
diff: Only output a unified/context header if there is a diff
This commit is contained in:
parent
c6c20d3bf3
commit
84b187e375
1 changed files with 4 additions and 1 deletions
|
@ -57,6 +57,9 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
|
||||
auto hunks = TRY(Diff::from_text(TRY(file1->read_until_eof()), TRY(file2->read_until_eof()), number_context_lines));
|
||||
|
||||
if (hunks.is_empty())
|
||||
return 0;
|
||||
|
||||
if (unified) {
|
||||
TRY(Diff::write_unified_header(filename1, filename2, *out));
|
||||
for (auto const& hunk : hunks)
|
||||
|
@ -70,5 +73,5 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
TRY(Diff::write_normal(hunk, *out, color_output));
|
||||
}
|
||||
|
||||
return hunks.is_empty() ? 0 : 1;
|
||||
return 1;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue