Repository: gitpython-developers/GitPython
Pull request #899 (2019-07-23 10:54:31)

Fix Git.transform_kwarg
While working on our project I found that `old_repo.git.rev_list('HEAD', max_parents=0)` started to work differently after the new release of GitPython and our tests started to fail. After some debugging I found the problem. Kwargs were not transformed correctly if a value was set to 0 due to wrong if condition:

```
>>> 0 not in (False, None)
False
>>> 0 is not False and 0 is not None
True
```

The commit also contains a test for the edge case.


Patch:
diff --git a/.appveyor.yml b/.appveyor.yml
index 017cf120..2658d96e 100644
--- a/.appveyor.yml
+++ b/.appveyor.yml
@@ -5,9 +5,6 @@ environment:
     CYGWIN64_GIT_PATH: "C:\\cygwin64\\bin;%GIT_DAEMON_PATH%"
 
     matrix:
-      - PYTHON: "C:\\Python27"
-        PYTHON_VERSION: "2.7"
-        GIT_PATH: "%GIT_DAEMON_PATH%"
       - PYTHON: "C:\\Python34-x64"
         PYTHON_VERSION: "3.4"
         GIT_PATH: "%GIT_DAEMON_PATH%"
@@ -26,12 +23,6 @@ environment:
         MAYFAIL: "yes"
         GIT_PATH: "%GIT_DAEMON_PATH%"
         ## Cygwin
-      - PYTHON: "C:\\Miniconda-x64"
-        PYTHON_VERSION: "2.7"
-        IS_CONDA: "yes"
-        IS_CYGWIN: "yes"
-        MAYFAIL: "yes"
-        GIT_PATH: "%CYGWIN_GIT_PATH%"
       - PYTHON: "C:\\Python35-x64"
         PYTHON_VERSION: "3.5"
         IS_CYGWIN: "yes"
diff --git a/.travis.yml b/.travis.yml
index 206c133e..56c86d1b 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,5 +1,6 @@
 language: python
 python:
+  - "2.7"
   - "3.4"
   - "3.5"
   - "3.6"
diff --git a/README.md b/README.md
index 3734019e..e252c34c 100644
--- a/README.md
+++ b/README.md
@@ -19,7 +19,7 @@ If it is not in your `PATH`, you can help GitPython find it by setting
 the `GIT_PYTHON_GIT_EXECUTABLE=<path/to/git>` environment variable.
 
 * Git (1.7.x or newer)
-* Python 3 to 3.7.
+* Python 2.7 to 3.7.
 
 The list of dependencies are listed in `./requirements.txt` and `./test-requirements.txt`.
 The installer takes care of installing them for you.
diff --git a/VERSION b/VERSION
index 348fc11e..ea4bd0fb 100644
--- a/VERSION
+++ b/VERSION
@@ -1,1 +1,1 @@
-2.1.12
+2.1.13
diff --git a/doc/source/changes.rst b/doc/source/changes.rst
index 92c28b69..b9f28638 100644
--- a/doc/source/changes.rst
+++ b/doc/source/changes.rst
@@ -2,6 +2,12 @@
 Changelog
 =========
 
+2.1.13 - Bring back Python 2.7 support
+======================================
+
+My apologies for any inconvenience this may have caused. Following semver, backward incompatible changes
+will be introduced in a minor version.
+
 2.1.12 - Bugfixes and Features
 ==============================
 
diff --git a/doc/source/intro.rst b/doc/source/intro.rst
index e2cd196b..d68e5eb2 100644
--- a/doc/source/intro.rst
+++ b/doc/source/intro.rst
@@ -13,7 +13,7 @@ The object database implementation is optimized for handling large quantities of
 Requirements
 ============
 
-* `Python`_ 3.0 or newer
+* `Python`_ 2.7 or newer
 * `Git`_ 1.7.0 or newer
     It should also work with older versions, but it may be that some operations
     involving remotes will not work as expected.
diff --git a/git/cmd.py b/git/cmd.py
index 64c3d480..50b1e321 100644
--- a/git/cmd.py
+++ b/git/cmd.py
@@ -893,7 +893,7 @@ class Git(LazyMixin):
         else:
             if value is True:
                 return ["--%s" % dashify(name)]
-            elif value not in (False, None):
+            elif value is not False and value is not None:
                 return ["--%s=%s" % (dashify(name), value)]
         return []
 
diff --git a/git/compat.py b/git/compat.py
index 02dc69de..b63768f3 100644
--- a/git/compat.py
+++ b/git/compat.py
@@ -30,10 +30,7 @@ PY3 = sys.version_info[0] >= 3
 is_win = (os.name == 'nt')
 is_posix = (os.name == 'posix')
 is_darwin = (os.name == 'darwin')
-if hasattr(sys, 'getfilesystemencoding'):
-    defenc = sys.getfilesystemencoding()
-if defenc is None:
-    defenc = sys.getdefaultencoding()
+defenc = sys.getdefaultencoding()
 
 if PY3:
     import io
diff --git a/git/repo/base.py b/git/repo/base.py
index 911494ad..f3587080 100644
--- a/git/repo/base.py
+++ b/git/repo/base.py
@@ -4,7 +4,6 @@
 # This module is part of GitPython and is released under
 # the BSD License: http://www.opensource.org/licenses/bsd-license.php
 
-from builtins import str
 from collections import namedtuple
 import logging
 import os
diff --git a/requirements.txt b/requirements.txt
index c0cca9f4..63d5ddfe 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -1,3 +1,1 @@
 gitdb2 (>=2.0.0)
-gitdb>=0.6.4
-ddt>=1.1.1
diff --git a/setup.py b/setup.py
index 65656d55..49288f69 100755
--- a/setup.py
+++ b/setup.py
@@ -79,7 +79,7 @@ setup(
     package_data={'git.test': ['fixtures/*']},
     package_dir={'git': 'git'},
     license="BSD License",
-    python_requires='>=3.0, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*',
+    python_requires='>=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*',
     install_requires=requirements,
     tests_require=requirements + test_requirements,
     zip_safe=False,
@@ -102,6 +102,8 @@ setup(
         "Operating System :: Microsoft :: Windows",
         "Operating System :: MacOS :: MacOS X",
         "Programming Language :: Python",
+        "Programming Language :: Python :: 2",
+        "Programming Language :: Python :: 2.7",
         "Programming Language :: Python :: 3",
         "Programming Language :: Python :: 3.4",
         "Programming Language :: Python :: 3.5",
diff --git a/tox.ini b/tox.ini
index e46136d6..36048fbc 100644
--- a/tox.ini
+++ b/tox.ini
@@ -1,5 +1,5 @@
 [tox]
-envlist = py27,py34,py35,py36,py37,flake8
+envlist = py34,py35,py36,py37,flake8
 
 [testenv]
 commands = nosetests {posargs}


Test patch:
diff --git a/git/test/test_git.py b/git/test/test_git.py
index 30a6a335..4a189267 100644
--- a/git/test/test_git.py
+++ b/git/test/test_git.py
@@ -86,6 +86,7 @@ class TestGit(TestBase):
 
         assert_equal(["--max-count"], self.git.transform_kwargs(**{'max_count': True}))
         assert_equal(["--max-count=5"], self.git.transform_kwargs(**{'max_count': 5}))
+        assert_equal(["--max-count=0"], self.git.transform_kwargs(**{'max_count': 0}))
         assert_equal([], self.git.transform_kwargs(**{'max_count': None}))
 
         # Multiple args are supported by using lists/tuples
diff --git a/test-requirements.txt b/test-requirements.txt
index ec0e4c56..ec2912ba 100644
--- a/test-requirements.txt
+++ b/test-requirements.txt
@@ -3,4 +3,3 @@ coverage
 flake8
 nose
 tox
-mock; python_version=='2.7'