mirror of
https://github.com/SerenityOS/serenity
synced 2024-09-06 17:06:31 +00:00
diff: Only output a unified/context header if there is a diff
This commit is contained in:
parent
c6c20d3bf3
commit
84b187e375
|
@ -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…
Reference in a new issue