diff options
author | Shawn O. Pearce <spearce@spearce.org> | 2010-01-28 11:10:52 -0800 |
---|---|---|
committer | Robin Rosenberg <robin.rosenberg@dewire.com> | 2010-01-29 05:48:31 +0100 |
commit | 48e9a010ae9cfee5cc2daae2bf20d510ab9c108f (patch) | |
tree | 35f60e6322516e0b1a4aa9aa50c523e2fff05f88 /org.eclipse.jgit.test/tst | |
parent | aa97c6e4499547c1e33b54a5630b03f2983828b4 (diff) | |
download | jgit-48e9a010ae9cfee5cc2daae2bf20d510ab9c108f.tar.gz jgit-48e9a010ae9cfee5cc2daae2bf20d510ab9c108f.zip |
Add unsetSection to Config to remove an entire block
The unsetSection method can be used to delete an entire configuration
block, such as a [branch ""] or [remote ""] section in a file.
Change-Id: I93390c9b2187eb1b0d51353518feaed83bed2aad
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
Diffstat (limited to 'org.eclipse.jgit.test/tst')
-rw-r--r-- | org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/RepositoryConfigTest.java | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/RepositoryConfigTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/RepositoryConfigTest.java index 203b7c8251..41c4971a04 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/RepositoryConfigTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/RepositoryConfigTest.java @@ -271,6 +271,47 @@ public class RepositoryConfigTest extends TestCase { assertEquals("[my]\n\tempty =\n", c.toText()); } + public void testUnsetBranchSection() throws ConfigInvalidException { + Config c = parse("" // + + "[branch \"keep\"]\n" + + " merge = master.branch.to.keep.in.the.file\n" + + "\n" + + "[branch \"remove\"]\n" + + " merge = this.will.get.deleted\n" + + " remote = origin-for-some-long-gone-place\n" + + "\n" + + "[core-section-not-to-remove-in-test]\n" + + " packedGitLimit = 14\n"); + c.unsetSection("branch", "does.not.exist"); + c.unsetSection("branch", "remove"); + assertEquals("" // + + "[branch \"keep\"]\n" + + " merge = master.branch.to.keep.in.the.file\n" + + "\n" + + "[core-section-not-to-remove-in-test]\n" + + " packedGitLimit = 14\n", c.toText()); + } + + public void testUnsetSingleSection() throws ConfigInvalidException { + Config c = parse("" // + + "[branch \"keep\"]\n" + + " merge = master.branch.to.keep.in.the.file\n" + + "\n" + + "[single]\n" + + " merge = this.will.get.deleted\n" + + " remote = origin-for-some-long-gone-place\n" + + "\n" + + "[core-section-not-to-remove-in-test]\n" + + " packedGitLimit = 14\n"); + c.unsetSection("single", null); + assertEquals("" // + + "[branch \"keep\"]\n" + + " merge = master.branch.to.keep.in.the.file\n" + + "\n" + + "[core-section-not-to-remove-in-test]\n" + + " packedGitLimit = 14\n", c.toText()); + } + private void assertReadLong(long exp) throws ConfigInvalidException { assertReadLong(exp, String.valueOf(exp)); } |