diff options
author | Matthias Sohn <matthias.sohn@sap.com> | 2021-05-26 17:21:02 +0200 |
---|---|---|
committer | Matthias Sohn <matthias.sohn@sap.com> | 2021-05-26 17:21:30 +0200 |
commit | 2f2f6e51b9e34034641f640691e4cc155e48153b (patch) | |
tree | d21824f7c48a3c7501a9f6b47db69ced8373fab3 /org.eclipse.jgit.pgm.test | |
parent | 4e290d389ab2f56b6e43d091e6542d0a6a36e9b7 (diff) | |
parent | 0667b8ec4d8b10ebc57271642953de6852c3331b (diff) | |
download | jgit-2f2f6e51b9e34034641f640691e4cc155e48153b.tar.gz jgit-2f2f6e51b9e34034641f640691e4cc155e48153b.zip |
Merge branch 'master' into stable-5.12
* master:
RepoCommand: Do not set 'branch' if the revision is a tag
pgm: rewrite parents when --parents flag is passed
ApplyCommand: fix "no newline at end" detection
ApplyCommand: handle completely empty context lines in text patches
ApplyCommand: use byte arrays for text patches, not strings
ApplyCommand: support binary patches
ApplyCommand: add a stream to apply a delta patch
ApplyCommand: add streams to read/write binary patch hunks
ApplyCommand: add a base-85 codec
ApplyCommand: convert to git internal format before applying patch
SSH config: fix whitespace handling
SSH config: fix negated patterns
Fix @since tag for introduction of PUBKEY_ACCEPTED_ALGORITHMS
Prepare 5.11.2-SNAPSHOT builds
JGit v5.11.1.202105131744-r
Add a cgit interoperability test for LockFile
Add TemporaryBuffer.toString(int limit)
LockFile: create OutputStream only when needed
Add git config for conflict style merge/diff3
Change-Id: If7751ff99079eaea31ed1fce811d141ecf209727
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Diffstat (limited to 'org.eclipse.jgit.pgm.test')
-rw-r--r-- | org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/RevListTest.java | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/RevListTest.java b/org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/RevListTest.java new file mode 100644 index 0000000000..06fddc29d9 --- /dev/null +++ b/org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/RevListTest.java @@ -0,0 +1,75 @@ +/* + * Copyright (C) 2021, kylezhao <kylezhao@tencent.com> and others. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Distribution License v. 1.0 which is available at + * https://www.eclipse.org/org/documents/edl-v10.php. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +package org.eclipse.jgit.pgm; + +import static org.junit.Assert.assertEquals; + +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.jgit.api.Git; +import org.eclipse.jgit.lib.CLIRepositoryTestCase; +import org.eclipse.jgit.revwalk.RevCommit; +import org.junit.Before; +import org.junit.Test; + +public class RevListTest extends CLIRepositoryTestCase { + + private Git git; + + @Override + @Before + public void setUp() throws Exception { + super.setUp(); + git = new Git(db); + } + + @Test + public void testWithParentsFlag() throws Exception { + List<RevCommit> commits = createCommitsForParentsFlag(git); + String result = toString( + execute("git rev-list HEAD --parents -- Test.txt")); + + String expect = toString( + commits.get(3).name() + ' ' + commits.get(1).name(), + commits.get(1).name()); + + assertEquals(expect, result); + } + + @Test + public void testWithoutParentsFlag() throws Exception { + List<RevCommit> commits = createCommitsForParentsFlag(git); + String result = toString(execute("git rev-list HEAD -- Test.txt")); + + String expect = toString(commits.get(3).name(), commits.get(1).name()); + + assertEquals(expect, result); + } + + private List<RevCommit> createCommitsForParentsFlag(Git git) + throws Exception { + List<RevCommit> commits = new ArrayList<>(); + writeTrashFile("Test1.txt", "Hello world"); + git.add().addFilepattern("Test1.txt").call(); + commits.add(git.commit().setMessage("commit#0").call()); + writeTrashFile("Test.txt", "Hello world!"); + git.add().addFilepattern("Test.txt").call(); + commits.add(git.commit().setMessage("commit#1").call()); + writeTrashFile("Test1.txt", "Hello world!!"); + git.add().addFilepattern("Test1.txt").call(); + commits.add(git.commit().setMessage("commit#2").call()); + writeTrashFile("Test.txt", "Hello world!!!"); + git.add().addFilepattern("Test.txt").call(); + commits.add(git.commit().setMessage("commit#3").call()); + return commits; + } +} |