FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Parsing error on git config · Issue #112 · gitpython-developers/GitPython · GitHub

Repository navigation

Parsing error on git config #112

Closed
Closed

Description

The error is below, doing a config.get_value("user", "name")

File "python-client/client.py", line 53, in <module>
main()
File "python-client/client.py", line 19, in main
user_info = githelpers.get_computer_info()["user"]
File "/home/sagar/dev/meteor/live-git/python-client/githelpers.py", line 35, in get_computer_info
user_name = config.get_value("user", "name")
File "/usr/local/lib/python2.7/dist-packages/git/config.py", line 379, in get_value
valuestr = self.get(section, option)
File "/usr/local/lib/python2.7/dist-packages/git/config.py", line 52, in assure_data_present
self.read()
File "/usr/local/lib/python2.7/dist-packages/git/config.py", line 291, in read
self._read(fp, fp.name)
File "/usr/local/lib/python2.7/dist-packages/git/config.py", line 262, in _read
raise e
ConfigParser.ParsingError: File contains parsing errors: /home/sagar/.gitconfig
[line 149]: '\t\tend\\n\\\n'
[line 150]: '\t\tFile.open(%(%A), %(w)) {|f| f.write(b)}\\n\\\n'
[line 151]: '\t\texit 1 if b.include?(%(<)*%L)\'"\n'

It happens on this .gitconfig after line 142. If you remove those parts, then it works fine.

https://github.com/cjhveal/dotfiles/blob/master/git/gitconfig.symlink

Activity

  1. jschlather commented on Sep 9, 2013

    Is this issue for the correct library? I can't find for instance a client.py in gitpython.

  2. louisrli commented on Sep 10, 2013

    Author

    Sorry, client.py is my file, but it makes a call to try to get a value from the .gitconfig (that looks like the linked one)

  3. added this to the v0.3.5 - bugfixes milestone on Nov 19, 2014
  4. Byron commented on Nov 19, 2014

    Member

    git-python uses the (downright terrible) standard configparser implementation, which is very picky.
    If a better library would be used, this one could be fixed as well I suppose.

  5. self-assigned this
    on Jan 9, 2015
  6. Byron commented on Jan 9, 2015

    Member

    I am able to reproduce the error and believe the only way to fix it is to use a different/better parser implementation. There seem to be alternatives which are available on pypi as well, and I am confident I will find something suitable.
    The config parser part of git-python has been a constant source for grief, and I will be happy to finally fix it.

  7. Byron commented on Jan 10, 2015

    Member

    I ended up improving the current (and custom) config parser implementation to the point where it can handle multi-line values correctly. There is a new test-case which verifies that git-python returns exactly the same value as git does.

    it config -f git/test/fixtures/git_config_with_comments --get "merge.railsschema.driver"
    ruby -e '
                    system %(git), %(merge-file), %(--marker-size=%L), %(%A), %(%O), %(%B)
                    b = File.read(%(%A))
                    b.sub!(/^<+ .*\nActiveRecord::Schema\.define.:version => (\d+). do\n=+\nActiveRecord::Schema\.define.:version => (\d+). do\n>+ .*/) do
                      %(ActiveRecord::Schema.define(:version => #{[$1, $2].max}) do)
                    end
                    File.open(%(%A), %(w)) {|f| f.write(b)}
                    exit 1 if b.include?(%(<)*%L)'
  8. Byron commented on Jan 10, 2015

    Member

    Also, just for fun, I have recorded the process of fixing this issue.

  9. added a commit that references this issue on Jul 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


    Back | FazBrowse Home | New Git URL