merge-trees: push choice to renormalize away from low level
The merge machinery decides whether to resmudge and clean relevant entries based on the global merge_renormalize setting, which is set by "git merge" based on its configuration (and left alone by other commands). A nicer interface would make that decision a parameter to merge_trees so callers would pass in a choice made on a call-by-call basis. Start by making blob_unchanged stop examining the merge_renormalize global. In other words, this change is a trivial no-op, but it brings us closer to something good. Cc: Eyvind Bernhardsen <eyvind.bernhardsen@gmail.com> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Jonathan Nieder committed
Aug 5, 2010 at 06:13 UTC
3e7589b7b3ff7a7aa93bec39c40603e370c51317
1 file changed
+5
-4
merge-recursive.c
+5
-4
@@ -1074,7 +1074,7 @@ static int read_sha1_strbuf(const unsigned char *sha1, struct strbuf *dst)
1074
1075
static int blob_unchanged(const unsigned char *o_sha,
1076
const unsigned char *a_sha,
1077
- const char *path)
1077
+ int renormalize, const char *path)
1078
{
1079
struct strbuf o = STRBUF_INIT;
1080
struct strbuf a = STRBUF_INIT;
@@ -1082,7 +1082,7 @@ static int blob_unchanged(const unsigned char *o_sha,
1082
1083
if (sha_eq(o_sha, a_sha))
1084
return 1;
1085
- if (!merge_renormalize)
1085
+ if (!renormalize)
1086
return 0;
1087
1088
assert(o_sha && a_sha);
@@ -1112,6 +1112,7 @@ static int process_entry(struct merge_options *o,
1112
print_index_entry("\tpath: ", entry);
1113
*/
1114
int clean_merge = 1;
1115
+ int normalize = merge_renormalize;
1116
unsigned o_mode = entry->stages[1].mode;
1117
unsigned a_mode = entry->stages[2].mode;
1118
unsigned b_mode = entry->stages[3].mode;
@@ -1122,8 +1123,8 @@ static int process_entry(struct merge_options *o,
1123
if (o_sha && (!a_sha || !b_sha)) {
1124
/* Case A: Deleted in one */
1125
if ((!a_sha && !b_sha) ||
1125
- (!b_sha && blob_unchanged(o_sha, a_sha, path)) ||
1126
- (!a_sha && blob_unchanged(o_sha, b_sha, path))) {
1126
+ (!b_sha && blob_unchanged(o_sha, a_sha, normalize, path)) ||
1127
+ (!a_sha && blob_unchanged(o_sha, b_sha, normalize, path))) {
1128
/* Deleted in both or deleted in one and
1129
* unchanged in the other */
1130
if (a_sha)