Skip to content

Crash when parsing commit message #16

Closed
@djdeath

Description

@djdeath

Here is the stack :

/usr/lib/ruby/1.8/git/lib.rb:148:in process_commit_data': undefined method<<' for nil:NilClass (NoMethodError)
from /usr/lib/ruby/1.8/git/lib.rb:135:in each' from /usr/lib/ruby/1.8/git/lib.rb:135:inprocess_commit_data'
from /usr/lib/ruby/1.8/git/lib.rb:123:in commit_data' from /usr/lib/ruby/1.8/git/object.rb:230:incheck_commit'
from /usr/lib/ruby/1.8/git/object.rb:197:in committer' from /usr/lib/ruby/1.8/git/object.rb:202:incommitter_date'
from /home/djdeath/bin/confront_patch_list.rb:32
from /home/djdeath/bin/confront_patch_list.rb:27:in `each_key'
from /home/djdeath/bin/confront_patch_list.rb:27

It happens when I call the committer_date method with something like this :

repo = Git::Base.open("#{ENV['PWD']}")
ob = Git::Object::Commit.new(repo, "whatevercommithash")
puts ob.committer_date

The problem is in the process_commit_data method in lib.rb because this method expects the commit's metadatas to be separated from the commit's comment by an empty line. But it does not expect the commit to contain a empty line too.

Here is what the commit triggering this crash looks like :

$ git cat-file commit a693b0cdba94f60f7ed43754d2c34151cdd11da5
tree 99cbf46748dfa4f35acc1d63ae51817f3e17ec9d
parent 484ab62c5ee805c2bdc405a85a4e64da2722690f
author Mauro Carvalho Chehab mchehab@redhat.com 1228161854 -0200
committer Mauro Carvalho Chehab mchehab@redhat.com 1228161854 -0200

em28xx: remove backward compat macro added on a previous fix

commit 50f3beb50abe0cc0228363af804e50e710b3e5b0 fixed em28xx-alsa
locking schema. However, a backport macro was kept.

This patch removes the macro, since it is not needed for the module
compilation against upstream.

Signed-off-by: Mauro Carvalho Chehab mchehab@redhat.com

So the fix is pretty easy, on lib.rb line 137 you have :

    if line == ''

Replace it by :

    if line == '' and not in_message                                       

Regards,

Lionel Landwerlin

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions