Преглед на файлове

Merge branch 'stable-3.2'

* stable-3.2:
  Canonicalize worktree path in BaseRepositoryBuilder if set via config
  Add missing @since tags for new public methods in Config
  Don't use API exception in RebaseTodoLine
  Fix aborting rebase with detached head
  Add recursive variant of Config.getNames() methods
  Prepare post 3.2.0-m3 builds
  JGit v3.2.0.201311130903-m3

Change-Id: Iad6e284e0fe2c7950f156372b334e47ebd82f3f7
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
tags/v3.3.0.201402191814-rc1
Matthias Sohn преди 10 години
родител
ревизия
aad7dee3ef

+ 177
- 36
org.eclipse.jgit.test/tst/org/eclipse/jgit/api/RebaseCommandTest.java Целия файл

@@ -64,13 +64,13 @@ import org.eclipse.jgit.api.RebaseCommand.InteractiveHandler;
import org.eclipse.jgit.api.RebaseCommand.Operation;
import org.eclipse.jgit.api.RebaseResult.Status;
import org.eclipse.jgit.api.errors.InvalidRebaseStepException;
import org.eclipse.jgit.api.errors.JGitInternalException;
import org.eclipse.jgit.api.errors.RefNotFoundException;
import org.eclipse.jgit.api.errors.UnmergedPathsException;
import org.eclipse.jgit.api.errors.WrongRepositoryStateException;
import org.eclipse.jgit.diff.DiffEntry;
import org.eclipse.jgit.dircache.DirCacheCheckout;
import org.eclipse.jgit.errors.AmbiguousObjectException;
import org.eclipse.jgit.errors.IllegalTodoFileModification;
import org.eclipse.jgit.errors.IncorrectObjectTypeException;
import org.eclipse.jgit.errors.MissingObjectException;
import org.eclipse.jgit.junit.RepositoryTestCase;
@@ -575,6 +575,69 @@ public class RebaseCommandTest extends RepositoryTestCase {
assertFalse(new File(db.getDirectory(), "rebase-merge").exists());
}

@Test
public void testStopOnConflictAndAbortWithDetachedHEAD() throws Exception {
// create file1 on master
RevCommit firstInMaster = writeFileAndCommit(FILE1, "Add file1", "1",
"2", "3");
// change first line in master
writeFileAndCommit(FILE1, "change file1 in master", "1master", "2", "3");
checkFile(FILE1, "1master", "2", "3");
// create a topic branch based on second commit
createBranch(firstInMaster, "refs/heads/topic");
checkoutBranch("refs/heads/topic");
// we have the old content again
checkFile(FILE1, "1", "2", "3");

// add a line (non-conflicting)
writeFileAndCommit(FILE1, "add a line to file1 in topic", "1", "2",
"3", "topic4");

// change first line (conflicting)
RevCommit conflicting = writeFileAndCommit(FILE1,
"change file1 in topic", "1topic", "2", "3", "topic4");

RevCommit lastTopicCommit = writeFileAndCommit(FILE1,
"change file1 in topic again", "1topic", "2", "3", "topic4");

git.checkout().setName(lastTopicCommit.getName()).call();

RebaseResult res = git.rebase().setUpstream("refs/heads/master").call();
assertEquals(Status.STOPPED, res.getStatus());
assertEquals(conflicting, res.getCurrentCommit());
checkFile(FILE1,
"<<<<<<< Upstream, based on master\n1master\n=======\n1topic",
">>>>>>> e0d1dea change file1 in topic\n2\n3\ntopic4");

assertEquals(RepositoryState.REBASING_INTERACTIVE,
db.getRepositoryState());
assertTrue(new File(db.getDirectory(), "rebase-merge").exists());
// the first one should be included, so we should have left two picks in
// the file
assertEquals(1, countPicks());

// rebase should not succeed in this state
try {
git.rebase().setUpstream("refs/heads/master").call();
fail("Expected exception was not thrown");
} catch (WrongRepositoryStateException e) {
// expected
}

// abort should reset to topic branch
res = git.rebase().setOperation(Operation.ABORT).call();
assertEquals(res.getStatus(), Status.ABORTED);
assertEquals(lastTopicCommit.getName(), db.getFullBranch());
checkFile(FILE1, "1topic", "2", "3", "topic4");
RevWalk rw = new RevWalk(db);
assertEquals(lastTopicCommit,
rw.parseCommit(db.resolve(Constants.HEAD)));
assertEquals(RepositoryState.SAFE, db.getRepositoryState());

// rebase- dir in .git must be deleted
assertFalse(new File(db.getDirectory(), "rebase-merge").exists());
}

