Skip to content

add --no-color option to commands like git log #30

Closed
@kkrol89

Description

@kkrol89

I get following errors on linux with git version 1.7.4.1 and ruby-git gem version 1.2.5 when color ui is set to always.

require 'git'; git = Git.open('.'); git.log(1).inspect
NoMethodError: undefined method `[]=' for nil:NilClass
    from /home/konrad/.rvm/gems/ruby-1.9.2-p180@example_gemset/gems/git-1.2.5/lib/git/lib.rb:153:in `block in process_commit_data'
    from /home/konrad/.rvm/gems/ruby-1.9.2-p180@example_gemset/gems/git-1.2.5/lib/git/lib.rb:135:in `each'
    from /home/konrad/.rvm/gems/ruby-1.9.2-p180@example_gemset/gems/git-1.2.5/lib/git/lib.rb:135:in `process_commit_data'
    from /home/konrad/.rvm/gems/ruby-1.9.2-p180@example_gemset/gems/git-1.2.5/lib/git/lib.rb:93:in `full_log_commits'
    from /home/konrad/.rvm/gems/ruby-1.9.2-p180@example_gemset/gems/git-1.2.5/lib/git/log.rb:108:in `run_log'
    from /home/konrad/.rvm/gems/ruby-1.9.2-p180@example_gemset/gems/git-1.2.5/lib/git/log.rb:101:in `check_log'
    from /home/konrad/.rvm/gems/ruby-1.9.2-p180@example_gemset/gems/git-1.2.5/lib/git/log.rb:84:in `each'
    from /home/konrad/.rvm/gems/ruby-1.9.2-p180@example_gemset/gems/git-1.2.5/lib/git/log.rb:72:in `map'
    from /home/konrad/.rvm/gems/ruby-1.9.2-p180@example_gemset/gems/git-1.2.5/lib/git/log.rb:72:in `to_s'
    from (irb):4:in `inspect'
    from (irb):4
    from /home/konrad/.rvm/rubies/ruby-1.9.2-p180/bin/irb:16:in `<main>'

Solution is to add --no-color option to git commands like git log or git diff, so that color tags like '\e[43m' are not included in data being processed.

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions