Git development
 help / color / mirror / Atom feed
From: Thell Fowler <git@tbfowler.name>
To: Junio C Hamano <gitster@pobox.com>
Cc: Thell Fowler <git@tbfowler.name>,
	git@vger.kernel.org, Johannes.Schindelin@gmx.de
Subject: Re: [PATCH-v2/RFC 3/6] xutils: fix ignore-all-space on incomplete line
Date: Sun, 23 Aug 2009 15:33:58 -0500 (CDT)	[thread overview]
Message-ID: <alpine.DEB.2.00.0908231515020.29625@GWPortableVCS> (raw)
In-Reply-To: <7vljlauxmk.fsf@alter.siamese.dyndns.org>

Junio C Hamano (gitster@pobox.com) wrote on Aug 23, 2009:

> Thell Fowler <git@tbfowler.name> writes:
> 
> > Because the flow is much more direct it also makes the test additions to 
> > t4015 obsolete as they essentially tested for line end conditions instead 
> > of whitespace (like they should have).
> 
> Your patch 6/6 that added the tests were useful to find a bug I originally
> had, which is the one below that is commented out.
> 

That's good to hear!

> >> +		/*
> >> +		 * If we do not want -b to imply --ignore-space-at-eol
> >> +		 * then you would need to add this:
> >> +		 *
> >> +		 * if (!(flags & XDF_IGNORE_WHITESPACE_AT_EOL))
> >> +		 *	return (s1 <= i1 && s2 <= i2);
> >> +		 *
> >> +		 */
> >> +
> >
> > While it would be nice to have -b and --ignore-space-at-eol be two 
> > different options that could be merged together the documentation states 
> > that -b ignores spaces at eol, and there are scripts that depend on this 
> > behavior.
> 
> Also that is how "diff -b" behaves, and that is why I said your tests
> found a _bug_ in my original.  I'll drop the above large comment and
> replace it with just a "/* -b implies --ignore-space-at-eol */".
> 

In that case the only other outstanding issue to being able to use 
patch-id to validate a whitespace fixed patch is diff's -B option to catch 
the situations where the original has multiple blank newlines at the end 
of file.


