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/t4100-apply-stat.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 / t4100-apply-stat.sh` 140 lines ยท 3181 bytes Raw Blame History 1 #!/bin/sh 2 # 3 # Copyright (c) 2005 Junio C Hamano 4 # 5 6 test_description='git apply --stat --summary test, with --recount 7 8 ' 9 10 . ./test-lib.sh 11 12 UNC='s/^\(@@ -[1-9][0-9]*\),[0-9]* \(+[1-9][0-9]*\),[0-9]* @@/\1,999 \2,999 @@/' 13 14 num=0 15 while read title 16 do 17 num=$(( $num + 1 )) 18 test_expect_success "$title" ' 19 git apply --stat --summary \ 20 <"$TEST_DIRECTORY/t4100/t-apply-$num.patch" >current && 21 test_cmp "$TEST_DIRECTORY"/t4100/t-apply-$num.expect current 22 ' 23 24 test_expect_success "$title with recount" ' 25 sed -e "$UNC" <"$TEST_DIRECTORY/t4100/t-apply-$num.patch" | 26 git apply --recount --stat --summary >current && 27 test_cmp "$TEST_DIRECTORY"/t4100/t-apply-$num.expect current 28 ' 29 done <<\EOF 30 rename 31 copy 32 rewrite 33 mode 34 non git (1) 35 non git (2) 36 non git (3) 37 incomplete (1) 38 incomplete (2) 39 EOF 40 41 test_expect_success 'applying a hunk header which overflows fails' ' 42 cat >patch <<-\EOF && 43 diff -u a/file b/file 44 --- a/file 45 +++ b/file 46 @@ -`98765432109876543210` +`98765432109876543210` @@ 47 -a 48 +b 49 EOF 50 test_must_fail git apply patch 2>err && 51 echo "error: corrupt patch at patch:4" >expect && 52 test_cmp expect err 53 ' 54 55 test_expect_success 'applying a hunk header which overflows from stdin fails' ' 56 cat >patch <<-\EOF && 57 diff -u a/file b/file 58 --- a/file 59 +++ b/file 60 @@ -`98765432109876543210` +`98765432109876543210` @@ 61 -a 62 +b 63 EOF 64 test_must_fail git apply err && 65 echo "error: corrupt patch at :4" >expect && 66 test_cmp expect err 67 ' 68 69 test_expect_success 'applying multiple patches reports the corrupted input' ' 70 cat >good.patch <<-\EOF && 71 diff -u a/file b/file 72 --- a/file 73 +++ b/file 74 @@ -1 +1 @@ 75 -a 76 +b 77 EOF 78 cat >bad.patch <<-\EOF && 79 diff -u a/file b/file 80 --- a/file 81 +++ b/file 82 @@ -`98765432109876543210` +`98765432109876543210` @@ 83 -a 84 +b 85 EOF 86 test_must_fail git apply --stat --summary good.patch bad.patch 2>err && 87 echo "error: corrupt patch at bad.patch:4" >expect && 88 test_cmp expect err 89 ' 90 91 test_expect_success 'applying a patch without a header reports the input' ' 92 cat >fragment.patch <<-\EOF && 93 @@ -1 +1 @@ 94 -a 95 +b 96 EOF 97 test_must_fail git apply fragment.patch 2>err && 98 echo "error: patch fragment without header at fragment.patch:1: @@ -1 +1 @@" >expect && 99 test_cmp expect err 100 ' 101 102 test_expect_success 'applying a patch with a missing filename reports the input' ' 103 cat >missing.patch <<-\EOF && 104 diff --git a/f b/f 105 index `7898192`..`6178079` 100644 106 --- a/f 107 @@ -1 +1 @@ 108 -a 109 +b 110 EOF 111 test_must_fail git apply missing.patch 2>err && 112 echo "error: git diff header lacks filename information at missing.patch:4" >expect && 113 test_cmp expect err 114 ' 115 116 test_expect_success 'applying a patch with an invalid mode reports the input' ' 117 cat >mode.patch <<-\EOF && 118 diff --git a/f b/f 119 old mode 10x644 120 EOF 121 test_must_fail git apply mode.patch 2>err && 122 cat >expect <<-\EOF && 123 error: invalid mode at mode.patch:2: 10x644 124 125 EOF 126 test_cmp expect err 127 ' 128 129 test_expect_success 'applying a patch with only garbage reports the input' ' 130 cat >garbage.patch <<-\EOF && 131 diff --git a/f b/f 132 --- a/f 133 +++ b/f 134 this is garbage 135 EOF 136 test_must_fail git apply garbage.patch 2>err && 137 echo "error: patch with only garbage at garbage.patch:4" >expect && 138 test_cmp expect err 139 ' 140 test_done