summaryrefslogtreecommitdiffstats
path: root/core/save-git.c
diff options
context:
space:
mode:
Diffstat (limited to 'core/save-git.c')
-rw-r--r--core/save-git.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/core/save-git.c b/core/save-git.c
index e5ff5378b..227430a2e 100644
--- a/core/save-git.c
+++ b/core/save-git.c
@@ -1151,22 +1151,30 @@ static int create_new_commit(git_repository *repo, const char *remote, const cha
/* If the parent commit has the same tree ID, do not create a new commit */
if (parent && git_oid_equal(tree_id, git_commit_tree_id((const git_commit *) parent))) {
/* If the parent already came from the ref, the commit is already there */
- if (ref)
+ if (ref) {
+ git_signature_free(author);
return 0;
+ }
/* Else we do want to create the new branch, but with the old commit */
commit = (git_commit *) parent;
} else {
struct membuffer commit_msg = { 0 };
create_commit_message(&commit_msg, create_empty);
- if (git_commit_create_v(&commit_id, repo, NULL, author, author, NULL, mb_cstring(&commit_msg), tree, parent != NULL, parent))
+ if (git_commit_create_v(&commit_id, repo, NULL, author, author, NULL, mb_cstring(&commit_msg), tree, parent != NULL, parent)) {
+ git_signature_free(author);
return report_error("Git commit create failed (%s)", strerror(errno));
+ }
free_buffer(&commit_msg);
- if (git_commit_lookup(&commit, repo, &commit_id))
+ if (git_commit_lookup(&commit, repo, &commit_id)) {
+ git_signature_free(author);
return report_error("Could not look up newly created commit");
+ }
}
+ git_signature_free(author);
+
if (!ref) {
if (git_branch_create(&ref, repo, branch, commit, 0))
return report_error("Failed to create branch '%s'", branch);
@@ -1198,8 +1206,6 @@ static int create_new_commit(git_repository *repo, const char *remote, const cha
if (! create_empty)
set_git_id(&commit_id);
- git_signature_free(author);
-
return 0;
}