Examples of FS


Examples of org.eclipse.jgit.util.FS

    try {
      ol.copyTo(channel);
    } finally {
      channel.close();
    }
    FS fs = repo.getFS();
    WorkingTreeOptions opt = repo.getConfig().get(WorkingTreeOptions.KEY);
    if (opt.isFileMode() && fs.supportsExecute()) {
      if (FileMode.EXECUTABLE_FILE.equals(entry.getRawMode())) {
        if (!fs.canExecute(tmpFile))
          fs.setExecute(tmpFile, true);
      } else {
        if (fs.canExecute(tmpFile))
          fs.setExecute(tmpFile, false);
      }
    }
    if (!tmpFile.renameTo(f)) {
      // tried to rename which failed. Let' delete the target file and try
      // again
View Full Code Here

Examples of org.eclipse.jgit.util.FS

      throw new NotSupportedException(
          "only --list option is currently supported");
  }

  private void list() throws IOException, ConfigInvalidException {
    final FS fs = getRepository().getFS();
    if (configFile != null) {
      list(new FileBasedConfig(configFile, fs));
      return;
    }
    if (system
        || (isListAll() && StringUtils.isEmptyOrNull(SystemReader
            .getInstance()
            .getenv(Constants.GIT_CONFIG_NOSYSTEM_KEY))))
      list(SystemReader.getInstance().openSystemConfig(null, fs));
    if (global || isListAll())
      list(SystemReader.getInstance().openUserConfig(null, fs));
    if (local || isListAll())
      list(new FileBasedConfig(fs.resolve(getRepository().getDirectory(),
          Constants.CONFIG), fs));
  }
View Full Code Here

Examples of org.eclipse.jgit.util.FS

   * @param forceWrite
   *            true to write to disk all entries logged, false to respect the
   *            repository's config and current log file status
   */
  public ReflogWriter(final Repository repository, final boolean forceWrite) {
    final FS fs = repository.getFS();
    parent = repository;
    File gitDir = repository.getDirectory();
    logsDir = fs.resolve(gitDir, LOGS);
    logsRefsDir = fs.resolve(gitDir, LOGS + '/' + R_REFS);
    this.forceWrite = forceWrite;
  }
View Full Code Here

Examples of org.eclipse.jgit.util.FS

   * the listeners only when it differs.
   */
  private final AtomicInteger lastNotifiedModCnt = new AtomicInteger();

  RefDirectory(final FileRepository db) {
    final FS fs = db.getFS();
    parent = db;
    gitDir = db.getDirectory();
    logWriter = new ReflogWriter(db);
    refsDir = fs.resolve(gitDir, R_REFS);
    packedRefsFile = fs.resolve(gitDir, PACKED_REFS);

    looseRefs.set(RefList.<LooseRef> emptyList());
    packedRefs.set(PackedRefList.NO_PACKED_REFS);
  }
View Full Code Here

Examples of org.eclipse.jgit.util.FS

   *            directory to begin searching in.
   * @return {@code this} (for chaining calls).
   */
  public B findGitDir(File current) {
    if (getGitDir() == null) {
      FS tryFS = safeFS();
      while (current != null) {
        File dir = new File(current, DOT_GIT);
        if (FileKey.isGitRepository(dir, tryFS)) {
          setGitDir(dir);
          break;
View Full Code Here

Examples of org.eclipse.jgit.util.FS

   * @throws IOException
   */
  public void pack(List<String> refs) throws IOException {
    if (refs.size() == 0)
      return;
    FS fs = parent.getFS();

    // Lock the packed refs file and read the content
    LockFile lck = new LockFile(packedRefsFile, fs);
    if (!lck.lock())
      throw new IOException(MessageFormat.format(
          JGitText.get().cannotLock, packedRefsFile));

    try {
      final PackedRefList packed = getPackedRefs();
      RefList<Ref> cur = readPackedRefs();

      // Iterate over all refs to be packed
      for (String refName : refs) {
        Ref ref = readRef(refName, cur);
        if (ref.isSymbolic())
          continue; // can't pack symbolic refs
        // Add/Update it to packed-refs
        int idx = cur.find(refName);
        if (idx >= 0)
          cur = cur.set(idx, peeledPackedRef(ref));
        else
          cur = cur.add(idx, peeledPackedRef(ref));
      }

      // The new content for packed-refs is collected. Persist it.
      commitPackedRefs(lck, cur, packed);

      // Now delete the loose refs which are now packed
      for (String refName : refs) {
        // Lock the loose ref
        File refFile = fileFor(refName);
        if (!fs.exists(refFile))
          continue;
        LockFile rLck = new LockFile(refFile,
            parent.getFS());
        if (!rLck.lock())
          continue;
View Full Code Here

Examples of org.eclipse.jgit.util.FS

      Set<String> untrackedAndIgnoredFiles = new TreeSet<String>(
          status.getUntracked());
      Set<String> untrackedAndIgnoredDirs = new TreeSet<String>(
          status.getUntrackedFolders());

      FS fs = getRepository().getFS();
      for (String p : status.getIgnoredNotInIndex()) {
        File f = new File(repo.getWorkTree(), p);
        if (fs.isFile(f) || fs.isSymLink(f))
          untrackedAndIgnoredFiles.add(p);
        else if (fs.isDirectory(f))
          untrackedAndIgnoredDirs.add(p);
      }

      Set<String> filtered = filterFolders(untrackedAndIgnoredFiles,
          untrackedAndIgnoredDirs);
View Full Code Here

Examples of org.eclipse.jgit.util.FS

    StoredConfig config = db.getConfig();
    config.setBoolean(ConfigConstants.CONFIG_CORE_SECTION, null,
        ConfigConstants.CONFIG_KEY_FILEMODE, true);
    config.save();

    FS executableFs = new FS() {

      public boolean supportsExecute() {
        return true;
      }

      public boolean setExecute(File f, boolean canExec) {
        return true;
      }

      public ProcessBuilder runInShell(String cmd, String[] args) {
        return null;
      }

      public boolean retryFailedLockFileCommit() {
        return false;
      }

      public FS newInstance() {
        return this;
      }

      protected File discoverGitPrefix() {
        return null;
      }

      public boolean canExecute(File f) {
        return true;
      }

      @Override
      public boolean isCaseSensitive() {
        return false;
      }
    };

    Git git = Git.open(db.getDirectory(), executableFs);
    String path = "a.txt";
    writeTrashFile(path, "content");
    git.add().addFilepattern(path).call();
    RevCommit commit1 = git.commit().setMessage("commit").call();
    TreeWalk walk = TreeWalk.forPath(db, path, commit1.getTree());
    assertNotNull(walk);
    assertEquals(FileMode.EXECUTABLE_FILE, walk.getFileMode(0));

    FS nonExecutableFs = new FS() {

      public boolean supportsExecute() {
        return false;
      }
View Full Code Here

Examples of org.eclipse.jgit.util.FS

  public static void checkoutEntry(final Repository repo, File f,
      DirCacheEntry entry, ObjectReader or) throws IOException {
    ObjectLoader ol = or.open(entry.getObjectId());
    File parentDir = f.getParentFile();
    parentDir.mkdirs();
    FS fs = repo.getFS();
    WorkingTreeOptions opt = repo.getConfig().get(WorkingTreeOptions.KEY);
    if (entry.getFileMode() == FileMode.SYMLINK
        && opt.getSymLinks() == SymLinks.TRUE) {
      byte[] bytes = ol.getBytes();
      String target = RawParseUtils.decode(bytes);
      fs.createSymLink(f, target);
      entry.setLength(bytes.length);
      entry.setLastModified(fs.lastModified(f));
    } else {
      File tmpFile = File.createTempFile(
          "._" + f.getName(), null, parentDir); //$NON-NLS-1$
      FileOutputStream rawChannel = new FileOutputStream(tmpFile);
      OutputStream channel;
      if (opt.getAutoCRLF() == AutoCRLF.TRUE)
        channel = new AutoCRLFOutputStream(rawChannel);
      else
        channel = rawChannel;
      try {
        ol.copyTo(channel);
      } finally {
        channel.close();
      }
      if (opt.isFileMode() && fs.supportsExecute()) {
        if (FileMode.EXECUTABLE_FILE.equals(entry.getRawMode())) {
          if (!fs.canExecute(tmpFile))
            fs.setExecute(tmpFile, true);
        } else {
          if (fs.canExecute(tmpFile))
            fs.setExecute(tmpFile, false);
        }
      }
      try {
        FileUtils.rename(tmpFile, f);
      } catch (IOException e) {
View Full Code Here

Examples of org.eclipse.jgit.util.FS

   * @throws IOException
   */
  public static long fsTick(File lastFile) throws InterruptedException,
      IOException {
    long sleepTime = 64;
    FS fs = FS.DETECTED;
    if (lastFile != null && !fs.exists(lastFile))
      throw new FileNotFoundException(lastFile.getPath());
    File tmp = File.createTempFile("FileTreeIteratorWithTimeControl", null);
    try {
      long startTime = (lastFile == null) ? fs.lastModified(tmp) : fs
          .lastModified(lastFile);
      long actTime = fs.lastModified(tmp);
      while (actTime <= startTime) {
        Thread.sleep(sleepTime);
        sleepTime *= 2;
        FileOutputStream fos = new FileOutputStream(tmp);
        fos.close();
        actTime = fs.lastModified(tmp);
      }
      return actTime;
    } finally {
      FileUtils.delete(tmp);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.