git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <junkio@cox.net>
To: Santi Bejar <sbejar@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: What's in git.git
Date: Thu, 26 Jan 2006 04:12:53 -0800	[thread overview]
Message-ID: <7vhd7rfare.fsf@assigned-by-dhcp.cox.net> (raw)
In-Reply-To: 8aa486160601260156h6157ca34s@mail.gmail.com

Santi Bejar <sbejar@gmail.com> writes:

> 2006/1/26, Junio C Hamano <junkio@cox.net>:
>> No comment on your message yet, but please fix your MUA so that
>> your messages do not get rejected by the mailing list software.
>>
>> I suspect it is base64 CTE that causes it.
>>
>>         Content-Type: text/plain; charset=UTF-8
>>         Content-Transfer-Encoding: base64
>
> Sorry, about that. But I didn't get any notification.

You do not need to feel sorry.  It's just your voice is not
heard as widely as it should have been, and you did not know
about it.

The spam filter just drops things on the floor without bothering
to notify potential spammers.

I think this patch would address your two issues (applies on top
of "pu"), but I have not had time to test it seriously enough.

-- >8 --
[PATCH] combine-diff: better hunk splitting.

It considered an otherwise unchanged line that had line removals
in front of it an interesting line, which caused hunks to have
one extra the trailing context line.

Signed-off-by: Junio C Hamano <junkio@cox.net>

---

 combine-diff.c |  142 ++++++++++++++++++++++++++++++++++++++++++++++----------
 1 files changed, 116 insertions(+), 26 deletions(-)

0aa20bc0c276c3fcb7215ba9f591960178792261
diff --git a/combine-diff.c b/combine-diff.c
index 3b219a0..d94a93d 100644
--- a/combine-diff.c
+++ b/combine-diff.c
@@ -323,52 +323,142 @@ static unsigned long line_all_diff(struc
 	return different;
 }
 
