From 802015246db6ad73e5024f3d2f557c3bc4046938 Mon Sep 17 00:00:00 2001 From: Julien Miotte Date: Tue, 12 Jul 2011 18:42:43 +0200 Subject: [PATCH] Small improvements of the documentation (commit and iterable trees) --- README.md | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 0519880..daa2824 100644 --- a/README.md +++ b/README.md @@ -49,7 +49,7 @@ Index read: Iterate over all entries of the index: - >>> for i in range(0, len(index)): + >>> for i in xrange(len(index)): ... entry = index[i] ... print entry.path, entry.sha @@ -65,6 +65,18 @@ Revision walking: >>> for commit in repo.walk(sha, GIT_SORT_TIME): ... print commit.sha +Read commit information: + + >>> master_ref = repo.lookup_reference("refs/heads/master") # Getting the Reference object + >>> commit = repo[master_ref.sha] + >>> [name, email, timestamp, tz_offset] = commit.author # Read the commit authored infos + >>> tree = commit.tree # Access the tree of the commit + +Iterate over all entries of the tree: + + >>> for entry in tree: + ... print entry.name, entry.sha, entry.attributes + CONTRIBUTING ==============