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

Ascertaining amount of "original" code across files/repo

From
Thomas Adam <thomas@xteddy.org>
Date
Oct 22, 2017, 21:25 UTC
Message-ID
<20171022212505.wxdpfaevxw7fsn7e@laptop.local>
Hi all,

I was recently left with an interesting problem of looking at a heuristic to determine how much original code was left in a repository. Or to put another way, how much the code had changed since. In my case "original code" means "since the initial commit", as this code base had been imported from CVS long ago; and that was the correct starting point.

What I came up with was the following heuristic. What I'm curious to know is whether there's an alternative way to look at this and/or if such tooling already exists.

What I did was first of all ascertain the number of original lines in each of the files I was interested in:

	for i in *.[ch]
	do
		c="$(git --no-pager blame "$i" | grep -c '^\^')"
		[ $c -gt 0 ] && echo "$i:$c"
	done | sort -t':' -k2 -nr

Given this, I then did some maths on the total lines from each of those files and to work out a percentage by file, and over all.

What I'm curious to know is whether this approach of using "git blame" is a good approach or not.

Thanks for your time.
-- Thomas Adam
Next: Junio C Hamano
Message 1 of 2 in “Ascertaining amount of "original" code across files/repo”
  1. Thomas AdamOct 22, 2017
  2. Junio C HamanoOct 23, 2017

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.