Skip to content

Instantly share code, notes, and snippets.

@sigmaris
Created July 31, 2011 01:21
Show Gist options
  • Save sigmaris/3bcc088234d2de488258 to your computer and use it in GitHub Desktop.
Save sigmaris/3bcc088234d2de488258 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
import pygit2
#created by "git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git"
LINUX_REPO = '/home/hugh/linux/.git'
repo = pygit2.Repository(LINUX_REPO)
# this commit is "shm: optimize locking and ipc_namespace getting"
commit = repo['4c677e2eefdba9c5bfc4474e2e91b26ae8458a1d']
tree = commit.tree
include = repo[tree['include'].sha]
linux = repo[include['linux'].sha]
print("Is 'i2c' in include/linux (via iteration)? {0}".format(
reduce(lambda a,b: a or b, [entry.name == 'i2c' for entry in linux], False)
))
print("Is 'i2c' in include/linux (via 'in')? {0}".format('i2c' in linux))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment