libgit2/libgit2 — pull request #1556 by arrbee (2013-05-07 14:25:29+00:00)
Title: Diff patch bug fixes

This started out with a discussion with @dannygreg - he was encountering some problems with diff patches when newlines were missing from the end of the file being diffed.

This PR has two main changes:

1. Add a `GIT_DIFF_LINE_CONTEXT_EOFNL` constant to use for diff lines that are generated as context lines at the end of a file that does not end in a newline. (For this to occur, you have to have a change within `context_lines` of the end of a file that does not end in a newline.)
2. Fix the line numbers assigned for all EOFNL lines in the patch because they were not being counted correctly.

Because of a problem I encountered while programmatically generated test data for these fixes, I started to work on nanosecond stat time checking, so I did a little refactoring in the diff code and there are a couple of code fragments in the resulting reorganized code that allow for nanosecond values to be tested, but I didn't actually hook up the code to copy over the values from stat data (which would be in the `git_index_entry__init_from_stat()` function and will probably have to be platform specific).

Also, this includes some doc fixes to the diff.h header after two different folks in the last couple of days asked about how to diff against the empty tree.