diff options
author | Sebastian Thiel <byronimo@gmail.com> | 2014-11-15 16:19:24 +0100 |
---|---|---|
committer | Sebastian Thiel <byronimo@gmail.com> | 2014-11-15 16:21:37 +0100 |
commit | ff13922f6cfb11128b7651ddfcbbd5cad67e477f (patch) | |
tree | 9d999b14a7817b1ceeb23ddd1cded446ace9255c /git/objects | |
parent | 9c39afa1f85f3293ad2ccef684ff62bf0a36e73c (diff) | |
parent | f7ed51ba4c8416888f5744ddb84726316c461051 (diff) | |
download | gitpython-ff13922f6cfb11128b7651ddfcbbd5cad67e477f.tar.gz |
Merge branch 'sf-master' of https://github.com/johnsca/GitPython into johnsca-sf-master
Conflicts:
git/cmd.py
git/objects/commit.py
git/objects/fun.py
git/objects/util.py
git/remote.py
git/repo/base.py
git/test/lib/helper.py
git/test/test_commit.py
git/test/test_fun.py
git/util.py
Diffstat (limited to 'git/objects')
-rw-r--r-- | git/objects/commit.py | 17 | ||||
-rw-r--r-- | git/objects/fun.py | 11 | ||||
-rw-r--r-- | git/objects/util.py | 9 |
3 files changed, 29 insertions, 8 deletions
diff --git a/git/objects/commit.py b/git/objects/commit.py index 4380f472..bc437e8b 100644 --- a/git/objects/commit.py +++ b/git/objects/commit.py @@ -8,6 +8,7 @@ from git.util import ( Actor, Iterable, Stats, + finalize_process ) from git.diff import Diffable from tree import Tree @@ -65,7 +66,6 @@ class Commit(base.Object, Iterable, Diffable, Traversable, Serializable): message=None, parents=None, encoding=None, gpgsig=None): """Instantiate a new Commit. All keyword arguments taking None as default will be implicitly set on first query. - :param binsha: 20 byte sha1 :param parents: tuple( Commit, ... ) is a tuple of commit ids or actual Commits @@ -252,6 +252,10 @@ class Commit(base.Object, Iterable, Diffable, Traversable, Serializable): assert len(hexsha) == 40, "Invalid line: %s" % hexsha yield Commit(repo, hex_to_bin(hexsha)) # END for each line in stream + # TODO: Review this - it seems process handling got a bit out of control + # due to many developers trying to fix the open file handles issue + if hasattr(proc_or_stream, 'wait'): + finalize_process(proc_or_stream) @classmethod @@ -430,14 +434,21 @@ class Commit(base.Object, Iterable, Diffable, Traversable, Serializable): self.author, self.authored_date, self.author_tz_offset = parse_actor_and_date(next_line) self.committer, self.committed_date, self.committer_tz_offset = parse_actor_and_date(readline()) - + + # we might run into one or more mergetag blocks, skip those for now + next_line = readline() + while next_line.startswith('mergetag '): + next_line = readline() + while next_line.startswith(' '): + next_line = readline() # now we can have the encoding line, or an empty line followed by the optional # message. self.encoding = self.default_encoding # read headers - buf = readline().strip() + enc = next_line + buf = enc.strip() while buf != "": if buf[0:10] == "encoding ": self.encoding = buf[buf.find(' ')+1:] diff --git a/git/objects/fun.py b/git/objects/fun.py index f73be542..66b7998e 100644 --- a/git/objects/fun.py +++ b/git/objects/fun.py @@ -70,9 +70,13 @@ def tree_entries_from_data(data): # default encoding for strings in git is utf8 # Only use the respective unicode object if the byte stream was encoded name = data[ns:i] - name_enc = name.decode("utf-8") - if len(name) > len(name_enc): - name = name_enc + try: + name_enc = name.decode("utf-8") + except UnicodeDecodeError: + pass + else: + if len(name) > len(name_enc): + name = name_enc # END handle encoding # byte is NULL, get next 20 @@ -84,6 +88,7 @@ def tree_entries_from_data(data): return out + def _find_by_name(tree_data, name, is_dir, start_at): """return data entry matching the given name and tree mode or None. diff --git a/git/objects/util.py b/git/objects/util.py index 2e44c9c0..cdf72bed 100644 --- a/git/objects/util.py +++ b/git/objects/util.py @@ -167,6 +167,7 @@ def parse_date(string_date): # precompiled regex _re_actor_epoch = re.compile(r'^.+? (.*) (\d+) ([+-]\d+).*$') +_re_only_actor = re.compile(r'^.+? (.*)$') def parse_actor_and_date(line): """Parse out the actor (author or committer) info from a line like:: @@ -174,10 +175,14 @@ def parse_actor_and_date(line): author Tom Preston-Werner <tom@mojombo.com> 1191999972 -0700 :return: [Actor, int_seconds_since_epoch, int_timezone_offset]""" + actor, epoch, offset = '', 0, 0 m = _re_actor_epoch.search(line) - actor, epoch, offset = m.groups() + if m: + actor, epoch, offset = m.groups() + else: + m = _re_only_actor.search(line) + actor = m.group(1) if m else line or '' return (Actor._from_string(actor), int(epoch), utctz_to_altz(offset)) - #} END functions |