[GitPython] Patches to fix more config parsing errors (#703960 #706218)

Jesse Keating jkeating at fedoraproject.org
Sat May 28 04:59:53 UTC 2011


commit 871014a02052682d831b61fb6102a94db0e72351
Author: Jesse Keating <jkeating at redhat.com>
Date:   Fri May 27 20:22:45 2011 -0700

    Patches to fix more config parsing errors (#703960 #706218)

 0001-Handle-indented-config-sections.patch         |   37 ++++++++++++++++++
 ...dle-indented-comments-in-git-config-files.patch |   40 ++++++++++++++++++++
 GitPython.spec                                     |   12 +++++-
 3 files changed, 88 insertions(+), 1 deletions(-)
---
diff --git a/0001-Handle-indented-config-sections.patch b/0001-Handle-indented-config-sections.patch
new file mode 100644
index 0000000..c0fe2b8
--- /dev/null
+++ b/0001-Handle-indented-config-sections.patch
@@ -0,0 +1,37 @@
+From 6b613b146021268ddac08bd47b310efba8c75ef0 Mon Sep 17 00:00:00 2001
+From: Jesse Keating <jkeating at redhat.com>
+Date: Fri, 27 May 2011 19:53:34 -0700
+Subject: [PATCH 1/2] Handle indented config sections
+
+This brings over some new code from RawConfigParser that handles lines
+that start with spaces but are also sections themselves, eg:
+
+[color]
+    ui = auto
+  [color "branch"]
+
+Previously this would cause a traceback.
+(https://bugzilla.redhat.com/show_bug.cgi?id=706218)
+---
+ lib/git/config.py |    5 +++++
+ 1 files changed, 5 insertions(+), 0 deletions(-)
+
+diff --git a/lib/git/config.py b/lib/git/config.py
+index e5fd990..236b4dc 100644
+--- a/lib/git/config.py
++++ b/lib/git/config.py
+@@ -201,6 +201,11 @@ class GitConfigParser(cp.RawConfigParser, object):
+             if line.split(None, 1)[0].lower() == 'rem' and line[0] in "rR":
+                 # no leading whitespace
+                 continue
++            # continuation line?
++            if line[0].isspace() and cursect is not None and optname:
++                value = line.strip()
++                if value:
++                    cursect[optname] = "%s\n%s" % (cursect[optname], value)
+             else:
+                 # is it a section header?
+                 mo = self.SECTCRE.match(line)
+-- 
+1.7.4.4
+
diff --git a/0002-Handle-indented-comments-in-git-config-files.patch b/0002-Handle-indented-comments-in-git-config-files.patch
new file mode 100644
index 0000000..ca48114
--- /dev/null
+++ b/0002-Handle-indented-comments-in-git-config-files.patch
@@ -0,0 +1,40 @@
+From e33a0621c1fb373bc8f07fc1d1e374f76e78088a Mon Sep 17 00:00:00 2001
+From: Jesse Keating <jkeating at redhat.com>
+Date: Fri, 27 May 2011 19:55:15 -0700
+Subject: [PATCH 2/2] Handle indented comments in git config files
+
+It's perfectly valid for a git config file to contain comments inside
+sections, e.g.:
+
+[core]
+    # This is a shared repository
+    sharedRepository = true
+
+The git tools all parse this fine while GitPython was choking on it.
+---
+ lib/git/config.py |    3 ++-
+ 1 files changed, 2 insertions(+), 1 deletions(-)
+
+diff --git a/lib/git/config.py b/lib/git/config.py
+index 236b4dc..7547a7d 100644
+--- a/lib/git/config.py
++++ b/lib/git/config.py
+@@ -190,13 +190,14 @@ class GitConfigParser(cp.RawConfigParser, object):
+         optname = None
+         lineno = 0
+         e = None                                  # None, or an exception
++        comment_re = re.compile('^\s*[#;]')
+         while True:
+             line = fp.readline()
+             if not line:
+                 break
+             lineno = lineno + 1
+             # comment or blank line?
+-            if line.strip() == '' or line[0] in '#;':
++            if line.strip() == '' or comment_re.match(line):
+                 continue
+             if line.split(None, 1)[0].lower() == 'rem' and line[0] in "rR":
+                 # no leading whitespace
+-- 
+1.7.4.4
+
diff --git a/GitPython.spec b/GitPython.spec
index 5878c81..7fe0e20 100644
--- a/GitPython.spec
+++ b/GitPython.spec
@@ -3,7 +3,7 @@
 
 Name:           GitPython
 Version:        0.2.0
-Release:        0.5.beta1%{?dist}
+Release:        0.6.beta1%{?dist}
 Summary:        Python Git Library
 
 Group:          Development/Languages
@@ -15,7 +15,12 @@ BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
 BuildArch:      noarch
 BuildRequires:  python-devel python-setuptools
 Requires:       /usr/bin/git
+# https://github.com/gitpython-developers/GitPython/commit/ea5d365a93a98907a1d7c25d433efd06a854109e
 Patch0:         0001-Match-any-number-of-leading-spaces-in-config-values.patch
+# https://github.com/jkeating/GitPython/commit/d27cd97d8317094454510e904b49c5c537fa202c
+Patch1:         0001-Handle-indented-config-sections.patch
+# https://github.com/tmzullinger/GitPython/commit/69253459a4924e2bf71cf42cd5e2c1c9e33af137
+Patch2:         0002-Handle-indented-comments-in-git-config-files.patch
 
 %description
 GitPython is a python library used to interact with Git repositories.
@@ -31,6 +36,8 @@ and Chris Wanstrath.
 %prep
 %setup -q -n %{name}-%{version}-beta1
 %patch0 -p1
+%patch1 -p1
+%patch2 -p1
 
 
 %build
@@ -55,6 +62,9 @@ rm -rf $RPM_BUILD_ROOT
 
 
 %changelog
+* Fri May 27 2011 Jesse Keating <jkeating at redhat.com> - 0.2.0-0.6.beta1
+- Patches for indented parts of git config files
+
 * Mon Feb 14 2011 Jesse Keating <jkeating at redhat.com> - 0.2.0-0.5.beta1
 - Fix parsing of config files
 


More information about the scm-commits mailing list