Example usage for org.eclipse.jgit.lib Constants OBJ_BLOB

List of usage examples for org.eclipse.jgit.lib Constants OBJ_BLOB

Introduction

In this page you can find the example usage for org.eclipse.jgit.lib Constants OBJ_BLOB.

Prototype

int OBJ_BLOB

To view the source code for org.eclipse.jgit.lib Constants OBJ_BLOB.

Click Source Link

Document

In-pack object type: blob.

Usage

From source file:svnserver.repository.git.GitRepository.java

License:GNU General Public License

@NotNull
public GitFilter getFilter(@NotNull FileMode fileMode, @NotNull GitProperty[] props)
        throws IOException, SVNException {
    if (fileMode.getObjectType() != Constants.OBJ_BLOB) {
        return gitFilters.get(GitFilterRaw.NAME);
    }/*w  w  w .j  ava2 s  .  c o m*/
    if (fileMode == FileMode.SYMLINK) {
        return gitFilters.get(GitFilterLink.NAME);
    }
    for (int i = props.length - 1; i >= 0; --i) {
        final String filterName = props[i].getFilterName();
        if (filterName != null) {
            final GitFilter filter = gitFilters.get(filterName);
            if (filter == null) {
                throw new InvalidStreamException("Unknown filter requested: " + filterName);
            }
            return filter;
        }
    }
    return gitFilters.get(GitFilterRaw.NAME);
}

From source file:svnserver.repository.git.LayoutHelper.java

License:GNU General Public License

@NotNull
private static ObjectId createFirstRevision(@NotNull Repository repository) throws IOException {
    // Generate UUID.
    final ObjectInserter inserter = repository.newObjectInserter();
    ObjectId uuidId = inserter.insert(Constants.OBJ_BLOB,
            UUID.randomUUID().toString().getBytes(StandardCharsets.UTF_8));
    // Create svn empty tree.
    final ObjectId treeId = inserter.insert(new TreeFormatter());
    // Create commit tree.
    final TreeFormatter rootBuilder = new TreeFormatter();
    rootBuilder.append(ENTRY_ROOT, FileMode.TREE, treeId);
    rootBuilder.append(ENTRY_UUID, FileMode.REGULAR_FILE, uuidId);
    new ObjectChecker().checkTree(rootBuilder.toByteArray());
    final ObjectId rootId = inserter.insert(rootBuilder);
    // Create first commit with message.
    final CommitBuilder commitBuilder = new CommitBuilder();
    commitBuilder.setAuthor(new PersonIdent("", "", 0, 0));
    commitBuilder.setCommitter(new PersonIdent("", "", 0, 0));
    commitBuilder.setMessage("#0: Initial revision");
    commitBuilder.setTreeId(rootId);/*from  w w w . j a v a  2s .c  o  m*/
    final ObjectId commitId = inserter.insert(commitBuilder);
    inserter.flush();
    return commitId;
}

From source file:svnserver.repository.git.prop.GitAutoProperty.java

License:GNU General Public License

@Nullable
@Override/*from ww  w. j a va 2  s . co m*/
public GitProperty createForChild(@NotNull String name, @NotNull FileMode fileMode) {
    if (fileMode.getObjectType() == Constants.OBJ_BLOB) {
        return null;
    }
    if (matcher.getSvnMaskGlobal() != null) {
        return null;
    }
    final PathMatcher matcherChild = matcher.createChild(name, true);
    if (matcherChild == null) {
        return null;
    }
    return new GitAutoProperty(matcherChild, property, value);
}

From source file:svnserver.repository.git.prop.GitFileProperty.java

License:GNU General Public License

@Nullable
@Override/*from   www. j av a2s.c o m*/
public GitProperty createForChild(@NotNull String name, @NotNull FileMode fileMode) {
    final boolean isDir = fileMode.getObjectType() != Constants.OBJ_BLOB;
    final PathMatcher matcherChild = matcher.createChild(name, isDir);
    if (matcherChild != null) {
        if (isDir) {
            return new GitFileProperty(matcherChild, property, value);
        } else if (matcherChild.isMatch()) {
            return new GitProperty() {
                @Override
                public void apply(@NotNull Map<String, String> props) {
                    if (value != null) {
                        props.put(property, value);
                    } else {
                        props.remove(property);
                    }
                }

                @Nullable
                @Override
                public String getFilterName() {
                    return null;
                }

                @Nullable
                @Override
                public GitProperty createForChild(@NotNull String name, @NotNull FileMode mode) {
                    return null;
                }
            };
        }
    }
    return null;
}

From source file:svnserver.repository.git.prop.GitFilterProperty.java

License:GNU General Public License

@Nullable
@Override/*from w ww .  j  av a 2s.c o m*/
public GitProperty createForChild(@NotNull String name, @NotNull FileMode fileMode) {
    final boolean isDir = fileMode.getObjectType() != Constants.OBJ_BLOB;
    final PathMatcher matcherChild = matcher.createChild(name, isDir);
    if ((matcherChild != null) && (isDir || matcherChild.isMatch())) {
        return new GitFilterProperty(matcherChild, filterName);
    }
    return null;
}

From source file:svnserver.repository.git.prop.GitIgnore.java

License:GNU General Public License

@Nullable
@Override//from w w  w .jav a2s . co  m
public GitProperty createForChild(@NotNull String name, @NotNull FileMode fileMode) {
    if (matchers.isEmpty() || (fileMode.getObjectType() == Constants.OBJ_BLOB)) {
        return null;
    }
    final List<String> localList = new ArrayList<>();
    final List<String> globalList = new ArrayList<>();
    final List<PathMatcher> childMatchers = new ArrayList<>();
    for (PathMatcher matcher : matchers) {
        processMatcher(localList, globalList, childMatchers, matcher.createChild(name, true));
    }
    if (localList.isEmpty() && globalList.isEmpty() && childMatchers.isEmpty()) {
        return null;
    }
    return new GitIgnore(localList, globalList, childMatchers);
}