Package org.eclipse.jgit.storage.file

Examples of org.eclipse.jgit.storage.file.FileBasedConfig


  }

  @Override
  public ProjectManager start() {
    // load and cache the project metadata
    projectConfigs = new FileBasedConfig(runtimeManager.getFileOrFolder(Keys.web.projectsFile, "${baseFolder}/projects.conf"), FS.detect());
    getProjectConfigs();

    return this;
  }
View Full Code Here


    }
    return success;
  }

  private StoredConfig getConfig() throws IOException, ConfigInvalidException {
    FileBasedConfig config = new FileBasedConfig(configFile, FS.detect());
    config.load();
    return config;
  }
View Full Code Here

  }

  private void testCoreAutoCrlf(AutoCRLF modeForCommitting,
      AutoCRLF modeForReset) throws Exception {
    Git git = new Git(db);
    FileBasedConfig config = db.getConfig();
    config.setEnum(ConfigConstants.CONFIG_CORE_SECTION, null,
        ConfigConstants.CONFIG_KEY_AUTOCRLF, modeForCommitting);
    config.save();

    String joinedCrlf = "a\r\nb\r\nc\r\n";
    File trashFile = writeTrashFile("file.txt", joinedCrlf);
    git.add().addFilepattern("file.txt").call();
    RevCommit commit = git.commit().setMessage("create file").call();

    // re-create file from the repo
    trashFile.delete();
    config.setEnum(ConfigConstants.CONFIG_CORE_SECTION, null,
        ConfigConstants.CONFIG_KEY_AUTOCRLF, modeForReset);
    config.save();
    git.reset().setMode(ResetType.HARD).call();

    BlameCommand command = new BlameCommand(db);
    command.setFilePath("file.txt");
    BlameResult lines = command.call();
View Full Code Here

        throw die(MessageFormat.format(
            CLIText.get().configFileNotFound, //
            configFile.getAbsolutePath()));
      }

      FileBasedConfig cfg = new FileBasedConfig(configFile, FS.DETECTED);
      cfg.load();
      new WindowCacheConfig().fromConfig(cfg).install();
      packConfig.fromConfig(cfg);
    }

    int threads = packConfig.getThreads();
View Full Code Here

  }

  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

    if (StringUtils.isEmptyOrNull(SystemReader.getInstance().getenv(
        Constants.GIT_CONFIG_NOSYSTEM_KEY)))
      systemConfig = SystemReader.getInstance().openSystemConfig(null,
          getFS());
    else
      systemConfig = new FileBasedConfig(null, FS.DETECTED) {
        public void load() {
          // empty, do not load
        }

        public boolean isOutdated() {
          // regular class would bomb here
          return false;
        }
      };
    userConfig = SystemReader.getInstance().openUserConfig(systemConfig,
        getFS());
    repoConfig = new FileBasedConfig(userConfig, getFS().resolve(
        getDirectory(), Constants.CONFIG),
        getFS());

    loadSystemConfig();
    loadUserConfig();
