{"thread":{"id":"3162","subject":"git rev-list","startedAt":"2006-01-27T03:46:58Z","lastAt":"2006-01-27T07:35:28Z","messageCount":2,"participants":["Aneesh Kumar","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"15160","messageId":"cc723f590601261946h101d7000oa1990c31c5b642fc@mail.gmail.com","threadId":"3162","inReplyTo":null,"subject":"git rev-list","fromName":"Aneesh Kumar","fromEmail":"aneesh.kumar@gmail.com","sentAt":"2006-01-27T03:46:58Z","receivedAt":"2006-01-27T03:46:58Z","isPatch":false,"sender":{"key":"aneesh.kumar@gmail.com","avatar":"https://gravatar.com/avatar/0621fc0b2f14ead1e9024382f16053a808c148596da30c1b92572fa075621f68?d=mp&s=160"},"body":"I am right now making a gnome based git repository browser [1] . I use\ngit-rev-list to get the revision list. What i found is  that from the\nsecond commit on wards i am finding some control character at the\nbeginning of the first line with respect to each commit. You can\nreproduce it easily by redirecting the output to a file and reading\nthe file using vi. I am using the latest git built from git repository\n\n[1] http://www.flickr.com/photos/17388011@N00/91636482/\nThis is based on bzrk GUI frontend to bazaar and written in python\n\n-aneesh\n"},{"id":"15163","messageId":"7vvew62ke7.fsf@assigned-by-dhcp.cox.net","threadId":"3162","inReplyTo":"cc723f590601261946h101d7000oa1990c31c5b642fc@mail.gmail.com","subject":"Re: git rev-list","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-01-27T07:35:28Z","receivedAt":"2006-01-27T07:35:28Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Aneesh Kumar <aneesh.kumar@gmail.com> writes:\n\n> ... I use\n> git-rev-list to get the revision list. What i found is  that from the\n> second commit on wards i am finding some control character at the\n> beginning of the first line with respect to each commit.\n\nIf you are using \"git-rev-list --header\" format, it uses an\nASCII NUL (0) to delimit each record.  Technically, it is not\n\"beginning of the first line starting from the second commit\",\nbut \"at the end of each commit\".\n\nWith Perl, you would read such NUL separated record by:\n\n\tlocal $/ = \"\\0\";\n\tmy $item = <>;\n\nAdmittedly my Python is quite rusty, and I do not offhand recall\nthere was no such \"line separator is NUL instead of normal LF\"\nconfiguration on readable file objects.  You may need to do\nsomething ugly like this:\n\n-- >8 --\nimport os\n\ndef rev_list(rev_range):\n    revlist = os.popen('git rev-list --header %s' % rev_range)\n    stash = []\n    while 1:\n        line = revlist.readline()\n        if line == '':\n            break\n        if line[0] == '\\0':\n            yield ''.join(stash)\n            stash = []\n            line = line[1:]\n            if line == '':\n                break\n        stash.append(line)\n    if len(stash):\n        yield ''.join(stash)\n\nfor commit in rev_list('master..pu'):\n    # Use commit which is from a single record..\n    print \"*<*\", commit, \"*>*\"\n"}]}