Re: [PATCH] xdl_merge(): fix and simplify conflict handling

4 messages, 3 authors, 2016-08-11 · open the first message on its own page

Re: [PATCH] xdl_merge(): fix and simplify conflict handling

From: Junio C Hamano <hidden>
Date: 2016-08-11 19:37:44

Thanks.

Looking at some other cases after applying your patch, I noticed
that I really like one thing that your version does over what
RCS merge does.

With RCS merge, a run of lines that are modified the same way in
both branches appear twice, like this:

	<<< orig
        alpha
        bravo
        charlie
        ...
	x-ray
	yankee
        zulu
        ===
        alpha
        bravo
        charlie
        ...
        x-ray
        yankee
        zebra
        >>> new

The common part at the beginning (or at the end for that
matter) can be hoisted outside, to produce:

        alpha
        bravo
        charlie
        ...
	x-ray
	yankee
	<<< orig
        zulu
        ===
        zebra
        >>> new

and your version seems to get this right.

When I had to deal with this kind of conflicts, I ended up
splitting the buffer in two, and ran M-x compare-windows to find
the true differences between the choices.  It was frustrating.
(I admit a big reason is I do not normally work in X environment
and do not tend to use xdiff -U or Kompare).

This is especially noticeable when recreating diff-delta.c merge
conflict in commit b485db98.  It's fun to see this large hunk
reduced down to only two lines ;-).

<<<<<<< HEAD/diff-delta.c
	/*
	 * Determine a limit on the number of entries in the same hash
	 * bucket.  This guard us against patological data sets causing
	 * really bad hash distribution with most entries in the same hash
	 * bucket that would bring us to O(m*n) computing costs (m and n
	 * corresponding to reference and target buffer sizes).
	 *
	 * The more the target buffer is large, the more it is important to
	 * have small entry lists for each hash buckets.  With such a limit
	 * the cost is bounded to something more like O(m+n).
	 */
	hlimit = (1 << 26) / trg_bufsize;
	if (hlimit < 16)
		hlimit = 16;

	/*
	 * Now make sure none of the hash buckets has more entries than
	 * we're willing to test.  Otherwise we short-circuit the entry
	 * list uniformly to still preserve a good repartition across
	 * the reference buffer.
	 */
	for (i = 0; i < hsize; i++) {
		if (hash_count[i] < hlimit)
			continue;
		entry = hash[i];
		do {
			struct index *keep = entry;
			int skip = hash_count[i] / hlimit / 2;
			do {
				entry = entry->next;
			} while(--skip && entry);
			keep->next = entry;
		} while(entry);
	}
	free(hash_count);

	return hash;
=======
	/*
	 * Determine a limit on the number of entries in the same hash
	 * bucket.  This guard us against patological data sets causing
	 * really bad hash distribution with most entries in the same hash
	 * bucket that would bring us to O(m*n) computing costs (m and n
	 * corresponding to reference and target buffer sizes).
	 *
	 * The more the target buffer is large, the more it is important to
	 * have small entry lists for each hash buckets.  With such a limit
	 * the cost is bounded to something more like O(m+n).
	 */
	hlimit = (1 << 26) / trg_bufsize;
	if (hlimit < 16)
		hlimit = 16;

	/*
	 * Now make sure none of the hash buckets has more entries than
	 * we're willing to test.  Otherwise we short-circuit the entry
	 * list uniformly to still preserve a good repartition across
	 * the reference buffer.
	 */
	for (i = 0; i < hsize; i++) {
		if (hash_count[i] < hlimit)
			continue;
		entry = hash[i];
		do {
			struct index *keep = entry;
			int skip = hash_count[i] / hlimit / 2;
			do {
				entry = entry->next;
			} while(--skip && entry);
			keep->next = entry;
		} while(entry);
	}
	free(hash_count);

	return hash-1;
quoted
quoted
quoted
quoted
quoted
quoted
38fd0721d0a2a1a723bc28fc0817e3571987b1ef/diff-delta.c

Re: [PATCH] xdl_merge(): fix and simplify conflict handling

From: Jakub Narebski <hidden>
Date: 2016-08-11 19:19:28

Junio C Hamano wrote:
Looking at some other cases after applying your patch, I noticed
that I really like one thing that your version does over what
RCS merge does.
Is it with "try harder" option?
-- 
Jakub Narebski
Warsaw, Poland
ShadeHawk on #git

Re: [PATCH] xdl_merge(): fix and simplify conflict handling

From: Johannes Schindelin <hidden>
Date: 2016-08-11 19:40:05

Hi,

On Tue, 5 Dec 2006, Jakub Narebski wrote:
Junio C Hamano wrote:
quoted
Looking at some other cases after applying your patch, I noticed
that I really like one thing that your version does over what
RCS merge does.
Is it with "try harder" option?
Yes, it uses the XDL_MERGE_ZEALOUS option.

Ciao,
Dscho

Re: [PATCH] xdl_merge(): fix and simplify conflict handling

From: Johannes Schindelin <hidden>
Date: 2016-08-11 19:54:40

Hi,

On Tue, 5 Dec 2006, Junio C Hamano wrote:
Looking at some other cases after applying your patch, I noticed that I 
really like one thing that your version does over what RCS merge does.
Gee, thanks!

Actually, this was what I intended to do first when somebody submitted a 
builtin merge: Be clever about what is a conflict and what not.

Speaking about a builtin merge: I like the fact that git-apply also works 
outside of git repositories. It makes life easier to have a sane patcher 
around.

Now, I'd like the same with git-diff, and an RCS merge replacement... Of 
course, what with all those porcelainish commands we should not add new 
commands, but enhance existing ones. Any ideas which ones?

Ciao,
Dscho
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help