Re: git rev-list
Aneesh Kumar <aneesh.kumar@gmail.com> writes:
> ... I use
> git-rev-list to get the revision list. What i found is that from the
> second commit on wards i am finding some control character at the
> beginning of the first line with respect to each commit.
If you are using "git-rev-list --header" format, it uses an ASCII NUL (0) to delimit each record. Technically, it is not "beginning of the first line starting from the second commit", but "at the end of each commit".
With Perl, you would read such NUL separated record by:
local $/ = "\0";
my $item = <>;
Admittedly my Python is quite rusty, and I do not offhand recall there was no such "line separator is NUL instead of normal LF" configuration on readable file objects. You may need to do something ugly like this:
-- >8 -- import os
def rev_list(rev_range):
revlist = os.popen('git rev-list --header %s' % rev_range)
stash = []
while 1:
line = revlist.readline()
if line == '':
break
if line[0] == '\0':
yield ''.join(stash)
stash = []
line = line[1:]
if line == '':
break
stash.append(line)
if len(stash):
yield ''.join(stash)for commit in rev_list('master..pu'):
# Use commit which is from a single record..
print "*<*", commit, "*>*"