@@ -850,6 +850,87 @@ test_expect_success '--replace-text all options' '
850
850
)
851
851
'
852
852
853
+ test_expect_success ' --replace-text binary zero_byte-0_char' '
854
+ (
855
+ set -e
856
+ set -u
857
+ REPO=replace-text-detect-binary
858
+ FILE=mangle.bin
859
+ OLD_STR=replace-from
860
+ NEW_STR=replace-with
861
+ # used with printf, contains a zero byte and a "0" character, binary
862
+ OLD_CONTENT_FORMAT="${OLD_STR}\\0${OLD_STR}\\n0\\n"
863
+ # expect content unchanged due to binary
864
+ NEW_CONTENT_FORMAT="${OLD_CONTENT_FORMAT}"
865
+
866
+ rm -rf "${REPO}"
867
+ git init "${REPO}"
868
+ cd "${REPO}"
869
+ echo "${OLD_STR}==>${NEW_STR}" >../replace-rules
870
+ printf "${NEW_CONTENT_FORMAT}" > ../expect
871
+ printf "${OLD_CONTENT_FORMAT}" > "${FILE}"
872
+ git add "${FILE}"
873
+ git commit -m ' test'
874
+ git filter-repo --force --replace-text ../replace-rules
875
+
876
+ test_cmp ../expect "${FILE}"
877
+ )
878
+ '
879
+
880
+ test_expect_success ' --replace-text binary zero_byte-no_0_char' '
881
+ (
882
+ set -e
883
+ set -u
884
+ REPO=replace-text-detect-binary
885
+ FILE=mangle.bin
886
+ OLD_STR=replace-from
887
+ NEW_STR=replace-with
888
+ # used with printf, contains a zero byte but no "0" character, binary
889
+ OLD_CONTENT_FORMAT="${OLD_STR}\\0${OLD_STR}\\n"
890
+ # expect content unchanged due to binary
891
+ NEW_CONTENT_FORMAT="${OLD_CONTENT_FORMAT}"
892
+
893
+ rm -rf "${REPO}"
894
+ git init "${REPO}"
895
+ cd "${REPO}"
896
+ echo "${OLD_STR}==>${NEW_STR}" >../replace-rules
897
+ printf "${NEW_CONTENT_FORMAT}" > ../expect
898
+ printf "${OLD_CONTENT_FORMAT}" > "${FILE}"
899
+ git add "${FILE}"
900
+ git commit -m ' test'
901
+ git filter-repo --force --replace-text ../replace-rules
902
+
903
+ test_cmp ../expect "${FILE}"
904
+ )
905
+ '
906
+
907
+ test_expect_success ' --replace-text text-file no_zero_byte-zero_char' '
908
+ (
909
+ set -e
910
+ set -u
911
+ REPO=replace-text-detect-binary
912
+ FILE=mangle.bin
913
+ OLD_STR=replace-from
914
+ NEW_STR=replace-with
915
+ # used with printf, contains no zero byte but contains a "0" character, text
916
+ OLD_CONTENT_FORMAT="${OLD_STR}0\\n0${OLD_STR}\\n0\\n"
917
+ # expect content changed due to text
918
+ NEW_CONTENT_FORMAT="${NEW_STR}0\\n0${NEW_STR}\\n0\\n"
919
+
920
+ rm -rf "${REPO}"
921
+ git init "${REPO}"
922
+ cd "${REPO}"
923
+ echo "${OLD_STR}==>${NEW_STR}" >../replace-rules
924
+ printf "${NEW_CONTENT_FORMAT}" > ../expect
925
+ printf "${OLD_CONTENT_FORMAT}" > "${FILE}"
926
+ git add "${FILE}"
927
+ git commit -m ' test'
928
+ git filter-repo --force --replace-text ../replace-rules
929
+
930
+ test_cmp ../expect "${FILE}"
931
+ )
932
+ '
933
+
853
934
test_expect_success ' --strip-blobs-bigger-than' '
854
935
setup_analyze_me &&
855
936
(
0 commit comments