Commit 6de48085b6d6c28ea90c57286d77f88f200da841

Edward Thomson 2019-08-27T11:29:24

Merge pull request #5189 from libgit2/ethomson/attrs_from_head Optionally read `.gitattributes` from HEAD

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
diff --git a/include/git2/attr.h b/include/git2/attr.h
index cab9758..72e4380 100644
--- a/include/git2/attr.h
+++ b/include/git2/attr.h
@@ -119,13 +119,20 @@ GIT_EXTERN(git_attr_value_t) git_attr_value(const char *attr);
 #define GIT_ATTR_CHECK_INDEX_ONLY		2
 
 /**
- * Check attribute flags: Using the system attributes file.
+ * Check attribute flags: controlling extended attribute behavior.
  *
  * Normally, attribute checks include looking in the /etc (or system
  * equivalent) directory for a `gitattributes` file.  Passing this
  * flag will cause attribute checks to ignore that file.
+ * equivalent) directory for a `gitattributes` file.  Passing the
+ * `GIT_ATTR_CHECK_NO_SYSTEM` flag will cause attribute checks to
+ * ignore that file.
+ *
+ * Passing the `GIT_ATTR_CHECK_INCLUDE_HEAD` flag will use attributes
+ * from a `.gitattributes` file in the repository at the HEAD revision.
  */
-#define GIT_ATTR_CHECK_NO_SYSTEM		(1 << 2)
+#define GIT_ATTR_CHECK_NO_SYSTEM        (1 << 2)
+#define GIT_ATTR_CHECK_INCLUDE_HEAD     (1 << 3)
 
 /**
  * Look up the value of one git attribute for path.
diff --git a/include/git2/blob.h b/include/git2/blob.h
index 072522d..1dfd6b7 100644
--- a/include/git2/blob.h
+++ b/include/git2/blob.h
@@ -97,6 +97,39 @@ GIT_EXTERN(const void *) git_blob_rawcontent(const git_blob *blob);
 GIT_EXTERN(git_off_t) git_blob_rawsize(const git_blob *blob);
 
 /**
+ * Flags to control the functionality of `git_blob_filter`.
+ */
+typedef enum {
+	/** When set, filters will not be applied to binary files. */
+	GIT_BLOB_FILTER_CHECK_FOR_BINARY = (1 << 0),
+
+	/**
+	 * When set, filters will not load configuration from the
+	 * system-wide `gitattributes` in `/etc` (or system equivalent).
+	 */
+	GIT_BLOB_FILTER_NO_SYSTEM_ATTRIBUTES = (1 << 1),
+
+	/**
+	 * When set, filters will be loaded from a `.gitattributes` file
+	 * in the HEAD commit.
+	 */
+	GIT_BLOB_FILTER_ATTTRIBUTES_FROM_HEAD = (1 << 2),
+} git_blob_filter_flag_t;
+
+/**
+ * The options used when applying filter options to a file.
+ */
+typedef struct {
+	int version;
+
+	/** Flags to control the filtering process */
+	git_blob_filter_flag_t flags;
+} git_blob_filter_options;
+
+#define GIT_BLOB_FILTER_OPTIONS_VERSION 1
+#define GIT_BLOB_FILTER_OPTIONS_INIT {GIT_BLOB_FILTER_OPTIONS_VERSION, GIT_BLOB_FILTER_CHECK_FOR_BINARY}
+
+/**
  * Get a buffer with the filtered content of a blob.
  *
  * This applies filters as if the blob was being checked out to the
@@ -115,15 +148,14 @@ GIT_EXTERN(git_off_t) git_blob_rawsize(const git_blob *blob);
  * @param out The git_buf to be filled in
  * @param blob Pointer to the blob
  * @param as_path Path used for file attribute lookups, etc.
- * @param check_for_binary_data Should this test if blob content contains
- *        NUL bytes / looks like binary data before applying filters?
+ * @param opts Options to use for filtering the blob
  * @return 0 on success or an error code
  */
-GIT_EXTERN(int) git_blob_filtered_content(
+GIT_EXTERN(int) git_blob_filter(
 	git_buf *out,
 	git_blob *blob,
 	const char *as_path,
-	int check_for_binary_data);
+	git_blob_filter_options *opts);
 
 /**
  * Read a file from the working folder of a repository
diff --git a/include/git2/deprecated.h b/include/git2/deprecated.h
index df53cf0..ac1ad1a 100644
--- a/include/git2/deprecated.h
+++ b/include/git2/deprecated.h
@@ -90,6 +90,13 @@ GIT_EXTERN(int) git_blob_create_fromstream_commit(
 GIT_EXTERN(int) git_blob_create_frombuffer(
 	git_oid *id, git_repository *repo, const void *buffer, size_t len);
 
+/** Deprecated in favor of @see git_blob_filter */
+GIT_EXTERN(int) git_blob_filtered_content(
+	git_buf *out,
+	git_blob *blob,
+	const char *as_path,
+	int check_for_binary_data);
+
 /**@}*/
 
 /** @name Deprecated Buffer Functions
diff --git a/include/git2/filter.h b/include/git2/filter.h
index 436a0f3..8860590 100644
--- a/include/git2/filter.h
+++ b/include/git2/filter.h
@@ -40,7 +40,15 @@ typedef enum {
  */
 typedef enum {
 	GIT_FILTER_DEFAULT = 0u,
+
+	/** Don't error for `safecrlf` violations, allow them to continue. */
 	GIT_FILTER_ALLOW_UNSAFE = (1u << 0),
+
+	/** Don't load `/etc/gitattributes` (or the system equivalent) */
+	GIT_FILTER_NO_SYSTEM_ATTRIBUTES = (1u << 1),
+
+	/** Load attributes from `.gitattributes` in the root of HEAD */
+	GIT_FILTER_ATTRIBUTES_FROM_HEAD = (1u << 2),
 } git_filter_flag_t;
 
 /**
diff --git a/src/attr.c b/src/attr.c
index 02a7148..bd517cd 100644
--- a/src/attr.c
+++ b/src/attr.c
@@ -305,7 +305,10 @@ static int system_attr_file(
 	return 0;
 }
 
-static int attr_setup(git_repository *repo, git_attr_session *attr_session)
+static int attr_setup(
+	git_repository *repo,
+	git_attr_session *attr_session,
+	uint32_t flags)
 {
 	git_buf path = GIT_BUF_INIT;
 	git_index *idx = NULL;
@@ -352,6 +355,11 @@ static int attr_setup(git_repository *repo, git_attr_session *attr_session)
 				       NULL, GIT_ATTR_FILE, true)) < 0)
 			goto out;
 
+	if ((flags & GIT_ATTR_CHECK_INCLUDE_HEAD) != 0 &&
+	    (error = preload_attr_file(repo, attr_session, GIT_ATTR_FILE__FROM_HEAD,
+				       NULL, GIT_ATTR_FILE, true)) < 0)
+		goto out;
+
 	if (attr_session)
 		attr_session->init_setup = 1;
 
@@ -428,6 +436,9 @@ static int attr_decide_sources(
 		break;
 	}
 
+	if ((flags & GIT_ATTR_CHECK_INCLUDE_HEAD) != 0)
+		srcs[count++] = GIT_ATTR_FILE__FROM_HEAD;
+
 	return count;
 }
 
@@ -460,7 +471,7 @@ static int push_attr_file(
 static int push_one_attr(void *ref, const char *path)
 {
 	attr_walk_up_info *info = (attr_walk_up_info *)ref;
-	git_attr_file_source src[2];
+	git_attr_file_source src[GIT_ATTR_FILE_NUM_SOURCES];
 	int error = 0, n_src, i;
 	bool allow_macros;
 
@@ -499,7 +510,7 @@ static int collect_attr_files(
 	const char *workdir = git_repository_workdir(repo);
 	attr_walk_up_info info = { NULL };
 
-	if ((error = attr_setup(repo, attr_session)) < 0)
+	if ((error = attr_setup(repo, attr_session, flags)) < 0)
 		return error;
 
 	/* Resolve path in a non-bare repo */
