summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md1
-rw-r--r--doc/source/changes.rst7
-rw-r--r--git/index/fun.py5
-rw-r--r--git/objects/util.py2
-rw-r--r--git/test/performance/test_commit.py2
-rw-r--r--git/test/test_index.py13
-rw-r--r--git/test/test_submodule.py33
7 files changed, 57 insertions, 6 deletions
diff --git a/README.md b/README.md
index f87cb0ef..75fcdcb2 100644
--- a/README.md
+++ b/README.md
@@ -78,7 +78,6 @@ 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 e6d7b09b..970ba195 100644
--- a/doc/source/changes.rst
+++ b/doc/source/changes.rst
@@ -2,6 +2,13 @@
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/index/fun.py b/git/index/fun.py
index 9ae46861..c1026fd6 100644
--- a/git/index/fun.py
+++ b/git/index/fun.py
@@ -41,7 +41,8 @@ from gitdb.base import IStream
from gitdb.typ import str_tree_type
from git.compat import (
defenc,
- force_text
+ force_text,
+ force_bytes
)
S_IFGITLINK = S_IFLNK | S_IFDIR # a submodule
@@ -124,7 +125,7 @@ def write_cache(entries, stream, extension_data=None, ShaStreamCls=IndexFileSHA1
write(entry[4]) # ctime
write(entry[5]) # mtime
path = entry[3]
- path = path.encode(defenc)
+ path = force_bytes(path, encoding=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 567b1d5b..8fd92a0a 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((altz / 3600) * 100)
+ utci = -1 * int((float(altz) / 3600) * 100)
utcs = str(abs(utci))
utcs = "0" * (4 - len(utcs)) + utcs
prefix = (utci < 0 and '-') or '+'
diff --git a/git/test/performance/test_commit.py b/git/test/performance/test_commit.py
index 7d3e87c4..b59c747e 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, self.gitrwrepo.head, True)
+ assert_commit_serialization(self.gitrwrepo, '58c78e6', True)
rwrepo = self.gitrwrepo
make_object = rwrepo.odb.store
diff --git a/git/test/test_index.py b/git/test/test_index.py
index 2fd53f65..ffc4bffe 100644
--- a/git/test/test_index.py
+++ b/git/test/test_index.py
@@ -18,6 +18,7 @@ from git.exc import (
)
from git import (
IndexFile,
+ Repo,
BlobFilter,
UnmergedEntriesError,
Tree,
@@ -45,6 +46,7 @@ from git.index.typ import (
IndexEntry
)
from git.index.fun import hook_path
+from gitdb.test.lib import with_rw_directory
class TestIndex(TestBase):
@@ -780,3 +782,14 @@ 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 cbf38c18..17ce605a 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(self, rwdir):
+ def test_git_submodules_and_add_sm_with_new_commit(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,6 +686,37 @@ 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'))