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

[PATCH 5/6] rerere: let caller decide whether to renormalize

From
Jonathan Nieder <jrnieder@gmail.com>
Date
Aug 4, 2010, 03:23 UTC
Message-ID
<20100804032338.GF19699@burratino>
In-Reply-To
<20100804031935.GA19699@burratino>

Add a RERERE_RENORMALIZE flag to rerere so callers can decide case-by-case whether the merge is likely to have overlapped with a change in smudge/clean rules.

This is only a change in internal plumbing. Many callers do not have a way to use that setting; this patch does not change that.

NEEDSWORK: this is a step in the wrong direction.  rerere needs
an -s option to use an arbitrary merge strategy and a -X option to
pass arbitrary options to that driver.  And maybe the options used
in a merge should be recorded somewhere to help rerere repeat it.

This treats the renormalize option specially anyway, to support the existing "git merge" behavior of using -Xrenormalize in its rerere call when configured to do so. It reluctant exposes that option in the rerere command as --renormalize for the sake of experimentation, too, but it does not advertise it.

Cc: Eyvind Bernhardsen <eyvind.bernhardsen@gmail.com>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
---
 builtin/commit.c |    4 ++++
 builtin/merge.c  |    7 +++++--
 builtin/rerere.c |    8 ++++++--
 builtin/revert.c |   11 +++++++++--
 rerere.c         |    5 +++--
 rerere.h         |    1 +
 6 files changed, 28 insertions(+), 8 deletions(-)
diff --git a/builtin/commit.c b/builtin/commit.c
index 3d99cf9..56c998f 100644
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@ -1377,6 +1377,10 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
 		     "new_index file. Check that disk is not full or quota is\n"
 		     "not exceeded, and then \"git reset HEAD\" to recover.");
 
