Merge "[findbugs] Respect exclude filter in maven build"
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/Constants.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/Constants.java
index 2269655..afeaffc 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/Constants.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/Constants.java
@@ -79,6 +79,9 @@ public final class Constants {
/** Special name for the "HEAD" symbolic-ref. */
public static final String HEAD = "HEAD";
+ /** Special name for the "FETCH_HEAD" symbolic-ref. */
+ public static final String FETCH_HEAD = "FETCH_HEAD";
+
/**
* Text string that identifies an object as a commit.
* <p>
@@ -527,6 +530,12 @@ public static int decodeTypeString(final AnyObjectId id,
/** name of the file containing the IDs of the parents of a merge commit */
public static final String MERGE_HEAD = "MERGE_HEAD";
+ /**
+ * name of the ref ORIG_HEAD used by certain commands to store the original
+ * value of HEAD
+ */
+ public static final String ORIG_HEAD = "ORIG_HEAD";
+
/** objectid for the empty blob */
public static final ObjectId EMPTY_BLOB_ID = ObjectId
.fromString("e69de29bb2d1d6434b8b29ae775ad8c2e48c5391");
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/IndexDiff.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/IndexDiff.java
index eccaa55..4319fed 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/IndexDiff.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/IndexDiff.java
@@ -46,6 +46,8 @@
package org.eclipse.jgit.lib;
import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collection;
import java.util.HashSet;
import org.eclipse.jgit.dircache.DirCache;
@@ -84,6 +86,8 @@ public class IndexDiff {
private final RevTree tree;
+ private TreeFilter filter = null;
+
private final WorkingTreeIterator initialWorkingTreeIterator;
private HashSet<String> added = new HashSet<String>();
@@ -140,6 +144,15 @@ public IndexDiff(Repository repository, ObjectId objectId,
this.initialWorkingTreeIterator = workingTreeIterator;
}
+ /**
+ * Sets a filter. Can be used e.g. for restricting the tree walk to a set of
+ * files.
+ *
+ * @param filter
+ */
+ public void setFilter(TreeFilter filter) {
+ this.filter = filter;
+ }
/**
* Run the diff operation. Until this is called, all lists will be empty
@@ -160,10 +173,14 @@ public boolean diff() throws IOException {
treeWalk.addTree(new EmptyTreeIterator());
treeWalk.addTree(new DirCacheIterator(dirCache));
treeWalk.addTree(initialWorkingTreeIterator);
- treeWalk.setFilter(TreeFilter.ANY_DIFF);
- treeWalk.setFilter(AndTreeFilter.create(new TreeFilter[] {
- new NotIgnoredFilter(WORKDIR), new SkipWorkTreeFilter(INDEX),
- TreeFilter.ANY_DIFF }));
+ Collection<TreeFilter> filters = new ArrayList<TreeFilter>(
+ filter == null ? 3 : 4);
+ if (filter != null)
+ filters.add(filter);
+ filters.add(new NotIgnoredFilter(WORKDIR));
+ filters.add(new SkipWorkTreeFilter(INDEX));
+ filters.add(TreeFilter.ANY_DIFF);
+ treeWalk.setFilter(AndTreeFilter.create(filters));
while (treeWalk.next()) {
AbstractTreeIterator treeIterator = treeWalk.getTree(TREE,
AbstractTreeIterator.class);
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/RefDatabase.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/RefDatabase.java
index 21e7041..b2ccf29 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/RefDatabase.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/RefDatabase.java
@@ -44,6 +44,7 @@
package org.eclipse.jgit.lib;
import java.io.IOException;
+import java.util.List;
import java.util.Map;
/**
@@ -177,6 +178,19 @@ public abstract RefRename newRename(String fromName, String toName)
public abstract Map<String, Ref> getRefs(String prefix) throws IOException;
/**
+ * Get the additional reference-like entities from the repository.
+ * <p>
+ * The result list includes non-ref items such as MERGE_HEAD and
+ * FETCH_RESULT cast to be refs. The names of these refs are not returned by
+ * <code>getRefs(ALL)</code> but are accepted by {@link #getRef(String)}
+ *
+ * @return a list of additional refs
+ * @throws IOException
+ * the reference space cannot be accessed.
+ */
+ public abstract List<Ref> getAdditionalRefs() throws IOException;
+
+ /**
* Peel a possibly unpeeled reference by traversing the annotated tags.
* <p>
* If the reference cannot be peeled (as it does not refer to an annotated
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/storage/file/RefDirectory.java b/org.eclipse.jgit/src/org/eclipse/jgit/storage/file/RefDirectory.java
index 0f073b6..2e4489c 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/storage/file/RefDirectory.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/storage/file/RefDirectory.java
@@ -69,6 +69,8 @@
import java.io.InputStreamReader;
import java.text.MessageFormat;
import java.util.Arrays;
+import java.util.LinkedList;
+import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicReference;
@@ -123,6 +125,10 @@ public class RefDirectory extends RefDatabase {
/** If in the header, denotes the file has peeled data. */
public static final String PACKED_REFS_PEELED = " peeled"; //$NON-NLS-1$
+ /** The names of the additional refs supported by this class */
+ private static final String[] additionalRefsNames = new String[] {
+ Constants.MERGE_HEAD, Constants.FETCH_HEAD, Constants.ORIG_HEAD };
+
private final FileRepository parent;
private final File gitDir;
@@ -297,6 +303,17 @@ public Map<String, Ref> getRefs(String prefix) throws IOException {
return new RefMap(prefix, packed, upcast(loose), symbolic.toRefList());
}
+ @Override
+ public List<Ref> getAdditionalRefs() throws IOException {
+ List<Ref> ret = new LinkedList<Ref>();
+ for (String name : additionalRefsNames) {
+ Ref r = getRef(name);
+ if (r != null)
+ ret.add(r);
+ }
+ return ret;
+ }
+
@SuppressWarnings("unchecked")
private RefList<Ref> upcast(RefList<? extends Ref> loose) {
return (RefList<Ref>) loose;
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/HttpAuthMethod.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/HttpAuthMethod.java
index 64c8bf0..5a559ab 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/HttpAuthMethod.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/HttpAuthMethod.java
@@ -203,7 +203,7 @@ void configureRequest(final HttpURLConnection conn) throws IOException {
final String expect;
if ("auth".equals(qop)) {
final String c = p.get("cnonce");
- final String nc = String.format("%8.8x", ++requestCount);
+ final String nc = String.format("%08x", ++requestCount);
p.put("nc", nc);
expect = KD(H(A1), nonce + ":" + nc + ":" + c + ":" + qop + ":"
+ H(A2));