Don't expand CRLFs when normalizing text during merge
Disable CRLF expansion when convert_to_working_tree() is called from normalize_buffer(). This improves performance when merging branches with conflicting line endings when core.eol=crlf or core.autocrlf=true by making the normalization act as if core.eol=lf. Signed-off-by: Eyvind Bernhardsen <eyvind.bernhardsen@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Eyvind Bernhardsen committed
Jul 2, 2010 at 21:20 UTC
43dd2332853b2460a5252b0f43d8de3c5b545b9a
1 file changed
+20
-7
convert.c
+20
-7
@@ -741,7 +741,9 @@ int convert_to_git(const char *path, const char *src, size_t len,
741
return ret | ident_to_git(path, src, len, dst, ident);
742
}
743
744
-int convert_to_working_tree(const char *path, const char *src, size_t len, struct strbuf *dst)
744
+static int convert_to_working_tree_internal(const char *path, const char *src,
745
+ size_t len, struct strbuf *dst,
746
+ int normalizing)
747
{
748
struct git_attr_check check[5];
749
enum action action = CRLF_GUESS;
@@ -767,18 +769,29 @@ int convert_to_working_tree(const char *path, const char *src, size_t len, struc
769
src = dst->buf;
770
len = dst->len;
771
}
770
- action = determine_action(action, eol_attr);
771
- ret |= crlf_to_worktree(path, src, len, dst, action);
772
- if (ret) {
773
- src = dst->buf;
774
- len = dst->len;
772
+ /*
773
+ * CRLF conversion can be skipped if normalizing, unless there
774
+ * is a smudge filter. The filter might expect CRLFs.
775
+ */
776
+ if (filter || !normalizing) {
777
+ action = determine_action(action, eol_attr);
778
+ ret |= crlf_to_worktree(path, src, len, dst, action);
779
+ if (ret) {
780
+ src = dst->buf;
781
+ len = dst->len;
782
+ }
783
}
784
return ret | apply_filter(path, src, len, dst, filter);
785
}
786
787
+int convert_to_working_tree(const char *path, const char *src, size_t len, struct strbuf *dst)
788
+{
789
+ return convert_to_working_tree_internal(path, src, len, dst, 0);
790
+}
791
+
792
int renormalize_buffer(const char *path, const char *src, size_t len, struct strbuf *dst)
793
{
781
- int ret = convert_to_working_tree(path, src, len, dst);
794
+ int ret = convert_to_working_tree_internal(path, src, len, dst, 1);
795
if (ret) {
796
src = dst->buf;
797
len = dst->len;