git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: git rev-list

From
Junio C Hamano <junkio@cox.net>
Date
Jan 27, 2006, 07:35 UTC
Message-ID
<7vvew62ke7.fsf@assigned-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, "*>*"
Previous: Aneesh Kumar
Message 2 of 2 in “git rev-list”
  1. Aneesh KumarJan 27, 2006
  2. Junio C HamanoJan 27, 2006

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.