Repository: gitpython-developers/GitPython
Pull request #341 (2015-08-19 22:12:25)

fix(cmd): make short options with arguments become two separate argum…
…ents for the executable.

So `git.Git.command(f=42)` becomes `git command -f 42` instead of `git command -f42`, which is not recognized by `git`. See #340.


Patch:
diff --git a/README.md b/README.md
index 75fcdcb2..f87cb0ef 100644
--- a/README.md
+++ b/README.md
@@ -78,6 +78,7 @@ New BSD License.  See the LICENSE file.
 
 [![Build Status](https://travis-ci.org/gitpython-developers/GitPython.svg)](https://travis-ci.org/gitpython-developers/GitPython)
 [![Code Climate](https://codeclimate.com/github/gitpython-developers/GitPython/badges/gpa.svg)](https://codeclimate.com/github/gitpython-developers/GitPython)
+[![Coverage Status](https://coveralls.io/repos/gitpython-developers/GitPython/badge.png?branch=master)](https://coveralls.io/r/gitpython-developers/GitPython?branch=master)
 [![Documentation Status](https://readthedocs.org/projects/gitpython/badge/?version=stable)](https://readthedocs.org/projects/gitpython/?badge=stable)
 [![Issue Stats](http://www.issuestats.com/github/gitpython-developers/GitPython/badge/pr)](http://www.issuestats.com/github/gitpython-developers/GitPython)
 [![Issue Stats](http://www.issuestats.com/github/gitpython-developers/GitPython/badge/issue)](http://www.issuestats.com/github/gitpython-developers/GitPython)
diff --git a/doc/source/changes.rst b/doc/source/changes.rst
index 970ba195..e6d7b09b 100644
--- a/doc/source/changes.rst
+++ b/doc/source/changes.rst
@@ -2,13 +2,6 @@
 Changelog
 =========
 
-1.0.2 - Fixes
-=============
-
-* CRITICAL: fixed incorrect `Commit` object serialization when authored or commit date had timezones which were not
-  divisable by 3600 seconds. This would happen if the timezone was something like `+0530` for instance.
-* A list of all additional fixes can be found `on github <https://github.com/gitpython-developers/GitPython/issues?q=milestone%3A%22v1.0.2+-+Fixes%22+is%3Aclosed>`_
-
 1.0.1 - Fixes
 =============
 
diff --git a/git/cmd.py b/git/cmd.py
index 31865d09..3cdc68ab 100644
--- a/git/cmd.py
+++ b/git/cmd.py
@@ -700,7 +700,7 @@ class Git(LazyMixin):
         finally:
             self.update_environment(**old_env)
 
-    def transform_kwargs(self, split_single_char_options=False, **kwargs):
+    def transform_kwargs(self, split_single_char_options=True, **kwargs):
         """Transforms Python style kwargs into git command line options."""
         args = list()
         for k, v in kwargs.items():
diff --git a/git/index/fun.py b/git/index/fun.py
index c1026fd6..9ae46861 100644
--- a/git/index/fun.py
+++ b/git/index/fun.py
@@ -41,8 +41,7 @@ from gitdb.base import IStream
 from gitdb.typ import str_tree_type
 from git.compat import (
     defenc,
-    force_text,
-    force_bytes
+    force_text
 )
 
 S_IFGITLINK = S_IFLNK | S_IFDIR     # a submodule
@@ -125,7 +124,7 @@ def write_cache(entries, stream, extension_data=None, ShaStreamCls=IndexFileSHA1
         write(entry[4])         # ctime
         write(entry[5])         # mtime
         path = entry[3]
-        path = force_bytes(path, encoding=defenc)
+        path = path.encode(defenc)
         plen = len(path) & CE_NAMEMASK      # path length
         assert plen == len(path), "Path %s too long to fit into index" % entry[3]
         flags = plen | (entry[2] & CE_NAMEMASK_INV)     # clear possible previous values
diff --git a/git/objects/util.py b/git/objects/util.py
index 8fd92a0a..567b1d5b 100644
--- a/git/objects/util.py
+++ b/git/objects/util.py
@@ -73,7 +73,7 @@ def utctz_to_altz(utctz):
 def altz_to_utctz_str(altz):
     """As above, but inverses the operation, returning a string that can be used
     in commit objects"""
-    utci = -1 * int((float(altz) / 3600) * 100)
+    utci = -1 * int((altz / 3600) * 100)
     utcs = str(abs(utci))
     utcs = "0" * (4 - len(utcs)) + utcs
     prefix = (utci < 0 and '-') or '+'


Test patch:
diff --git a/git/test/performance/test_commit.py b/git/test/performance/test_commit.py
index b59c747e..7d3e87c4 100644
--- a/git/test/performance/test_commit.py
+++ b/git/test/performance/test_commit.py
@@ -76,7 +76,7 @@ class TestPerformance(TestBigRepoRW):
               % (nc, elapsed_time, nc / elapsed_time), file=sys.stderr)
 
     def test_commit_serialization(self):
-        assert_commit_serialization(self.gitrwrepo, '58c78e6', True)
+        assert_commit_serialization(self.gitrwrepo, self.gitrwrepo.head, True)
 
         rwrepo = self.gitrwrepo
         make_object = rwrepo.odb.store
diff --git a/git/test/test_git.py b/git/test/test_git.py
index f386150f..3e3e21e4 100644
--- a/git/test/test_git.py
+++ b/git/test/test_git.py
@@ -65,7 +65,7 @@ class TestGit(TestBase):
 
     def test_it_transforms_kwargs_into_git_command_arguments(self):
         assert_equal(["-s"], self.git.transform_kwargs(**{'s': True}))
-        assert_equal(["-s5"], self.git.transform_kwargs(**{'s': 5}))
+        assert_equal(["-s", "5"], self.git.transform_kwargs(**{'s': 5}))
 
         assert_equal(["--max-count"], self.git.transform_kwargs(**{'max_count': True}))
         assert_equal(["--max-count=5"], self.git.transform_kwargs(**{'max_count': 5}))
diff --git a/git/test/test_index.py b/git/test/test_index.py
index ffc4bffe..2fd53f65 100644
--- a/git/test/test_index.py
+++ b/git/test/test_index.py
@@ -18,7 +18,6 @@ from git.exc import (
 )
 from git import (
     IndexFile,
-    Repo,
     BlobFilter,
     UnmergedEntriesError,
     Tree,
@@ -46,7 +45,6 @@ from git.index.typ import (
     IndexEntry
 )
 from git.index.fun import hook_path
-from gitdb.test.lib import with_rw_directory
 
 
 class TestIndex(TestBase):
@@ -782,14 +780,3 @@ class TestIndex(TestBase):
         except InvalidGitRepositoryError:
             asserted = True
         assert asserted, "Adding using a filename is not correctly asserted."
-
-    @with_rw_directory
-    def test_add_utf8P_path(self, rw_dir):
-        # NOTE: fp is not a Unicode object in python 2 (which is the source of the problem)
-        fp = os.path.join(rw_dir, 'ø.txt')
-        with open(fp, 'wb') as fs:
-            fs.write(u'content of ø'.encode('utf-8'))
-
-        r = Repo.init(rw_dir)
-        r.index.add([fp])
-        r.index.commit('Added orig and prestable')
diff --git a/git/test/test_submodule.py b/git/test/test_submodule.py
index 17ce605a..cbf38c18 100644
--- a/git/test/test_submodule.py
+++ b/git/test/test_submodule.py
@@ -661,7 +661,7 @@ class TestSubmodule(TestBase):
         # end for each checkout mode
 
     @with_rw_directory
-    def test_git_submodules_and_add_sm_with_new_commit(self, rwdir):
+    def test_git_submodules(self, rwdir):
         parent = git.Repo.init(os.path.join(rwdir, 'parent'))
         parent.git.submodule('add', self._small_repo_url(), 'module')
         parent.index.commit("added submodule")
@@ -686,37 +686,6 @@ class TestSubmodule(TestBase):
         sm.move(sm.path + '_moved')
         sm2.move(sm2.path + '_moved')
 
-        parent.index.commit("moved submodules")
-
-        smm = sm.module()
-        fp = os.path.join(smm.working_tree_dir, 'empty-file')
-        with open(fp, 'w'):
-            pass
-        smm.git.add(fp)
-        smm.git.commit(m="new file added")
-
-        # submodules are retrieved from the current commit's tree, therefore we can't really get a new submodule
-        # object pointing to the new submodule commit
-        sm_too = parent.submodules['module_moved']
-        assert parent.head.commit.tree[sm.path].binsha == sm.binsha
-        assert sm_too.binsha == sm.binsha, "cached submodule should point to the same commit as updated one"
-
-        added_bies = parent.index.add([sm])  # addded base-index-entries
-        assert len(added_bies) == 1
-        parent.index.commit("add same submodule entry")
-        commit_sm = parent.head.commit.tree[sm.path]
-        assert commit_sm.binsha == added_bies[0].binsha
-        assert commit_sm.binsha == sm.binsha
-
-        sm_too.binsha = sm_too.module().head.commit.binsha
-        added_bies = parent.index.add([sm_too])
-        assert len(added_bies) == 1
-        parent.index.commit("add new submodule entry")
-        commit_sm = parent.head.commit.tree[sm.path]
-        assert commit_sm.binsha == added_bies[0].binsha
-        assert commit_sm.binsha == sm_too.binsha
-        assert sm_too.binsha != sm.binsha
-
     @with_rw_directory
     def test_git_submodule_compatibility(self, rwdir):
         parent = git.Repo.init(os.path.join(rwdir, 'parent'))