convert: convert renormalize_buffer to take an index

Signed-off-by: Brandon Williams <bmwill@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Brandon Williams committed Jun 12, 2017 at 15:13 UTC a33e0b2a77d7010ba8bf0e025fffaf98f464a938
4 files changed +9 -6
convert.c
+4 -2
@@ -1,3 +1,4 @@
1 +#define NO_THE_INDEX_COMPATIBILITY_MACROS
2 #include "cache.h"
3 #include "attr.h"
4 #include "run-command.h"
@@ -1165,14 +1166,15 @@ int convert_to_working_tree(const char *path, const char *src, size_t len, struc
1166 return convert_to_working_tree_internal(path, src, len, dst, 0);
1167 }
1168
1168 -int renormalize_buffer(const char *path, const char *src, size_t len, struct strbuf *dst)
1169 +int renormalize_buffer(const struct index_state *istate, const char *path,
1170 + const char *src, size_t len, struct strbuf *dst)
1171 {
1172 int ret = convert_to_working_tree_internal(path, src, len, dst, 1);
1173 if (ret) {
1174 src = dst->buf;
1175 len = dst->len;
1176 }
1175 - return ret | convert_to_git(&the_index, path, src, len, dst, SAFE_CRLF_RENORMALIZE);
1177 + return ret | convert_to_git(istate, path, src, len, dst, SAFE_CRLF_RENORMALIZE);
1178 }
1179
1180 /*****************************************************************
convert.h
+2 -1
@@ -46,7 +46,8 @@ extern int convert_to_git(const struct index_state *istate,
46 struct strbuf *dst, enum safe_crlf checksafe);
47 extern int convert_to_working_tree(const char *path, const char *src,
48 size_t len, struct strbuf *dst);
49 -extern int renormalize_buffer(const char *path, const char *src, size_t len,
49 +extern int renormalize_buffer(const struct index_state *istate,
50 + const char *path, const char *src, size_t len,
51 struct strbuf *dst);
52 static inline int would_convert_to_git(const struct index_state *istate,
53 const char *path)
ll-merge.c
+1 -1
@@ -339,7 +339,7 @@ static const struct ll_merge_driver *find_ll_merge_driver(const char *merge_attr
339 static void normalize_file(mmfile_t *mm, const char *path)
340 {
341 struct strbuf strbuf = STRBUF_INIT;
342 - if (renormalize_buffer(path, mm->ptr, mm->size, &strbuf)) {
342 + if (renormalize_buffer(&the_index, path, mm->ptr, mm->size, &strbuf)) {
343 free(mm->ptr);
344 mm->size = strbuf.len;
345 mm->ptr = strbuf_detach(&strbuf, NULL);
merge-recursive.c
+2 -2
@@ -1639,8 +1639,8 @@ static int blob_unchanged(struct merge_options *opt,
1639 * performed. Comparison can be skipped if both files are
1640 * unchanged since their sha1s have already been compared.
1641 */
1642 - if (renormalize_buffer(path, o.buf, o.len, &o) |
1643 - renormalize_buffer(path, a.buf, a.len, &a))
1642 + if (renormalize_buffer(&the_index, path, o.buf, o.len, &o) |
1643 + renormalize_buffer(&the_index, path, a.buf, a.len, &a))
1644 ret = (o.len == a.len && !memcmp(o.buf, a.buf, o.len));
1645
1646 error_return: