]> source.dussan.org Git - jgit.git/commitdiff
Do not cherry-pick or revert commit more than once 23/2223/1
authorRobin Rosenberg <robin.rosenberg@dewire.com>
Mon, 10 Jan 2011 07:47:14 +0000 (08:47 +0100)
committerRobin Rosenberg <robin.rosenberg@dewire.com>
Mon, 10 Jan 2011 07:47:14 +0000 (08:47 +0100)
Instead just return success. In the case that no commit has been
cherry-picked or reverted, just return the old HEAD.

Bug: 333814
Change-Id: I67db2b77b52c43932436d22a8daa5a6556423484
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
org.eclipse.jgit/src/org/eclipse/jgit/api/CherryPickCommand.java
org.eclipse.jgit/src/org/eclipse/jgit/api/RevertCommand.java

index 2a57b11ac9469c3aae0c7c8e2a0bf79094b3939f..153c10000f1e3605c63d7ff4b58845ae494b56af 100644 (file)
@@ -114,6 +114,8 @@ public class CherryPickCommand extends GitCommand<RevCommit> {
                                                JGitText.get().commitOnRepoWithoutHEADCurrentlyNotSupported);
                        RevCommit headCommit = revWalk.parseCommit(headRef.getObjectId());
 
+                       newHead = headCommit;
+
                        // loop through all refs to be cherry-picked
                        for (Ref src : commits) {
                                // get the commit to be cherry-picked
@@ -137,6 +139,9 @@ public class CherryPickCommand extends GitCommand<RevCommit> {
                                merger.setBase(srcParent.getTree());
 
                                if (merger.merge(headCommit, srcCommit)) {
+                                       if (AnyObjectId.equals(headCommit.getTree().getId(), merger
+                                                       .getResultTreeId()))
+                                               continue;
                                        DirCacheCheckout dco = new DirCacheCheckout(repo,
                                                        headCommit.getTree(), repo.lockDirCache(),
                                                        merger.getResultTreeId());
index 26403edfda054d1b18833cd3e23f6ae7914420e7..57c69cc08a82d5115cef241d69d9f30e8efd0f4b 100644 (file)
@@ -113,6 +113,8 @@ public class RevertCommand extends GitCommand<RevCommit> {
                                                JGitText.get().commitOnRepoWithoutHEADCurrentlyNotSupported);
                        RevCommit headCommit = revWalk.parseCommit(headRef.getObjectId());
 
+                       newHead = headCommit;
+
                        // loop through all refs to be reverted
                        for (Ref src : commits) {
                                // get the commit to be reverted
@@ -136,6 +138,9 @@ public class RevertCommand extends GitCommand<RevCommit> {
                                merger.setBase(srcCommit.getTree());
 
                                if (merger.merge(headCommit, srcParent)) {
+                                       if (AnyObjectId.equals(headCommit.getTree().getId(), merger
+                                                       .getResultTreeId()))
+                                               continue;
                                        DirCacheCheckout dco = new DirCacheCheckout(repo,
                                                        headCommit.getTree(), repo.lockDirCache(),
                                                        merger.getResultTreeId());