Commit graph

10 commits

Author SHA1 Message Date
Ori Bernstein 5d37407e3c diff: avoid empty hunks when there are no changes
Currently, diff outputs a file header, even if there are
no changes to the file. This is wonky.

It means that the header chunks are ambiguous, since
not all header chunks are followed by '@@ hunk', and
'--- file', '+++ file' lines can be generated from
file content.

This changes the way that we decide to print the file
header, so we only print it when outputting the first
hunk on flushchanges.

Flushchanges is called once per regular file, at the
end of `diffreg`, so we output a hunk header once per
file.
2022-06-04 02:21:19 +00:00
Ori Bernstein 6fbb1acc8f diff: clean up some comments
I did the tidying and fixes. Let's remove those
comments.
2022-05-22 21:49:08 +00:00
Ori Bernstein 23f8872bc1 diff: retain original file names
When diffing non-regular files, like /dev/null,
pipes, and similar, diff will generate a temp
file to diff against. This is the right thing
to do, but the temp file leaks into the diff.

This patch retains the original file name all
the way through to diff output.
2022-05-22 16:41:47 +00:00
Ori Bernstein 4649189126 diff: fix style
remove useless macros, bring formatting closer
to regular 9front formatting, and use the
ARGBEGIN/ARGEND macros. No functional change.
2022-05-22 16:34:33 +00:00
cinap_lenrek 68572ab451 diff: revert last change, this breaks git/diff 2021-11-09 01:29:30 +00:00
Kyle Milz cd7480f68f diff: fix -u when comparing identical files 2021-11-05 19:03:20 +00:00
kvik fc36bf0711 diff: fix change marker for -c mode 2020-11-16 19:19:37 +01:00
Ori Bernstein 8fe1d622b5 diff: support unified diff via -u
The format produced by `diff -u` is inferior to that
produced by `diff -c`, but it's what ape/patch and
unix patch expect, so it's useful to generate it.

This patch adds `diff -u`.
2020-09-21 09:40:42 -07:00
Taru Karttunen a9060cc06b Import sources from 2011-03-30 iso image - lib 2011-03-30 19:35:09 +03:00
Taru Karttunen e5888a1ffd Import sources from 2011-03-30 iso image 2011-03-30 15:46:40 +03:00