diff options
Diffstat (limited to 'git/objects/commit.py')
-rw-r--r-- | git/objects/commit.py | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/git/objects/commit.py b/git/objects/commit.py index d778f2d7..453afe66 100644 --- a/git/objects/commit.py +++ b/git/objects/commit.py @@ -258,7 +258,7 @@ class Commit(base.Object, Iterable, Diffable, Traversable, Serializable): finalize_process(proc_or_stream) @classmethod - def create_from_tree(cls, repo, tree, message, parent_commits=None, head=False): + def create_from_tree(cls, repo, tree, message, parent_commits=None, head=False, author=None, committer=None): """Commit the given tree, creating a commit object. :param repo: Repo object the commit should be part of @@ -276,6 +276,10 @@ class Commit(base.Object, Iterable, Diffable, Traversable, Serializable): If True, the HEAD will be advanced to the new commit automatically. Else the HEAD will remain pointing on the previous commit. This could lead to undesired results when diffing files. + :param author: The name of the author, optional. If unset, the repository + configuration is used to obtain this value. + :param committer: The name of the committer, optional. If unset, the + repository configuration is used to obtain this value. :return: Commit object representing the new commit @@ -283,7 +287,6 @@ class Commit(base.Object, Iterable, Diffable, Traversable, Serializable): Additional information about the committer and Author are taken from the environment or from the git configuration, see git-commit-tree for more information""" - parents = parent_commits if parent_commits is None: try: parent_commits = [repo.head.commit] @@ -303,8 +306,8 @@ class Commit(base.Object, Iterable, Diffable, Traversable, Serializable): cr = repo.config_reader() env = os.environ - committer = Actor.committer(cr) - author = Actor.author(cr) + committer = committer or Actor.committer(cr) + author = author or Actor.author(cr) # PARSE THE DATES unix_time = int(time()) @@ -357,7 +360,6 @@ class Commit(base.Object, Iterable, Diffable, Traversable, Serializable): 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, new_commit, logmsg="commit (initial): %s" % message) repo.head.set_reference(master, logmsg='commit: Switching to %s' % master) # END handle empty repositories |