git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 0/2] Custom low-level merge driver support.

From
Junio C Hamano <junkio@cox.net>
Date
Apr 18, 2007, 19:23 UTC
Message-ID
<7vslaxfpvk.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<7vzm55fqyv.fsf@assigned-by-dhcp.cox.net>
Junio C Hamano <junkio@cox.net> writes:
Show 12 quoted lines
> Linus Torvalds <torvalds@linux-foundation.org> writes:
>
>> For example, for a three-way merge, it makes sense to do the three-way 
>> merge for the "internal" merge too. But it might be that that isn't true 
>> for all strategies.
>
> Yes, that is what I alluded to in one of my previous message,
> but I think the "foo-recursive" idea is a good one.  I was
> planning to give only "3-way" or "pick ancestor" choice to
> external low-level merge drivers.
>
> But I think that is a separate issue.

The syntax is a bit different from the one you came up in your MUA.

	# a recursive merge will always just pick the ORIGINAL
	# version of a file when blending - the blending will
	# be done only on the final merge
	[merge "blend"]
		name = blend (changelog) strategy
		driver = blend %A %O %B
		recursive = binary

The variable merge.<<drivername>>.recursive names a different low level merge driver to be used while performing the virtual ancestor merge. In this example, the built-in "binary" merge which picks 'ours' for the final round and 'origin' for the internal merge already does what we want.

-- >8 -- [PATCH] Allow low-level driver to specify different behaviour during internal merge.

This allows [merge "drivername"] to have a variable "recursive" that names a different low-level merge driver to be used when merging common ancestors to come up with a virtual ancestor.

Signed-off-by: Junio C Hamano <junkio@cox.net>
---
 merge-recursive.c |   12 ++++++++++++
 1 files changed, 12 insertions(+), 0 deletions(-)
diff --git a/merge-recursive.c b/merge-recursive.c
index 4af69d7..43d6117 100644
--- a/merge-recursive.c
+++ b/merge-recursive.c
@@ -677,6 +677,7 @@ struct ll_merge_driver {
 	const char *name;
 	const char *description;
 	ll_merge_fn fn;
+	const char *recursive;
 	struct ll_merge_driver *next;
 	char *cmdline;
 };
@@ -934,6 +935,13 @@ static int read_merge_config(const char *var, const char *value)
 		return 0;
 	}
 
+	if (!strcmp("recursive", ep)) {
+		if (!value)
+			return error("%s: lacks value", var);
+		fn->recursive = strdup(value);
+		return 0;
+	}
+
 	return 0;
 }
 
@@ -1013,6 +1021,10 @@ static int ll_merge(mmbuffer_t *result_buf,
 	merge_attr = git_path_check_merge(a->path);
 	driver = find_ll_merge_driver(merge_attr);
 
+	if (index_only && driver->recursive) {
+		merge_attr = git_attr(driver->recursive, strlen(driver->recursive));
+		driver = find_ll_merge_driver(merge_attr);
+	}
 	merge_status = driver->fn(driver, a->path,
 				  &orig, &src1, name1, &src2, name2,
 				  result_buf);
-- 
1.5.1.1.905.g4cad0
Previous: Junio C HamanoNext: Linus Torvalds
Message 14 of 23 in “Custom low-level merge driver support.”
  1. 0/2 Custom low-level merge driver support.Junio C Hamano, Apr 18, 2007
  2. 1/2 Custom low-level merge driver support.Junio C Hamano, Apr 18, 2007
  3. Johannes SixtApr 18, 2007
  4. Johannes SchindelinApr 18, 2007
  5. 2/2 Allow the default low-level merge driver to be configured.Junio C Hamano, Apr 18, 2007
  6. Johannes SchindelinApr 18, 2007
  7. Martin WaitzApr 18, 2007
  8. Junio C HamanoApr 18, 2007
  9. Martin WaitzApr 18, 2007
  10. Linus TorvaldsApr 18, 2007
  11. Junio C HamanoApr 18, 2007
  12. Linus TorvaldsApr 18, 2007
  13. Junio C HamanoApr 18, 2007
  14. Junio C HamanoApr 18, 2007
  15. Linus TorvaldsApr 18, 2007
  16. Linus TorvaldsApr 18, 2007
  17. Junio C HamanoApr 18, 2007
  18. Linus TorvaldsApr 18, 2007
  19. David LangApr 18, 2007
  20. Junio C HamanoApr 18, 2007
  21. Martin WaitzApr 19, 2007
  22. Junio C HamanoApr 19, 2007
  23. Custom low-level merge driver: change the configuration scheme.Junio C Hamano, Apr 18, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.