summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.test
diff options
context:
space:
mode:
authorMatthias Sohn <matthias.sohn@sap.com>2018-03-13 02:20:29 +0100
committerMatthias Sohn <matthias.sohn@sap.com>2018-03-13 02:20:29 +0100
commite23b09ad6efc35f6574cfefd4467ad20e5212ff2 (patch)
tree2496db04e5c6c321c5df516b6e92c3c7005c90cd /org.eclipse.jgit.test
parent6f82de449fa8c2e30b60afedf9b557d879fdde8c (diff)
downloadjgit-e23b09ad6efc35f6574cfefd4467ad20e5212ff2.tar.gz
jgit-e23b09ad6efc35f6574cfefd4467ad20e5212ff2.zip
Implement --force option in FetchCommand and CLI fetch command
Change-Id: I42cdb57b8fb54ce466d1958391f12f911045327f Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Diffstat (limited to 'org.eclipse.jgit.test')
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/api/FetchCommandTest.java19
1 files changed, 19 insertions, 0 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/FetchCommandTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/FetchCommandTest.java
index 83a0564c77..cf1afceae6 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/FetchCommandTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/FetchCommandTest.java
@@ -102,6 +102,25 @@ public class FetchCommandTest extends RepositoryTestCase {
}
@Test
+ public void testForcedFetch() throws Exception {
+ remoteGit.commit().setMessage("commit").call();
+ remoteGit.commit().setMessage("commit2").call();
+ git.fetch().setRemote("test")
+ .setRefSpecs("refs/heads/master:refs/heads/master").call();
+
+ remoteGit.commit().setAmend(true).setMessage("amended").call();
+ FetchResult res = git.fetch().setRemote("test")
+ .setRefSpecs("refs/heads/master:refs/heads/master").call();
+ assertEquals(RefUpdate.Result.REJECTED,
+ res.getTrackingRefUpdate("refs/heads/master").getResult());
+ res = git.fetch().setRemote("test")
+ .setRefSpecs("refs/heads/master:refs/heads/master")
+ .setForceUpdate(true).call();
+ assertEquals(RefUpdate.Result.FORCED,
+ res.getTrackingRefUpdate("refs/heads/master").getResult());
+ }
+
+ @Test
public void fetchShouldAutoFollowTag() throws Exception {
remoteGit.commit().setMessage("commit").call();
Ref tagRef = remoteGit.tag().setName("foo").call();