From 49c689276d750dbc78fe7a5d0ff27e6d2278fcd4 Mon Sep 17 00:00:00 2001 From: Jonathan Corbet Date: Wed, 17 Feb 2010 08:29:40 -0700 Subject: [PATCH] Add findoldfiles YA brutal hack; this one crawls the tree and prints out files which have not been touched since the original commit. Signed-off-by: Jonathan Corbet --- findoldfiles | 27 ++++++++++++++++++ linetags | 77 ---------------------------------------------------- 2 files changed, 27 insertions(+), 77 deletions(-) create mode 100755 findoldfiles delete mode 100755 linetags diff --git a/findoldfiles b/findoldfiles new file mode 100755 index 0000000..fdf2ba1 --- /dev/null +++ b/findoldfiles @@ -0,0 +1,27 @@ +#!/usr/bin/python +# +# Another quick hack of a script to find files unchanged +# since a given commit. +# +import sys, os + +OriginalSin = '1da177e4c3f41524e886b7f1b8a0c1fc7321cac2' + +def CheckFile(file): + git = os.popen('git log --pretty=oneline -1 ' + file, 'r') + line = git.readline() + if line.startswith(OriginalSin): + print file + git.close() +# +# Here we just plow through all the files. +# +if len(sys.argv) != 2: + sys.stderr.write('Usage: findoldfiles directory\n') + sys.exit(1) + +os.chdir(sys.argv[1]) +files = os.popen('/usr/bin/find . -type f', 'r') +for file in files.readlines(): + if file.find('.git/') < 0: + CheckFile(file[:-1]) diff --git a/linetags b/linetags deleted file mode 100755 index 767e399..0000000 --- a/linetags +++ /dev/null @@ -1,77 +0,0 @@ -#!/usr/bin/python -# -# Find out how many lines were introduced in each major release. -# -# linetags -# -import sys, re, os, pickle - -CommitLines = { } - -commitpat = re.compile(r'^([\da-f][\da-f]+) ') - -def GetCommitLines(file): - print file - blame = os.popen('git blame -p ' + file, 'r') - for line in blame.readlines(): - m = commitpat.search(line) - # - # All-zero commits mean we got fed a file that git doesn't - # know about. We could throw an exception and abort processing - # now, or we can just silently ignore it... - # - if not m or m.group(1) == '0000000000000000000000000000000000000000': - continue - try: - CommitLines[m.group(1)] += 1 - except KeyError: - CommitLines[m.group(1)] = 1 - blame.close() - -# -# Try to figure out which tag is the first to contain each commit. -# -refpat = re.compile(r'^(v2\.6\.\d\d).*$') -def CommitToTag(commit): - try: - return DB[commit] - except KeyError: - print 'Missing commit %s' % (commit) - return 'WTF?' - -TagLines = { } -def MapCommits(): - print 'Mapping tags...' - for commit in CommitLines.keys(): - tag = CommitToTag(commit) - try: - TagLines[tag] += CommitLines[commit] - except KeyError: - TagLines[tag] = CommitLines[commit] - -# -# Here we just plow through all the files. -# -if len(sys.argv) != 2: - sys.stderr.write('Usage: linetags directory\n') - sys.exit(1) -# -# Grab the tags/version database. -# -dbf = open('committags.db', 'r') -DB = pickle.load(dbf) -dbf.close() - -out = open('linetags.out', 'w') -os.chdir(sys.argv[1]) -files = os.popen('/usr/bin/find . -type f', 'r') -for file in files.readlines(): - if file.find('.git/') < 0: - GetCommitLines(file[:-1]) -MapCommits() -# print TagLines -tags = TagLines.keys() -tags.sort() -for tag in tags: - out.write('%s %d\n' % (tag, TagLines[tag])) -out.close() -- 2.39.5