-static int make_hunks(struct sline *sline, unsigned long cnt,
-		       int num_parent, int dense)
+static unsigned long adjust_hunk_tail(struct sline *sline,
+				      unsigned long all_mask,
+				      unsigned long hunk_begin,
+				      unsigned long i)
+{
+	/* i points at the first uninteresting line.
+	 * If the last line of the hunk was interesting
+	 * only because it has some deletion, then
+	 * it is not all that interesting for the
+	 * purpose of giving trailing context lines.
+	 */
+	if ((hunk_begin + 1 <= i) &&
+	    ((sline[i-1].flag & all_mask) == all_mask))
+		i--;
+	return i;
+}
+
+static unsigned long next_interesting(struct sline *sline,
+				      unsigned long mark,
+				      unsigned long i,
+				      unsigned long cnt,
+				      int uninteresting)
+{
+	while (i < cnt)
+		if (uninteresting ?
+		    !(sline[i].flag & mark) :
+		    (sline[i].flag & mark))
+			return i;
+		else
+			i++;
+	return cnt;
+}
+
+static int give_context(struct sline *sline, unsigned long cnt, int num_parent)
 {
 	unsigned long all_mask = (1UL<<num_parent) - 1;
 	unsigned long mark = (1UL<<num_parent);
 	unsigned long i;
 	int has_interesting = 0;
 
-	i = 0;
+	i = next_interesting(sline, mark, 0, cnt, 0);
+	if (cnt <= i)
+		return 0;
+
 	while (i < cnt) {
-		if (interesting(&sline[i], all_mask)) {
-			unsigned long j = (context < i) ? i - context : 0;
-			while (j <= i)
+		unsigned long j = (context < i) ? (i - context) : 0;
+		unsigned long k;
+		while (j < i)
+			sline[j++].flag |= mark;
+
+	again:
+		j = next_interesting(sline, mark, i, cnt, 1);
+		if (cnt <= j)
+			break; /* the rest are all interesting */
+
+		/* lookahead context lines */
+		k = next_interesting(sline, mark, j, cnt, 0);
+		j = adjust_hunk_tail(sline, all_mask, i, j);
+
+		if (k < j + context) {
+			/* k is interesting and [j,k) are not, but
+			 * paint them interesting because the gap is small.
+			 */
+			while (j < k)
 				sline[j++].flag |= mark;
-			while (++i < cnt) {
-				if (!interesting(&sline[i], all_mask))
-					break;
-				sline[i].flag |= mark;
-			}
-			j = (i + context < cnt) ? i + context : cnt;
-			while (i < j)
-				sline[i++].flag |= mark;
-			has_interesting = 1;
-			continue;
+			i = k;
+			goto again;
 		}
-		i++;
+
+		/* j is the first uninteresting line and there is
+		 * no overlap beyond it within context lines.
+		 */
+		i = k;
+		k = (j + context < cnt) ? j + context : cnt;
+		while (j < k)
+			sline[j++].flag |= mark;
+	}
+	return 1;
+}
+
+static int make_hunks(struct sline *sline, unsigned long cnt,
+		       int num_parent, int dense)
+{
+	unsigned long all_mask = (1UL<<num_parent) - 1;
+	unsigned long mark = (1UL<<num_parent);
+	unsigned long i;
+	int has_interesting = 0;
+
+	for (i = 0; i < cnt; i++) {
+		if (interesting(&sline[i], all_mask))
+			sline[i].flag |= mark;
+		else
+			sline[i].flag &= ~mark;
 	}
 	if (!dense)
-		return has_interesting;
+		return give_context(sline, cnt, num_parent);
 
 	/* Look at each hunk, and if we have changes from only one
 	 * parent, or the changes are the same from all but one
 	 * parent, mark that uninteresting.
 	 */
-	has_interesting = 0;
 	i = 0;
 	while (i < cnt) {
-		int j, hunk_end, same, diff;
+		unsigned long j, hunk_begin, hunk_end;
+		int same, diff;
 		unsigned long same_diff, all_diff;
 		while (i < cnt && !(sline[i].flag & mark))
 			i++;
 		if (cnt <= i)
 			break; /* No more interesting hunks */
-		for (hunk_end = i + 1; hunk_end < cnt; hunk_end++)
-			if (!(sline[hunk_end].flag & mark))
-				break;
+		hunk_begin = i;
+		for (j = i + 1; j < cnt; j++) {
+			if (!(sline[j].flag & mark)) {
+				/* Look beyond the end to see if there
+				 * is an interesting line after this
+				 * hunk within context span.
+				 */
+				unsigned long la; /* lookahead */
+				int contin = 0;
+				la = adjust_hunk_tail(sline, all_mask,
+						     hunk_begin, j);
+				la = (la + context < cnt) ?
+					(la + context) : cnt;
+				while (j <= --la) {
+					if (sline[la].flag & mark) {
+						contin = 1;
+						break;
+					}
+				}
+				if (!contin)
+					break;
+				j = la;
+			}
+		}
+		hunk_end = j;
+
 		/* [i..hunk_end) are interesting.  Now does it have
 		 * the same change with all but one parent?
 		 */
@@ -387,13 +477,13 @@ static int make_hunks(struct sline *slin
 		}
 		if ((num_parent - 1 <= same) || (diff == 1)) {
 			/* This hunk is not that interesting after all */
-			for (j = i; j < hunk_end; j++)
+			for (j = hunk_begin; j < hunk_end; j++)
 				sline[j].flag &= ~mark;
 		}
-		else
-			has_interesting = 1;
 		i = hunk_end;
 	}
+
+	has_interesting = give_context(sline, cnt, num_parent);
 	return has_interesting;
 }
 
-- 
1.1.4.g2cff

  parent reply	other threads:[~2006-01-26 12:13 UTC|newest]

Thread overview: 240+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-01-25 13:00 What's in git.git Junio C Hamano
     [not found] ` <8aa486160601250741k120f0021h@mail.gmail.com>
2006-01-25 19:24   ` Junio C Hamano
2006-01-25 20:36 ` Jason Riedy
     [not found] ` <8aa486160601250634v294857e0j@mail.gmail.com>
2006-01-25 23:56   ` Junio C Hamano
     [not found]     ` <8aa486160601260104v745594d9m@mail.gmail.com>
     [not found]       ` <7vk6cngwfh.fsf@assigned-by-dhcp.cox.net>
     [not found]         ` <8aa486160601260156h6157ca34s@mail.gmail.com>
2006-01-26 12:12           ` Junio C Hamano [this message]
2006-01-26 16:24             ` Santi Bejar
  -- strict thread matches above, loose matches on Subject: below --
2008-01-30  8:32 What's in git.git (stable frozen) Junio C Hamano
2008-02-12  7:25 ` What's in git.git Junio C Hamano
2008-02-12  9:15   ` Daniel Stenberg
2008-02-12  9:47     ` Mike Hommey
2008-02-12 11:35       ` Daniel Stenberg
2007-05-13 22:30 What's in git.git (stable) Junio C Hamano
2007-05-17  0:21 ` Junio C Hamano
2007-05-19  5:24   ` Junio C Hamano
2007-05-23 21:46     ` Junio C Hamano
2007-05-29 10:12       ` Junio C Hamano
2007-06-02 21:09         ` Junio C Hamano
2007-06-07  2:08           ` Junio C Hamano
2007-06-13 20:11             ` Junio C Hamano
2007-06-21  7:21               ` Junio C Hamano
2007-06-25  9:43                 ` Junio C Hamano
2007-07-02  0:16                   ` Junio C Hamano
2007-07-13  6:06                     ` What's in git.git Junio C Hamano
2006-11-25 10:12 Junio C Hamano
2006-11-28 19:23 ` Carl Worth
2006-11-29 10:21   ` Johannes Schindelin
2006-11-23  2:49 Junio C Hamano
2006-11-18 22:24 Junio C Hamano
2006-11-18 23:14 ` Junio C Hamano
2006-11-19 15:17   ` Johannes Schindelin
2006-11-19 15:45     ` Jakub Narebski
2006-11-19 16:30       ` Johannes Schindelin
2006-11-19 18:31         ` Jakub Narebski
2006-11-19 19:06           ` Johannes Schindelin
2006-11-19 17:01     ` Petr Baudis
2006-11-12  6:07 Junio C Hamano
2006-11-08  3:21 Junio C Hamano
2006-11-08  4:13 ` David Lang
2006-11-09  2:28   ` Horst H. von Brand
2006-11-09  2:54     ` Junio C Hamano
2006-11-09  3:04       ` Junio C Hamano
2006-11-09  3:45       ` Dave Dillow
2006-11-12 22:25   ` Johannes Schindelin
2006-11-08  7:40 ` Jakub Narebski
2006-11-08  7:59   ` Junio C Hamano
2006-11-08  7:58 ` Jakub Narebski
2006-11-08  8:26   ` Junio C Hamano
2006-11-08 14:51 ` Petr Baudis
2006-11-09  0:02 ` Junio C Hamano
2006-11-02  0:53 Junio C Hamano
2006-11-02 10:02 ` Johannes Schindelin
2006-11-05 17:24 ` Rene Scharfe
2006-11-05 18:47   ` Junio C Hamano
2006-10-26  8:47 Junio C Hamano
2006-10-26  9:12 ` Jakub Narebski
2006-10-26  9:24   ` Junio C Hamano
2006-10-26 12:08   ` Petr Baudis
2006-10-26 12:17     ` Jakub Narebski
2006-10-26  9:19 ` Jakub Narebski
2006-10-27  1:10   ` Petr Baudis
2006-10-26 12:22 ` Petr Baudis
2006-10-26 17:27 ` Andy Whitcroft
2006-10-24  6:32 Junio C Hamano
2006-10-19  5:58 Junio C Hamano
2006-10-17  7:44 Junio C Hamano
2006-10-17 17:16 ` Linus Torvalds
2006-10-17 18:15   ` Davide Libenzi
2006-10-17 18:19   ` Junio C Hamano
2006-10-17 18:53     ` Linus Torvalds
2006-10-17 18:57     ` Andy Whitcroft
2006-10-06  0:59 Junio C Hamano
2006-09-28  7:39 Junio C Hamano
2006-09-28  9:36 ` Petr Baudis
2006-09-28 13:27   ` Johannes Schindelin
2006-09-29  7:34   ` Junio C Hamano
2006-09-29  8:32     ` Petr Baudis
2006-09-30  7:31       ` Junio C Hamano
2006-09-29  8:09   ` Junio C Hamano
2006-09-11  2:21 Junio C Hamano
2006-09-11 11:29 ` Jakub Narebski
2006-09-11 16:31   ` Junio C Hamano
2006-09-11 21:06     ` Jakub Narebski
2006-09-11 22:14       ` Petr Baudis
2006-09-11 23:48         ` Junio C Hamano
2006-09-18  5:33 ` Junio C Hamano
2006-09-18  5:39   ` Jakub Narebski
2006-09-18  5:50     ` Junio C Hamano
2006-09-18  6:07       ` Jakub Narebski
2006-09-18  8:11         ` Johannes Schindelin
2006-09-18  8:19           ` Junio C Hamano
2006-09-18  5:48   ` Jakub Narebski
2006-09-18 14:23   ` Franck Bui-Huu
2006-09-24 10:37   ` Junio C Hamano
2006-08-28  7:19 Junio C Hamano
2006-08-17  6:45 Junio C Hamano
2006-08-14  2:30 Junio C Hamano
2006-08-14  8:11 ` Alex Riesen
2006-08-04 10:12 Junio C Hamano
2006-08-04 10:27 ` Jakub Narebski
2006-08-04 18:40 ` Johannes Schindelin
2006-08-04 18:55 ` Jakub Narebski
2006-08-04 19:09   ` Junio C Hamano
2006-08-04 19:50     ` Junio C Hamano
2006-08-04 20:06       ` Junio C Hamano
2006-08-04 20:27       ` Jakub Narebski
2006-08-01 23:54 Junio C Hamano
2006-08-02  0:34 ` Johannes Schindelin
2006-08-02  7:41   ` Junio C Hamano
2006-08-02 14:02 ` Alex Riesen
2006-08-03  4:56   ` Junio C Hamano
2006-08-03  8:09     ` Alex Riesen
2006-08-03  9:16       ` Junio C Hamano
2006-08-03 12:32         ` Alex Riesen
2006-08-03 12:35           ` Alex Riesen
2006-08-02 19:29 ` carbonated beverage
2006-08-03  4:52   ` Junio C Hamano
2006-08-03  5:15     ` A Large Angry SCM
2006-08-03  5:30     ` carbonated beverage
2006-08-03  5:48       ` carbonated beverage
2006-08-03  7:36         ` carbonated beverage
2006-08-03  7:37           ` carbonated beverage
2006-08-03  8:39           ` Junio C Hamano
2006-08-03  8:50             ` carbonated beverage
2006-08-03  9:31               ` carbonated beverage
2006-08-03  9:03             ` Jakub Narebski
2006-07-17  8:29 Junio C Hamano
2006-07-08  0:37 Junio C Hamano
2006-07-08  2:28 ` Johannes Schindelin
2006-07-08 21:28 ` Jakub Narebski
2006-07-02  7:45 Junio C Hamano
2006-06-29  6:41 Junio C Hamano
2006-06-25  9:37 Junio C Hamano
2006-06-25 17:47 ` Linus Torvalds
2006-06-25 18:07   ` Timo Hirvonen
2006-06-25 18:43     ` Linus Torvalds
2006-06-27  5:54   ` Junio C Hamano
2006-06-27  6:29     ` Linus Torvalds
2006-06-27  7:55       ` Johannes Schindelin
2006-06-26 22:24 ` Martin Langhoff
2006-06-18  0:48 Junio C Hamano
2006-06-18 12:26 ` Johannes Schindelin
2006-06-18 13:08   ` Petr Baudis
2006-06-18 18:43     ` Johannes Schindelin
2006-06-19  7:34     ` Junio C Hamano
2006-06-19  8:35       ` Johannes Schindelin
2006-05-29  6:44 Junio C Hamano
2006-05-24 22:40 Junio C Hamano
2006-05-21 19:01 Junio C Hamano
2006-05-16  5:30 Junio C Hamano
2006-05-10  3:11 Junio C Hamano
2006-05-10  3:48 ` Linus Torvalds
2006-05-10  4:21 ` Linus Torvalds
2006-05-10  4:26   ` Linus Torvalds
2006-05-10  4:41   ` Junio C Hamano
2006-05-10  4:51     ` Linus Torvalds
2006-05-10  4:36 ` Randal L. Schwartz
2006-05-10  4:45   ` Linus Torvalds
2006-05-10 14:15     ` Nicolas Pitre
2006-05-10 15:00       ` Alex Riesen
2006-05-10 16:48       ` Linus Torvalds
2006-05-10  5:05   ` Junio C Hamano
2006-05-10  5:34 ` Martin Langhoff
2006-05-10  6:48 ` Jakub Narebski
2006-05-04  8:14 Junio C Hamano
2006-05-04  9:06 ` Petr Baudis
2006-05-03 18:54 Junio C Hamano
2006-04-26 11:09 Junio C Hamano
2006-04-22  0:52 Junio C Hamano
2006-04-22 11:25 ` Johannes Schindelin
2006-04-14  7:49 Junio C Hamano
2006-04-18  8:44 ` Junio C Hamano
2006-04-11  4:40 Junio C Hamano
2006-04-11 13:50 ` Linus Torvalds
2006-04-11 15:55   ` Petr Baudis
2006-04-11 17:58     ` Junio C Hamano
2006-04-04 23:06 Junio C Hamano
2006-03-28  0:28 Junio C Hamano
2006-03-26  6:00 Junio C Hamano
2006-03-22  1:58 Junio C Hamano
2006-03-22  2:18 ` Randal L. Schwartz
2006-03-22  3:26   ` Randal L. Schwartz
2006-03-22  5:07     ` Junio C Hamano
2006-03-22  5:35       ` Randal L. Schwartz
2006-03-22  5:46         ` Junio C Hamano
2006-03-22 16:21           ` Linus Torvalds
2006-03-22 10:21 ` Bertrand Jacquin
2006-03-22 11:52 ` Petr Baudis
2006-03-22 19:15   ` Junio C Hamano
2006-03-15 22:13 Junio C Hamano
2006-03-07 22:23 Francis Daly
2006-03-06  7:13 Junio C Hamano
2006-03-06  9:05 ` Martin Langhoff
2006-03-10 10:44   ` Fredrik Kuivinen
2006-03-10 11:17     ` Johannes Schindelin
2006-03-10 11:59       ` Martin Langhoff
2006-03-13  5:01     ` Junio C Hamano
2006-03-06  9:15 ` Johannes Schindelin
2006-03-06 10:29 ` Lukas Sandström
2006-03-05  4:22 Junio C Hamano
2006-03-05  4:51 ` Junio C Hamano
2006-03-05  4:58 ` Linus Torvalds
2006-03-05  5:44   ` Junio C Hamano
2006-03-05 17:53     ` Linus Torvalds
2006-03-05 18:29       ` Linus Torvalds
2006-03-05 19:36         ` Junio C Hamano
2006-03-05 20:04           ` Linus Torvalds
2006-03-05 19:53         ` Junio C Hamano
2006-03-05  9:21 ` Martin Langhoff
2006-03-05  9:58   ` Alexandre Julliard
2006-03-05 10:15     ` Martin Langhoff
2006-03-05 10:47       ` Alexandre Julliard
2006-03-05 10:10   ` Junio C Hamano
2006-03-01 12:24 Junio C Hamano
2006-03-01 21:28 ` Nicolas Pitre
2006-03-01 22:51   ` Junio C Hamano
2006-03-01 23:01 ` Luck, Tony
2006-02-23  2:05 Junio C Hamano
2006-02-22 10:45 Junio C Hamano
2006-02-22 13:46 ` Alex Riesen
2006-02-20  7:57 Junio C Hamano
2006-02-20  8:34 ` Andreas Ericsson
2006-02-20  9:04   ` Junio C Hamano
2006-02-20  9:47   ` Junio C Hamano
2006-02-19  8:56 Junio C Hamano
2006-02-17 14:28 linux
2006-02-18  6:49 ` Junio C Hamano
2006-02-16  6:57 Junio C Hamano
2006-02-10 17:03 Luck, Tony
2006-02-09 23:49 Luck, Tony
2006-02-10  0:28 ` Junio C Hamano
2006-02-10  0:35   ` Junio C Hamano
2006-02-14 23:10     ` Luck, Tony
2006-02-10  0:40 ` Ryan Anderson
2006-02-10  0:46   ` Junio C Hamano
2006-02-09  6:47 Junio C Hamano
     [not found] ` <20060209030905.319f2e48.seanlkml@sympatico.ca>
2006-02-09  8:09   ` sean
2006-02-09  9:04     ` Andreas Ericsson
     [not found]       ` <20060209044039.45763d4f.seanlkml@sympatico.ca>
2006-02-09  9:40         ` sean
2006-02-09  9:55       ` Junio C Hamano
2006-02-09 10:29         ` Andreas Ericsson
2006-02-09 10:55           ` Junio C Hamano
2006-02-09 11:35             ` Andreas Ericsson
2006-02-10  0:47               ` Junio C Hamano
2006-02-09  9:58 ` Johannes Schindelin
2006-02-09 10:32   ` Junio C Hamano
2006-02-09 11:24     ` Johannes Schindelin
2006-02-09 23:14 ` Tony Luck
2006-02-09 23:30   ` Ryan Anderson
2006-02-09 23:44   ` Junio C Hamano
2006-02-10 15:02   ` Junio C Hamano
2006-01-28 21:08 Junio C Hamano
2006-01-20  8:42 Junio C Hamano

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=7vhd7rfare.fsf@assigned-by-dhcp.cox.net \
    --to=junkio@cox.net \
    --cc=git@vger.kernel.org \
    --cc=sbejar@gmail.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).