All of lore.kernel.org
 help / color / mirror / Atom feed
From: "René Scharfe" <l.s.r@web.de>
To: Junio C Hamano <gitster@pobox.com>
Cc: "Michael Haggerty" <mhagger@alum.mit.edu>,
	"David Turner" <dturner@twopensource.com>,
	"Ramsay Jones" <ramsay@ramsayjones.plus.com>,
	"Eric Sunshine" <sunshine@sunshineco.com>,
	"Jeff King" <peff@peff.net>,
	"Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>,
	git@vger.kernel.org
Subject: Re: [PATCH 05/38] refs: create a base class "ref_store" for files_ref_store
Date: Thu, 9 Jun 2016 23:54:48 +0200	[thread overview]
Message-ID: <5759E5A8.9060000@web.de> (raw)
In-Reply-To: <xmqqfusprmeq.fsf@gitster.mtv.corp.google.com>

Am 07.06.2016 um 18:31 schrieb Junio C Hamano:
> This is a tangent, but your series that ends at 4aa2c475 (grep: -W:
> don't extend context to trailing empty lines, 2016-05-28) does not
> seem to have much effect when viewing the change to refs.c this
> patch makes (it modifies a function in an early part, and then adds
> bunch of new functions at the end) with "git show -W".
> 
> Thanks.

Good catch, thanks!

-- >8 --
Subject: [PATCH] xdiff: fix merging of appended hunk with -W

When -W is given we search the lines between the end of the current
context and the next change for a function line.  If there is none then
we merge those two hunks as they must be part of the same function.

If the next change is an appended chunk we abort the search early in
get_func_line(), however, because its line number is out of range.  Fix
that by searching from the end of the pre-image in that case instead.

Reported-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Rene Scharfe <l.s.r@web.de>
---
 t/t4051-diff-function-context.sh | 24 +++++++++++++++++++++++-
 xdiff/xemit.c                    |  3 ++-
 2 files changed, 25 insertions(+), 2 deletions(-)

diff --git a/t/t4051-diff-function-context.sh b/t/t4051-diff-function-context.sh
index b6bb04a..b79b877 100755
--- a/t/t4051-diff-function-context.sh
+++ b/t/t4051-diff-function-context.sh
@@ -64,7 +64,13 @@ test_expect_success 'setup' '
 
 	grep -v "Begin of second part" <file.c >file.c.new &&
 	mv file.c.new file.c &&
-	commit_and_tag long_common_tail file.c
+	commit_and_tag long_common_tail file.c &&
+
+	git checkout initial &&
+	grep -v "delete me from hello" <file.c >file.c.new &&
+	mv file.c.new file.c &&
+	cat "$dir/appended1.c" >>file.c &&
+	commit_and_tag changed_hello_appended file.c
 '
 
 check_diff changed_hello 'changed function'
@@ -157,4 +163,20 @@ test_expect_success ' context does not include preceding empty lines' '
 	test "$(first_context_line <long_common_tail.diff.diff)" != " "
 '
 
+check_diff changed_hello_appended 'changed function plus appended function'
+
+test_expect_success ' context includes begin' '
+	grep "^ .*Begin of hello" changed_hello_appended.diff &&
+	grep "^[+].*Begin of first part" changed_hello_appended.diff
+'
+
+test_expect_success ' context includes end' '
+	grep "^ .*End of hello" changed_hello_appended.diff &&
+	grep "^[+].*End of first part" changed_hello_appended.diff
+'
+
+test_expect_success ' context does not include other functions' '
+	test $(grep -c "^[ +-].*Begin" changed_hello_appended.diff) -le 2
+'
+
 test_done
diff --git a/xdiff/xemit.c b/xdiff/xemit.c
index bfa53d3..49aa16f 100644
--- a/xdiff/xemit.c
+++ b/xdiff/xemit.c
@@ -246,7 +246,8 @@ int xdl_emit_diff(xdfenv_t *xe, xdchange_t *xscr, xdemitcb_t *ecb,
 			 * its new end.
 			 */
 			if (xche->next) {
-				long l = xche->next->i1;
+				long l = XDL_MIN(xche->next->i1,
+						 xe->xdf1.nrec - 1);
 				if (l <= e1 ||
 				    get_func_line(xe, xecfg, NULL, l, e1) < 0) {
 					xche = xche->next;
-- 
2.8.3

  reply	other threads:[~2016-06-09 21:56 UTC|newest]

Thread overview: 67+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-03 21:03 [PATCH 00/38] Virtualization of the refs API Michael Haggerty
2016-06-03 21:03 ` [PATCH 01/38] resolve_gitlink_ref(): eliminate temporary variable Michael Haggerty
2016-06-03 21:03 ` [PATCH 02/38] rename_ref_available(): add docstring Michael Haggerty
2016-06-07 18:10   ` Junio C Hamano
2016-06-09 13:09     ` Michael Haggerty
2016-06-09 15:08       ` Junio C Hamano
2016-06-03 21:03 ` [PATCH 03/38] refs: rename struct ref_cache to files_ref_store Michael Haggerty
2016-06-03 21:03 ` [PATCH 04/38] refs: add a backend method structure Michael Haggerty
2016-06-03 21:03 ` [PATCH 05/38] refs: create a base class "ref_store" for files_ref_store Michael Haggerty
2016-06-07 16:31   ` Junio C Hamano
2016-06-09 21:54     ` René Scharfe [this message]
2016-06-07 17:03   ` Junio C Hamano
2016-06-09 14:10     ` Michael Haggerty
2016-06-09 16:14       ` Junio C Hamano
2016-06-10  6:18         ` Michael Haggerty
2016-06-10 15:53           ` Junio C Hamano
2016-06-10  8:08   ` Eric Sunshine
2016-06-10 12:02     ` Michael Haggerty
2016-06-03 21:03 ` [PATCH 06/38] add_packed_ref(): add a files_ref_store argument Michael Haggerty
2016-06-03 21:03 ` [PATCH 07/38] get_packed_ref(): " Michael Haggerty
2016-06-03 21:03 ` [PATCH 08/38] resolve_missing_loose_ref(): " Michael Haggerty
2016-06-03 21:03 ` [PATCH 09/38] {lock,commit,rollback}_packed_refs(): add files_ref_store arguments Michael Haggerty
2016-06-03 21:03 ` [PATCH 10/38] refs: add a transaction_commit() method Michael Haggerty
2016-06-03 21:03 ` [PATCH 11/38] refs: reorder definitions Michael Haggerty
2016-06-03 21:03 ` [PATCH 12/38] resolve_packed_ref(): rename function from resolve_missing_loose_ref() Michael Haggerty
2016-06-03 21:03 ` [PATCH 13/38] resolve_gitlink_packed_ref(): remove function Michael Haggerty
2016-06-03 21:03 ` [PATCH 14/38] read_raw_ref(): take a (struct ref_store *) argument Michael Haggerty
2016-06-03 21:03 ` [PATCH 15/38] resolve_ref_recursively(): new function Michael Haggerty
2016-06-03 21:03 ` [PATCH 16/38] resolve_gitlink_ref(): implement using resolve_ref_recursively() Michael Haggerty
2016-06-07 17:19   ` Junio C Hamano
2016-06-14  5:03   ` Eric Sunshine
2016-06-16  4:03     ` Michael Haggerty
2016-06-03 21:03 ` [PATCH 17/38] resolve_gitlink_ref(): avoid memory allocation in many cases Michael Haggerty
2016-06-07 17:29   ` Junio C Hamano
2016-06-09 14:37     ` Michael Haggerty
2016-06-03 21:03 ` [PATCH 18/38] resolve_gitlink_ref(): rename path parameter to submodule Michael Haggerty
2016-06-03 21:03 ` [PATCH 19/38] refs: make read_raw_ref() virtual Michael Haggerty
2016-06-03 21:03 ` [PATCH 20/38] refs: make verify_refname_available() virtual Michael Haggerty
2016-06-03 21:03 ` [PATCH 21/38] refs: make pack_refs() virtual Michael Haggerty
2016-06-07 17:35   ` Junio C Hamano
2016-06-09 14:46     ` Michael Haggerty
2016-06-03 21:03 ` [PATCH 22/38] refs: make create_symref() virtual Michael Haggerty
2016-06-03 21:03 ` [PATCH 23/38] refs: make peel_ref() virtual Michael Haggerty
2016-06-07 17:36   ` Junio C Hamano
2016-06-09 15:05     ` Michael Haggerty
2016-06-03 21:03 ` [PATCH 24/38] repack_without_refs(): add a files_ref_store argument Michael Haggerty
2016-06-03 21:04 ` [PATCH 25/38] lock_raw_ref(): " Michael Haggerty
2016-06-03 21:04 ` [PATCH 26/38] commit_ref_update(): " Michael Haggerty
2016-06-03 21:04 ` [PATCH 27/38] lock_ref_for_update(): " Michael Haggerty
2016-06-03 21:04 ` [PATCH 28/38] lock_ref_sha1_basic(): " Michael Haggerty
2016-06-03 21:04 ` [PATCH 29/38] split_symref_update(): " Michael Haggerty
2016-06-03 21:04 ` [PATCH 30/38] files_ref_iterator_begin(): take a ref_store argument Michael Haggerty
2016-06-03 21:04 ` [PATCH 31/38] refs: add method iterator_begin Michael Haggerty
2016-06-03 21:04 ` [PATCH 32/38] refs: add methods for reflog Michael Haggerty
2016-06-03 21:04 ` [PATCH 33/38] refs: add method for initial ref transaction commit Michael Haggerty
2016-06-03 21:04 ` [PATCH 34/38] refs: add method for delete_refs Michael Haggerty
2016-06-07 17:43   ` Junio C Hamano
2016-06-09 15:14     ` Michael Haggerty
2016-06-03 21:04 ` [PATCH 35/38] refs: add methods to init refs db Michael Haggerty
2016-06-03 21:04 ` [PATCH 36/38] refs: add method to rename refs Michael Haggerty
2016-06-03 21:04 ` [PATCH 37/38] refs: make lock generic Michael Haggerty
2016-06-07 17:50   ` Junio C Hamano
2016-06-09 15:21     ` Michael Haggerty
2016-06-09 15:53     ` Michael Haggerty
2016-06-03 21:04 ` [PATCH 38/38] refs: implement iteration over only per-worktree refs Michael Haggerty
2016-07-10 15:09 ` [PATCH 00/38] Virtualization of the refs API Duy Nguyen
2016-07-13 15:26   ` Michael Haggerty

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=5759E5A8.9060000@web.de \
    --to=l.s.r@web.de \
    --cc=dturner@twopensource.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=mhagger@alum.mit.edu \
    --cc=pclouds@gmail.com \
    --cc=peff@peff.net \
    --cc=ramsay@ramsayjones.plus.com \
    --cc=sunshine@sunshineco.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.