git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v2 1/1] contrib: add coverage-diff script

From
Derrick Stolee <stolee@gmail.com>
Date
Sep 13, 2018, 18:15 UTC
Message-ID
<3ba684df-f6eb-1ebb-2421-160b89b2f246@gmail.com>
In-Reply-To
<xmqqzhwlfg7o.fsf@gitster-ct.c.googlers.com>
On 9/13/2018 1:40 PM, Junio C Hamano wrote:
Show 39 quoted lines
> "Derrick Stolee via GitGitGadget" <gitgitgadget@gmail.com> writes:
>> +			then
>> +				line_num=$(($line_num + 1))
>> +			fi
>> +		fi
>> +	done
> I have a feeling that a single Perl script instead of a shell loop
> that runs many grep and awk as subprocesses performs better even on
> Windows, and it would be more readable and maintainable.
>
> perl -e '
> 	my $line_num;
> 	while (<>) {
> 		# Hunk header?  Grab the beginning in postimage.
> 		if (/^@@ -\d+(?:,\d+)? \+(\d+)(?:,\d+)? @@/) {
> 			$line_num = $1;
> 			next;
> 		}
>
> 		# Have we seen a hunk?  Ignore "diff --git" etc.
> 		next unless defined $line_num;
>
> 		# Deleted line? Ignore.
> 		if (/^-/) {
> 			next;
> 		}
>
> 		# Show only the line number of added lines.
> 		if (/^\+/) {
> 			print "$line_num\n";
> 		}
> 		# Either common context or added line appear in
> 		# the postimage.  Count it.
> 		$line_num++;
> 	}
> '
>
> or something like that, given that you seem to only need line
> numbers in new_lines.txt anyway?

Thanks for the deep dive here, especially with the perl assistance. I've never written any perl, but it seems like the right tool here. I'll have time to revisit this next week.

Thanks,
-Stolee
Previous: Junio C HamanoNext: Eric Sunshine
Message 13 of 22 in “contrib: Add script to show uncovered "new" lines”
  1. 0/1 contrib: Add script to show uncovered "new" linesDerrick Stolee via GitGitGadget, Sep 12, 2018
  2. 1/1 contrib: add coverage-diff scriptDerrick Stolee via GitGitGadget, Sep 12, 2018
  3. Junio C HamanoSep 12, 2018
  4. Junio C HamanoSep 12, 2018
  5. Derrick StoleeSep 13, 2018
  6. Junio C HamanoSep 13, 2018
  7. Derrick StoleeSep 12, 2018
  8. Ben PeartSep 12, 2018
  9. Junio C HamanoSep 12, 2018
  10. 0/1 contrib: Add script to show uncovered "new" linesDerrick Stolee via GitGitGadget, Sep 13, 2018
  11. 1/1 contrib: add coverage-diff scriptDerrick Stolee via GitGitGadget, Sep 13, 2018
  12. Junio C HamanoSep 13, 2018
  13. Derrick StoleeSep 13, 2018
  14. Eric SunshineSep 13, 2018
  15. 0/1 contrib: Add script to show uncovered "new" linesDerrick Stolee via GitGitGadget, Sep 21, 2018
  16. 1/1 contrib: add coverage-diff scriptDerrick Stolee via GitGitGadget, Sep 21, 2018
  17. Junio C HamanoSep 25, 2018
  18. Derrick StoleeSep 21, 2018
  19. 0/1 contrib: Add script to show uncovered "new" linesDerrick Stolee via GitGitGadget, Oct 8, 2018
  20. 1/1 contrib: add coverage-diff scriptDerrick Stolee via GitGitGadget, Oct 8, 2018
  21. Junio C HamanoOct 12, 2018
  22. Derrick StoleeOct 12, 2018

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.