git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Keith Cascio <keith@CS.UCLA.EDU>
To: git@vger.kernel.org
Cc: Johannes Schindelin <Johannes.Schindelin@gmx.de>,
	Junio C Hamano <gitster@pobox.com>
Subject: [PATCH/RFC v1 1/1] bug fix, diff whitespace ignore options
Date: Sun, 18 Jan 2009 18:01:47 -0800 (PST)	[thread overview]
Message-ID: <alpine.GSO.2.00.0901181754190.9333@kiwi.cs.ucla.edu> (raw)
In-Reply-To: <alpine.DEB.1.00.0901190218470.3586@pacific.mpi-cbg.de>

  Fixed bug in diff whitespace ignore options.
  It is now OK to specify more than one whitespace ignore option
  on the command line. In unit test 4015, expect success rather
  than failure for 4 cases.
  Note: I do not fully understand why this fix works, but it passes
  all 68 t4???-* diff test scripts.

The semantics of the three whitespace ignore flags
{ -w, -b, --ignore-space-at-eol }
obey a relation of transitive implication, i.e. the stronger
options imply the weaker options:
-w                    implies the other two
-b                    implies --ignore-space-at-eol
--ignore-space-at-eol implies only itself

Therefore it is never necessary to specify more than one of these
on the command line.  Yet we imagine scenarios where software
wrappers (e.g. GUIs, etc) generate command lines that switch on
more than one of these flags simultaneously.  It is unreasonable
to prohibit specifying more than one, since a new user might not
immediately discern the implication relation.  Now we call such
a command line valid and legal.

Signed-off-by: Keith Cascio <keith@cs.ucla.edu>
---
  t/t4015-diff-whitespace.sh |    8 ++++----
  xdiff/xutils.c             |   22 ++++++++++++----------
  2 files changed, 16 insertions(+), 14 deletions(-)

diff --git a/t/t4015-diff-whitespace.sh b/t/t4015-diff-whitespace.sh
index dbb608c..6d13da3 100755
--- a/t/t4015-diff-whitespace.sh
+++ b/t/t4015-diff-whitespace.sh
@@ -99,11 +99,11 @@ EOF
  git diff -w > out
  test_expect_success 'another test, with -w' 'test_cmp expect out'
  git diff -w -b > out
-test_expect_failure 'another test, with -w -b' 'test_cmp expect out'
+test_expect_success 'another test, with -w -b' 'test_cmp expect out'
  git diff -w --ignore-space-at-eol > out
-test_expect_failure 'another test, with -w --ignore-space-at-eol' 'test_cmp expect out'
+test_expect_success 'another test, with -w --ignore-space-at-eol' 'test_cmp expect out'
  git diff -w -b --ignore-space-at-eol > out
-test_expect_failure 'another test, with -w -b --ignore-space-at-eol' 'test_cmp expect out'
+test_expect_success 'another test, with -w -b --ignore-space-at-eol' 'test_cmp expect out'

  tr 'Q' '\015' << EOF > expect
  diff --git a/x b/x
@@ -123,7 +123,7 @@ EOF
  git diff -b > out
  test_expect_success 'another test, with -b' 'test_cmp expect out'
  git diff -b --ignore-space-at-eol > out
-test_expect_failure 'another test, with -b --ignore-space-at-eol' 'test_cmp expect out'
+test_expect_success 'another test, with -b --ignore-space-at-eol' 'test_cmp expect out'

  tr 'Q' '\015' << EOF > expect
  diff --git a/x b/x
diff --git a/xdiff/xutils.c b/xdiff/xutils.c
index d7974d1..b9bda86 100644
--- a/xdiff/xutils.c
+++ b/xdiff/xutils.c
@@ -245,17 +245,19 @@ static unsigned long xdl_hash_record_with_whitespace(char const **data,
  			while (ptr + 1 < top && isspace(ptr[1])
  					&& ptr[1] != '\n')
  				ptr++;
-			if (flags & XDF_IGNORE_WHITESPACE_CHANGE
-					&& ptr[1] != '\n') {
-				ha += (ha << 5);
-				ha ^= (unsigned long) ' ';
-			}
-			if (flags & XDF_IGNORE_WHITESPACE_AT_EOL
-					&& ptr[1] != '\n') {
-				while (ptr2 != ptr + 1) {
+			if( ! (          flags & XDF_IGNORE_WHITESPACE       )){
+				if(      flags & XDF_IGNORE_WHITESPACE_CHANGE
+						&& ptr[1] != '\n') {
  					ha += (ha << 5);
-					ha ^= (unsigned long) *ptr2;
-					ptr2++;
+					ha ^= (unsigned long) ' ';
+				}
+				else if( flags & XDF_IGNORE_WHITESPACE_AT_EOL
+						&& ptr[1] != '\n') {
+					while (ptr2 != ptr + 1) {
+						ha += (ha << 5);
+						ha ^= (unsigned long) *ptr2;
+						ptr2++;
+					}
  				}
  			}
  			continue;
-- 
1.6.1.203.ga83c8.dirty

  reply	other threads:[~2009-01-19  2:03 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-01-18 10:53 [PATCH 0/3] Implement 'git archive --submodules' Lars Hjemli
2009-01-18 10:53 ` [PATCH 1/3] sha1_file: add function to insert alternate object db Lars Hjemli
2009-01-18 10:53   ` [PATCH 2/3] Teach read_tree_recursive() how to traverse into submodules Lars Hjemli
2009-01-18 10:53     ` [PATCH 3/3] git-archive: add support for --submodules Lars Hjemli
2009-01-18 15:51       ` Johannes Schindelin
2009-01-18 15:48     ` [PATCH 2/3] Teach read_tree_recursive() how to traverse into submodules Johannes Schindelin
2009-01-18 17:45       ` Lars Hjemli
2009-01-18 18:33         ` Johannes Schindelin
2009-01-18 19:45           ` Lars Hjemli
2009-01-18 21:02             ` Johannes Schindelin
2009-01-18 21:31               ` Lars Hjemli
2009-01-18 21:55                 ` Johannes Schindelin
2009-01-18 22:46                   ` Lars Hjemli
2009-01-19  1:24                     ` Johannes Schindelin
2009-01-19  2:01                       ` Keith Cascio [this message]
2009-01-19  3:53                         ` [PATCH/RFC v1 1/1] bug fix, diff whitespace ignore options Johannes Schindelin
2009-01-19 18:03                           ` [PATCH/RFC v2 " Keith Cascio
2009-01-19 18:36                             ` Johannes Schindelin
2009-01-20  7:04                             ` Junio C Hamano
2009-01-19  3:02         ` [PATCH 2/3] Teach read_tree_recursive() how to traverse into submodules Junio C Hamano
2009-01-18 16:13     ` René Scharfe
2009-01-18 16:37       ` Lars Hjemli
2009-01-18 19:00         ` Junio C Hamano
2009-01-18 19:50           ` Lars Hjemli
2009-01-18 15:32   ` [PATCH 1/3] sha1_file: add function to insert alternate object db Johannes Schindelin
2009-01-18 15:55     ` [PATCH] " Lars Hjemli

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.GSO.2.00.0901181754190.9333@kiwi.cs.ucla.edu \
    --to=keith@cs.ucla.edu \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).