Examples of WorkingTreeOptions


Examples of org.eclipse.jgit.treewalk.WorkingTreeOptions

      DirCacheEntry entry, ObjectReader or) throws IOException {
    ObjectLoader ol = or.open(entry.getObjectId());
    File parentDir = f.getParentFile();
    parentDir.mkdirs();
    File tmpFile = File.createTempFile("._" + f.getName(), null, parentDir);
    WorkingTreeOptions opt = repo.getConfig().get(WorkingTreeOptions.KEY);
    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();
    }
    FS fs = repo.getFS();
    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
      FileUtils.delete(f);
      if (!tmpFile.renameTo(f)) {
        throw new IOException(MessageFormat.format(
            JGitText.get().couldNotWriteFile, tmpFile.getPath(),
            f.getPath()));
      }
    }
    entry.setLastModified(f.lastModified());
    if (opt.getAutoCRLF() != AutoCRLF.FALSE)
      entry.setLength(f.length()); // AutoCRLF wants on-disk-size
    else
      entry.setLength((int) ol.getSize());
  }
View Full Code Here

Examples of org.eclipse.jgit.treewalk.WorkingTreeOptions

      DirCacheEntry entry, ObjectReader or) throws IOException {
    ObjectLoader ol = or.open(entry.getObjectId());
    File parentDir = f.getParentFile();
    parentDir.mkdirs();
    File tmpFile = File.createTempFile("._" + f.getName(), null, parentDir); //$NON-NLS-1$
    WorkingTreeOptions opt = repo.getConfig().get(WorkingTreeOptions.KEY);
    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();
    }
    FS fs = repo.getFS();
    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
      FileUtils.delete(f);
      if (!tmpFile.renameTo(f)) {
        throw new IOException(MessageFormat.format(
            JGitText.get().couldNotWriteFile, tmpFile.getPath(),
            f.getPath()));
      }
    }
    entry.setLastModified(f.lastModified());
    if (opt.getAutoCRLF() != AutoCRLF.FALSE)
      entry.setLength(f.length()); // AutoCRLF wants on-disk-size
    else
      entry.setLength((int) ol.getSize());
  }
View Full Code Here

Examples of org.eclipse.jgit.treewalk.WorkingTreeOptions

      DirCacheEntry entry, ObjectReader or) throws IOException {
    ObjectLoader ol = or.open(entry.getObjectId());
    File parentDir = f.getParentFile();
    parentDir.mkdirs();
    File tmpFile = File.createTempFile("._" + f.getName(), null, parentDir); //$NON-NLS-1$
    WorkingTreeOptions opt = repo.getConfig().get(WorkingTreeOptions.KEY);
    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();
    }
    FS fs = repo.getFS();
    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) {
      throw new IOException(MessageFormat.format(
          JGitText.get().couldNotWriteFile, tmpFile.getPath(),
          f.getPath()));
    }
    entry.setLastModified(f.lastModified());
    if (opt.getAutoCRLF() != AutoCRLF.FALSE)
      entry.setLength(f.length()); // AutoCRLF wants on-disk-size
    else
      entry.setLength((int) ol.getSize());
  }
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.