View Full Code Here

   *
   * @throws IOException
   *             in case of IO problem
   */
  public void create(boolean bare) throws IOException {
    final FileBasedConfig cfg = getConfig();
    if (cfg.getFile().exists()) {
      throw new IllegalStateException(MessageFormat.format(
          JGitText.get().repositoryAlreadyExists, getDirectory()));
    }
    FileUtils.mkdirs(getDirectory(), true);
    HideDotFiles hideDotFiles = getConfig().getEnum(
        ConfigConstants.CONFIG_CORE_SECTION, null,
        ConfigConstants.CONFIG_KEY_HIDEDOTFILES,
        HideDotFiles.DOTGITONLY);
    if (hideDotFiles != HideDotFiles.FALSE && !isBare())
      getFS().setHidden(getDirectory(), true);
    refs.create();
    objectDatabase.create();

    FileUtils.mkdir(new File(getDirectory(), "branches")); //$NON-NLS-1$
    FileUtils.mkdir(new File(getDirectory(), "hooks")); //$NON-NLS-1$

    RefUpdate head = updateRef(Constants.HEAD);
    head.disableRefLog();
    head.link(Constants.R_HEADS + Constants.MASTER);

    final boolean fileMode;
    if (getFS().supportsExecute()) {
      File tmp = File.createTempFile("try", "execute", getDirectory()); //$NON-NLS-1$ //$NON-NLS-2$

      getFS().setExecute(tmp, true);
      final boolean on = getFS().canExecute(tmp);

      getFS().setExecute(tmp, false);
      final boolean off = getFS().canExecute(tmp);
      FileUtils.delete(tmp);

      fileMode = on && !off;
    } else {
      fileMode = false;
    }

    SymLinks symLinks = SymLinks.FALSE;
    if (getFS().supportsSymlinks()) {
      File tmp = new File(getDirectory(), "tmplink"); //$NON-NLS-1$
      try {
        getFS().createSymLink(tmp, "target"); //$NON-NLS-1$
        symLinks = null;
        FileUtils.delete(tmp);
      } catch (IOException e) {
        // Normally a java.nio.file.FileSystemException
      }
    }
    if (symLinks != null)
      cfg.setString(ConfigConstants.CONFIG_CORE_SECTION, null,
          ConfigConstants.CONFIG_KEY_SYMLINKS, symLinks.name()
              .toLowerCase());
    cfg.setInt(ConfigConstants.CONFIG_CORE_SECTION, null,
        ConfigConstants.CONFIG_KEY_REPO_FORMAT_VERSION, 0);
    cfg.setBoolean(ConfigConstants.CONFIG_CORE_SECTION, null,
        ConfigConstants.CONFIG_KEY_FILEMODE, fileMode);
    if (bare)
      cfg.setBoolean(ConfigConstants.CONFIG_CORE_SECTION, null,
          ConfigConstants.CONFIG_KEY_BARE, true);
    cfg.setBoolean(ConfigConstants.CONFIG_CORE_SECTION, null,
        ConfigConstants.CONFIG_KEY_LOGALLREFUPDATES, !bare);
    if (SystemReader.getInstance().isMacOS())
      // Java has no other way
      cfg.setBoolean(ConfigConstants.CONFIG_CORE_SECTION, null,
          ConfigConstants.CONFIG_KEY_PRECOMPOSEUNICODE, true);
    cfg.save();
  }
View Full Code Here

      // We only want the repository's configuration file, and not
      // the user file, as these parameters must be unique to this
      // repository and not inherited from other files.
      //
      File path = safeFS().resolve(getGitDir(), Constants.CONFIG);
      FileBasedConfig cfg = new FileBasedConfig(path, safeFS());
      try {
        cfg.load();
      } catch (ConfigInvalidException err) {
        throw new IllegalArgumentException(MessageFormat.format(
            JGitText.get().repositoryConfigFileInvalid, path
                .getAbsolutePath(), err.getMessage()));
      }
View Full Code Here

    return dir;
  }

  private void setBare(File gitDir, boolean bare) throws IOException,
      ConfigInvalidException {
    FileBasedConfig cfg = configFor(gitDir);
    cfg.setBoolean(ConfigConstants.CONFIG_CORE_SECTION, null,
        ConfigConstants.CONFIG_KEY_BARE, bare);
    cfg.save();
  }
View Full Code Here

  private void setWorkTree(File gitDir, File workTree)
      throws IOException,
      ConfigInvalidException {
    String path = workTree.getAbsolutePath();
    FileBasedConfig cfg = configFor(gitDir);
    cfg.setString(ConfigConstants.CONFIG_CORE_SECTION, null,
        ConfigConstants.CONFIG_KEY_WORKTREE, path);
    cfg.save();
  }
View Full Code Here

TOP

Related Classes of org.eclipse.jgit.storage.file.FileBasedConfig

Copyright © 2018 www.massapicom. 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.