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/tools/coverage-diff.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 / tools / coverage-diff.sh` 103 lines ยท 2066 bytes Raw Blame History 1 #!/bin/sh 2 3 # Usage: Run 'contrib/coverage-diff.sh ' from source-root 4 # after running 5 # 6 # make coverage-test 7 # make coverage-report 8 # 9 # while checked out at . This script combines the *.gcov files 10 # generated by the 'make' commands above with 'git diff ' 11 # to report new lines that are not covered by the test suite. 12 13 V1=$1 14 V2=$2 15 16 diff_lines () { 17 perl -e ' 18 my $line_num; 19 while (<>) { 20 # Hunk header? Grab the beginning in postimage. 21 if (/^@@ -\d+(?:,\d+)? \+(\d+)(?:,\d+)? @@/) { 22 $line_num = $1; 23 next; 24 } 25 26 # Have we seen a hunk? Ignore "diff --git" etc. 27 next unless defined $line_num; 28 29 # Deleted line? Ignore. 30 if (/^-/) { 31 next; 32 } 33 34 # Show only the line number of added lines. 35 if (/^\+/) { 36 print "$line_num\n"; 37 } 38 # Either common context or added line appear in 39 # the postimage. Count it. 40 $line_num++; 41 } 42 ' 43 } 44 45 files=$(git diff --name-only "$V1" "$V2" -- \*.c) 46 47 # create empty file 48 >coverage-data.txt 49 50 for file in $files 51 do 52 git diff "$V1" "$V2" -- "$file" | 53 diff_lines | 54 sort >new_lines.txt 55 56 if ! test -s new_lines.txt 57 then 58 continue 59 fi 60 61 hash_file=$(echo $file | sed "s/\//\#/") 62 63 if ! test -s "$hash_file.gcov" 64 then 65 continue 66 fi 67 68 sed -ne '/#####:/{ 69 s/ #####:// 70 s/:.*// 71 s/ //g 72 p 73 }' "$hash_file.gcov" | 74 sort >uncovered_lines.txt 75 76 comm -12 uncovered_lines.txt new_lines.txt | 77 sed -e 's/$/\)/' -e 's/^/ /' >uncovered_new_lines.txt 78 79 grep -q '[^[:space:]]' >coverage-data.txt && 81 git blame -s "$V2" -- "$file" | 82 sed 's/\t//g' | 83 grep -f uncovered_new_lines.txt >>coverage-data.txt && 84 echo >>coverage-data.txt 85 86 rm -f new_lines.txt uncovered_lines.txt uncovered_new_lines.txt 87 done 88 89 cat coverage-data.txt 90 91 echo "Commits introducing uncovered code:" 92 93 commit_list=$(awk '/^[0-9a-f]{7,}/ { print $1 }' coverage-data.txt | sort -u) 94 95 ( 96 for commit in $commit_list 97 do 98 git log --no-decorate --pretty=format:'%an %h: %s' -1 $commit 99 echo 100 done 101 ) | sort 102 103 rm coverage-data.txt