diff options
Diffstat (limited to 'objects')
-rw-r--r-- | objects/commit.py | 20 | ||||
-rw-r--r-- | objects/submodule/base.py | 2 | ||||
-rw-r--r-- | objects/submodule/root.py | 28 |
3 files changed, 27 insertions, 23 deletions
diff --git a/objects/commit.py b/objects/commit.py index 9c7e66a3..69a3adc4 100644 --- a/objects/commit.py +++ b/objects/commit.py @@ -350,13 +350,13 @@ class Commit(base.Object, Iterable, Diffable, Traversable, Serializable): # as well ... import git.refs try: - repo.head.commit = new_commit + repo.head.set_commit(new_commit, logmsg="commit: %s" % message) except ValueError: # head is not yet set to the ref our HEAD points to # Happens on first commit import git.refs - master = git.refs.Head.create(repo, repo.head.ref, commit=new_commit) - repo.head.reference = master + master = git.refs.Head.create(repo, repo.head.ref, commit=new_commit, logmsg="commit (initial): %s" % message) + repo.head.set_reference(master, logmsg='commit: Switching to %s' % master) # END handle empty repositories # END advance head handling @@ -382,7 +382,12 @@ class Commit(base.Object, Iterable, Diffable, Traversable, Serializable): self.authored_date, altz_to_utctz_str(self.author_tz_offset))) - write(fmt % ("committer", c.name, c.email, + # encode committer + aname = c.name + if isinstance(aname, unicode): + aname = aname.encode(self.encoding) + # END handle unicode in name + write(fmt % ("committer", aname, c.email, self.committed_date, altz_to_utctz_str(self.committer_tz_offset))) @@ -440,6 +445,13 @@ class Commit(base.Object, Iterable, Diffable, Traversable, Serializable): print >> sys.stderr, "Failed to decode author name '%s' using encoding %s" % (self.author.name, self.encoding) # END handle author's encoding + # decode committer name + try: + self.committer.name = self.committer.name.decode(self.encoding) + except UnicodeDecodeError: + print >> sys.stderr, "Failed to decode committer name '%s' using encoding %s" % (self.committer.name, self.encoding) + # END handle author's encoding + # a stream from our data simply gives us the plain message # The end of our message stream is marked with a newline that we strip self.message = stream.read() diff --git a/objects/submodule/base.py b/objects/submodule/base.py index 5d32d600..36b48d78 100644 --- a/objects/submodule/base.py +++ b/objects/submodule/base.py @@ -344,7 +344,7 @@ class Submodule(util.IndexObject, Iterable, Traversable): # END initial checkout + branch creation # make sure HEAD is not detached - mrepo.head.ref = local_branch + mrepo.head.set_reference(local_branch, logmsg="submodule: attaching head to %s" % local_branch) mrepo.head.ref.set_tracking_branch(remote_branch) except IndexError: print >> sys.stderr, "Warning: Failed to checkout tracking branch %s" % self.branch_path diff --git a/objects/submodule/root.py b/objects/submodule/root.py index d194cd5b..753c6df4 100644 --- a/objects/submodule/root.py +++ b/objects/submodule/root.py @@ -68,19 +68,15 @@ class RootModule(Submodule): ################## cur_commit = repo.head.commit if previous_commit is None: - symref = repo.head.orig_head() try: - previous_commit = symref.commit - except Exception: - pcommits = cur_commit.parents - if pcommits: - previous_commit = pcommits[0] - else: - # in this special case, we just diff against ourselve, which - # means exactly no change - previous_commit = cur_commit - # END handle initial commit - # END no ORIG_HEAD + previous_commit = repo.commit(repo.head.log_entry(-1).oldhexsha) + if previous_commit.binsha == previous_commit.NULL_BIN_SHA: + raise IndexError + #END handle initial commit + except IndexError: + # in new repositories, there is no previous commit + previous_commit = cur_commit + #END exception handling else: previous_commit = repo.commit(previous_commit) # obtain commit object # END handle previous commit @@ -207,12 +203,8 @@ class RootModule(Submodule): smm = sm.module() smmr = smm.remotes try: - tbr = git.Head.create(smm, sm.branch_name) - except git.GitCommandError, e: - if e.status != 128: - raise - #END handle something unexpected - + tbr = git.Head.create(smm, sm.branch_name, logmsg='branch: Created from HEAD') + except OSError: # ... or reuse the existing one tbr = git.Head(smm, sm.branch_path) #END assure tracking branch exists |