Hi all! Please give me a sanity check before I go crazy... There is a bug in git diff (ignoring whitespace) that does not take into account a trailing space at the end of a line at the end of a file when no new line follows. Here is the example of the bug: mkdir test_ws_eof cd test_ws_eof git init echo -n "Test" > test.txt git add . git commit -m'test' git symbolic-ref HEAD refs/heads/with_space rm .git/index git clean -f echo -n "Test ">test.txt git add . git commit -m'test' # Ignoring all whitespace there shouldn't be a diff. git diff -w master -- test.txt # Ignoring space at eol there shouldn't be a diff git diff --ignore-space-at-eol master -- test.txt # Ignoring with -b might have a case for a diff showing. git diff -b master -- test.txt In the xutils.c xdl_hash_record_with_whitespace function the trailing space prior to eof was being calculated into the hash, I fixed that with the change below, but there is still a difference being noted in xdl_recmatch because of the size difference. Before I go changing something that shouldn't be changed could someone provide some input please? Thanks for reading, Thell diff --git a/xdiff/xutils.c b/xdiff/xutils.c index 04ad468..623da92 100644 --- a/xdiff/xutils.c +++ b/xdiff/xutils.c @@ -243,17 +243,17 @@ static unsigned long xdl_hash_record_with_whitespace(char const **data, if (isspace(*ptr)) { const char *ptr2 = ptr; while (ptr + 1 < top && isspace(ptr[1]) - && ptr[1] != '\n') + && ( ptr[1] != '\n' && ptr[1] != '\0' ) ) ptr++; if (flags & XDF_IGNORE_WHITESPACE) ; /* already handled */ else if (flags & XDF_IGNORE_WHITESPACE_CHANGE - && ptr[1] != '\n') { + && ( ptr[1] != '\n' && ptr[1] != '\0' ) ) { ha += (ha << 5); ha ^= (unsigned long) ' '; } else if (flags & XDF_IGNORE_WHITESPACE_AT_EOL - && ptr[1] != '\n') { + && ( ptr[1] != '\n' && ptr[1] != '\0' ) ) { while (ptr2 != ptr + 1) { -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html