Commit Briefs

Stefan Sperling

print trailing 'No newline at EOF' message for final chunk only (main)

This makes test 126 pass.


Stefan Sperling

back out "improve accuracy of function prototype in hunk headers"

which was commit 8993f42562696079866fc2dec7191877b6cc1f18 This commit introduced a regression where hunk headers would contain lines taken from below or within a change. Reported by tb@ and sthen@. There is some confusion around how the -p feature was documented: -p With unified and context diffs, show with each change the first 40 characters of the last line before the context beginning with a letter, an underscore or a dollar sign. For C source code following standard layout conventions, this will show the prototype of the function the change applies to. The original behaviour matches "the last line before the context beginning with a letter ...". The new (reverted) behaviour sometimes matches "will show the prototype of the function the change applies to". This did always happen as intended, as seen when some .c files in the OpenBSD src tree were changed. The new behaviour was also worse for Makefiles in the OpenBSD ports tree. Let's revert to the traditional -p behaviour until a better fix is found. Details: https://marc.gameoftrees.org/mail/1692696001.69872_0.html https://marc.info/?l=gameoftrees&m=169269624516330&w=2 ok tb@


Mark Jamsek

add public APIs to enable chunk byte offset retrieval

Prompted by changes to conflict marker detection in got.git, add chunk offset getters for both left- and right-hand side files. This facilitates more efficient caller diff_result use by directly seeking to a given chunk rather than counting lines. ok stsp@


tj

diff: handle missing new lines in trailing context

If there is a missing new line in the context we currently miss it and fail to print the warning. This trips up patch and leads to failures. Catch these cases in for unidiff output and add a test case. ok stsp@


Mark Jamsek

improve accuracy of function prototype in hunk headers

Initial diff by Tom Jones with fixes from stsp. ok stsp@


Mark Jamsek

collect line type metadata when generating diff

Similar to line offsets, create an array of line types (i.e., hunk, context, minus, plus) for each line output in the diff. ok stsp@


Stefan Sperling

add missing line offset information for unidiff output

We forgot to generate line offset information for lines of the form: "Binary files %s and %s differ" Which is causing scrolling problems in tog's diff view. ok thomas_adam


Stefan Sperling

fix performance issues in the search for function prototypes

with + ok naddy


Stefan Sperling

allow for telling the difference between empty and non-existent files

Adjust labels used in diff output accordingly; non-existent files should have the label "/dev/null"



Christian Weisgerber

add a missing include for uint8_t and switch from <inttypes.h> to <stdint.h>

ok millert stsp




Neels Hofmeyr

add sanity assertions around adding result chunks

uncovers errors related to placing minus chunks above already added plus chunks.



Stefan Sperling

allow diff API users to atomize files separately

This is a breaking API change (not that we care about that at this point). This can avoid redundant work spent on atomizing a file multiple times. There are use cases where one particular file must be compared to other files over and over again, such as when blaming file history. The old API gave access to both versions of the file to the atomizer just in case a future atomizer implementation needs this. This can still be achieved by passing a second file via the atomizer's private data pointer.







Stefan Sperling

put functions required for using diff_output_unidiff_chunk() into public API

They will be needed to implement 'got stage -p' and 'got revert -p', etc. Chunks stored in diff_result still need post-processing in order to be displayed as expected by diff_output_unidiff_chunk(). Exposing these functions allows API consumers to implement the same chunk merging loop as used internally by output_unidiff() and output_edscript(). (Perhaps, ideally, the public diff API would provide pre-merged chunks at some point in the future? Then this commit could probably be reverted.) Change return values from bool to int to avoid making stdbool.h a requirement for the public diff API.



Stefan Sperling

print "\ No newline at end of file" message like UNIX diff(1) does

Not adding new tests since this behaviour is covered by tests in Got.