convert: convert renormalize_buffer to take an index
authorBrandon Williams <bmwill@google.com>
Mon, 12 Jun 2017 22:13:56 +0000 (15:13 -0700)
committerJunio C Hamano <gitster@pobox.com>
Tue, 13 Jun 2017 18:40:51 +0000 (11:40 -0700)
Signed-off-by: Brandon Williams <bmwill@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
convert.c
convert.h
ll-merge.c
merge-recursive.c
index 600d11e73f9dab409380b41bde2e97da2b7f02f2..4097f521f240240fde1a3bfa8519515fdaac75f6 100644 (file)
--- a/convert.c
+++ b/convert.c
@@ -1,3 +1,4 @@
+#define NO_THE_INDEX_COMPATIBILITY_MACROS
 #include "cache.h"
 #include "attr.h"
 #include "run-command.h"
@@ -1165,14 +1166,15 @@ int convert_to_working_tree(const char *path, const char *src, size_t len, struc
        return convert_to_working_tree_internal(path, src, len, dst, 0);
 }
 
-int renormalize_buffer(const char *path, const char *src, size_t len, struct strbuf *dst)
+int renormalize_buffer(const struct index_state *istate, const char *path,
+                      const char *src, size_t len, struct strbuf *dst)
 {
        int ret = convert_to_working_tree_internal(path, src, len, dst, 1);
        if (ret) {
                src = dst->buf;
                len = dst->len;
        }
-       return ret | convert_to_git(&the_index, path, src, len, dst, SAFE_CRLF_RENORMALIZE);
+       return ret | convert_to_git(istate, path, src, len, dst, SAFE_CRLF_RENORMALIZE);
 }
 
 /*****************************************************************
index 60cb41d6a47be20aed5bce3692d6ed35cd9cede0..cecf59d1aa15f234473dc16520c0a6647e255280 100644 (file)
--- a/convert.h
+++ b/convert.h
@@ -46,7 +46,8 @@ extern int convert_to_git(const struct index_state *istate,
                          struct strbuf *dst, enum safe_crlf checksafe);
 extern int convert_to_working_tree(const char *path, const char *src,
                                   size_t len, struct strbuf *dst);
-extern int renormalize_buffer(const char *path, const char *src, size_t len,
+extern int renormalize_buffer(const struct index_state *istate,
+                             const char *path, const char *src, size_t len,
                              struct strbuf *dst);
 static inline int would_convert_to_git(const struct index_state *istate,
                                       const char *path)
index ac0d4a5d78d956f09aa0082b286babc36f04b593..d7eafb61a6831020149d0da607bb47b995192296 100644 (file)
@@ -339,7 +339,7 @@ static const struct ll_merge_driver *find_ll_merge_driver(const char *merge_attr
 static void normalize_file(mmfile_t *mm, const char *path)
 {
        struct strbuf strbuf = STRBUF_INIT;
-       if (renormalize_buffer(path, mm->ptr, mm->size, &strbuf)) {
+       if (renormalize_buffer(&the_index, path, mm->ptr, mm->size, &strbuf)) {
                free(mm->ptr);
                mm->size = strbuf.len;
                mm->ptr = strbuf_detach(&strbuf, NULL);
index ae5238d82ca8c86b99391a0836a0539efe7eacde..eac12d4888993ebf4fde5194e19704db885824ee 100644 (file)
@@ -1639,8 +1639,8 @@ static int blob_unchanged(struct merge_options *opt,
         * performed.  Comparison can be skipped if both files are
         * unchanged since their sha1s have already been compared.
         */
-       if (renormalize_buffer(path, o.buf, o.len, &o) |
-           renormalize_buffer(path, a.buf, a.len, &a))
+       if (renormalize_buffer(&the_index, path, o.buf, o.len, &o) |
+           renormalize_buffer(&the_index, path, a.buf, a.len, &a))
                ret = (o.len == a.len && !memcmp(o.buf, a.buf, o.len));
 
 error_return: