org.eclipse.jgit.lib.Repository.readGitDirectoryFile()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(8.8k)|赞(0)|评价(0)|浏览(97)

本文整理了Java中org.eclipse.jgit.lib.Repository.readGitDirectoryFile方法的一些代码示例,展示了Repository.readGitDirectoryFile的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Repository.readGitDirectoryFile方法的具体详情如下:
包路径:org.eclipse.jgit.lib.Repository
类名称:Repository
方法名:readGitDirectoryFile

Repository.readGitDirectoryFile介绍

[英]Read a file from the git directory.
[中]从git目录中读取文件。

代码示例

代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit

/**
 * Return the information stored in the file $GIT_DIR/MERGE_HEAD. In this
 * file operations triggering a merge will store the IDs of all heads which
 * should be merged together with HEAD.
 *
 * @return a list of commits which IDs are listed in the MERGE_HEAD file or
 *         {@code null} if this file doesn't exist. Also if the file exists
 *         but is empty {@code null} will be returned
 * @throws java.io.IOException
 * @throws org.eclipse.jgit.errors.NoWorkTreeException
 *             if this is bare, which implies it has no working directory.
 *             See {@link #isBare()}.
 */
@Nullable
public List<ObjectId> readMergeHeads() throws IOException, NoWorkTreeException {
  if (isBare() || getDirectory() == null)
    throw new NoWorkTreeException();
  byte[] raw = readGitDirectoryFile(Constants.MERGE_HEAD);
  if (raw == null)
    return null;
  LinkedList<ObjectId> heads = new LinkedList<>();
  for (int p = 0; p < raw.length;) {
    heads.add(ObjectId.fromString(raw, p));
    p = RawParseUtils
        .nextLF(raw, p + Constants.OBJECT_ID_STRING_LENGTH);
  }
  return heads;
}

代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit

/**
 * Return the information stored in the file $GIT_DIR/ORIG_HEAD.
 *
 * @return object id from ORIG_HEAD file or {@code null} if this file
 *         doesn't exist. Also if the file exists but is empty {@code null}
 *         will be returned
 * @throws java.io.IOException
 * @throws org.eclipse.jgit.errors.NoWorkTreeException
 *             if this is bare, which implies it has no working directory.
 *             See {@link #isBare()}.
 */
@Nullable
public ObjectId readOrigHead() throws IOException, NoWorkTreeException {
  if (isBare() || getDirectory() == null)
    throw new NoWorkTreeException();
  byte[] raw = readGitDirectoryFile(Constants.ORIG_HEAD);
  return raw != null ? ObjectId.fromString(raw, 0) : null;
}

代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit

/**
 * Return the information stored in the file $GIT_DIR/CHERRY_PICK_HEAD.
 *
 * @return object id from CHERRY_PICK_HEAD file or {@code null} if this file
 *         doesn't exist. Also if the file exists but is empty {@code null}
 *         will be returned
 * @throws java.io.IOException
 * @throws org.eclipse.jgit.errors.NoWorkTreeException
 *             if this is bare, which implies it has no working directory.
 *             See {@link #isBare()}.
 */
@Nullable
public ObjectId readCherryPickHead() throws IOException,
    NoWorkTreeException {
  if (isBare() || getDirectory() == null)
    throw new NoWorkTreeException();
  byte[] raw = readGitDirectoryFile(Constants.CHERRY_PICK_HEAD);
  if (raw == null)
    return null;
  return ObjectId.fromString(raw, 0);
}

代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit

/**
 * Return the information stored in the file $GIT_DIR/REVERT_HEAD.
 *
 * @return object id from REVERT_HEAD file or {@code null} if this file
 *         doesn't exist. Also if the file exists but is empty {@code null}
 *         will be returned
 * @throws java.io.IOException
 * @throws org.eclipse.jgit.errors.NoWorkTreeException
 *             if this is bare, which implies it has no working directory.
 *             See {@link #isBare()}.
 */
@Nullable
public ObjectId readRevertHead() throws IOException, NoWorkTreeException {
  if (isBare() || getDirectory() == null)
    throw new NoWorkTreeException();
  byte[] raw = readGitDirectoryFile(Constants.REVERT_HEAD);
  if (raw == null)
    return null;
  return ObjectId.fromString(raw, 0);
}

代码示例来源:origin: sonia.jgit/org.eclipse.jgit

/**
 * Return the information stored in the file $GIT_DIR/MERGE_HEAD. In this
 * file operations triggering a merge will store the IDs of all heads which
 * should be merged together with HEAD.
 *
 * @return a list of commits which IDs are listed in the MERGE_HEAD file or
 *         {@code null} if this file doesn't exist. Also if the file exists
 *         but is empty {@code null} will be returned
 * @throws IOException
 * @throws NoWorkTreeException
 *             if this is bare, which implies it has no working directory.
 *             See {@link #isBare()}.
 */
@Nullable
public List<ObjectId> readMergeHeads() throws IOException, NoWorkTreeException {
  if (isBare() || getDirectory() == null)
    throw new NoWorkTreeException();
  byte[] raw = readGitDirectoryFile(Constants.MERGE_HEAD);
  if (raw == null)
    return null;
  LinkedList<ObjectId> heads = new LinkedList<ObjectId>();
  for (int p = 0; p < raw.length;) {
    heads.add(ObjectId.fromString(raw, p));
    p = RawParseUtils
        .nextLF(raw, p + Constants.OBJECT_ID_STRING_LENGTH);
  }
  return heads;
}

代码示例来源:origin: berlam/github-bucket

/**
 * Return the information stored in the file $GIT_DIR/MERGE_HEAD. In this
 * file operations triggering a merge will store the IDs of all heads which
 * should be merged together with HEAD.
 *
 * @return a list of commits which IDs are listed in the MERGE_HEAD file or
 *         {@code null} if this file doesn't exist. Also if the file exists
 *         but is empty {@code null} will be returned
 * @throws java.io.IOException
 * @throws org.eclipse.jgit.errors.NoWorkTreeException
 *             if this is bare, which implies it has no working directory.
 *             See {@link #isBare()}.
 */
@Nullable
public List<ObjectId> readMergeHeads() throws IOException, NoWorkTreeException {
  if (isBare() || getDirectory() == null)
    throw new NoWorkTreeException();
  byte[] raw = readGitDirectoryFile(Constants.MERGE_HEAD);
  if (raw == null)
    return null;
  LinkedList<ObjectId> heads = new LinkedList<>();
  for (int p = 0; p < raw.length;) {
    heads.add(ObjectId.fromString(raw, p));
    p = RawParseUtils
        .nextLF(raw, p + Constants.OBJECT_ID_STRING_LENGTH);
  }
  return heads;
}

代码示例来源:origin: sonia.jgit/org.eclipse.jgit

/**
 * Return the information stored in the file $GIT_DIR/ORIG_HEAD.
 *
 * @return object id from ORIG_HEAD file or {@code null} if this file
 *         doesn't exist. Also if the file exists but is empty {@code null}
 *         will be returned
 * @throws IOException
 * @throws NoWorkTreeException
 *             if this is bare, which implies it has no working directory.
 *             See {@link #isBare()}.
 */
@Nullable
public ObjectId readOrigHead() throws IOException, NoWorkTreeException {
  if (isBare() || getDirectory() == null)
    throw new NoWorkTreeException();
  byte[] raw = readGitDirectoryFile(Constants.ORIG_HEAD);
  return raw != null ? ObjectId.fromString(raw, 0) : null;
}

代码示例来源:origin: berlam/github-bucket

/**
 * Return the information stored in the file $GIT_DIR/REVERT_HEAD.
 *
 * @return object id from REVERT_HEAD file or {@code null} if this file
 *         doesn't exist. Also if the file exists but is empty {@code null}
 *         will be returned
 * @throws java.io.IOException
 * @throws org.eclipse.jgit.errors.NoWorkTreeException
 *             if this is bare, which implies it has no working directory.
 *             See {@link #isBare()}.
 */
@Nullable
public ObjectId readRevertHead() throws IOException, NoWorkTreeException {
  if (isBare() || getDirectory() == null)
    throw new NoWorkTreeException();
  byte[] raw = readGitDirectoryFile(Constants.REVERT_HEAD);
  if (raw == null)
    return null;
  return ObjectId.fromString(raw, 0);
}

代码示例来源:origin: berlam/github-bucket

/**
 * Return the information stored in the file $GIT_DIR/ORIG_HEAD.
 *
 * @return object id from ORIG_HEAD file or {@code null} if this file
 *         doesn't exist. Also if the file exists but is empty {@code null}
 *         will be returned
 * @throws java.io.IOException
 * @throws org.eclipse.jgit.errors.NoWorkTreeException
 *             if this is bare, which implies it has no working directory.
 *             See {@link #isBare()}.
 */
@Nullable
public ObjectId readOrigHead() throws IOException, NoWorkTreeException {
  if (isBare() || getDirectory() == null)
    throw new NoWorkTreeException();
  byte[] raw = readGitDirectoryFile(Constants.ORIG_HEAD);
  return raw != null ? ObjectId.fromString(raw, 0) : null;
}

代码示例来源:origin: sonia.jgit/org.eclipse.jgit

/**
 * Return the information stored in the file $GIT_DIR/REVERT_HEAD.
 *
 * @return object id from REVERT_HEAD file or {@code null} if this file
 *         doesn't exist. Also if the file exists but is empty {@code null}
 *         will be returned
 * @throws IOException
 * @throws NoWorkTreeException
 *             if this is bare, which implies it has no working directory.
 *             See {@link #isBare()}.
 */
@Nullable
public ObjectId readRevertHead() throws IOException, NoWorkTreeException {
  if (isBare() || getDirectory() == null)
    throw new NoWorkTreeException();
  byte[] raw = readGitDirectoryFile(Constants.REVERT_HEAD);
  if (raw == null)
    return null;
  return ObjectId.fromString(raw, 0);
}

代码示例来源:origin: sonia.jgit/org.eclipse.jgit

/**
 * Return the information stored in the file $GIT_DIR/CHERRY_PICK_HEAD.
 *
 * @return object id from CHERRY_PICK_HEAD file or {@code null} if this file
 *         doesn't exist. Also if the file exists but is empty {@code null}
 *         will be returned
 * @throws IOException
 * @throws NoWorkTreeException
 *             if this is bare, which implies it has no working directory.
 *             See {@link #isBare()}.
 */
@Nullable
public ObjectId readCherryPickHead() throws IOException,
    NoWorkTreeException {
  if (isBare() || getDirectory() == null)
    throw new NoWorkTreeException();
  byte[] raw = readGitDirectoryFile(Constants.CHERRY_PICK_HEAD);
  if (raw == null)
    return null;
  return ObjectId.fromString(raw, 0);
}

代码示例来源:origin: berlam/github-bucket

/**
 * Return the information stored in the file $GIT_DIR/CHERRY_PICK_HEAD.
 *
 * @return object id from CHERRY_PICK_HEAD file or {@code null} if this file
 *         doesn't exist. Also if the file exists but is empty {@code null}
 *         will be returned
 * @throws java.io.IOException
 * @throws org.eclipse.jgit.errors.NoWorkTreeException
 *             if this is bare, which implies it has no working directory.
 *             See {@link #isBare()}.
 */
@Nullable
public ObjectId readCherryPickHead() throws IOException,
    NoWorkTreeException {
  if (isBare() || getDirectory() == null)
    throw new NoWorkTreeException();
  byte[] raw = readGitDirectoryFile(Constants.CHERRY_PICK_HEAD);
  if (raw == null)
    return null;
  return ObjectId.fromString(raw, 0);
}

相关文章

Repository类方法