summaryrefslogtreecommitdiff
path: root/lib/git/index.py
diff options
context:
space:
mode:
Diffstat (limited to 'lib/git/index.py')
-rw-r--r--lib/git/index.py53
1 files changed, 4 insertions, 49 deletions
diff --git a/lib/git/index.py b/lib/git/index.py
index 930f2c75..b3dd12fd 100644
--- a/lib/git/index.py
+++ b/lib/git/index.py
@@ -995,58 +995,13 @@ class IndexFile(LazyMixin, diff.Diffable):
"""
Commit the current index, creating a commit object.
- ``message``
- Commit message. It may be an empty string if no message is provided.
- It will be converted to a string in any case.
-
- ``parent_commits``
- Optional Commit objects to use as parents for the new commit.
- If empty list, the commit will have no parents at all and become
- a root commit.
- If None , the current head commit will be the parent of the
- new commit object
-
- ``head``
- 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.
-
+ For more information on the arguments, see tree.commit.
+
Returns
Commit object representing the new commit
-
- Note:
- Additional information about hte 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:
- parent_commits = [ self.repo.head.commit ]
-
- parent_args = [ ("-p", str(commit)) for commit in parent_commits ]
-
- # create message stream
- tmp_file_path = tempfile.mktemp()
- fp = open(tmp_file_path,"wb")
- fp.write(str(message))
- fp.close()
- fp = open(tmp_file_path,"rb")
- fp.seek(0)
-
- try:
- # write the current index as tree
- tree_sha = self.repo.git.write_tree()
- commit_sha = self.repo.git.commit_tree(tree_sha, parent_args, istream=fp)
- new_commit = Commit(self.repo, commit_sha)
-
- if head:
- self.repo.head.commit = new_commit
- # END advance head handling
-
- return new_commit
- finally:
- fp.close()
- os.remove(tmp_file_path)
+ tree_sha = self.repo.git.write_tree()
+ return Commit.create_from_tree(self.repo, tree_sha, message, parent_commits, head)
@classmethod
def _flush_stdin_and_wait(cls, proc):