From 79f33419ec073edf31a1db16ae9b11e69ee997a1 Mon Sep 17 00:00:00 2001 From: Robin Stocker Date: Sun, 7 Oct 2012 17:18:58 +0200 Subject: CommitCommand: Use original author on amend if author is not set This way, callers don't have to parse author ident of HEAD themselves. Bug: 362391 Change-Id: I383a817e6ed4707d637c52c007bc7b57728e6c85 --- org.eclipse.jgit/src/org/eclipse/jgit/api/CommitCommand.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'org.eclipse.jgit/src/org/eclipse/jgit/api') diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/CommitCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/CommitCommand.java index 87c282d110..a166790a40 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/api/CommitCommand.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/CommitCommand.java @@ -187,6 +187,8 @@ public class CommitCommand extends GitCommand { RevCommit[] p = previousCommit.getParents(); for (int i = 0; i < p.length; i++) parents.add(0, p[i].getId()); + if (author == null) + author = previousCommit.getAuthorIdent(); } else { parents.add(0, headId); } @@ -471,7 +473,7 @@ public class CommitCommand extends GitCommand { private void processOptions(RepositoryState state) throws NoMessageException { if (committer == null) committer = new PersonIdent(repo); - if (author == null) + if (author == null && !amend) author = committer; // when doing a merge commit parse MERGE_HEAD and MERGE_MSG files @@ -574,7 +576,8 @@ public class CommitCommand extends GitCommand { /** * Sets the author for this {@code commit}. If no author is explicitly * specified because this method is never called or called with {@code null} - * value then the author will be set to the committer. + * value then the author will be set to the committer or to the original + * author when amending. * * @param author * the author used for the {@code commit} @@ -589,7 +592,8 @@ public class CommitCommand extends GitCommand { /** * Sets the author for this {@code commit}. If no author is explicitly * specified because this method is never called or called with {@code null} - * value then the author will be set to the committer. + * value then the author will be set to the committer or to the original + * author when amending. * * @param name * the name of the author used for the {@code commit} -- cgit v1.2.3