Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/git/blob/master/t/t4125-apply-ws-fuzz.sh # git [Ported from github.com/git/git] Sync with Git 2.56.1 Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `master` Branches Tags History `git / t / t4125-apply-ws-fuzz.sh` 100 lines ยท 2258 bytes Raw Blame History 1 #!/bin/sh 2 3 test_description='applying patch that has broken whitespaces in context' 4 5 . ./test-lib.sh 6 7 test_expect_success setup ' 8 9 >file && 10 git add file && 11 12 # file-0 is full of whitespace breakages 13 printf "%s \n" a bb c d eeee f ggg h >file-0 && 14 15 # patch-0 creates a whitespace broken file 16 cat file-0 >file && 17 git diff >patch-0 && 18 git add file && 19 20 # file-1 is still full of whitespace breakages, 21 # but has one line updated, without fixing any 22 # whitespaces. 23 # patch-1 records that change. 24 sed -e "s/d/D/" file-0 >file-1 && 25 cat file-1 >file && 26 git diff >patch-1 && 27 28 # patch-all is the effect of both patch-0 and patch-1 29 >file && 30 git add file && 31 cat file-1 >file && 32 git diff >patch-all && 33 34 # patch-2 is the same as patch-1 but is based 35 # on a version that already has whitespace fixed, 36 # and does not introduce whitespace breakages. 37 sed -e "s/ \$//" patch-1 >patch-2 && 38 39 # If all whitespace breakages are fixed the contents 40 # should look like file-fixed 41 sed -e "s/ \$//" file-1 >file-fixed 42 43 ' 44 45 test_expect_success nofix ' 46 47 >file && 48 git add file && 49 50 # Baseline. Applying without fixing any whitespace 51 # breakages. 52 git apply --whitespace=nowarn patch-0 && 53 git apply --whitespace=nowarn patch-1 && 54 55 # The result should obviously match. 56 test_cmp file-1 file 57 ' 58 59 test_expect_success 'withfix (forward)' ' 60 61 >file && 62 git add file && 63 64 # The first application will munge the context lines 65 # the second patch depends on. We should be able to 66 # adjust and still apply. 67 git apply --whitespace=fix patch-0 && 68 git apply --whitespace=fix patch-1 && 69 70 test_cmp file-fixed file 71 ' 72 73 test_expect_success 'withfix (backward)' ' 74 75 >file && 76 git add file && 77 78 # Now we have a whitespace breakages on our side. 79 git apply --whitespace=nowarn patch-0 && 80 81 # And somebody sends in a patch based on image 82 # with whitespace already fixed. 83 git apply --whitespace=fix patch-2 && 84 85 # The result should accept the whitespace fixed 86 # postimage. But the line with "h" is beyond context 87 # horizon and left unfixed. 88 89 sed -e /h/d file-fixed >fixed-head && 90 sed -e /h/d file >file-head && 91 test_cmp fixed-head file-head && 92 93 sed -n -e /h/p file-fixed >fixed-tail && 94 sed -n -e /h/p file >file-tail && 95 96 ! test_cmp fixed-tail file-tail 97 98 ' 99 100 test_done