Skip to content

Commit ba67e4f

Browse files
committed
Assure API remains backwards compatible; update API docs
1 parent 9780b7a commit ba67e4f

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

‎git/objects/commit.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -276,14 +276,17 @@ def create_from_tree(cls, repo, tree, message, parent_commits=None, head=False,
276276
If True, the HEAD will be advanced to the new commit automatically.
277277
Else the HEAD will remain pointing on the previous commit. This could
278278
lead to undesired results when diffing files.
279+
:param author: The name of the author, optional. If unset, the repository
280+
configuration is used to obtain this value.
281+
:param committer: The name of the committer, optional. If unset, the
282+
repository configuration is used to obtain this value.
279283
280284
:return: Commit object representing the new commit
281285
282286
:note:
283287
Additional information about the committer and Author are taken from the
284288
environment or from the git configuration, see git-commit-tree for
285289
more information"""
286-
parents = parent_commits
287290
if parent_commits is None:
288291
try:
289292
parent_commits = [repo.head.commit]
@@ -357,7 +360,6 @@ def create_from_tree(cls, repo, tree, message, parent_commits=None, head=False,
357360
except ValueError:
358361
# head is not yet set to the ref our HEAD points to
359362
# Happens on first commit
360-
import git.refs
361363
master = git.refs.Head.create(repo, repo.head.ref, new_commit, logmsg="commit (initial): %s" % message)
362364
repo.head.set_reference(master, logmsg='commit: Switching to %s' % master)
363365
# END handle empty repositories

‎git/refs/symbolic.py

+9-3
Original file line numberDiff line numberDiff line change
@@ -356,10 +356,16 @@ def log_append(self, oldbinsha, message, newbinsha=None):
356356
will be used
357357
:return: added RefLogEntry instance"""
358358
# NOTE: we use the committer of the currently active commit - this should be
359-
# correct. See https://github.com/gitpython-developers/GitPython/pull/146
360-
return RefLog.append_entry(self.commit.committer, RefLog.path(self), oldbinsha,
359+
# correct to allow overriding the committer on a per-commit level.
360+
# See https://github.com/gitpython-developers/GitPython/pull/146
361+
try:
362+
committer_or_reader = self.commit.committer
363+
except ValueError:
364+
committer_or_reader = self.repo.config_reader()
365+
# end handle newly cloned repositories
366+
return RefLog.append_entry(committer_or_reader, RefLog.path(self), oldbinsha,
361367
(newbinsha is None and self.commit.binsha) or newbinsha,
362-
message)
368+
message)
363369

364370
def log_entry(self, index):
365371
""":return: RefLogEntry at the given index

0 commit comments

Comments
 (0)