Skip to content

Commit

Permalink
Merged gitblit-org#241 "issue-527: Synchronize changes from upstream …
Browse files Browse the repository at this point in the history
…Bugtraq"
  • Loading branch information
gitblit committed Feb 26, 2015
2 parents 4011b60 + f1f3036 commit 7a30680
Showing 1 changed file with 44 additions and 12 deletions.
56 changes: 44 additions & 12 deletions src/main/bugtraq/com/syntevo/bugtraq/BugtraqConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,30 @@
*/
package com.syntevo.bugtraq;

import java.io.*;
import java.util.*;

import org.eclipse.jgit.errors.*;
import org.eclipse.jgit.lib.*;
import org.eclipse.jgit.revwalk.*;
import org.eclipse.jgit.storage.file.*;
import org.eclipse.jgit.treewalk.*;
import org.eclipse.jgit.treewalk.filter.*;
import org.jetbrains.annotations.*;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import org.eclipse.jgit.errors.ConfigInvalidException;
import org.eclipse.jgit.lib.Config;
import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.FileMode;
import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.lib.ObjectLoader;
import org.eclipse.jgit.lib.Ref;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.revwalk.RevCommit;
import org.eclipse.jgit.revwalk.RevTree;
import org.eclipse.jgit.revwalk.RevWalk;
import org.eclipse.jgit.storage.file.FileBasedConfig;
import org.eclipse.jgit.treewalk.TreeWalk;
import org.eclipse.jgit.treewalk.filter.PathFilterGroup;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

public final class BugtraqConfig {

Expand Down Expand Up @@ -66,7 +80,17 @@ public static BugtraqConfig read(@NotNull Repository repository) throws IOExcept
}

final Set<String> allNames = new HashSet<String>();
final Config config = repository.getConfig();
final Config config;
try {
config = repository.getConfig();
}
catch (RuntimeException ex) {
final Throwable cause = ex.getCause();
if (cause instanceof IOException) {
throw (IOException)cause;
}
throw ex;
}
if (getString(null, URL, config, baseConfig) != null) {
allNames.add(null);
}
Expand Down Expand Up @@ -166,7 +190,15 @@ private static Config getBaseConfig(@NotNull Repository repository, @NotNull Str
TreeWalk tw = new TreeWalk(repository);
tw.setFilter(PathFilterGroup.createFromStrings(configFileName));
try {
ObjectId headId = repository.getRef(Constants.HEAD).getTarget().getObjectId();
final Ref ref = repository.getRef(Constants.HEAD);
if (ref == null) {
return null;
}

ObjectId headId = ref.getTarget().getObjectId();
if (headId == null || ObjectId.zeroId().equals(headId)) {
return null;
}
RevCommit commit = rw.parseCommit(headId);
RevTree tree = commit.getTree();
tw.reset(tree);
Expand Down

0 comments on commit 7a30680

Please sign in to comment.