git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] Document git-diff whitespace flags -b and -w

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Dec 3, 2006, 18:25 UTC
Message-ID
<Pine.LNX.4.63.0612031908020.28348@wbgn013.biozentrum.uni-wuerzburg.de>
In-Reply-To
<11651630814064-git-send-email-jnareb@gmail.com>
Hi,
On Sun, 3 Dec 2006, Jakub Narebski wrote:
> +--ignore-space-change::
> +	Ignore changes in amount of white space.  This ignores white
> +	space at line end, and consider all other sequences of one or
> +	more white space characters to be equivalent.

Thank you for bringing this up. The latter part is correct, but the first part not yet. I asked at the time if somebody cares, but got no answer, so "-b" does _not_ ignore white space at the end of line ATM, but only white space change. So here is a patch to fix that behaviour:

-- snip -- diff -b: ignore whitespace at end of line

This is _not_ the same as "treat eol as whitespace", since that would mean that multiple empty lines would be treated as equal to e.g. a space.

---
diff --git a/xdiff/xutils.c b/xdiff/xutils.c
index 9e4bb47..1b899f3 100644
--- a/xdiff/xutils.c
+++ b/xdiff/xutils.c
@@ -230,7 +230,8 @@ unsigned long xdl_hash_record(char const **data, char const *top, long flags) {
 			while (ptr + 1 < top && isspace(ptr[1])
 					&& ptr[1] != '\n')
 				ptr++;
-			if (flags & XDF_IGNORE_WHITESPACE_CHANGE) {
+			if (flags & XDF_IGNORE_WHITESPACE_CHANGE
+					&& ptr[1] != '\n') {
 				ha += (ha << 5);
 				ha ^= (unsigned long) ' ';
 			}
Previous: Jakub NarebskiNext: Jakub Narebski
Message 2 of 6 in “Document git-diff whitespace flags -b and -w”
  1. Document git-diff whitespace flags -b and -wJakub Narebski, Dec 3, 2006
  2. Johannes SchindelinDec 3, 2006
  3. Jakub NarebskiDec 3, 2006
  4. Johannes SchindelinDec 3, 2006
  5. Junio C HamanoDec 4, 2006
  6. Johannes SchindelinDec 4, 2006

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.