Git development
 help / color / mirror / Atom feed
* [PATCH] Document git-diff whitespace flags -b and -w
@ 2006-12-03 16:24 Jakub Narebski
  2006-12-03 18:25 ` Johannes Schindelin
  0 siblings, 1 reply; 6+ messages in thread
From: Jakub Narebski @ 2006-12-03 16:24 UTC (permalink / raw)
  To: git; +Cc: Jakub Narebski

Document git diff options -b / --ignore-space-change and
-w / --ignore-all-space, introduced by Johannes Schindelin
in commit 0d21efa51cc7de5250d5da46bceacda78ba35373:
  "Teach diff about -b and -w flags".

The description of options is taken from GNU diff man page and
GNU Diffutils info documentation.

Signed-off-by: Jakub Narebski <jnareb@gmail.com>
---
Inspired by kblin (Kai Blin) asking on #git about git-diff option to
ignore whitespace only change.

 Documentation/diff-options.txt |   16 ++++++++++++++++
 1 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/Documentation/diff-options.txt b/Documentation/diff-options.txt
index e112172..9cdd171 100644
--- a/Documentation/diff-options.txt
+++ b/Documentation/diff-options.txt
@@ -129,5 +129,21 @@
 -a::
 	Shorthand for "--text".
 
+--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.
+
+-b::
+	Shorthand for "--ignore-space-change".
+
+--ignore-all-space::
+	Ignore white space when comparing lines.  This ignores
+	difference even if one line has white space where the other
+	line has none.
+
+-w::
+	Shorthand for "--ignore-all-space".
+
 For more detailed explanation on these common options, see also
 link:diffcore.html[diffcore documentation].
-- 
1.4.4.1

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] Document git-diff whitespace flags -b and -w
  2006-12-03 16:24 [PATCH] Document git-diff whitespace flags -b and -w Jakub Narebski
@ 2006-12-03 18:25 ` Johannes Schindelin
  2006-12-03 18:38   ` Jakub Narebski
  0 siblings, 1 reply; 6+ messages in thread
From: Johannes Schindelin @ 2006-12-03 18:25 UTC (permalink / raw)
  To: Jakub Narebski; +Cc: git

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) ' ';
 			}


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] Document git-diff whitespace flags -b and -w
  2006-12-03 18:25 ` Johannes Schindelin
@ 2006-12-03 18:38   ` Jakub Narebski
  2006-12-03 19:10     ` Johannes Schindelin
  0 siblings, 1 reply; 6+ messages in thread
From: Jakub Narebski @ 2006-12-03 18:38 UTC (permalink / raw)
  To: git

Johannes Schindelin wrote:

> 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:

Alternate solution would be to fix documentation, to document existing code.
I used GNU diff documentation, perhaps it is better if we are GNU diff
compatibile...
-- 
Jakub Narebski
Warsaw, Poland
ShadeHawk on #git


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] Document git-diff whitespace flags -b and -w
  2006-12-03 18:38   ` Jakub Narebski
@ 2006-12-03 19:10     ` Johannes Schindelin
  2006-12-04  2:20       ` Junio C Hamano
  0 siblings, 1 reply; 6+ messages in thread
From: Johannes Schindelin @ 2006-12-03 19:10 UTC (permalink / raw)
  To: Jakub Narebski; +Cc: git

Hi,

On Sun, 3 Dec 2006, Jakub Narebski wrote:

> Alternate solution would be to fix documentation, to document existing 
> code. I used GNU diff documentation, perhaps it is better if we are GNU 
> diff compatibile...

Since the whole point of "-w/-b" is to steal the nice feature from GNU 
diff, it does not make any sense breaking compatibility.

BTW on top of my patch you need this, if you want the tests to pass 
(danger ahead: intentional white space at eol):

-- snip --
make tests pass for recent "diff -b" change

---

	Am I the only one finding it funny to read diffs of diffs, 
	especially when being used to combined diffs?

diff --git a/t/t4015-diff-whitespace.sh b/t/t4015-diff-whitespace.sh
index 1bc5b7a..adf4993 100755
--- a/t/t4015-diff-whitespace.sh
+++ b/t/t4015-diff-whitespace.sh
@@ -109,12 +109,10 @@ index d99af23..8b32fb5 100644
 +	whitespace at beginning
  whitespace change
 -whitespace in the middle
--whitespace at end
 +white space in the middle
-+whitespace at end  
+ whitespace at end
  unchanged line
--CR at endQ
-+CR at end
+ CR at endQ
 EOF
 git-diff -b > out

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] Document git-diff whitespace flags -b and -w
  2006-12-03 19:10     ` Johannes Schindelin
@ 2006-12-04  2:20       ` Junio C Hamano
  2006-12-04  9:00         ` Johannes Schindelin
  0 siblings, 1 reply; 6+ messages in thread
From: Junio C Hamano @ 2006-12-04  2:20 UTC (permalink / raw)
  To: Johannes Schindelin; +Cc: git

Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:

> make tests pass for recent "diff -b" change

Both patches look sane.  Thanks.  Mind if I forge your
signature?

> 	Am I the only one finding it funny to read diffs of diffs, 
> 	especially when being used to combined diffs?

I agree that it is very hard to get used to.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] Document git-diff whitespace flags -b and -w
  2006-12-04  2:20       ` Junio C Hamano
@ 2006-12-04  9:00         ` Johannes Schindelin
  0 siblings, 0 replies; 6+ messages in thread
From: Johannes Schindelin @ 2006-12-04  9:00 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

Hi,

On Sun, 3 Dec 2006, Junio C Hamano wrote:

> Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
> 
> > make tests pass for recent "diff -b" change
> 
> Both patches look sane.  Thanks.  Mind if I forge your
> signature?

Not at all. I forget it, you forge it.

Ciao,
Dscho

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2006-12-04  9:01 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-12-03 16:24 [PATCH] Document git-diff whitespace flags -b and -w Jakub Narebski
2006-12-03 18:25 ` Johannes Schindelin
2006-12-03 18:38   ` Jakub Narebski
2006-12-03 19:10     ` Johannes Schindelin
2006-12-04  2:20       ` Junio C Hamano
2006-12-04  9:00         ` Johannes Schindelin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox