git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* Ascertaining amount of "original" code across files/repo
@ 2017-10-22 21:25 Thomas Adam
  2017-10-23  2:04 ` Junio C Hamano
  0 siblings, 1 reply; 2+ messages in thread
From: Thomas Adam @ 2017-10-22 21:25 UTC (permalink / raw)
  To: git

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-10-23  2:04 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-22 21:25 Ascertaining amount of "original" code across files/repo Thomas Adam
2017-10-23  2:04 ` Junio C Hamano

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).