+	/*
+	 * NEEDSWORK: use RERERE_RENORMALIZE after a merge with
+	 * merge.renormalize set
+	 */
 	rerere(0);
 	run_hook(get_index_file(), "post-commit", NULL);
 	if (amend && !no_post_rewrite) {
diff --git a/builtin/merge.c b/builtin/merge.c
index b836e9c..823b76b 100644
--- a/builtin/merge.c
+++ b/builtin/merge.c
@@ -822,7 +822,7 @@ static int finish_automerge(struct commit_list *common,
 static int suggest_conflicts(void)
 {
 	FILE *fp;
-	int pos;
+	int pos, flag;
 
 	fp = fopen(git_path("MERGE_MSG"), "a");
 	if (!fp)
@@ -841,7 +841,10 @@ static int suggest_conflicts(void)
 		}
 	}
 	fclose(fp);
-	rerere(allow_rerere_auto);
+	flag = allow_rerere_auto;
+	if (merge_renormalize)
+		flag |= RERERE_RENORMALIZE;
+	rerere(flag);
 	printf("Automatic merge failed; "
 			"fix conflicts and then commit the result.\n");
 	return 1;
diff --git a/builtin/rerere.c b/builtin/rerere.c
index 295fe75..4009c01 100644
--- a/builtin/rerere.c
+++ b/builtin/rerere.c
@@ -111,15 +111,19 @@ int cmd_rerere(int argc, const char **argv, const char *prefix)
 	struct option options[] = {
 		OPT_SET_INT(0, "rerere-autoupdate", &autoupdate,
 			"register clean resolutions in index", 1),
+		{ OPTION_BIT, 0, "renormalize-before-merge", &flags, NULL,
+			"simplify conflict hunks for normalization changes",
+			PARSE_OPT_NOARG | PARSE_OPT_HIDDEN, NULL,
+			RERERE_RENORMALIZE },
 		OPT_END(),
 	};
 
 	argc = parse_options(argc, argv, prefix, options, rerere_usage, 0);
 
 	if (autoupdate == 1)
-		flags = RERERE_AUTOUPDATE;
+		flags |= RERERE_AUTOUPDATE;
 	if (autoupdate == 0)
-		flags = RERERE_NOAUTOUPDATE;
+		flags |= RERERE_NOAUTOUPDATE;
 
 	if (argc < 1)
 		return rerere(flags);
diff --git a/builtin/revert.c b/builtin/revert.c
index 853e9e4..c694801 100644
--- a/builtin/revert.c
+++ b/builtin/revert.c
@@ -338,7 +338,7 @@ static void do_recursive_merge(struct commit *base, struct commit *next,
 	rollback_lock_file(&index_lock);
 
 	if (!clean) {
-		int i;
+		int i, flags;
 		strbuf_addstr(msgbuf, "\nConflicts:\n\n");
 		for (i = 0; i < active_nr;) {
 			struct cache_entry *ce = active_cache[i++];
@@ -354,7 +354,10 @@ static void do_recursive_merge(struct commit *base, struct commit *next,
 		write_message(msgbuf, defmsg);
 		fprintf(stderr, "Automatic %s failed.%s\n",
 			me, help_msg());
-		rerere(allow_rerere_auto);
+		flags = allow_rerere_auto;
+		if (o.renormalize)
+			flags |= RERERE_RENORMALIZE;
+		rerere(flags);
 		exit(1);
 	}
 	write_message(msgbuf, defmsg);
@@ -481,6 +484,10 @@ static int do_pick_commit(void)
 		if (res) {
 			fprintf(stderr, "Automatic %s with strategy %s failed.%s\n",
 				me, strategy, help_msg());
+			/*
+			 * NEEDSWORK: use RERERE_RENORMALIZE after
+			 * a merge with merge.renormalize set
+			 */
 			rerere(allow_rerere_auto);
 			exit(1);
 		}
diff --git a/rerere.c b/rerere.c
index 17dcc3c..8767024 100644
--- a/rerere.c
+++ b/rerere.c
@@ -553,12 +553,13 @@ int setup_rerere(struct string_list *merge_rr, int flags)
 int rerere(int flags)
 {
 	struct string_list merge_rr = { NULL, 0, 0, 1 };
-	int fd;
+	int fd, renormalize;
 
 	fd = setup_rerere(&merge_rr, flags);
 	if (fd < 0)
 		return 0;
-	return do_plain_rerere(&merge_rr, fd, merge_renormalize);
+	renormalize = (flags & RERERE_RENORMALIZE) ? 1 : 0;
+	return do_plain_rerere(&merge_rr, fd, renormalize);
 }
 
 static int rerere_forget_one_path(const char *path, struct string_list *rr)
diff --git a/rerere.h b/rerere.h
index eaa9004..a73555f 100644
--- a/rerere.h
+++ b/rerere.h
@@ -5,6 +5,7 @@
 
 #define RERERE_AUTOUPDATE   01
 #define RERERE_NOAUTOUPDATE 02
+#define RERERE_RENORMALIZE  04
 
 extern int setup_rerere(struct string_list *, int);
 extern int rerere(int);
-- 
1.7.2.1.544.ga752d.dirty
Previous: Jonathan NiederNext: Junio C Hamano
Message 12 of 35 in “Merge renormalization, config renamed”
  1. 0/3 Merge renormalization, config renamedEyvind Bernhardsen, Jul 2, 2010
  2. 1/3 Avoid conflicts when merging branches with mixed normalizationEyvind Bernhardsen, Jul 2, 2010
  3. 2/3 Try normalizing files to avoid delete/modify conflicts when mergingEyvind Bernhardsen, Jul 2, 2010
  4. 3/3 Don't expand CRLFs when normalizing text during mergeEyvind Bernhardsen, Jul 2, 2010
  5. Junio C HamanoJul 2, 2010
  6. 0/6 merge -XrenormalizeJonathan Nieder, Aug 4, 2010
  7. 1/6 merge-trees: push choice to renormalize away from low levelJonathan Nieder, Aug 4, 2010
  8. 2/6 merge-trees: let caller decide whether to renormalizeJonathan Nieder, Aug 4, 2010
  9. 3/6 ll-merge: let caller decide whether to renormalizeJonathan Nieder, Aug 4, 2010
  10. Junio C HamanoAug 4, 2010
  11. 4/6 rerere: migrate to parse-options APIJonathan Nieder, Aug 4, 2010
  12. 5/6 rerere: let caller decide whether to renormalizeJonathan Nieder, Aug 4, 2010
  13. Junio C HamanoAug 4, 2010
  14. 0/12 Re: rerere: let caller decide whether to renormalizeJonathan Nieder, Aug 5, 2010
  15. 01/12 t6038 (merge.renormalize): style nitpicksJonathan Nieder, Aug 5, 2010
  16. Ævar Arnfjörð BjarmasonAug 5, 2010
  17. Jonathan NiederAug 5, 2010
  18. 02/12 t6038 (merge.renormalize): try checkout -m and cherry-pickJonathan Nieder, Aug 5, 2010
  19. 03/12 t6038 (merge.renormalize): check that it can be turned offJonathan Nieder, Aug 5, 2010
  20. 04/12 merge-trees: push choice to renormalize away from low levelJonathan Nieder, Aug 5, 2010
  21. 05/12 merge-trees: let caller decide whether to renormalizeJonathan Nieder, Aug 5, 2010
  22. 06/12 Documentation/technical: document ll_mergeJonathan Nieder, Aug 5, 2010
  23. 07/12 ll-merge: make flag easier to populateJonathan Nieder, Aug 5, 2010
  24. Bert WesargAug 5, 2010
  25. Jonathan NiederAug 5, 2010
  26. Bert WesargAug 5, 2010
  27. Jonathan NiederAug 5, 2010
  28. 08/12 ll-merge: let caller decide whether to renormalizeJonathan Nieder, Aug 5, 2010
  29. 09/12 t4200 (rerere): modernize styleJonathan Nieder, Aug 5, 2010
  30. 10/12 rerere: migrate to parse-options APIJonathan Nieder, Aug 5, 2010
  31. 11/12 rerere: never renormalizeJonathan Nieder, Aug 5, 2010
  32. 12/12 merge-recursive --renormalizeJonathan Nieder, Aug 5, 2010
  33. Eyvind BernhardsenAug 5, 2010
  34. 6/6 merge-recursive: add -Xrenormalize optionJonathan Nieder, Aug 4, 2010
  35. Junio C HamanoAug 4, 2010

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.