diff options
author | Dariusz Luksza | 2011-02-21 20:31:44 +0000 |
---|---|---|
committer | Dariusz Luksza | 2011-02-23 14:46:40 +0000 |
commit | ac389e12320449824c78eb5e970b0ba5e6fdeeba (patch) | |
tree | 94fcdc3a12fb2af727b6993f0f14bf35228351fe /org.eclipse.egit.core | |
parent | e21649480b45d419c19a1f46d56bc6150eb18cfe (diff) | |
download | egit-ac389e12320449824c78eb5e970b0ba5e6fdeeba.tar.gz egit-ac389e12320449824c78eb5e970b0ba5e6fdeeba.tar.xz egit-ac389e12320449824c78eb5e970b0ba5e6fdeeba.zip |
[sync] Fix NPE when synchronizing empty repository
Synchronization fails with NPE when it was launched on empty
repository.
Test case for this issue were added. Also there were made some changes
in all test cases to improve theirs reliability.
Bug: 337540
Change-Id: Ie904980c9a7cf6f4495219ef99514083e72b6bbc
Signed-off-by: Dariusz Luksza <dariusz@luksza.org>
Diffstat (limited to 'org.eclipse.egit.core')
-rw-r--r-- | org.eclipse.egit.core/src/org/eclipse/egit/core/synchronize/dto/GitSynchronizeData.java | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/org.eclipse.egit.core/src/org/eclipse/egit/core/synchronize/dto/GitSynchronizeData.java b/org.eclipse.egit.core/src/org/eclipse/egit/core/synchronize/dto/GitSynchronizeData.java index 1c983f8d0c..255aa5d834 100644 --- a/org.eclipse.egit.core/src/org/eclipse/egit/core/synchronize/dto/GitSynchronizeData.java +++ b/org.eclipse.egit.core/src/org/eclipse/egit/core/synchronize/dto/GitSynchronizeData.java @@ -67,9 +67,21 @@ public class GitSynchronizeData { repo = repository; ObjectWalk ow = new ObjectWalk(repo); - this.srcRev = ow.parseCommit(repo.resolve(srcRev)); - this.dstRev = ow.parseCommit(repo.resolve(dstRev)); - this.commonAncestorRev = getCommonAncestor(repo, this.srcRev, this.dstRev); + if (!srcRev.isEmpty()) + this.srcRev = ow.parseCommit(repo.resolve(srcRev)); + else + this.srcRev = null; + + if (!dstRev.isEmpty()) + this.dstRev = ow.parseCommit(repo.resolve(dstRev)); + else + this.dstRev = null; + + if (this.dstRev != null || this.srcRev != null) + this.commonAncestorRev = getCommonAncestor(repo, this.srcRev, + this.dstRev); + else + this.commonAncestorRev = null; this.includeLocal = includeLocal; repoParentPath = repo.getDirectory().getParentFile().getAbsolutePath(); |