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.
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.
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.
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)'
Activity
jschlather commented on Sep 9, 2013
Is this issue for the correct library? I can't find for instance a client.py in gitpython.
louisrli commented on Sep 10, 2013
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)
Byron commented on Nov 19, 2014
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.
Byron commented on Jan 9, 2015
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.
Byron commented on Jan 10, 2015
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.
Byron commented on Jan 10, 2015
Also, just for fun, I have recorded the process of fixing this issue.
Merge pull request gitpython-developers#112 from gitpython-developers…