Commits


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@


do not treat \r\n line endings as special Previously, we would go out of our way to handle both \n and \r\n line endings as equivalent. However, for files with \r\n line endings, this results in diffs that omit the final \r and therefore cannot be applied with patch(1) on Unix platforms. ok stsp


always cast ctype' is*() arguments to unsigned char Almost all had already an unsigned argument (uint8_t or unsigned char), but cast anyway in case the types are changed in the future. ok stsp@


improve accuracy of function prototype in hunk headers Initial diff by Tom Jones with fixes from stsp. ok stsp@


remove gcc ternary if extension ok stsp@


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@


sync files from got.git 58e31a80da4f4a9e10eaea148672190f35107a47 ok stsp@


avoid writing just one character at a time in diff_output_lines() With input from ori@ and millert@


fix performance issues in the search for function prototypes with + ok naddy


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"


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


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.


C++ function prototype support based on OpenBSD's diff(1) code


search for prototypes above, not at, the first line touched by the diff chunk


add support for showing function prototypes in unidiff hunk headers


don't hex-escape non-printable ASCII in diff_output_lines(); UTF-8 must pass


atoms are stored in an array, not a list; use direct indexing instead of loop


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.


rename diff_atom->d to diff_atom->root, because it always is The idea was that for each diff box within the files, the atoms would have a backpointer to the current layer of diff_data (indicating the current section), but it is not actually needed to update the backpointer in each atom to the current diff_data. That is why the current code always points atom->d to the root diff_data for the entire file. Clarify by proper name. Constructs like atom->d->root->foo are redundant, just use atom->root->foo.


add missing curly braces (clang reported misleading indentation)


move headers from include/diff/ to include/; makes things easier for consumers


check results of ARRAYLIST_ADD


check return value of diff_output_lines


optionally provide information about the generated diff to the API user


add APIs to write out the left and right versions of diff chunks