Commit Briefs

cd0adebad1 Stefan Sperling

update diff README; it was heavily outdated (main)


edc37d001a Omar Polo

fix some typos; ok tb@ stsp@


b5a9c15f4d Stefan Sperling

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

This makes test 126 pass.


35d0481840 Stefan Sperling

add a test which triggers redundant 'No newline at end of file' messages

The message appears after each hunk, but should only appear at the end of the entire diff. Regression introduced in commit 4125b1eff8d9dfcd961dc70ebbd5d54c97bdc3f6 "diff: handle missing new lines in trailing context" problem noticed by op@


dc306c6bd8 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@


f46fa9b5e7 Christian Weisgerber

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


e78a8d73c2 Mark Jamsek

make diff_chunk_type() public and clarify comment

As discussed with stsp, reword an easily misunderstood comment, and move diff_chunk_type() into the public diff API to improve caller efficiency. ok stsp@


f26db7cd28 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@


1dce05e8f9 Omar Polo

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@



Branches

Tags

This repository contains no tags

Tree

.gitignorecommits | blame
LICENCEcommits | blame
READMEcommits | blame
compat/
diff/
diff-version.mkcommits | blame
include/
lib/
man/
test/

README

This is a collection of diff algorithms, implemented in portable C.

The aim is to provide a faster diff implementation for Game of Trees
(gameoftrees.org) with a BSD license. The project began at the u2k20
OpenBSD hackathon. The original author is Neels Hofmeyr.

The Myers and Patience Diff algorithm implementations found here are based on
the explanations found in these blog post series:
  https://blog.jcoglan.com/2017/02/12/the-myers-diff-algorithm-part-1/ ff.
and
  https://blog.jcoglan.com/2017/09/19/the-patience-diff-algorithm/ ff.
-- possibly the single most comprehensive explanations of these algorithms.
Many thanks for this valuable door opener!
The source code itself is not based on the code found in those blogs, but
written from scratch with the knowledge gained.

Compile:
  make -C diff

Test:
  make -C test/