# git rev-list

2 messages from 2006-01-27 to 2006-01-27. Participants: Aneesh Kumar, Junio C Hamano.
Thread: https://gitlist.dev/t/3162

## Aneesh Kumar, 2006-01-27 03:46

Subject: git rev-list
Message-ID: <cc723f590601261946h101d7000oa1990c31c5b642fc@mail.gmail.com>
URL: https://gitlist.dev/e/cc723f590601261946h101d7000oa1990c31c5b642fc%40mail.gmail.com

```
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, 2006-01-27 07:35

Subject: Re: git rev-list
Message-ID: <7vvew62ke7.fsf@assigned-by-dhcp.cox.net>
URL: https://gitlist.dev/e/7vvew62ke7.fsf%40assigned-by-dhcp.cox.net
In-Reply-To: <cc723f590601261946h101d7000oa1990c31c5b642fc@mail.gmail.com>

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

```