diff --git a/src/attr_file.c b/src/attr_file.c
index f8769c6..a1b4c73 100644
--- a/src/attr_file.c
+++ b/src/attr_file.c
@@ -109,6 +109,8 @@ int git_attr_file__load(
 	bool allow_macros)
 {
 	int error = 0;
+	git_tree *tree = NULL;
+	git_tree_entry *tree_entry = NULL;
 	git_blob *blob = NULL;
 	git_buf content = GIT_BUF_INIT;
 	const char *content_str;
@@ -117,6 +119,8 @@ int git_attr_file__load(
 	bool nonexistent = false;
 	int bom_offset;
 	git_bom_t bom;
+	git_oid id;
+	git_off_t blobsize;
 
 	*out = NULL;
 
@@ -125,9 +129,6 @@ int git_attr_file__load(
 		/* in-memory attribute file doesn't need data */
 		break;
 	case GIT_ATTR_FILE__FROM_INDEX: {
-		git_oid id;
-		git_off_t blobsize;
-
 		if ((error = attr_file_oid_from_index(&id, repo, entry->path)) < 0 ||
 			(error = git_blob_lookup(&blob, repo, &id)) < 0)
 			return error;
@@ -157,6 +158,25 @@ int git_attr_file__load(
 
 		break;
 	}
+	case GIT_ATTR_FILE__FROM_HEAD: {
+		if ((error = git_repository_head_tree(&tree, repo)) < 0 ||
+		    (error = git_tree_entry_bypath(&tree_entry, tree, entry->path)) < 0 ||
+		    (error = git_blob_lookup(&blob, repo, git_tree_entry_id(tree_entry))) < 0)
+			goto cleanup;
+
+		/*
+		 * Do not assume that data straight from the ODB is NULL-terminated;
+		 * copy the contents of a file to a buffer to work on.
+		 */
+		blobsize = git_blob_rawsize(blob);
+
+		GIT_ERROR_CHECK_BLOBSIZE(blobsize);
+		if ((error = git_buf_put(&content,
+			git_blob_rawcontent(blob), (size_t)blobsize)) < 0)
+			goto cleanup;
+
+		break;
+	}
 	default:
 		git_error_set(GIT_ERROR_INVALID, "unknown file source %d", source);
 		return -1;
@@ -188,6 +208,8 @@ int git_attr_file__load(
 		file->nonexistent = 1;
 	else if (source == GIT_ATTR_FILE__FROM_INDEX)
 		git_oid_cpy(&file->cache_data.oid, git_blob_id(blob));
+	else if (source == GIT_ATTR_FILE__FROM_HEAD)
+		git_oid_cpy(&file->cache_data.oid, git_tree_id(tree));
 	else if (source == GIT_ATTR_FILE__FROM_FILE)
 		git_futils_filestamp_set_from_stat(&file->cache_data.stamp, &st);
 	/* else always cacheable */
@@ -196,6 +218,8 @@ int git_attr_file__load(
 
 cleanup:
 	git_blob_free(blob);
+	git_tree_entry_free(tree_entry);
+	git_tree_free(tree);
 	git_buf_dispose(&content);
 
 	return error;
@@ -236,6 +260,19 @@ int git_attr_file__out_of_date(
 		return (git_oid__cmp(&file->cache_data.oid, &id) != 0);
 	}
 
+	case GIT_ATTR_FILE__FROM_HEAD: {
+		git_tree *tree;
+		int error;
+
+		if ((error = git_repository_head_tree(&tree, repo)) < 0)
+			return error;
+
+		error = git_oid__cmp(&file->cache_data.oid, git_tree_id(tree));
+
+		git_tree_free(tree);
+		return error;
+	}
+
 	default:
 		git_error_set(GIT_ERROR_INVALID, "invalid file type %d", file->source);
 		return -1;
diff --git a/src/attr_file.h b/src/attr_file.h
index f4f9a09..2b6b1d6 100644
--- a/src/attr_file.h
+++ b/src/attr_file.h
@@ -40,8 +40,9 @@ typedef enum {
 	GIT_ATTR_FILE__IN_MEMORY   = 0,
 	GIT_ATTR_FILE__FROM_FILE   = 1,
 	GIT_ATTR_FILE__FROM_INDEX  = 2,
+	GIT_ATTR_FILE__FROM_HEAD   = 3,
 
-	GIT_ATTR_FILE_NUM_SOURCES  = 3
+	GIT_ATTR_FILE_NUM_SOURCES  = 4
 } git_attr_file_source;
 
 extern const char *git_attr__true;
diff --git a/src/blob.c b/src/blob.c
index 31e6ccf..487e608 100644
--- a/src/blob.c
+++ b/src/blob.c
@@ -400,25 +400,40 @@ int git_blob_is_binary(const git_blob *blob)
 	return git_buf_text_is_binary(&content);
 }
 
-int git_blob_filtered_content(
+int git_blob_filter(
 	git_buf *out,
 	git_blob *blob,
 	const char *path,
-	int check_for_binary_data)
+	git_blob_filter_options *given_opts)
 {
 	int error = 0;
 	git_filter_list *fl = NULL;
+	git_blob_filter_options opts = GIT_BLOB_FILTER_OPTIONS_INIT;
+	git_filter_flag_t flags = GIT_FILTER_DEFAULT;
 
 	assert(blob && path && out);
 
 	git_buf_sanitize(out);
 
-	if (check_for_binary_data && git_blob_is_binary(blob))
+	GIT_ERROR_CHECK_VERSION(
+		given_opts, GIT_BLOB_FILTER_OPTIONS_VERSION, "git_blob_filter_options");
+
+	if (given_opts != NULL)
+		memcpy(&opts, given_opts, sizeof(git_blob_filter_options));
+
+	if ((opts.flags & GIT_BLOB_FILTER_CHECK_FOR_BINARY) != 0 &&
+	    git_blob_is_binary(blob))
 		return 0;
 
+	if ((opts.flags & GIT_BLOB_FILTER_NO_SYSTEM_ATTRIBUTES) != 0)
+		flags |= GIT_FILTER_NO_SYSTEM_ATTRIBUTES;
+
+	if ((opts.flags & GIT_BLOB_FILTER_ATTTRIBUTES_FROM_HEAD) != 0)
+		flags |= GIT_FILTER_ATTRIBUTES_FROM_HEAD;
+
 	if (!(error = git_filter_list_load(
 			&fl, git_blob_owner(blob), blob, path,
-			GIT_FILTER_TO_WORKTREE, GIT_FILTER_DEFAULT))) {
+			GIT_FILTER_TO_WORKTREE, flags))) {
 
 		error = git_filter_list_apply_to_blob(out, fl, blob);
 
@@ -460,3 +475,19 @@ int git_blob_create_fromstream_commit(
 {
 	return git_blob_create_from_stream_commit(out, stream);
 }
+
+int git_blob_filtered_content(
+	git_buf *out,
+	git_blob *blob,
+	const char *path,
+	int check_for_binary_data)
+{
+	git_blob_filter_options opts = GIT_BLOB_FILTER_OPTIONS_INIT;
+
+	if (check_for_binary_data)
+		opts.flags |= GIT_BLOB_FILTER_CHECK_FOR_BINARY;
+	else
+		opts.flags &= ~GIT_BLOB_FILTER_CHECK_FOR_BINARY;
+
+	return git_blob_filter(out, blob, path, &opts);
+}
diff --git a/src/filter.c b/src/filter.c
index 6c929c0..7b7e7f1 100644
--- a/src/filter.c
+++ b/src/filter.c
@@ -428,13 +428,21 @@ static int filter_list_check_attributes(
 	git_filter_def *fdef,
 	const git_filter_source *src)
 {
-	int error;
-	size_t i;
 	const char **strs = git__calloc(fdef->nattrs, sizeof(const char *));
+	uint32_t flags = 0;
+	size_t i;
+	int error;
+
 	GIT_ERROR_CHECK_ALLOC(strs);
 
+	if ((src->flags & GIT_FILTER_NO_SYSTEM_ATTRIBUTES) != 0)
+		flags |= GIT_ATTR_CHECK_NO_SYSTEM;
+
+	if ((src->flags & GIT_FILTER_ATTRIBUTES_FROM_HEAD) != 0)
+		flags |= GIT_ATTR_CHECK_INCLUDE_HEAD;
+
 	error = git_attr_get_many_with_session(
-		strs, repo, attr_session, 0, src->path, fdef->nattrs, fdef->attrs);
+		strs, repo, attr_session, flags, src->path, fdef->nattrs, fdef->attrs);
 
 	/* if no values were found but no matches are needed, it's okay! */
 	if (error == GIT_ENOTFOUND && !fdef->nmatches) {
diff --git a/tests/filter/bare.c b/tests/filter/bare.c
new file mode 100644
index 0000000..430931e
--- /dev/null
+++ b/tests/filter/bare.c
@@ -0,0 +1,134 @@
+#include "clar_libgit2.h"
+#include "crlf.h"
+
+static git_repository *g_repo = NULL;
+static git_blob_filter_options filter_opts = GIT_BLOB_FILTER_OPTIONS_INIT;
+
+void test_filter_bare__initialize(void)
+{
+	cl_fixture_sandbox("crlf.git");
+	cl_git_pass(git_repository_open(&g_repo, "crlf.git"));
+
+	filter_opts.flags |= GIT_BLOB_FILTER_NO_SYSTEM_ATTRIBUTES;
+	filter_opts.flags |= GIT_BLOB_FILTER_ATTTRIBUTES_FROM_HEAD;
+}
+
+void test_filter_bare__cleanup(void)
+{
+	git_repository_free(g_repo);
+	cl_fixture_cleanup("crlf.git");
+}
+
+void test_filter_bare__all_crlf(void)
+{
+	git_blob *blob;
+	git_buf buf = { 0 };
+
+	cl_git_pass(git_revparse_single(
+		(git_object **)&blob, g_repo, "a9a2e89")); /* all-crlf */
+
+	cl_assert_equal_s(ALL_CRLF_TEXT_RAW, git_blob_rawcontent(blob));
+
+	cl_git_pass(git_blob_filter(&buf, blob, "file.bin", &filter_opts));
+
+	cl_assert_equal_s(ALL_CRLF_TEXT_RAW, buf.ptr);
+
+	cl_git_pass(git_blob_filter(&buf, blob, "file.crlf", &filter_opts));
+
+	/* in this case, raw content has crlf in it already */
+	cl_assert_equal_s(ALL_CRLF_TEXT_AS_CRLF, buf.ptr);
+
+	cl_git_pass(git_blob_filter(&buf, blob, "file.lf", &filter_opts));
+
+	/* we never convert CRLF -> LF on platforms that have LF */
+	cl_assert_equal_s(ALL_CRLF_TEXT_AS_CRLF, buf.ptr);
+
+	cl_git_pass(git_blob_filter(&buf, blob, "file.txt", &filter_opts));
+
+	/* in this case, raw content has crlf in it already */
+	cl_assert_equal_s(ALL_CRLF_TEXT_AS_CRLF, buf.ptr);
+
+	git_buf_dispose(&buf);
+	git_blob_free(blob);
+}
+
+void test_filter_bare__from_lf(void)
+{
+	git_blob *blob;
+	git_buf buf = { 0 };
+
+	cl_git_pass(git_revparse_single(
+		(git_object **)&blob, g_repo, "799770d")); /* all-lf */
+
+	cl_assert_equal_s(ALL_LF_TEXT_RAW, git_blob_rawcontent(blob));
+
+	cl_git_pass(git_blob_filter(&buf, blob, "file.bin", &filter_opts));
+
+	cl_assert_equal_s(ALL_LF_TEXT_RAW, buf.ptr);
+
+	cl_git_pass(git_blob_filter(&buf, blob, "file.crlf", &filter_opts));
+
+	/* in this case, raw content has crlf in it already */
+	cl_assert_equal_s(ALL_LF_TEXT_AS_CRLF, buf.ptr);
+
+	cl_git_pass(git_blob_filter(&buf, blob, "file.lf", &filter_opts));
+
+	/* we never convert CRLF -> LF on platforms that have LF */
+	cl_assert_equal_s(ALL_LF_TEXT_AS_LF, buf.ptr);
+
+	git_buf_dispose(&buf);
+	git_blob_free(blob);
+}
+
+void test_filter_bare__nested_attributes(void)
+{
+	git_blob *blob;
+	git_buf buf = { 0 };
+
+	cl_git_pass(git_revparse_single(
+		(git_object **)&blob, g_repo, "799770d")); /* all-lf */
+
+	cl_assert_equal_s(ALL_LF_TEXT_RAW, git_blob_rawcontent(blob));
+
+	cl_git_pass(git_blob_filter(&buf, blob, "raw/file.bin", &filter_opts));
+	cl_assert_equal_s(ALL_LF_TEXT_RAW, buf.ptr);
+
+	cl_git_pass(git_blob_filter(&buf, blob, "raw/file.crlf", &filter_opts));
+	cl_assert_equal_s(ALL_LF_TEXT_RAW, buf.ptr);
+
+	cl_git_pass(git_blob_filter(&buf, blob, "raw/file.lf", &filter_opts));
+	cl_assert_equal_s(ALL_LF_TEXT_RAW, buf.ptr);
+
+	git_buf_dispose(&buf);
+	git_blob_free(blob);
+}
+
+void test_filter_bare__sanitizes(void)
+{
+	git_blob *blob;
+	git_buf buf = GIT_BUF_INIT;
+
+	cl_git_pass(git_revparse_single(
+		(git_object **)&blob, g_repo, "e69de29")); /* zero-byte */
+
+	cl_assert_equal_i(0, git_blob_rawsize(blob));
+	cl_assert_equal_s("", git_blob_rawcontent(blob));
+
+	cl_git_pass(git_blob_filter(&buf, blob, "file.bin", &filter_opts));
+	cl_assert_equal_sz(0, buf.size);
+	cl_assert_equal_s("", buf.ptr);
+	git_buf_dispose(&buf);
+
+	cl_git_pass(git_blob_filter(&buf, blob, "file.crlf", &filter_opts));
+	cl_assert_equal_sz(0, buf.size);
+	cl_assert_equal_s("", buf.ptr);
+	git_buf_dispose(&buf);
+
+	cl_git_pass(git_blob_filter(&buf, blob, "file.lf", &filter_opts));
+	cl_assert_equal_sz(0, buf.size);
+	cl_assert_equal_s("", buf.ptr);
+	git_buf_dispose(&buf);
+
+	git_blob_free(blob);
+}
+
diff --git a/tests/filter/blob.c b/tests/filter/blob.c
index 22f3503..1cc33d4 100644
--- a/tests/filter/blob.c
+++ b/tests/filter/blob.c
@@ -30,16 +30,16 @@ void test_filter_blob__all_crlf(void)
 
 	cl_assert_equal_s(ALL_CRLF_TEXT_RAW, git_blob_rawcontent(blob));
 
-	cl_git_pass(git_blob_filtered_content(&buf, blob, "file.bin", 1));
+	cl_git_pass(git_blob_filter(&buf, blob, "file.bin", NULL));
 
 	cl_assert_equal_s(ALL_CRLF_TEXT_RAW, buf.ptr);
 
-	cl_git_pass(git_blob_filtered_content(&buf, blob, "file.crlf", 1));
+	cl_git_pass(git_blob_filter(&buf, blob, "file.crlf", NULL));
 
 	/* in this case, raw content has crlf in it already */
 	cl_assert_equal_s(ALL_CRLF_TEXT_AS_CRLF, buf.ptr);
 
-	cl_git_pass(git_blob_filtered_content(&buf, blob, "file.lf", 1));
+	cl_git_pass(git_blob_filter(&buf, blob, "file.lf", NULL));
 
 	/* we never convert CRLF -> LF on platforms that have LF */
 	cl_assert_equal_s(ALL_CRLF_TEXT_AS_CRLF, buf.ptr);
@@ -48,6 +48,34 @@ void test_filter_blob__all_crlf(void)
 	git_blob_free(blob);
 }
 
+void test_filter_blob__from_lf(void)
+{
+	git_blob *blob;
+	git_buf buf = { 0 };
+
+	cl_git_pass(git_revparse_single(
+		(git_object **)&blob, g_repo, "799770d")); /* all-lf */
+
+	cl_assert_equal_s(ALL_LF_TEXT_RAW, git_blob_rawcontent(blob));
+
+	cl_git_pass(git_blob_filter(&buf, blob, "file.bin", NULL));
+
+	cl_assert_equal_s(ALL_LF_TEXT_RAW, buf.ptr);
+
+	cl_git_pass(git_blob_filter(&buf, blob, "file.crlf", NULL));
+
+	/* in this case, raw content has crlf in it already */
+	cl_assert_equal_s(ALL_LF_TEXT_AS_CRLF, buf.ptr);
+
+	cl_git_pass(git_blob_filter(&buf, blob, "file.lf", NULL));
+
+	/* we never convert CRLF -> LF on platforms that have LF */
+	cl_assert_equal_s(ALL_LF_TEXT_AS_LF, buf.ptr);
+
+	git_buf_dispose(&buf);
+	git_blob_free(blob);
+}
+
 void test_filter_blob__sanitizes(void)
 {
 	git_blob *blob;
@@ -60,19 +88,19 @@ void test_filter_blob__sanitizes(void)
 	cl_assert_equal_s("", git_blob_rawcontent(blob));
 
 	memset(&buf, 0, sizeof(git_buf));
-	cl_git_pass(git_blob_filtered_content(&buf, blob, "file.bin", 1));
+	cl_git_pass(git_blob_filter(&buf, blob, "file.bin", NULL));
 	cl_assert_equal_sz(0, buf.size);
 	cl_assert_equal_s("", buf.ptr);
 	git_buf_dispose(&buf);
 
 	memset(&buf, 0, sizeof(git_buf));
-	cl_git_pass(git_blob_filtered_content(&buf, blob, "file.crlf", 1));
+	cl_git_pass(git_blob_filter(&buf, blob, "file.crlf", NULL));
 	cl_assert_equal_sz(0, buf.size);
 	cl_assert_equal_s("", buf.ptr);
 	git_buf_dispose(&buf);
 
 	memset(&buf, 0, sizeof(git_buf));
-	cl_git_pass(git_blob_filtered_content(&buf, blob, "file.lf", 1));
+	cl_git_pass(git_blob_filter(&buf, blob, "file.lf", NULL));
 	cl_assert_equal_sz(0, buf.size);
 	cl_assert_equal_s("", buf.ptr);
 	git_buf_dispose(&buf);
@@ -99,15 +127,15 @@ void test_filter_blob__ident(void)
 	cl_assert_equal_s(
 		"Some text\n$Id$\nGoes there\n", git_blob_rawcontent(blob));
 
-	cl_git_pass(git_blob_filtered_content(&buf, blob, "filter.bin", 1));
+	cl_git_pass(git_blob_filter(&buf, blob, "filter.bin", NULL));
 	cl_assert_equal_s(
 		"Some text\n$Id$\nGoes there\n", buf.ptr);
 
-	cl_git_pass(git_blob_filtered_content(&buf, blob, "filter.identcrlf", 1));
+	cl_git_pass(git_blob_filter(&buf, blob, "filter.identcrlf", NULL));
 	cl_assert_equal_s(
 		"Some text\r\n$Id: 3164f585d548ac68027d22b104f2d8100b2b6845 $\r\nGoes there\r\n", buf.ptr);
 
-	cl_git_pass(git_blob_filtered_content(&buf, blob, "filter.identlf", 1));
+	cl_git_pass(git_blob_filter(&buf, blob, "filter.identlf", NULL));
 	cl_assert_equal_s(
 		"Some text\n$Id: 3164f585d548ac68027d22b104f2d8100b2b6845 $\nGoes there\n", buf.ptr);
 
diff --git a/tests/filter/custom.c b/tests/filter/custom.c
index b9e4f73..fe2025f 100644
--- a/tests/filter/custom.c
+++ b/tests/filter/custom.c
@@ -208,7 +208,7 @@ void test_filter_custom__order_dependency(void)
 		& git_index_get_bypath(index, "hero.1.rev-ident", 0)->id));
 	cl_assert_equal_s(
 		"\n!nuf evaH\n$dI$\ntset a si sihT", git_blob_rawcontent(blob));
-	cl_git_pass(git_blob_filtered_content(&buf, blob, "hero.1.rev-ident", 0));
+	cl_git_pass(git_blob_filter(&buf, blob, "hero.1.rev-ident", NULL));
 	/* no expansion because id was reversed at checkin and now at ident
 	 * time, reverse is not applied yet */
 	cl_assert_equal_s(
@@ -219,7 +219,7 @@ void test_filter_custom__order_dependency(void)
 		& git_index_get_bypath(index, "hero.2.rev-ident", 0)->id));
 	cl_assert_equal_s(
 		"\n!yzarC\n$Id$\ntset rehtonA", git_blob_rawcontent(blob));
-	cl_git_pass(git_blob_filtered_content(&buf, blob, "hero.2.rev-ident", 0));
+	cl_git_pass(git_blob_filter(&buf, blob, "hero.2.rev-ident", NULL));
 	/* expansion because reverse was applied at checkin and at ident time,
 	 * reverse is not applied yet */
 	cl_assert_equal_s(
diff --git a/tests/filter/systemattrs.c b/tests/filter/systemattrs.c
new file mode 100644
index 0000000..4996b3b
--- /dev/null
+++ b/tests/filter/systemattrs.c
@@ -0,0 +1,81 @@
+#include "clar_libgit2.h"
+#include "crlf.h"
+#include "path.h"
+
+static git_repository *g_repo = NULL;
+static git_buf system_attr_path = GIT_BUF_INIT;
+
+void test_filter_systemattrs__initialize(void)
+{
+	g_repo = cl_git_sandbox_init("crlf");
+	cl_must_pass(p_unlink("crlf/.gitattributes"));
+
+	cl_git_pass(git_libgit2_opts(
+		GIT_OPT_GET_SEARCH_PATH, GIT_CONFIG_LEVEL_SYSTEM, &system_attr_path));
+	cl_git_pass(git_buf_joinpath(&system_attr_path,
+		system_attr_path.ptr, "gitattributes"));
+
+	cl_git_mkfile(system_attr_path.ptr,
+		"*.txt text\n"
+		"*.bin binary\n"
+		"*.crlf text eol=crlf\n"
+		"*.lf text eol=lf\n");
+}
+
+void test_filter_systemattrs__cleanup(void)
+{
+	cl_must_pass(p_unlink(system_attr_path.ptr));
+	git_buf_dispose(&system_attr_path);
+
+	cl_git_sandbox_cleanup();
+}
+
+void test_filter_systemattrs__reads_system_attributes(void)
+{
+	git_blob *blob;
+	git_buf buf = { 0 };
+
+	cl_git_pass(git_revparse_single(
+		(git_object **)&blob, g_repo, "799770d")); /* all-lf */
+
+	cl_assert_equal_s(ALL_LF_TEXT_RAW, git_blob_rawcontent(blob));
+
+	cl_git_pass(git_blob_filter(&buf, blob, "file.bin", NULL));
+	cl_assert_equal_s(ALL_LF_TEXT_RAW, buf.ptr);
+
+	cl_git_pass(git_blob_filter(&buf, blob, "file.crlf", NULL));
+	cl_assert_equal_s(ALL_LF_TEXT_AS_CRLF, buf.ptr);
+
+	cl_git_pass(git_blob_filter(&buf, blob, "file.lf", NULL));
+	cl_assert_equal_s(ALL_LF_TEXT_AS_LF, buf.ptr);
+
+	git_buf_dispose(&buf);
+	git_blob_free(blob);
+}
+
+void test_filter_systemattrs__disables_system_attributes(void)
+{
+	git_blob *blob;
+	git_buf buf = { 0 };
+	git_blob_filter_options opts = GIT_BLOB_FILTER_OPTIONS_INIT;
+
+	opts.flags |= GIT_BLOB_FILTER_NO_SYSTEM_ATTRIBUTES;
+
+	cl_git_pass(git_revparse_single(
+		(git_object **)&blob, g_repo, "799770d")); /* all-lf */
+
+	cl_assert_equal_s(ALL_LF_TEXT_RAW, git_blob_rawcontent(blob));
+
+	cl_git_pass(git_blob_filter(&buf, blob, "file.bin", &opts));
+	cl_assert_equal_s(ALL_LF_TEXT_RAW, buf.ptr);
+
+	/* No attributes mean these are all treated literally */
+	cl_git_pass(git_blob_filter(&buf, blob, "file.crlf", &opts));
+	cl_assert_equal_s(ALL_LF_TEXT_RAW, buf.ptr);
+
+	cl_git_pass(git_blob_filter(&buf, blob, "file.lf", &opts));
+	cl_assert_equal_s(ALL_LF_TEXT_RAW, buf.ptr);
+
+	git_buf_dispose(&buf);
+	git_blob_free(blob);
+}
diff --git a/tests/resources/crlf.git/HEAD b/tests/resources/crlf.git/HEAD
new file mode 100644
index 0000000..cb089cd
--- /dev/null
+++ b/tests/resources/crlf.git/HEAD
@@ -0,0 +1 @@
+ref: refs/heads/master
diff --git a/tests/resources/crlf.git/config b/tests/resources/crlf.git/config
new file mode 100644
index 0000000..a8e94d7
--- /dev/null
+++ b/tests/resources/crlf.git/config
@@ -0,0 +1,13 @@
+[core]
+	repositoryformatversion = 0
+	filemode = true
+	bare = false
+	logallrefupdates = true
+	ignorecase = true
+	precomposeunicode = true
+[remote "origin"]
+	url = /Users/ethomson/libgit2/libgit2-3/tests/resources/crlf.git
+	fetch = +refs/heads/*:refs/remotes/origin/*
+[branch "master"]
+	remote = origin
+	merge = refs/heads/master
diff --git a/tests/resources/crlf.git/logs/HEAD b/tests/resources/crlf.git/logs/HEAD
new file mode 100644
index 0000000..44f6651
--- /dev/null
+++ b/tests/resources/crlf.git/logs/HEAD
@@ -0,0 +1,2 @@
+0000000000000000000000000000000000000000 6b9d5748663795f573ea857276eb2a5f8330efa0 Edward Thomson <ethomson@edwardthomson.com> 1563721143 +0100	clone: from /Users/ethomson/libgit2/libgit2-3/tests/resources/crlf.git
+6b9d5748663795f573ea857276eb2a5f8330efa0 124f4293444614aa8da53be149792c2e43e9bfd9 Edward Thomson <ethomson@edwardthomson.com> 1563721187 +0100	commit: subdir with no translation
diff --git a/tests/resources/crlf.git/logs/refs/heads/master b/tests/resources/crlf.git/logs/refs/heads/master
new file mode 100644
index 0000000..44f6651
--- /dev/null
+++ b/tests/resources/crlf.git/logs/refs/heads/master
@@ -0,0 +1,2 @@
+0000000000000000000000000000000000000000 6b9d5748663795f573ea857276eb2a5f8330efa0 Edward Thomson <ethomson@edwardthomson.com> 1563721143 +0100	clone: from /Users/ethomson/libgit2/libgit2-3/tests/resources/crlf.git
+6b9d5748663795f573ea857276eb2a5f8330efa0 124f4293444614aa8da53be149792c2e43e9bfd9 Edward Thomson <ethomson@edwardthomson.com> 1563721187 +0100	commit: subdir with no translation
diff --git a/tests/resources/crlf.git/logs/refs/remotes/origin/HEAD b/tests/resources/crlf.git/logs/refs/remotes/origin/HEAD
new file mode 100644
index 0000000..6cca825
--- /dev/null
+++ b/tests/resources/crlf.git/logs/refs/remotes/origin/HEAD
@@ -0,0 +1 @@
+0000000000000000000000000000000000000000 6b9d5748663795f573ea857276eb2a5f8330efa0 Edward Thomson <ethomson@edwardthomson.com> 1563721143 +0100	clone: from /Users/ethomson/libgit2/libgit2-3/tests/resources/crlf.git
diff --git a/tests/resources/crlf.git/objects/04/4bcd5c9bf5ebdd51e514a9a36457018f06f6e1 b/tests/resources/crlf.git/objects/04/4bcd5c9bf5ebdd51e514a9a36457018f06f6e1
new file mode 100644
index 0000000..a32a9b2
--- /dev/null
+++ b/tests/resources/crlf.git/objects/04/4bcd5c9bf5ebdd51e514a9a36457018f06f6e1
@@ -0,0 +1 @@
+x-j0D{W4H++C(ɡ]aJU|}̃ʺ.
кVE@vȔvBx=%l
sDxH!x3E9AhPdUTk{k+Av`C2|h괟lR{~/]`z-̥<]M5?]udr&K!
\ No newline at end of file
diff --git a/tests/resources/crlf.git/objects/04/de00b358f13389948756732158eaaaefa1448c b/tests/resources/crlf.git/objects/04/de00b358f13389948756732158eaaaefa1448c
new file mode 100644
index 0000000..c3b7598
Binary files /dev/null and b/tests/resources/crlf.git/objects/04/de00b358f13389948756732158eaaaefa1448c differ
diff --git a/tests/resources/crlf.git/objects/09/7722be9b67b48dfe3b19396d02fd535300ee46 b/tests/resources/crlf.git/objects/09/7722be9b67b48dfe3b19396d02fd535300ee46
new file mode 100644
index 0000000..5c5c24c
Binary files /dev/null and b/tests/resources/crlf.git/objects/09/7722be9b67b48dfe3b19396d02fd535300ee46 differ
diff --git a/tests/resources/crlf.git/objects/0a/a76e474d259bd7c13eb726a1396c381db55c88 b/tests/resources/crlf.git/objects/0a/a76e474d259bd7c13eb726a1396c381db55c88
new file mode 100644
index 0000000..e118d66
Binary files /dev/null and b/tests/resources/crlf.git/objects/0a/a76e474d259bd7c13eb726a1396c381db55c88 differ
diff --git a/tests/resources/crlf.git/objects/0d/06894e14df22e066763ae906e0ed3eb79c205f b/tests/resources/crlf.git/objects/0d/06894e14df22e066763ae906e0ed3eb79c205f
new file mode 100644
index 0000000..b7a1f32
Binary files /dev/null and b/tests/resources/crlf.git/objects/0d/06894e14df22e066763ae906e0ed3eb79c205f differ
diff --git a/tests/resources/crlf.git/objects/0e/052888828a954ca17e5882638e3c6a083e75c0 b/tests/resources/crlf.git/objects/0e/052888828a954ca17e5882638e3c6a083e75c0
new file mode 100644
index 0000000..746143f
Binary files /dev/null and b/tests/resources/crlf.git/objects/0e/052888828a954ca17e5882638e3c6a083e75c0 differ
diff --git a/tests/resources/crlf.git/objects/0f/f5a53f19bfd2b5eea1ba550295c47515678987 b/tests/resources/crlf.git/objects/0f/f5a53f19bfd2b5eea1ba550295c47515678987
new file mode 100644
index 0000000..5366acd
Binary files /dev/null and b/tests/resources/crlf.git/objects/0f/f5a53f19bfd2b5eea1ba550295c47515678987 differ
diff --git a/tests/resources/crlf.git/objects/12/4f4293444614aa8da53be149792c2e43e9bfd9 b/tests/resources/crlf.git/objects/12/4f4293444614aa8da53be149792c2e43e9bfd9
new file mode 100644
index 0000000..29c6740
--- /dev/null
+++ b/tests/resources/crlf.git/objects/12/4f4293444614aa8da53be149792c2e43e9bfd9
@@ -0,0 +1,4 @@
+x]
+0})]m/l--Doo|IJKԡUf`"Ǩ=h쭱Q*.80yʹpBozp
+HH
+\*ҋj\֭d8swoKX(Z(~3bǴTx-m\UۃRxjU
\ No newline at end of file
diff --git a/tests/resources/crlf.git/objects/16/78031ee023a23bd3515e4e1693b661a69f0a73 b/tests/resources/crlf.git/objects/16/78031ee023a23bd3515e4e1693b661a69f0a73
new file mode 100644
index 0000000..4aa4ffb
Binary files /dev/null and b/tests/resources/crlf.git/objects/16/78031ee023a23bd3515e4e1693b661a69f0a73 differ
diff --git a/tests/resources/crlf.git/objects/16/c72b67861f8524a5bebc05cd20472d3fca00da b/tests/resources/crlf.git/objects/16/c72b67861f8524a5bebc05cd20472d3fca00da
new file mode 100644
index 0000000..e2b1994
Binary files /dev/null and b/tests/resources/crlf.git/objects/16/c72b67861f8524a5bebc05cd20472d3fca00da differ
diff --git a/tests/resources/crlf.git/objects/18/c637c5d9aba6eed226ee1840cd1ca2e6c4e4c5 b/tests/resources/crlf.git/objects/18/c637c5d9aba6eed226ee1840cd1ca2e6c4e4c5
new file mode 100644
index 0000000..790eb13
Binary files /dev/null and b/tests/resources/crlf.git/objects/18/c637c5d9aba6eed226ee1840cd1ca2e6c4e4c5 differ
diff --git a/tests/resources/crlf.git/objects/20/3555c5676d75cd80d69b50beb1f4b588c59ceb b/tests/resources/crlf.git/objects/20/3555c5676d75cd80d69b50beb1f4b588c59ceb
new file mode 100644
index 0000000..8038a9b
Binary files /dev/null and b/tests/resources/crlf.git/objects/20/3555c5676d75cd80d69b50beb1f4b588c59ceb differ
diff --git a/tests/resources/crlf.git/objects/23/f4582779e60bfa7f14750ad507399a58876611 b/tests/resources/crlf.git/objects/23/f4582779e60bfa7f14750ad507399a58876611
new file mode 100644
index 0000000..4a4e4dc
Binary files /dev/null and b/tests/resources/crlf.git/objects/23/f4582779e60bfa7f14750ad507399a58876611 differ
diff --git a/tests/resources/crlf.git/objects/2a/d3df895f68f4dda6a0a815c620b909bdd27c05 b/tests/resources/crlf.git/objects/2a/d3df895f68f4dda6a0a815c620b909bdd27c05
new file mode 100644
index 0000000..f5421cf
Binary files /dev/null and b/tests/resources/crlf.git/objects/2a/d3df895f68f4dda6a0a815c620b909bdd27c05 differ
diff --git a/tests/resources/crlf.git/objects/2b/55b4b94f655c857635b6a9005c056aa7de3532 b/tests/resources/crlf.git/objects/2b/55b4b94f655c857635b6a9005c056aa7de3532
new file mode 100644
index 0000000..031fd66
--- /dev/null
+++ b/tests/resources/crlf.git/objects/2b/55b4b94f655c857635b6a9005c056aa7de3532
@@ -0,0 +1,2 @@
+x-Kj0D)z2tca].OVȄ	zRݶԛAvyIfLi.υPɘL0d<=&b{O.09o4ŜI˔
+G_jk	-Yھ~XTW ذNjqKu:_ǣ]na.ZZk7!<#WF
\ No newline at end of file
diff --git a/tests/resources/crlf.git/objects/2b/d9d81b51a867352bab307b89cbb5b4a69adfe1 b/tests/resources/crlf.git/objects/2b/d9d81b51a867352bab307b89cbb5b4a69adfe1
new file mode 100644
index 0000000..96d952e
Binary files /dev/null and b/tests/resources/crlf.git/objects/2b/d9d81b51a867352bab307b89cbb5b4a69adfe1 differ
diff --git a/tests/resources/crlf.git/objects/2c/03f9f407b576eae80327864bab572e282a33ea b/tests/resources/crlf.git/objects/2c/03f9f407b576eae80327864bab572e282a33ea
new file mode 100644
index 0000000..0e4afbb
Binary files /dev/null and b/tests/resources/crlf.git/objects/2c/03f9f407b576eae80327864bab572e282a33ea differ
diff --git a/tests/resources/crlf.git/objects/33/cdead44e1c3ec178e39a4a69085280dbacf01b b/tests/resources/crlf.git/objects/33/cdead44e1c3ec178e39a4a69085280dbacf01b
new file mode 100644
index 0000000..72dc780
Binary files /dev/null and b/tests/resources/crlf.git/objects/33/cdead44e1c3ec178e39a4a69085280dbacf01b differ
diff --git a/tests/resources/crlf.git/objects/38/1cfe630df902bc29271a202d3277981180e4a6 b/tests/resources/crlf.git/objects/38/1cfe630df902bc29271a202d3277981180e4a6
new file mode 100644
index 0000000..0cf7072
Binary files /dev/null and b/tests/resources/crlf.git/objects/38/1cfe630df902bc29271a202d3277981180e4a6 differ
diff --git a/tests/resources/crlf.git/objects/3f/96bdca0e37616026afaa325c148cec4aa62d04 b/tests/resources/crlf.git/objects/3f/96bdca0e37616026afaa325c148cec4aa62d04
new file mode 100644
index 0000000..a204fc9
Binary files /dev/null and b/tests/resources/crlf.git/objects/3f/96bdca0e37616026afaa325c148cec4aa62d04 differ
diff --git a/tests/resources/crlf.git/objects/41/7786fc35b3c71aa546e3f95eb5da3c8dad8c41 b/tests/resources/crlf.git/objects/41/7786fc35b3c71aa546e3f95eb5da3c8dad8c41
new file mode 100644
index 0000000..ec57bde
Binary files /dev/null and b/tests/resources/crlf.git/objects/41/7786fc35b3c71aa546e3f95eb5da3c8dad8c41 differ
diff --git a/tests/resources/crlf.git/objects/47/fbc2c28a18df0dc773276a253eb85c7516ca50 b/tests/resources/crlf.git/objects/47/fbc2c28a18df0dc773276a253eb85c7516ca50
new file mode 100644
index 0000000..d16db96
Binary files /dev/null and b/tests/resources/crlf.git/objects/47/fbc2c28a18df0dc773276a253eb85c7516ca50 differ
diff --git a/tests/resources/crlf.git/objects/4b/825dc642cb6eb9a060e54bf8d69288fbee4904 b/tests/resources/crlf.git/objects/4b/825dc642cb6eb9a060e54bf8d69288fbee4904
new file mode 100644
index 0000000..adf6411
Binary files /dev/null and b/tests/resources/crlf.git/objects/4b/825dc642cb6eb9a060e54bf8d69288fbee4904 differ
diff --git a/tests/resources/crlf.git/objects/5a/fb6a14a864e30787857dd92af837e8cdd2cb1b b/tests/resources/crlf.git/objects/5a/fb6a14a864e30787857dd92af837e8cdd2cb1b
new file mode 100644
index 0000000..11a25c5
Binary files /dev/null and b/tests/resources/crlf.git/objects/5a/fb6a14a864e30787857dd92af837e8cdd2cb1b differ
diff --git a/tests/resources/crlf.git/objects/68/03c385642cebc8103fddd526ef395d75678a7e b/tests/resources/crlf.git/objects/68/03c385642cebc8103fddd526ef395d75678a7e
new file mode 100644
index 0000000..f8d489f
--- /dev/null
+++ b/tests/resources/crlf.git/objects/68/03c385642cebc8103fddd526ef395d75678a7e
@@ -0,0 +1,2 @@
+xKj0Ьu},!d	&hZ0QvgWuz9OAHvBh9!EM}cf52v%m`/=ZËMoeV3
+fr1pѓj8.[_
K^@kѡYj
\ No newline at end of file
diff --git a/tests/resources/crlf.git/objects/69/597764abeaa1a403ebf589d2ea579c6a8f877e b/tests/resources/crlf.git/objects/69/597764abeaa1a403ebf589d2ea579c6a8f877e
new file mode 100644
index 0000000..ee4f427
--- /dev/null
+++ b/tests/resources/crlf.git/objects/69/597764abeaa1a403ebf589d2ea579c6a8f877e
@@ -0,0 +1 @@
+xэ0a3Owr&%`NĎ-J!1|si`ݸkUȢr.*{zgr>ɱcbn\ui c.x"D,N,VuՒ.umgzL=@[kIǦismbY>!nJL
\ No newline at end of file
diff --git a/tests/resources/crlf.git/objects/6a/e3e9c11a51f0aabebcffcbd5c00f4beed143c9 b/tests/resources/crlf.git/objects/6a/e3e9c11a51f0aabebcffcbd5c00f4beed143c9
new file mode 100644
index 0000000..6c18a3a
Binary files /dev/null and b/tests/resources/crlf.git/objects/6a/e3e9c11a51f0aabebcffcbd5c00f4beed143c9 differ
diff --git a/tests/resources/crlf.git/objects/6b/9d5748663795f573ea857276eb2a5f8330efa0 b/tests/resources/crlf.git/objects/6b/9d5748663795f573ea857276eb2a5f8330efa0
new file mode 100644
index 0000000..680c7cd
--- /dev/null
+++ b/tests/resources/crlf.git/objects/6b/9d5748663795f573ea857276eb2a5f8330efa0
@@ -0,0 +1 @@
+xK0CYGk>B\`ҙ.ڠ0S7`g?˖,N3q1=GN:e[Rb	3{6ꎍWxL1GlqLnkDv((|T\腍:QW8F?纡.G0}0zZmt;+:AwE\YSm
\ No newline at end of file
diff --git a/tests/resources/crlf.git/objects/6c/589757f65a970a6cc07c71c3f3d2528c611cbc b/tests/resources/crlf.git/objects/6c/589757f65a970a6cc07c71c3f3d2528c611cbc
new file mode 100644
index 0000000..fe4da8c
--- /dev/null
+++ b/tests/resources/crlf.git/objects/6c/589757f65a970a6cc07c71c3f3d2528c611cbc
@@ -0,0 +1,2 @@
+x-KN0Y;PYpr5j#ǀ=nnF3iUUp$dKbN)OL)`Pf'VpCVY$SճcqVI:W
+oZ^tvӁGW9gL2<kM+Ko	|\ʺ;Nݱ>$81ÛeUer}.Q
\ No newline at end of file
diff --git a/tests/resources/crlf.git/objects/72/10e91413baa3d9b90215e970ae53397ecc526e b/tests/resources/crlf.git/objects/72/10e91413baa3d9b90215e970ae53397ecc526e
new file mode 100644
index 0000000..38c000d
Binary files /dev/null and b/tests/resources/crlf.git/objects/72/10e91413baa3d9b90215e970ae53397ecc526e differ
diff --git a/tests/resources/crlf.git/objects/77/afe26d93c49279ca90604c125496920753fede b/tests/resources/crlf.git/objects/77/afe26d93c49279ca90604c125496920753fede
new file mode 100644
index 0000000..a377cb0
Binary files /dev/null and b/tests/resources/crlf.git/objects/77/afe26d93c49279ca90604c125496920753fede differ
diff --git a/tests/resources/crlf.git/objects/78/db270c1841841f75a8157321bdcb50ab12e6c3 b/tests/resources/crlf.git/objects/78/db270c1841841f75a8157321bdcb50ab12e6c3
new file mode 100644
index 0000000..8a55bb0
Binary files /dev/null and b/tests/resources/crlf.git/objects/78/db270c1841841f75a8157321bdcb50ab12e6c3 differ
diff --git a/tests/resources/crlf.git/objects/79/9770d1cff46753a57db7a066159b5610da6e3a b/tests/resources/crlf.git/objects/79/9770d1cff46753a57db7a066159b5610da6e3a
new file mode 100644
index 0000000..5c701b8
Binary files /dev/null and b/tests/resources/crlf.git/objects/79/9770d1cff46753a57db7a066159b5610da6e3a differ
diff --git a/tests/resources/crlf.git/objects/7c/ce67e58173e2b01f7db124ceaabe3183d19c49 b/tests/resources/crlf.git/objects/7c/ce67e58173e2b01f7db124ceaabe3183d19c49
new file mode 100644
index 0000000..8e836ab
Binary files /dev/null and b/tests/resources/crlf.git/objects/7c/ce67e58173e2b01f7db124ceaabe3183d19c49 differ
diff --git a/tests/resources/crlf.git/objects/85/340755cfe5e28c2835781978bb1cece91b3d0f b/tests/resources/crlf.git/objects/85/340755cfe5e28c2835781978bb1cece91b3d0f
new file mode 100644
index 0000000..e83fbc2
Binary files /dev/null and b/tests/resources/crlf.git/objects/85/340755cfe5e28c2835781978bb1cece91b3d0f differ
diff --git a/tests/resources/crlf.git/objects/92/0e90a663bea5d740989d5f935f6dfb473a0c5d b/tests/resources/crlf.git/objects/92/0e90a663bea5d740989d5f935f6dfb473a0c5d
new file mode 100644
index 0000000..f872be6
Binary files /dev/null and b/tests/resources/crlf.git/objects/92/0e90a663bea5d740989d5f935f6dfb473a0c5d differ
diff --git a/tests/resources/crlf.git/objects/96/87e444bcbb85645cb496080434c292f1b57182 b/tests/resources/crlf.git/objects/96/87e444bcbb85645cb496080434c292f1b57182
new file mode 100644
index 0000000..5df64d8
--- /dev/null
+++ b/tests/resources/crlf.git/objects/96/87e444bcbb85645cb496080434c292f1b57182
@@ -0,0 +1 @@
+xAJ1@Q9E!T:Y	ޢRMAoGp/m7L*LQ)yEU(JqfP2Q1%L$QS	,xѾoz|xz󰾱I0{S@x轻}_wU+H50'2=T
\ No newline at end of file
diff --git a/tests/resources/crlf.git/objects/97/449da2d225557c558ac244384d487e66c3e591 b/tests/resources/crlf.git/objects/97/449da2d225557c558ac244384d487e66c3e591
new file mode 100644
index 0000000..d3917a4
Binary files /dev/null and b/tests/resources/crlf.git/objects/97/449da2d225557c558ac244384d487e66c3e591 differ
diff --git a/tests/resources/crlf.git/objects/9a/6c3533fef19abd6eec8e61206b5c51982b80d9 b/tests/resources/crlf.git/objects/9a/6c3533fef19abd6eec8e61206b5c51982b80d9
new file mode 100644
index 0000000..78fc8ae
Binary files /dev/null and b/tests/resources/crlf.git/objects/9a/6c3533fef19abd6eec8e61206b5c51982b80d9 differ
diff --git a/tests/resources/crlf.git/objects/9d/29b5bb165bf65637ffcb5ededb82ddd7c3fd13 b/tests/resources/crlf.git/objects/9d/29b5bb165bf65637ffcb5ededb82ddd7c3fd13
new file mode 100644
index 0000000..106332d
Binary files /dev/null and b/tests/resources/crlf.git/objects/9d/29b5bb165bf65637ffcb5ededb82ddd7c3fd13 differ
diff --git a/tests/resources/crlf.git/objects/a2/34455d62297f1856c4603686150c59fcb0aafe b/tests/resources/crlf.git/objects/a2/34455d62297f1856c4603686150c59fcb0aafe
new file mode 100644
index 0000000..7d204f4
Binary files /dev/null and b/tests/resources/crlf.git/objects/a2/34455d62297f1856c4603686150c59fcb0aafe differ
diff --git a/tests/resources/crlf.git/objects/a9/a2e8913c1dbe2812fac5e6b4e0a4bd5d0d5966 b/tests/resources/crlf.git/objects/a9/a2e8913c1dbe2812fac5e6b4e0a4bd5d0d5966
new file mode 100644
index 0000000..33d59f1
--- /dev/null
+++ b/tests/resources/crlf.git/objects/a9/a2e8913c1dbe2812fac5e6b4e0a4bd5d0d5966
@@ -0,0 +1 @@
+xKOR02aH.I$	
\ No newline at end of file
diff --git a/tests/resources/crlf.git/objects/aa/f083a9cb53dac3669dcfa0e48921580d629ec7 b/tests/resources/crlf.git/objects/aa/f083a9cb53dac3669dcfa0e48921580d629ec7
new file mode 100644
index 0000000..38775d0
Binary files /dev/null and b/tests/resources/crlf.git/objects/aa/f083a9cb53dac3669dcfa0e48921580d629ec7 differ
diff --git a/tests/resources/crlf.git/objects/af/6fcf6da196f615d7cda269b55b5c4ecfb4a5b3 b/tests/resources/crlf.git/objects/af/6fcf6da196f615d7cda269b55b5c4ecfb4a5b3
new file mode 100644
index 0000000..0acc974
Binary files /dev/null and b/tests/resources/crlf.git/objects/af/6fcf6da196f615d7cda269b55b5c4ecfb4a5b3 differ
diff --git a/tests/resources/crlf.git/objects/bb/29a7b46b5d4ba3ea17b238ae561b81d59dc818 b/tests/resources/crlf.git/objects/bb/29a7b46b5d4ba3ea17b238ae561b81d59dc818
new file mode 100644
index 0000000..a08789b
Binary files /dev/null and b/tests/resources/crlf.git/objects/bb/29a7b46b5d4ba3ea17b238ae561b81d59dc818 differ
diff --git a/tests/resources/crlf.git/objects/c3/e11722855ff260bd27418988ac1467c4e9e73a b/tests/resources/crlf.git/objects/c3/e11722855ff260bd27418988ac1467c4e9e73a
new file mode 100644
index 0000000..5f96dc7
Binary files /dev/null and b/tests/resources/crlf.git/objects/c3/e11722855ff260bd27418988ac1467c4e9e73a differ
diff --git a/tests/resources/crlf.git/objects/c8/d0b1ebcaccdd8f968c4aae3c2175e7fed651fe b/tests/resources/crlf.git/objects/c8/d0b1ebcaccdd8f968c4aae3c2175e7fed651fe
new file mode 100644
index 0000000..21e2ce0
--- /dev/null
+++ b/tests/resources/crlf.git/objects/c8/d0b1ebcaccdd8f968c4aae3c2175e7fed651fe
@@ -0,0 +1,2 @@
+x-Kn0C)f8od(t4#؈e9~;$RKI1*1;tf9Edb&1LʈPyk 0#*FeYtٱ{7opkuI^ec3Z?	NRI)c
+[^}|+?wTX
#ވ,L!5C^V>=R~
\ No newline at end of file
diff --git a/tests/resources/crlf.git/objects/cd/574f5a2baa4c79504f8837b730fa0b11defe99 b/tests/resources/crlf.git/objects/cd/574f5a2baa4c79504f8837b730fa0b11defe99
new file mode 100644
index 0000000..e8d0202
Binary files /dev/null and b/tests/resources/crlf.git/objects/cd/574f5a2baa4c79504f8837b730fa0b11defe99 differ
diff --git a/tests/resources/crlf.git/objects/cd/d3dacc5c0501d5ea57bbdf90e3d80176606139 b/tests/resources/crlf.git/objects/cd/d3dacc5c0501d5ea57bbdf90e3d80176606139
new file mode 100644
index 0000000..72cf3b0
Binary files /dev/null and b/tests/resources/crlf.git/objects/cd/d3dacc5c0501d5ea57bbdf90e3d80176606139 differ
diff --git a/tests/resources/crlf.git/objects/d1/1e7ef63ba7db1db3b1b99cdbafc57a8549f8a4 b/tests/resources/crlf.git/objects/d1/1e7ef63ba7db1db3b1b99cdbafc57a8549f8a4
new file mode 100644
index 0000000..05d88fc
Binary files /dev/null and b/tests/resources/crlf.git/objects/d1/1e7ef63ba7db1db3b1b99cdbafc57a8549f8a4 differ
diff --git a/tests/resources/crlf.git/objects/dc/88e3b917de821e25962bea7ec1f55c4ce2112c b/tests/resources/crlf.git/objects/dc/88e3b917de821e25962bea7ec1f55c4ce2112c
new file mode 100644
index 0000000..3db13aa
Binary files /dev/null and b/tests/resources/crlf.git/objects/dc/88e3b917de821e25962bea7ec1f55c4ce2112c differ
diff --git a/tests/resources/crlf.git/objects/de/5bfa165999d9d6c6dbafad2a7e709f93ec30fd b/tests/resources/crlf.git/objects/de/5bfa165999d9d6c6dbafad2a7e709f93ec30fd
new file mode 100644
index 0000000..e288b97
Binary files /dev/null and b/tests/resources/crlf.git/objects/de/5bfa165999d9d6c6dbafad2a7e709f93ec30fd differ
diff --git a/tests/resources/crlf.git/objects/e0/be8c0fa467f0a554484347c12802799d6c04fa b/tests/resources/crlf.git/objects/e0/be8c0fa467f0a554484347c12802799d6c04fa
new file mode 100644
index 0000000..b655485
Binary files /dev/null and b/tests/resources/crlf.git/objects/e0/be8c0fa467f0a554484347c12802799d6c04fa differ
diff --git a/tests/resources/crlf.git/objects/e1/379fd9942d04e7e80892b866d37bdb7da9e4e1 b/tests/resources/crlf.git/objects/e1/379fd9942d04e7e80892b866d37bdb7da9e4e1
new file mode 100644
index 0000000..01f8745
Binary files /dev/null and b/tests/resources/crlf.git/objects/e1/379fd9942d04e7e80892b866d37bdb7da9e4e1 differ
diff --git a/tests/resources/crlf.git/objects/e5/062da7d7802cf492975eda580f09ac4876bd88 b/tests/resources/crlf.git/objects/e5/062da7d7802cf492975eda580f09ac4876bd88
new file mode 100644
index 0000000..62835b9
--- /dev/null
+++ b/tests/resources/crlf.git/objects/e5/062da7d7802cf492975eda580f09ac4876bd88
@@ -0,0 +1 @@
+xQ1D)j'd2")xN,3x^AQj)UD`iJֻ>Fc:D&Rr.1#DǓ,HPϖ}9rPGŏ6	~a/}IDx$kj&_֨GZכ›|ǸU
\ No newline at end of file
diff --git a/tests/resources/crlf.git/objects/e6/9de29bb2d1d6434b8b29ae775ad8c2e48c5391 b/tests/resources/crlf.git/objects/e6/9de29bb2d1d6434b8b29ae775ad8c2e48c5391
new file mode 100644
index 0000000..7112238
Binary files /dev/null and b/tests/resources/crlf.git/objects/e6/9de29bb2d1d6434b8b29ae775ad8c2e48c5391 differ
diff --git a/tests/resources/crlf.git/objects/ea/030d3c6cec212069eca698cabaa5b4550f1511 b/tests/resources/crlf.git/objects/ea/030d3c6cec212069eca698cabaa5b4550f1511
new file mode 100644
index 0000000..117dc72
Binary files /dev/null and b/tests/resources/crlf.git/objects/ea/030d3c6cec212069eca698cabaa5b4550f1511 differ
diff --git a/tests/resources/crlf.git/objects/ea/a6ce5bc192f4c3c19354e7434c01e4686e95d7 b/tests/resources/crlf.git/objects/ea/a6ce5bc192f4c3c19354e7434c01e4686e95d7
new file mode 100644
index 0000000..e994143
Binary files /dev/null and b/tests/resources/crlf.git/objects/ea/a6ce5bc192f4c3c19354e7434c01e4686e95d7 differ
diff --git a/tests/resources/crlf.git/objects/ef/0dcd356d77221e9c27f4f3928ad28e80b87ceb b/tests/resources/crlf.git/objects/ef/0dcd356d77221e9c27f4f3928ad28e80b87ceb
new file mode 100644
index 0000000..33aceda
Binary files /dev/null and b/tests/resources/crlf.git/objects/ef/0dcd356d77221e9c27f4f3928ad28e80b87ceb differ
diff --git a/tests/resources/crlf.git/objects/f2/b745d7f47d114a3a6b31a7b628e61e804d1a58 b/tests/resources/crlf.git/objects/f2/b745d7f47d114a3a6b31a7b628e61e804d1a58
new file mode 100644
index 0000000..7b2e7a1
Binary files /dev/null and b/tests/resources/crlf.git/objects/f2/b745d7f47d114a3a6b31a7b628e61e804d1a58 differ
diff --git a/tests/resources/crlf.git/objects/f4/d25b796d86387205a5498175d66e91d1e5006a b/tests/resources/crlf.git/objects/f4/d25b796d86387205a5498175d66e91d1e5006a
new file mode 100644
index 0000000..792b165
Binary files /dev/null and b/tests/resources/crlf.git/objects/f4/d25b796d86387205a5498175d66e91d1e5006a differ
diff --git a/tests/resources/crlf.git/objects/fa/1385d99a319b43c06f5309d1aae9fdd3adea46 b/tests/resources/crlf.git/objects/fa/1385d99a319b43c06f5309d1aae9fdd3adea46
new file mode 100644
index 0000000..d0dda45
Binary files /dev/null and b/tests/resources/crlf.git/objects/fa/1385d99a319b43c06f5309d1aae9fdd3adea46 differ
diff --git a/tests/resources/crlf.git/objects/fe/085d9ace90cc675b87df15e1aeed0c3a31407f b/tests/resources/crlf.git/objects/fe/085d9ace90cc675b87df15e1aeed0c3a31407f
new file mode 100644
index 0000000..2e8d10b
Binary files /dev/null and b/tests/resources/crlf.git/objects/fe/085d9ace90cc675b87df15e1aeed0c3a31407f differ
diff --git a/tests/resources/crlf.git/objects/fe/ab3713c4659bb22700042b3c55b8d60d0a952b b/tests/resources/crlf.git/objects/fe/ab3713c4659bb22700042b3c55b8d60d0a952b
new file mode 100644
index 0000000..8552c7b
Binary files /dev/null and b/tests/resources/crlf.git/objects/fe/ab3713c4659bb22700042b3c55b8d60d0a952b differ
diff --git a/tests/resources/crlf.git/packed-refs b/tests/resources/crlf.git/packed-refs
new file mode 100644
index 0000000..33446e7
--- /dev/null
+++ b/tests/resources/crlf.git/packed-refs
@@ -0,0 +1,3 @@
+# pack-refs with: peeled fully-peeled sorted 
+9687e444bcbb85645cb496080434c292f1b57182 refs/remotes/origin/empty-files
+6b9d5748663795f573ea857276eb2a5f8330efa0 refs/remotes/origin/master
diff --git a/tests/resources/crlf.git/refs/heads/empty-files b/tests/resources/crlf.git/refs/heads/empty-files
new file mode 100644
index 0000000..8f1fe61
--- /dev/null
+++ b/tests/resources/crlf.git/refs/heads/empty-files
@@ -0,0 +1 @@
+9687e444bcbb85645cb496080434c292f1b57182
diff --git a/tests/resources/crlf.git/refs/heads/master b/tests/resources/crlf.git/refs/heads/master
new file mode 100644
index 0000000..97c85bc
--- /dev/null
+++ b/tests/resources/crlf.git/refs/heads/master
@@ -0,0 +1 @@
+124f4293444614aa8da53be149792c2e43e9bfd9
diff --git a/tests/resources/crlf.git/refs/remotes/origin/HEAD b/tests/resources/crlf.git/refs/remotes/origin/HEAD
new file mode 100644
index 0000000..6efe28f
--- /dev/null
+++ b/tests/resources/crlf.git/refs/remotes/origin/HEAD
@@ -0,0 +1 @@
+ref: refs/remotes/origin/master