From: Jonathan Nieder <jrnieder@gmail.com>
To: Eyvind Bernhardsen <eyvind.bernhardsen@gmail.com>
Cc: Junio C Hamano <gitster@pobox.com>,
Jakub Narebski <jnareb@gmail.com>,
Finn Arne Gangstad <finnag@pvv.org>,
"git@vger.kernel.org List" <git@vger.kernel.org>
Subject: [PATCH 5/6] rerere: let caller decide whether to renormalize
Date: Tue, 3 Aug 2010 22:23:38 -0500 [thread overview]
Message-ID: <20100804032338.GF19699@burratino> (raw)
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
next prev parent reply other threads:[~2010-08-04 3:25 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-07-02 19:20 [PATCH v6 0/3] Merge renormalization, config renamed Eyvind Bernhardsen
2010-07-02 19:20 ` [PATCH v6 1/3] Avoid conflicts when merging branches with mixed normalization Eyvind Bernhardsen
2010-07-02 19:20 ` [PATCH v6 2/3] Try normalizing files to avoid delete/modify conflicts when merging Eyvind Bernhardsen
2010-07-02 19:20 ` [PATCH v6 3/3] Don't expand CRLFs when normalizing text during merge Eyvind Bernhardsen
2010-07-02 22:46 ` [PATCH v6 0/3] Merge renormalization, config renamed Junio C Hamano
2010-08-04 3:19 ` [PATCH/RFC eb/double-convert-before-merge 0/6] merge -Xrenormalize Jonathan Nieder
2010-08-04 3:20 ` [PATCH 1/6] merge-trees: push choice to renormalize away from low level Jonathan Nieder
2010-08-04 3:21 ` [PATCH 2/6] merge-trees: let caller decide whether to renormalize Jonathan Nieder
2010-08-04 3:21 ` [PATCH 3/6] ll-merge: " Jonathan Nieder
2010-08-04 18:12 ` Junio C Hamano
2010-08-04 3:22 ` [PATCH 4/6] rerere: migrate to parse-options API Jonathan Nieder
2010-08-04 3:23 ` Jonathan Nieder [this message]
2010-08-04 18:12 ` [PATCH 5/6] rerere: let caller decide whether to renormalize Junio C Hamano
2010-08-05 11:08 ` [PATCH/RFC v2 0/12] " Jonathan Nieder
2010-08-05 11:09 ` [PATCH 01/12] t6038 (merge.renormalize): style nitpicks Jonathan Nieder
2010-08-05 11:41 ` Ævar Arnfjörð Bjarmason
2010-08-05 11:54 ` Jonathan Nieder
2010-08-05 11:11 ` [PATCH 02/12] t6038 (merge.renormalize): try checkout -m and cherry-pick Jonathan Nieder
2010-08-05 11:13 ` [PATCH 03/12] t6038 (merge.renormalize): check that it can be turned off Jonathan Nieder
2010-08-05 11:13 ` [PATCH 04/12] merge-trees: push choice to renormalize away from low level Jonathan Nieder
2010-08-05 11:15 ` [PATCH 05/12] merge-trees: let caller decide whether to renormalize Jonathan Nieder
2010-08-05 11:16 ` [PATCH 06/12] Documentation/technical: document ll_merge Jonathan Nieder
2010-08-05 11:17 ` [PATCH 07/12] ll-merge: make flag easier to populate Jonathan Nieder
2010-08-05 12:12 ` Bert Wesarg
2010-08-05 12:16 ` Jonathan Nieder
2010-08-05 13:05 ` Bert Wesarg
2010-08-05 13:11 ` Jonathan Nieder
2010-08-05 11:24 ` [PATCH 08/12] ll-merge: let caller decide whether to renormalize Jonathan Nieder
2010-08-05 11:25 ` [PATCH 09/12] t4200 (rerere): modernize style Jonathan Nieder
2010-08-05 11:28 ` [PATCH 10/12] rerere: migrate to parse-options API Jonathan Nieder
2010-08-05 11:30 ` [PATCH 11/12] rerere: never renormalize Jonathan Nieder
2010-08-05 11:32 ` [PATCH 12/12] merge-recursive --renormalize Jonathan Nieder
2010-08-05 19:02 ` [PATCH/RFC v2 0/12] Re: rerere: let caller decide whether to renormalize Eyvind Bernhardsen
2010-08-04 3:29 ` [PATCH 6/6] merge-recursive: add -Xrenormalize option Jonathan Nieder
2010-08-04 18:10 ` [PATCH/RFC eb/double-convert-before-merge 0/6] merge -Xrenormalize Junio C Hamano
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=20100804032338.GF19699@burratino \
--to=jrnieder@gmail.com \
--cc=eyvind.bernhardsen@gmail.com \
--cc=finnag@pvv.org \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=jnareb@gmail.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.