diff options
author | Robin Stocker <robin@nibor.org> | 2012-10-07 17:18:58 +0200 |
---|---|---|
committer | Robin Stocker <robin@nibor.org> | 2012-10-08 00:31:27 +0200 |
commit | 79f33419ec073edf31a1db16ae9b11e69ee997a1 (patch) | |
tree | 0d96710ee0d70e4f92a58ed64ee65fe163618704 /org.eclipse.jgit/src/org/eclipse/jgit/api | |
parent | c96b40d5921d68edb96afad38b9c171388af4e05 (diff) | |
download | jgit-79f33419ec073edf31a1db16ae9b11e69ee997a1.tar.gz jgit-79f33419ec073edf31a1db16ae9b11e69ee997a1.zip |
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
Diffstat (limited to 'org.eclipse.jgit/src/org/eclipse/jgit/api')
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/api/CommitCommand.java | 10 |
1 files changed, 7 insertions, 3 deletions
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> { 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<RevCommit> { 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<RevCommit> { /** * 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<RevCommit> { /** * 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} |