summaryrefslogtreecommitdiff
path: root/builtin
diff options
context:
space:
mode:
authorJonathan Nieder <jrnieder@gmail.com>2010-08-05 06:32:41 -0500
committerJunio C Hamano <gitster@pobox.com>2010-08-06 09:20:02 -0700
commit7610fa57e63b0acc0a66717fc2d85755634db591 (patch)
tree068161cdd6ca96746439efda939c4d15beba190d /builtin
parentff8ba59e7b015ba96d6a3271000f16aa71dc4a6f (diff)
downloadgit-7610fa57e63b0acc0a66717fc2d85755634db591.tar.gz
merge-recursive --renormalize
Teach "git merge-recursive" a --renormalize option to enable the merge.renormalize configuration. The --no-renormalize option can be used to override it in the negative. So in the future, you might be able to, e.g.: git checkout -m -Xrenormalize otherbranch or git revert -Xrenormalize otherpatch or git pull --rebase -Xrenormalize The bad part: merge.renormalize is still not honored for most commands. And it reveals lots of places that -X has not been plumbed in (so we get "git merge -Xrenormalize" but not much else). NEEDSWORK: tests Cc: Eyvind Bernhardsen <eyvind.bernhardsen@gmail.com> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin')
-rw-r--r--builtin/checkout.c7
-rw-r--r--builtin/merge-recursive.c4
-rw-r--r--builtin/merge.c19
-rw-r--r--builtin/revert.c7
4 files changed, 32 insertions, 5 deletions
diff --git a/builtin/checkout.c b/builtin/checkout.c
index a0c00d3878..24b67d5dea 100644
--- a/builtin/checkout.c
+++ b/builtin/checkout.c
@@ -437,6 +437,13 @@ static int merge_working_tree(struct checkout_opts *opts,
*/
add_files_to_cache(NULL, NULL, 0);
+ /*
+ * NEEDSWORK: carrying over local changes
+ * when branches have different end-of-line
+ * normalization (or clean+smudge rules) is
+ * a pain; plumb in an option to set
+ * o.renormalize?
+ */
init_merge_options(&o);
o.verbosity = 0;
work = write_tree_from_memory(&o);
diff --git a/builtin/merge-recursive.c b/builtin/merge-recursive.c
index d8875d5892..c2d4677fd3 100644
--- a/builtin/merge-recursive.c
+++ b/builtin/merge-recursive.c
@@ -45,6 +45,10 @@ int cmd_merge_recursive(int argc, const char **argv, const char *prefix)
o.subtree_shift = "";
else if (!prefixcmp(arg+2, "subtree="))
o.subtree_shift = arg + 10;
+ else if (!strcmp(arg+2, "renormalize"))
+ o.renormalize = 1;
+ else if (!strcmp(arg+2, "no-renormalize"))
+ o.renormalize = 0;
else
die("Unknown option %s", arg);
continue;
diff --git a/builtin/merge.c b/builtin/merge.c
index b836e9c68b..037cd47e70 100644
--- a/builtin/merge.c
+++ b/builtin/merge.c
@@ -54,6 +54,7 @@ static size_t use_strategies_nr, use_strategies_alloc;
static const char **xopts;
static size_t xopts_nr, xopts_alloc;
static const char *branch;
+static int option_renormalize;
static int verbosity;
static int allow_rerere_auto;
@@ -503,9 +504,8 @@ static int git_merge_config(const char *k, const char *v, void *cb)
return git_config_string(&pull_octopus, k, v);
else if (!strcmp(k, "merge.log") || !strcmp(k, "merge.summary"))
option_log = git_config_bool(k, v);
- else if (!strcmp(k, "merge.renormalize")) {
- merge_renormalize = git_config_bool(k, v);
- }
+ else if (!strcmp(k, "merge.renormalize"))
+ option_renormalize = git_config_bool(k, v);
return git_diff_ui_config(k, v, cb);
}
@@ -627,6 +627,11 @@ static int try_merge_strategy(const char *strategy, struct commit_list *common,
if (!strcmp(strategy, "subtree"))
o.subtree_shift = "";
+ o.renormalize = option_renormalize;
+
+ /*
+ * NEEDSWORK: merge with table in builtin/merge-recursive
+ */
for (x = 0; x < xopts_nr; x++) {
if (!strcmp(xopts[x], "ours"))
o.recursive_variant = MERGE_RECURSIVE_OURS;
@@ -636,6 +641,10 @@ static int try_merge_strategy(const char *strategy, struct commit_list *common,
o.subtree_shift = "";
else if (!prefixcmp(xopts[x], "subtree="))
o.subtree_shift = xopts[x]+8;
+ else if (!strcmp(xopts[x], "renormalize"))
+ o.renormalize = 1;
+ else if (!strcmp(xopts[x], "no-renormalize"))
+ o.renormalize = 0;
else
die("Unknown option for merge-recursive: -X%s", xopts[x]);
}
@@ -819,7 +828,7 @@ static int finish_automerge(struct commit_list *common,
return 0;
}
-static int suggest_conflicts(void)
+static int suggest_conflicts(int renormalizing)
{
FILE *fp;
int pos;
@@ -1304,5 +1313,5 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
"stopped before committing as requested\n");
return 0;
} else
- return suggest_conflicts();
+ return suggest_conflicts(option_renormalize);
}
diff --git a/builtin/revert.c b/builtin/revert.c
index 853e9e406c..11132533c6 100644
--- a/builtin/revert.c
+++ b/builtin/revert.c
@@ -318,6 +318,13 @@ static void do_recursive_merge(struct commit *base, struct commit *next,
index_fd = hold_locked_index(&index_lock, 1);
read_cache();
+
+ /*
+ * NEEDSWORK: cherry-picking between branches with
+ * different end-of-line normalization is a pain;
+ * plumb in an option to set o.renormalize?
+ * (or better: arbitrary -X options)
+ */
init_merge_options(&o);
o.ancestor = base ? base_label : "(empty tree)";
o.branch1 = "HEAD";