Documentation/technical: document ll_merge
[gitweb.git] / ll-merge.c
index 3764a1ab72354a3ce643c899c1e8cf5443d4e7cb..5068fe069faeef07363407c622624264c5cf3a6c 100644 (file)
@@ -321,6 +321,16 @@ static int git_path_check_merge(const char *path, struct git_attr_check check[2]
        return git_checkattr(path, 2, check);
 }
 
+static void normalize_file(mmfile_t *mm, const char *path)
+{
+       struct strbuf strbuf = STRBUF_INIT;
+       if (renormalize_buffer(path, mm->ptr, mm->size, &strbuf)) {
+               free(mm->ptr);
+               mm->size = strbuf.len;
+               mm->ptr = strbuf_detach(&strbuf, NULL);
+       }
+}
+
 int ll_merge(mmbuffer_t *result_buf,
             const char *path,
             mmfile_t *ancestor, const char *ancestor_label,
@@ -334,6 +344,11 @@ int ll_merge(mmbuffer_t *result_buf,
        const struct ll_merge_driver *driver;
        int virtual_ancestor = flag & 01;
 
+       if (merge_renormalize) {
+               normalize_file(ancestor, path);
+               normalize_file(ours, path);
+               normalize_file(theirs, path);
+       }
        if (!git_path_check_merge(path, check)) {
                ll_driver_name = check[0].value;
                if (check[1].value) {