threads / discuss / 3162

git rev-list

Subject: git rev-list

## tl;dr

2 messages between Jan 27, 2006 and Jan 27, 2006.

replies: 1people: 2as markdown or json

Aneesh Kumar· Jan 27, 2006, 03:46 UTC · lore

I am right now making a gnome based git repository browser [1] . 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. You can reproduce it easily by redirecting the output to a file and reading the file using vi. I am using the latest git built from git repository

[1] http://www.flickr.com/photos/17388011@N00/91636482/ This is based on bzrk GUI frontend to bazaar and written in python

-aneesh
Junio C Hamano· Jan 27, 2006, 07:35 UTC · re: Aneesh Kumar · lore

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, "*>*"

← back to recent threads