@Test
public void testStopOnConflictAndContinue() throws Exception {
// create file1 on master
@@ -1890,8 +1953,12 @@ public class RebaseCommandTest extends RepositoryTestCase {
RebaseResult res2 = git.rebase().setUpstream("HEAD~2")
.runInteractively(new InteractiveHandler() {
public void prepareSteps(List<RebaseTodoLine> steps) {
steps.get(0).setAction(Action.COMMENT); // delete
// RevCommit c4
try {
// delete RevCommit c4
steps.get(0).setAction(Action.COMMENT);
} catch (IllegalTodoFileModification e) {
fail("unexpected exception: " + e);
}
}

public String modifyCommitMessage(String commit) {
@@ -2020,7 +2087,7 @@ public class RebaseCommandTest extends RepositoryTestCase {
try {
new RebaseTodoLine("This is a invalid comment");
fail("Constructing a comment line with invalid comment string should fail, but doesn't");
} catch (JGitInternalException e) {
} catch (IllegalArgumentException e) {
// expected
}
RebaseTodoLine validCommentLine = new RebaseTodoLine(
@@ -2035,7 +2102,7 @@ public class RebaseCommandTest extends RepositoryTestCase {
try {
actionLineToBeChanged.setComment("invalid comment");
fail("Setting a invalid comment string should fail but doesn't");
} catch (JGitInternalException e) {
} catch (IllegalArgumentException e) {
assertEquals(null, actionLineToBeChanged.getComment());
}

@@ -2044,7 +2111,7 @@ public class RebaseCommandTest extends RepositoryTestCase {
try {
actionLineToBeChanged.setComment("invalid comment");
fail("Setting a invalid comment string should fail but doesn't");
} catch (JGitInternalException e) {
} catch (IllegalArgumentException e) {
// expected
// setting comment failed, but was successfully set before,
// therefore it may not be altered since then
@@ -2061,7 +2128,7 @@ public class RebaseCommandTest extends RepositoryTestCase {
actionLineToBeChanged.setComment("line1 \n\r line2");
actionLineToBeChanged.setComment("\n\r");
fail("Setting a multiline comment string should fail but doesn't");
} catch (JGitInternalException e) {
} catch (IllegalArgumentException e) {
// expected
}
// Try setting valid comments
@@ -2113,9 +2180,15 @@ public class RebaseCommandTest extends RepositoryTestCase {

RebaseResult res = git.rebase().setUpstream("HEAD~2")
.runInteractively(new InteractiveHandler() {

public void prepareSteps(List<RebaseTodoLine> steps) {
steps.get(0).setAction(Action.REWORD);
try {
steps.get(0).setAction(Action.REWORD);
} catch (IllegalTodoFileModification e) {
fail("unexpected exception: " + e);
}
}

public String modifyCommitMessage(String commit) {
return "rewritten commit message";
}
@@ -2155,7 +2228,11 @@ public class RebaseCommandTest extends RepositoryTestCase {
RebaseResult res = git.rebase().setUpstream("HEAD~2")
.runInteractively(new InteractiveHandler() {
public void prepareSteps(List<RebaseTodoLine> steps) {
steps.get(0).setAction(Action.EDIT);
try {
steps.get(0).setAction(Action.EDIT);
} catch (IllegalTodoFileModification e) {
fail("unexpected exception: " + e);
}
}

public String modifyCommitMessage(String commit) {
@@ -2215,7 +2292,11 @@ public class RebaseCommandTest extends RepositoryTestCase {
.runInteractively(new InteractiveHandler() {

public void prepareSteps(List<RebaseTodoLine> steps) {
steps.get(1).setAction(Action.SQUASH);
try {
steps.get(1).setAction(Action.SQUASH);
} catch (IllegalTodoFileModification e) {
fail("unexpected exception: " + e);
}
}

public String modifyCommitMessage(String commit) {
@@ -2290,8 +2371,12 @@ public class RebaseCommandTest extends RepositoryTestCase {
.runInteractively(new InteractiveHandler() {

public void prepareSteps(List<RebaseTodoLine> steps) {
steps.get(1).setAction(Action.SQUASH);
steps.get(2).setAction(Action.SQUASH);
try {
steps.get(1).setAction(Action.SQUASH);
steps.get(2).setAction(Action.SQUASH);
} catch (IllegalTodoFileModification e) {
fail("unexpected exception: " + e);
}
}

public String modifyCommitMessage(String commit) {
@@ -2367,8 +2452,12 @@ public class RebaseCommandTest extends RepositoryTestCase {
.runInteractively(new InteractiveHandler() {

public void prepareSteps(List<RebaseTodoLine> steps) {
steps.get(1).setAction(Action.FIXUP);
steps.get(2).setAction(Action.SQUASH);
try {
steps.get(1).setAction(Action.FIXUP);
steps.get(2).setAction(Action.SQUASH);
} catch (IllegalTodoFileModification e) {
fail("unexpected exception: " + e);
}
}

public String modifyCommitMessage(String commit) {
@@ -2437,7 +2526,11 @@ public class RebaseCommandTest extends RepositoryTestCase {
.runInteractively(new InteractiveHandler() {

public void prepareSteps(List<RebaseTodoLine> steps) {
steps.get(1).setAction(Action.FIXUP);
try {
steps.get(1).setAction(Action.FIXUP);
} catch (IllegalTodoFileModification e) {
fail("unexpected exception: " + e);
}
}

public String modifyCommitMessage(String commit) {
@@ -2481,7 +2574,11 @@ public class RebaseCommandTest extends RepositoryTestCase {
.runInteractively(new InteractiveHandler() {

public void prepareSteps(List<RebaseTodoLine> steps) {
steps.get(1).setAction(Action.FIXUP);
try {
steps.get(1).setAction(Action.FIXUP);
} catch (IllegalTodoFileModification e) {
fail("unexpected exception: " + e);
}
}

public String modifyCommitMessage(String commit) {
@@ -2516,7 +2613,11 @@ public class RebaseCommandTest extends RepositoryTestCase {
.runInteractively(new InteractiveHandler() {

public void prepareSteps(List<RebaseTodoLine> steps) {
steps.get(0).setAction(Action.FIXUP);
try {
steps.get(0).setAction(Action.FIXUP);
} catch (IllegalTodoFileModification e) {
fail("unexpected exception: " + e);
}
}

public String modifyCommitMessage(String commit) {
@@ -2544,7 +2645,11 @@ public class RebaseCommandTest extends RepositoryTestCase {
.runInteractively(new InteractiveHandler() {

public void prepareSteps(List<RebaseTodoLine> steps) {
steps.get(0).setAction(Action.SQUASH);
try {
steps.get(0).setAction(Action.SQUASH);
} catch (IllegalTodoFileModification e) {
fail("unexpected exception: " + e);
}
}

public String modifyCommitMessage(String commit) {
@@ -2571,7 +2676,11 @@ public class RebaseCommandTest extends RepositoryTestCase {
.runInteractively(new InteractiveHandler() {

public void prepareSteps(List<RebaseTodoLine> steps) {
steps.get(0).setAction(Action.EDIT);
try {
steps.get(0).setAction(Action.EDIT);
} catch (IllegalTodoFileModification e) {
fail("unexpected exception: " + e);
}
}

public String modifyCommitMessage(String commit) {
@@ -2610,7 +2719,11 @@ public class RebaseCommandTest extends RepositoryTestCase {

public void prepareSteps(List<RebaseTodoLine> steps) {
steps.remove(0);
steps.get(0).setAction(Action.EDIT);
try {
steps.get(0).setAction(Action.EDIT);
} catch (IllegalTodoFileModification e) {
fail("unexpected exception: " + e);
}
}

public String modifyCommitMessage(String commit) {
@@ -2648,7 +2761,11 @@ public class RebaseCommandTest extends RepositoryTestCase {

public void prepareSteps(List<RebaseTodoLine> steps) {
steps.remove(0);
steps.get(0).setAction(Action.REWORD);
try {
steps.get(0).setAction(Action.REWORD);
} catch (IllegalTodoFileModification e) {
fail("unexpected exception: " + e);
}
}

public String modifyCommitMessage(String commit) {
@@ -2661,7 +2778,11 @@ public class RebaseCommandTest extends RepositoryTestCase {

public void prepareSteps(List<RebaseTodoLine> steps) {
steps.remove(0);
steps.get(0).setAction(Action.REWORD);
try {
steps.get(0).setAction(Action.REWORD);
} catch (IllegalTodoFileModification e) {
fail("unexpected exception: " + e);
}
}

public String modifyCommitMessage(String commit) {
@@ -2702,9 +2823,13 @@ public class RebaseCommandTest extends RepositoryTestCase {
.runInteractively(new InteractiveHandler() {

public void prepareSteps(List<RebaseTodoLine> steps) {
steps.get(0).setAction(Action.PICK);
steps.remove(1);
steps.get(1).setAction(Action.SQUASH);
try {
steps.get(0).setAction(Action.PICK);
steps.remove(1);
steps.get(1).setAction(Action.SQUASH);
} catch (IllegalTodoFileModification e) {
fail("unexpected exception: " + e);
}
}

public String modifyCommitMessage(String commit) {
@@ -2716,9 +2841,13 @@ public class RebaseCommandTest extends RepositoryTestCase {
result = git.rebase().runInteractively(new InteractiveHandler() {

public void prepareSteps(List<RebaseTodoLine> steps) {
steps.get(0).setAction(Action.PICK);
steps.remove(1);
steps.get(1).setAction(Action.SQUASH);
try {
steps.get(0).setAction(Action.PICK);
steps.remove(1);
steps.get(1).setAction(Action.SQUASH);
} catch (IllegalTodoFileModification e) {
fail("unexpected exception: " + e);
}
}

public String modifyCommitMessage(String commit) {
@@ -2760,9 +2889,13 @@ public class RebaseCommandTest extends RepositoryTestCase {
.runInteractively(new InteractiveHandler() {

public void prepareSteps(List<RebaseTodoLine> steps) {
steps.get(0).setAction(Action.PICK);
steps.remove(1);
steps.get(1).setAction(Action.FIXUP);
try {
steps.get(0).setAction(Action.PICK);
steps.remove(1);
steps.get(1).setAction(Action.FIXUP);
} catch (IllegalTodoFileModification e) {
fail("unexpected exception: " + e);
}
}

public String modifyCommitMessage(String commit) {
@@ -2774,9 +2907,13 @@ public class RebaseCommandTest extends RepositoryTestCase {
result = git.rebase().runInteractively(new InteractiveHandler() {

public void prepareSteps(List<RebaseTodoLine> steps) {
steps.get(0).setAction(Action.PICK);
steps.remove(1);
steps.get(1).setAction(Action.FIXUP);
try {
steps.get(0).setAction(Action.PICK);
steps.remove(1);
steps.get(1).setAction(Action.FIXUP);
} catch (IllegalTodoFileModification e) {
fail("unexpected exception: " + e);
}
}

public String modifyCommitMessage(String commit) {
@@ -2823,8 +2960,12 @@ public class RebaseCommandTest extends RepositoryTestCase {
.runInteractively(new InteractiveHandler() {

public void prepareSteps(List<RebaseTodoLine> steps) {
steps.get(0).setAction(Action.EDIT);
steps.get(1).setAction(Action.PICK);
try {
steps.get(0).setAction(Action.EDIT);
steps.get(1).setAction(Action.PICK);
} catch (IllegalTodoFileModification e) {
fail("unexpected exception: " + e);
}
}

public String modifyCommitMessage(String commit) {

+ 55
- 1
org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ConfigTest.java Целия файл

@@ -519,6 +519,31 @@ public class ConfigTest {
assertFalse(itr.hasNext());
}

@Test
public void test_ReadNamesInSectionRecursive()
throws ConfigInvalidException {
String baseConfigString = "[core]\n" + "logAllRefUpdates = true\n";
String configString = "[core]\n" + "repositoryFormatVersion = 0\n"
+ "filemode = false\n";
final Config c = parse(configString, parse(baseConfigString));
Set<String> names = c.getNames("core", true);
assertEquals("Core section size", 3, names.size());
assertTrue("Core section should contain \"filemode\"",
names.contains("filemode"));
assertTrue("Core section should contain \"repositoryFormatVersion\"",
names.contains("repositoryFormatVersion"));
assertTrue("Core section should contain \"logAllRefUpdates\"",
names.contains("logAllRefUpdates"));
assertTrue("Core section should contain \"logallrefupdates\"",
names.contains("logallrefupdates"));

Iterator<String> itr = names.iterator();
assertEquals("filemode", itr.next());
assertEquals("repositoryFormatVersion", itr.next());
assertEquals("logAllRefUpdates", itr.next());
assertFalse(itr.hasNext());
}

@Test
public void test010_readNamesInSubSection() throws ConfigInvalidException {
String configString = "[a \"sub1\"]\n"//
@@ -540,6 +565,30 @@ public class ConfigTest {
assertTrue("Subsection should contain \"b\"", names.contains("b"));
}

@Test
public void readNamesInSubSectionRecursive() throws ConfigInvalidException {
String baseConfigString = "[a \"sub1\"]\n"//
+ "x = 0\n" //
+ "y = false\n"//
+ "[a \"sub2\"]\n"//
+ "A=0\n";//
String configString = "[a \"sub1\"]\n"//
+ "z = true\n"//
+ "[a \"sub2\"]\n"//
+ "B=1\n";
final Config c = parse(configString, parse(baseConfigString));
Set<String> names = c.getNames("a", "sub1", true);
assertEquals("Subsection size", 3, names.size());
assertTrue("Subsection should contain \"x\"", names.contains("x"));
assertTrue("Subsection should contain \"y\"", names.contains("y"));
assertTrue("Subsection should contain \"z\"", names.contains("z"));
names = c.getNames("a", "sub2", true);
assertEquals("Subsection size", 2, names.size());
assertTrue("Subsection should contain \"A\"", names.contains("A"));
assertTrue("Subsection should contain \"a\"", names.contains("a"));
assertTrue("Subsection should contain \"B\"", names.contains("B"));
}

@Test
public void testQuotingForSubSectionNames() {
String resultPattern = "[testsection \"{0}\"]\n\ttestname = testvalue\n";
@@ -584,7 +633,12 @@ public class ConfigTest {

private static Config parse(final String content)
throws ConfigInvalidException {
final Config c = new Config(null);
return parse(content, null);
}

private static Config parse(final String content, Config baseConfig)
throws ConfigInvalidException {
final Config c = new Config(baseConfig);
c.fromText(content);
return c;
}

+ 18
- 13
org.eclipse.jgit/src/org/eclipse/jgit/api/RebaseCommand.java Целия файл

@@ -1101,24 +1101,29 @@ public class RebaseCommand extends GitCommand<RebaseResult> {
}
try {
String headName = rebaseState.readFile(HEAD_NAME);
if (headName.startsWith(Constants.R_REFS)) {
monitor.beginTask(MessageFormat.format(
JGitText.get().resettingHead, headName),
ProgressMonitor.UNKNOWN);

Result res = null;
RefUpdate refUpdate = repo.updateRef(Constants.HEAD, false);
refUpdate.setRefLogMessage("rebase: aborting", false); //$NON-NLS-1$
if (headName.startsWith(Constants.R_REFS)) {
// update the HEAD
RefUpdate refUpdate = repo.updateRef(Constants.HEAD, false);
refUpdate.setRefLogMessage("rebase: aborting", false); //$NON-NLS-1$
Result res = refUpdate.link(headName);
switch (res) {
case FAST_FORWARD:
case FORCED:
case NO_CHANGE:
break;
default:
throw new JGitInternalException(
JGitText.get().abortingRebaseFailed);
}
res = refUpdate.link(headName);
} else {
refUpdate.setNewObjectId(repo.readOrigHead());
res = refUpdate.forceUpdate();

}
switch (res) {
case FAST_FORWARD:
case FORCED:
case NO_CHANGE:
break;
default:
throw new JGitInternalException(
JGitText.get().abortingRebaseFailed);
}
boolean stashConflicts = autoStashApply();
// cleanup the files

+ 59
- 0
org.eclipse.jgit/src/org/eclipse/jgit/errors/IllegalTodoFileModification.java Целия файл

@@ -0,0 +1,59 @@
/*
* Copyright (C) 2013, Christian Halstrick <christian.halstrick@sap.com>
* and other copyright owners as documented in the project's IP log.
*
* This program and the accompanying materials are made available
* under the terms of the Eclipse Distribution License v1.0 which
* accompanies this distribution, is reproduced below, and is
* available at http://www.eclipse.org/org/documents/edl-v10.php
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or
* without modification, are permitted provided that the following
* conditions are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* - Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
*
* - Neither the name of the Eclipse Foundation, Inc. nor the
* names of its contributors may be used to endorse or promote
* products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package org.eclipse.jgit.errors;

/**
* Attempt to modify a rebase-todo file in an unsupported way
*
* @since 3.2
*/
public class IllegalTodoFileModification extends Exception {
private static final long serialVersionUID = 1L;

/**
* @param msg
*/
public IllegalTodoFileModification(final String msg) {
super(msg);
}
}

+ 1
- 1
org.eclipse.jgit/src/org/eclipse/jgit/lib/BaseRepositoryBuilder.java Целия файл

@@ -695,7 +695,7 @@ public class BaseRepositoryBuilder<B extends BaseRepositoryBuilder, R extends Re
String path = cfg.getString(CONFIG_CORE_SECTION, null,
CONFIG_KEY_WORKTREE);
if (path != null)
return safeFS().resolve(getGitDir(), path);
return safeFS().resolve(getGitDir(), path).getCanonicalFile();

// If core.bare is set, honor its value. Assume workTree is
// the parent directory of the repository.

+ 29
- 0
org.eclipse.jgit/src/org/eclipse/jgit/lib/Config.java Целия файл

@@ -527,6 +527,35 @@ public class Config {
return getState().getNames(section, subsection);
}

/**
* @param section
* the section
* @param recursive
* if {@code true} recursively adds the names defined in all base
* configurations
* @return the list of names defined for this section
* @since 3.2
*/
public Set<String> getNames(String section, boolean recursive) {
return getState().getNames(section, null, recursive);
}

/**
* @param section
* the section
* @param subsection
* the subsection
* @param recursive
* if {@code true} recursively adds the names defined in all base
* configurations
* @return the list of names defined for this subsection
* @since 3.2
*/
public Set<String> getNames(String section, String subsection,
boolean recursive) {
return getState().getNames(section, subsection, recursive);
}

/**
* Obtain a handle to a parsed set of configuration values.
*

+ 13
- 1
org.eclipse.jgit/src/org/eclipse/jgit/lib/ConfigSnapshot.java Целия файл

@@ -97,6 +97,16 @@ class ConfigSnapshot {
}

Set<String> getNames(String section, String subsection) {
return getNames(section, subsection, false);
}

Set<String> getNames(String section, String subsection, boolean recursive) {
Map<String, String> m = getNamesInternal(section, subsection, recursive);
return new CaseFoldingSet(m);
}

private Map<String, String> getNamesInternal(String section,
String subsection, boolean recursive) {
List<ConfigLine> s = sorted();
int idx = find(s, section, subsection, ""); //$NON-NLS-1$
if (idx < 0)
@@ -113,7 +123,9 @@ class ConfigSnapshot {
if (!m.containsKey(l))
m.put(l, e.name);
}
return new CaseFoldingSet(m);
if (recursive && baseState != null)
m.putAll(baseState.getNamesInternal(section, subsection, recursive));
return m;
}

String[] get(String section, String subsection, String name) {

+ 9
- 7
org.eclipse.jgit/src/org/eclipse/jgit/lib/RebaseTodoLine.java Целия файл

@@ -45,7 +45,7 @@ package org.eclipse.jgit.lib;

import java.text.MessageFormat;

import org.eclipse.jgit.api.errors.JGitInternalException;
import org.eclipse.jgit.errors.IllegalTodoFileModification;
import org.eclipse.jgit.internal.JGitText;

/**
@@ -111,7 +111,7 @@ public class RebaseTodoLine {
|| action.shortToken.equals(token))
return action;
}
throw new JGitInternalException(MessageFormat.format(
throw new IllegalArgumentException(MessageFormat.format(
JGitText.get().unknownOrUnsupportedCommand, token,
Action.values()));
}
@@ -167,8 +167,11 @@ public class RebaseTodoLine {
* non-comment.
*
* @param newAction
* @throws IllegalTodoFileModification
* on attempt to set a non-comment action on a line which was a
* comment line before.
*/
public void setAction(Action newAction) {
public void setAction(Action newAction) throws IllegalTodoFileModification {
if (!Action.COMMENT.equals(action) && Action.COMMENT.equals(newAction)) {
// transforming from non-comment to comment
if (comment == null)
@@ -180,7 +183,7 @@ public class RebaseTodoLine {
} else if (Action.COMMENT.equals(action) && !Action.COMMENT.equals(newAction)) {
// transforming from comment to non-comment
if (commit == null)
throw new JGitInternalException(MessageFormat.format(
throw new IllegalTodoFileModification(MessageFormat.format(
JGitText.get().cannotChangeActionOnComment, action,
newAction));
}
@@ -219,12 +222,11 @@ public class RebaseTodoLine {
throw createInvalidCommentException(newComment);
}

private static JGitInternalException createInvalidCommentException(
private static IllegalArgumentException createInvalidCommentException(
String newComment) {
IllegalArgumentException iae = new IllegalArgumentException(
return new IllegalArgumentException(
MessageFormat.format(
JGitText.get().argumentIsNotAValidCommentString, newComment));
return new JGitInternalException(iae.getMessage(), iae);
}

/**

Loading…
Отказ
Запис