Skip to content

Instantly share code, notes, and snippets.

@simos
Created October 24, 2014 11:31
Show Gist options
  • Save simos/8d4666fa3edd1c52fce2 to your computer and use it in GitHub Desktop.
Save simos/8d4666fa3edd1c52fce2 to your computer and use it in GitHub Desktop.
Align a tarball to a commit in a git repository
#!/usr/bin/env python
import os
import subprocess
# We want to reach back to a commit where the following file is identical in the tarball.
FILENAME="page_alloc.c"
# We created this file with: git log | grep '^commit' | awk '{ print $2}' > /tmp/commit-list.txt
commit_file = open("/tmp/commit-list.txt", "r")
all_commits = commit_file.readlines()
for commit in all_commits:
subprocess.call(["git", "checkout", commit.rstrip()])
ret = subprocess.call(["diff", FILENAME, "../../linux-3.4-sunxi/mm/" + FILENAME])
# If this checked out version has a FILENAME file that matches the one from the tarbal,
if ret == 0:
print "MATCH! At commit", commit
break
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment