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

Re: [PATCH 12/13] Build in merge

From
Miklos Vajna <vmiklos@frugalware.org>
Date
Jun 27, 2008, 01:06 UTC
Message-ID
<20080627010609.GJ29404@genesis.frugalware.org>
In-Reply-To
<486270D5.5050204@free.fr>
On Wed, Jun 25, 2008 at 06:22:45PM +0200, Olivier Marin <dkr+ml.git@free.fr> wrote:
Show 8 quoted lines
> > +	if (new_head && show_diffstat) {
> > +		diff_setup(&opts);
> > +		opts.output_format |=
> > +			DIFF_FORMAT_SUMMARY | DIFF_FORMAT_DIFFSTAT;
> > +		opts.detect_rename = DIFF_DETECT_RENAME;
> 
> You probably want to add DIFF_OPT_SET(&opts, COLOR_DIFF) to have a nice colored diff
> like the original script.
That would always turn colors on.
This should respect diff.color:
diff --git a/builtin-merge.c b/builtin-merge.c
index 66189d2..c2a32ee 100644
--- a/builtin-merge.c
+++ b/builtin-merge.c
@@ -331,6 +331,8 @@ static void finish(const unsigned char *new_head, const char *msg)
 		opts.output_format |=
 			DIFF_FORMAT_SUMMARY | DIFF_FORMAT_DIFFSTAT;
 		opts.detect_rename = DIFF_DETECT_RENAME;
+		if (diff_use_color_default > 0)
+			DIFF_OPT_SET(&opts, COLOR_DIFF);
 		diff_tree_sha1(head, new_head, "", &opts);
 		diffcore_std(&opts);
 		diff_flush(&opts);
@@ -693,6 +695,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
 	}
 
 	git_config(git_merge_config, NULL);
+	git_config(git_diff_ui_config, NULL);
 
 	argc = parse_options(argc, argv, builtin_merge_options,
 			builtin_merge_usage, 0);

> > +int cmd_merge(int argc, const char **argv, const char *prefix)
> > +{
> 
> [...]
> 
> > +	} else if (allow_fast_forward && !remoteheads->next &&
> > +		!hashcmp(common->item->object.sha1, head)) {
> > +		/* Again the most common case of merging one remote. */
> > +		struct strbuf msg;
> > +		struct object *o;
> > +
> > +		printf("Updating %s..%s\n",
> > +			find_unique_abbrev(head, DEFAULT_ABBREV),
> > +			find_unique_abbrev(remoteheads->item->object.sha1,
> > +			DEFAULT_ABBREV));
> 
> Here, the second call to find_unique_abbrev() will overwrite the previous returned
> value because this function return a pointer to a static buffer.

This should fix it:

diff --git a/builtin-merge.c b/builtin-merge.c
index cc04d01..77de9e8 100644
--- a/builtin-merge.c
+++ b/builtin-merge.c
@@ -836,9 +836,12 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
 		/* Again the most common case of merging one remote. */
 		struct strbuf msg;
 		struct object *o;
+		char hex[41];
+
+		memcpy(hex, find_unique_abbrev(head, DEFAULT_ABBREV), 41);
 
 		printf("Updating %s..%s\n",
-			find_unique_abbrev(head, DEFAULT_ABBREV),
+			hex,
 			find_unique_abbrev(remoteheads->item->object.sha1,
 			DEFAULT_ABBREV));
 		refresh_cache(REFRESH_QUIET);

I pushed both to my working branch and I'll send proper patches to this
list among with other small changes soon.

Thanks!
Previous: Olivier MarinNext: Olivier Marin
Message 9 of 15 in “Build in merge”
  1. 00/13 Build in mergeMiklos Vajna, Jun 21, 2008
  2. 09/13 Add new test to ensure git-merge handles more than 25 refs.Miklos Vajna, Jun 21, 2008
  3. 10/13 Introduce get_merge_bases_many()Miklos Vajna, Jun 21, 2008
  4. 11/13 Introduce reduce_heads()Miklos Vajna, Jun 21, 2008
  5. 12/13 Build in mergeMiklos Vajna, Jun 21, 2008
  6. 13/13 Add new test case to ensure git-merge filters for independent parentsMiklos Vajna, Jun 21, 2008
  7. 13/13 Add new test case to ensure git-merge reduces octopus parents when possibleMiklos Vajna, Jun 21, 2008
  8. Olivier MarinJun 25, 2008
  9. Miklos VajnaJun 27, 2008
  10. Olivier MarinJun 27, 2008
  11. Miklos VajnaJun 27, 2008
  12. Olivier MarinJun 27, 2008
  13. Miklos VajnaJun 27, 2008
  14. Johannes SchindelinJun 27, 2008
  15. Miklos VajnaJun 27, 2008

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.