> > Right now the xdl_recmatch() checks three distinct flags before having the 
> > opportunity to do the default behavior of a straight diff.  In 
> > xdl_hash_record there is an initial check for whitespace flags.
> >
> > ...
> > 	if (flags & XDF_WHITESPACE_FLAGS)
> > 		return xdl_hash_record_with_whitespace(data, top, flags);
> > ...
> >
> > Perhaps a similar setup for xdl_rematch() and a 
> > xdl_recmatch_with_whitespace() ?
> 
> Or we can just move the final else clause up and start the function like
> this:
> 
> 	int i1, i2;
> 
> 	if (!(flags & XDF_WHITESPACE_FLAGS))
>  		return s1 == s2 && !memcmp(l1, l2, s1);
> 
> 	i1 = i2 = 0;
>  	if (flags & XDF_IGNORE_WHITESPACE) {
> 		...
> 
> that would get rid of two unnecessary clearing of variables (i1 and i2,
> even though I suspect that the compiler _could_ optimize them out without
> such an change), and three flags-bit check in the most common case of not
> ignoring any whitespaces.
> 

HA!  That's a nifty way to do that with the variables.

> > Since your to counter-proposals give the same results, provide safer and 
> > faster processing, eliminate the additional test, as well as being easier 
> > to read and comprehend I propose a v3 with just those two patches.  I'll 
> > be glad to post it, with or without a xdl_recmatch_with_whitespace, if 
> > need be.  And should I, or do I need to, add something to the commit (ie: 
> > ack, tested, ...) ?
> 
> I can amend the counterproposal patches with tests from your 6/6 and add
> your "Tested-by:" and commit them myself.
> 

Excellent.

> > Thank you again for taking the time to look at this change!
> 
> Thank _you_ for bringing this issue up in the first place.

My pleasure!  It has been quite the learning experience!

-- 
Thell

  reply	other threads:[~2009-08-23 20:34 UTC|newest]

Thread overview: 63+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-08-04 23:33 Help/Advice needed on diff bug in xutils.c Thell Fowler
2009-08-05 20:45 ` Johannes Schindelin
2009-08-10 18:54   ` Thell Fowler
2009-08-12  0:47   ` [PATCH/RFC] Add diff tests for trailing-space and now newline Thell Fowler
2009-08-19 23:05 ` [PATCH 0/6 RFC] Series to correct xutils incomplete line handling Thell Fowler
2009-08-21 17:39   ` Thell Fowler
2009-08-21 22:16     ` Alex Riesen
2009-08-22  4:23       ` Thell Fowler
     [not found] ` <cover.1250719760.git.git@tbfowler.name>
2009-08-19 23:06   ` [PATCH 1/6] Add supplemental test for trailing-whitespace on incomplete lines Thell Fowler
2009-08-19 23:06   ` [PATCH 2/6] Make xdl_hash_record_with_whitespace ignore eof Thell Fowler
2009-08-19 23:07   ` [PATCH 3/6] Make diff -w handle trailing-spaces on incomplete lines Thell Fowler
2009-08-20 23:09     ` Thell Fowler
2009-08-19 23:07   ` [PATCH 4/6] Make diff -b " Thell Fowler
2009-08-19 23:08   ` [PATCH 5/6] Make diff --ignore-space-at-eol handle " Thell Fowler
2009-08-19 23:09   ` [PATCH 6/6] Add diff tests for trailing-space on " Thell Fowler
2009-08-23  3:47 ` [PATCH-v2/RFC 0/6] improvements for trailing-space processing " Thell Fowler
2009-08-23  3:49   ` [PATCH-v2/RFC 1/6] Add supplemental test for trailing-whitespace " Thell Fowler
2009-08-23  3:49   ` [PATCH-v2/RFC 2/6] xutils: fix hash with whitespace on incomplete line Thell Fowler
2009-08-23  7:51     ` Junio C Hamano
2009-08-23 17:02       ` Thell Fowler
2009-08-23  3:49   ` [PATCH-v2/RFC 3/6] xutils: fix ignore-all-space " Thell Fowler
2009-08-23  7:57     ` Junio C Hamano
2009-08-23  8:18       ` Nanako Shiraishi
2009-08-23  8:56         ` Junio C Hamano
2009-08-23 21:07           ` Nanako Shiraishi
2009-08-23 21:14             ` Junio C Hamano
2009-08-23 22:13             ` Thell Fowler
2009-08-23 22:30               ` Junio C Hamano
2009-08-24  4:16                 ` [PATCH] Teach mailinfo to ignore everything before -- >8 -- mark Nicolas Sebrecht
2009-08-24  4:51                   ` Junio C Hamano
2009-08-24  5:36                     ` Junio C Hamano
2009-08-24  6:21                       ` [PATCH] " Nicolas Sebrecht
2009-08-24  6:58                         ` Junio C Hamano
2009-08-24  7:31                           ` Nicolas Sebrecht
2009-08-24 14:02                             ` Don Zickus
2009-08-24 21:48                               ` Junio C Hamano
2009-08-24  5:16                   ` [PATCH] " Nanako Shiraishi
2009-08-24  7:17                     ` [PATCH] " Nicolas Sebrecht
2009-08-24  7:24                       ` Nicolas Sebrecht
2009-08-24 22:17                       ` Junio C Hamano
2009-08-25 16:18                         ` Nicolas Sebrecht
2009-08-26  1:51                           ` Junio C Hamano
     [not found]                             ` <20090826110332.6117@nanako3.lavabit.com>
2009-08-26  2:20                               ` Junio C Hamano
2009-08-26  3:03                             ` Junio C Hamano
2009-08-26  5:02                               ` Nicolas Sebrecht
2009-08-26  8:57                                 ` Jakub Narebski
2009-08-26  9:00                                   ` Johannes Schindelin
2009-08-27  5:46                                     ` Junio C Hamano
2009-08-27 10:49                                       ` Johannes Schindelin
2009-08-26  9:03                                   ` Junio C Hamano
2009-08-26  3:54                             ` Nicolas Sebrecht
2009-08-24  8:09                     ` [PATCH] " Nanako Shiraishi
2009-08-23 17:01       ` [PATCH-v2/RFC 3/6] xutils: fix ignore-all-space on incomplete line Thell Fowler
2009-08-23 19:40         ` Junio C Hamano
2009-08-23 20:33           ` Thell Fowler [this message]
2009-08-23 21:11             ` Junio C Hamano
2009-08-24  3:26               ` Thell Fowler
2009-08-24  6:02                 ` Junio C Hamano
2009-08-24 14:13                   ` Thell Fowler
2009-08-25  5:58                     ` Thell Fowler
2009-08-23  3:49   ` [PATCH-v2/RFC 4/6] xutils: fix ignore-space-change " Thell Fowler
2009-08-23  3:49   ` [PATCH-v2/RFC 5/6] xutils: fix ignore-space-at-eol " Thell Fowler
2009-08-23  3:49   ` [PATCH-v2/RFC 6/6] t4015: add tests for trailing-space " Thell Fowler

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

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

  git send-email \
    --in-reply-to=alpine.DEB.2.00.0908231515020.29625@GWPortableVCS \
    --to=git@tbfowler.name \
    --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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox