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/t4032-diff-inter-hunk-context.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 / t4032-diff-inter-hunk-context.sh` 125 lines ยท 2169 bytes Raw Blame History 1 #!/bin/sh 2 3 test_description='diff hunk fusing' 4 5 . ./test-lib.sh 6 7 f() { 8 echo $1 9 i=1 10 while test $i -le $2 11 do 12 echo $i 13 i=$(expr $i + 1) 14 done 15 echo $3 16 } 17 18 t() { 19 use_config= 20 git config --unset diff.interHunkContext || : 21 22 case $# in 23 4) hunks=$4; cmd="diff -U$3";; 24 5) hunks=$5; cmd="diff -U$3 --inter-hunk-context=$4";; 25 6) hunks=$5; cmd="diff -U$3"; git config diff.interHunkContext $4; use_config="(diff.interHunkContext=$4) ";; 26 esac 27 label="$use_config$cmd, $1 common $2" 28 file=f$1 29 expected=expected.$file.$3.$hunks 30 31 if ! test -f $file 32 then 33 f A $1 B >$file 34 git add $file 35 git commit -q -m. $file 36 f X $1 Y >$file 37 fi 38 39 test_expect_success "$label: count hunks ($hunks)" " 40 test $(git $cmd $file | grep '^@@ ' | wc -l) = $hunks 41 " 42 43 if test -f $expected 44 then 45 test_expect_success "$label: check output" " 46 git $cmd $file | grep -v '^index ' >actual && 47 test_cmp $expected actual 48 " 49 fi 50 } 51 52 cat <expected.f1.0.1 || exit 1 53 diff --git a/f1 b/f1 54 --- a/f1 55 +++ b/f1 56 @@ -1,3 +1,3 @@ 57 -A 58 +X 59 1 60 -B 61 +Y 62 EOF 63 64 cat <expected.f1.0.2 || exit 1 65 diff --git a/f1 b/f1 66 --- a/f1 67 +++ b/f1 68 @@ -1 +1 @@ 69 -A 70 +X 71 @@ -3 +3 @@ A 72 -B 73 +Y 74 EOF 75 76 # common lines ctx intrctx hunks 77 t 1 line 0 2 78 t 1 line 0 0 2 79 t 1 line 0 1 1 80 t 1 line 0 2 1 81 t 1 line 1 1 82 83 t 2 lines 0 2 84 t 2 lines 0 0 2 85 t 2 lines 0 1 2 86 t 2 lines 0 2 1 87 t 2 lines 1 1 88 89 t 3 lines 1 2 90 t 3 lines 1 0 2 91 t 3 lines 1 1 1 92 t 3 lines 1 2 1 93 94 t 9 lines 3 2 95 t 9 lines 3 2 2 96 t 9 lines 3 3 1 97 98 # use diff.interHunkContext? 99 t 1 line 0 0 2 config 100 t 1 line 0 1 1 config 101 t 1 line 0 2 1 config 102 t 9 lines 3 3 1 config 103 t 2 lines 0 0 2 config 104 t 2 lines 0 1 2 config 105 t 2 lines 0 2 1 config 106 t 3 lines 1 0 2 config 107 t 3 lines 1 1 1 config 108 t 3 lines 1 2 1 config 109 t 9 lines 3 2 2 config 110 t 9 lines 3 3 1 config 111 112 test_expect_success 'diff.interHunkContext invalid' ' 113 git config diff.interHunkContext asdf && 114 test_must_fail git diff && 115 git config diff.interHunkContext -1 && 116 test_must_fail git diff 117 ' 118 119 test_expect_success '--inter-hunk-context rejects negative value' ' 120 test_unconfig diff.interHunkContext && 121 test_must_fail git diff --inter-hunk-context=-1 2>err && 122 test_grep "expects a non-negative integer" err 123 ' 124 125 test_done