From 42d0ee8302c361a0e3bde7bc59858eda94bc13a4 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Sat, 6 May 2006 00:15:54 -0700 Subject: [PATCH] binary diff and apply: testsuite. Signed-off-by: Junio C Hamano --- t/t4012-diff-binary.sh | 85 +++++++++++++++++++++++++++++++++++++++++ t/test4012.png | Bin 0 -> 5660 bytes 2 files changed, 85 insertions(+) create mode 100755 t/t4012-diff-binary.sh create mode 100644 t/test4012.png diff --git a/t/t4012-diff-binary.sh b/t/t4012-diff-binary.sh new file mode 100755 index 000000000..bdd95c0d3 --- /dev/null +++ b/t/t4012-diff-binary.sh @@ -0,0 +1,85 @@ +#!/bin/sh +# +# Copyright (c) 2006 Junio C Hamano +# + +test_description='Binary diff and apply +' + +. ./test-lib.sh + +test_expect_success 'prepare repository' \ + 'echo AIT >a && echo BIT >b && echo CIT >c && echo DIT >d && + git-update-index --add a b c d && + echo git >a && + cat ../test4012.png >b && + echo git >c && + cat b b >d' + +test_expect_success 'diff without --binary' \ + 'git-diff | git-apply --stat --summary >current && + cmp current - <<\EOF + a | 2 +- + b | Bin + c | 2 +- + d | Bin + 4 files changed, 2 insertions(+), 2 deletions(-) +EOF' + +test_expect_success 'diff with --binary' \ + 'git-diff --binary | git-apply --stat --summary >current && + cmp current - <<\EOF + a | 2 +- + b | Bin + c | 2 +- + d | Bin + 4 files changed, 2 insertions(+), 2 deletions(-) +EOF' + +# apply needs to be able to skip the binary material correctly +# in order to report the line number of a corrupt patch. +test_expect_success 'apply detecting corrupt patch correctly' \ + 'git-diff | sed -e 's/-CIT/xCIT/' >broken && + if git-apply --stat --summary broken 2>detected + then + echo unhappy - should have detected an error + (exit 1) + else + echo happy + fi && + detected=`cat detected` && + detected=`expr "$detected" : "fatal.*at line \\([0-9]*\\)\$"` && + detected=`sed -ne "${detected}p" broken` && + test "$detected" = xCIT' + +test_expect_success 'apply detecting corrupt patch correctly' \ + 'git-diff --binary | sed -e 's/-CIT/xCIT/' >broken && + if git-apply --stat --summary broken 2>detected + then + echo unhappy - should have detected an error + (exit 1) + else + echo happy + fi && + detected=`cat detected` && + detected=`expr "$detected" : "fatal.*at line \\([0-9]*\\)\$"` && + detected=`sed -ne "${detected}p" broken` && + test "$detected" = xCIT' + +test_expect_success 'initial commit' 'git-commit -a -m initial' + +# Try removal (b), modification (d), and creation (e). +test_expect_success 'diff-index with --binary' \ + 'echo AIT >a && mv b e && echo CIT >c && cat e >d && + git-update-index --add --remove a b c d e && + tree0=`git-write-tree` && + git-diff --cached --binary >current && + git-apply --stat --summary current' + +test_expect_success 'apply binary patch' \ + 'git-reset --hard && + git-apply --binary --index sqc34tLUx=XqS5RmRtNT#adw*x2I9+WOA_7_h002OwrmCoqmhk@u9uE2`GlnCC7C6=# zDvE$&03+ax@KXu}T7&PQYT^X|JZJfDVEBKL^+hXjz16goaObeGK-d!bT|z-<6`i+| zvA2S|tE-)xH$cJD&dS@)meJ4A+kx?wgB_!anwIXVEt?wvKoO>7>Bb1@wA( z;IT7g@ymCuJiLhbPfJr|i5H4;)mjji#JOK|U)hzPX8i5ho0BF*QXf6}{V_RmjX^h8 zBX9QX=3g&vi&AGE{oEKtLP%V(w6-2<2(l+h-nm!Hmw@v)rNU2(v7(ZQ1OQ+h$~Qc!!FTf57o zu@)h>i~DEs@uRKF6UyxAS&3G<*BiMjfLv_bQk;T##&v(4!pgG<+=YYE3cc(axf8D9 zEEhtoFt%jRU1M;}oLSBkd3UE+Bp6q6dcVEAvKKT8h56DsbkcsuTR<;ULeL+`fsARWL=kI0d{qqjDcA8beq&VqMECGM`@nbtHGW~M zVgSM};mmy>`nnA#(QCN?Baj(X%|*?D80!1maWLA8wjEi;G#0;OVGMoH)_Pcp$ery0 zjs>Q-gtJ$l@)T}w%&Z^$)Y2wNbTYowJmp2ztd9e|I_BXcEKR<=vvYxUi1R{eofw4( zMn>91(?+TULadq}xsDau-@@Y(1<-!VbRi6SK0dN5AE40;n;cI&kg4VgwFoy&V_kkw zMpno-g;(Q79&+8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