Package org.eclipse.jgit.dircache

Examples of org.eclipse.jgit.dircache.DirCacheEditor$PathEdit


        expected, diff.getConflictingStageStates().get("a"));
  }

  private void removeFromIndex(String path) throws IOException {
    final DirCache dirc = db.lockDirCache();
    final DirCacheEditor edit = dirc.editor();
    edit.add(new DirCacheEditor.DeletePath(path));
    if (!edit.commit())
      throw new IOException("could not commit");
  }
View Full Code Here


  public void addExistentSubmodule() throws Exception {
    final ObjectId id = ObjectId
        .fromString("abcd1234abcd1234abcd1234abcd1234abcd1234");
    final String path = "sub";
    DirCache cache = db.lockDirCache();
    DirCacheEditor editor = cache.editor();
    editor.add(new PathEdit(path) {

      public void apply(DirCacheEntry ent) {
        ent.setFileMode(FileMode.GITLINK);
        ent.setObjectId(id);
      }
    });
    editor.commit();

    SubmoduleAddCommand command = new SubmoduleAddCommand(db);
    command.setPath(path);
    command.setURI("git://server/repo.git");
    try {
View Full Code Here

      GitAPIException {
    final ObjectId id = ObjectId
        .fromString("abcd1234abcd1234abcd1234abcd1234abcd1234");
    final String path = "sub";
    DirCache cache = db.lockDirCache();
    DirCacheEditor editor = cache.editor();
    editor.add(new PathEdit(path) {

      public void apply(DirCacheEntry ent) {
        ent.setFileMode(FileMode.GITLINK);
        ent.setObjectId(id);
      }
    });
    editor.commit();

    SubmoduleStatusCommand command = new SubmoduleStatusCommand(db);
    Map<String, SubmoduleStatus> statuses = command.call();
    assertNotNull(statuses);
    assertEquals(1, statuses.size());
View Full Code Here

      GitAPIException {
    final ObjectId id = ObjectId
        .fromString("abcd1234abcd1234abcd1234abcd1234abcd1234");
    final String path = "sub";
    DirCache cache = db.lockDirCache();
    DirCacheEditor editor = cache.editor();
    editor.add(new PathEdit(path) {

      public void apply(DirCacheEntry ent) {
        ent.setFileMode(FileMode.GITLINK);
        ent.setObjectId(id);
      }
    });
    editor.commit();

    FileBasedConfig modulesConfig = new FileBasedConfig(new File(
        db.getWorkTree(), Constants.DOT_GIT_MODULES), db.getFS());
    modulesConfig.setString(ConfigConstants.CONFIG_SUBMODULE_SECTION, path,
        ConfigConstants.CONFIG_KEY_PATH, path);
View Full Code Here

      GitAPIException {
    final ObjectId id = ObjectId
        .fromString("abcd1234abcd1234abcd1234abcd1234abcd1234");
    final String path = "sub";
    DirCache cache = db.lockDirCache();
    DirCacheEditor editor = cache.editor();
    editor.add(new PathEdit(path) {

      public void apply(DirCacheEntry ent) {
        ent.setFileMode(FileMode.GITLINK);
        ent.setObjectId(id);
      }
    });
    editor.commit();

    String url = "git://server/repo.git";
    StoredConfig config = db.getConfig();
    config.setString(ConfigConstants.CONFIG_SUBMODULE_SECTION, path,
        ConfigConstants.CONFIG_KEY_URL, url);
View Full Code Here

      GitAPIException {
    final ObjectId id = ObjectId
        .fromString("abcd1234abcd1234abcd1234abcd1234abcd1234");
    final String path = "sub";
    DirCache cache = db.lockDirCache();
    DirCacheEditor editor = cache.editor();
    editor.add(new PathEdit(path) {

      public void apply(DirCacheEntry ent) {
        ent.setFileMode(FileMode.GITLINK);
        ent.setObjectId(id);
      }
    });
    editor.commit();

    String url = "git://server/repo.git";
    StoredConfig config = db.getConfig();
    config.setString(ConfigConstants.CONFIG_SUBMODULE_SECTION, path,
        ConfigConstants.CONFIG_KEY_URL, url);
View Full Code Here

      GitAPIException {
    final ObjectId id = ObjectId
        .fromString("abcd1234abcd1234abcd1234abcd1234abcd1234");
    final String path = "sub";
    DirCache cache = db.lockDirCache();
    DirCacheEditor editor = cache.editor();
    editor.add(new PathEdit(path) {

      public void apply(DirCacheEntry ent) {
        ent.setFileMode(FileMode.GITLINK);
        ent.setObjectId(id);
      }
    });
    editor.commit();

    String url = "git://server/repo.git";
    StoredConfig config = db.getConfig();
    config.setString(ConfigConstants.CONFIG_SUBMODULE_SECTION, path,
        ConfigConstants.CONFIG_KEY_URL, url);
View Full Code Here

      throws IOException, GitAPIException {
    final ObjectId id = ObjectId
        .fromString("abcd1234abcd1234abcd1234abcd1234abcd1234");
    final String path = "sub";
    DirCache cache = db.lockDirCache();
    DirCacheEditor editor = cache.editor();
    editor.add(new PathEdit(path) {

      public void apply(DirCacheEntry ent) {
        ent.setFileMode(FileMode.GITLINK);
        ent.setObjectId(id);
      }
    });
    editor.commit();

    String url = "git://server/repo.git";
    StoredConfig config = db.getConfig();
    config.setString(ConfigConstants.CONFIG_SUBMODULE_SECTION, path,
        ConfigConstants.CONFIG_KEY_URL, url);
View Full Code Here

  }

  private void setIndex(final ObjectId id, String path)
      throws MissingObjectException, IOException {
    DirCache lockedDircache;
    DirCacheEditor dcedit;

    lockedDircache = db.lockDirCache();
    dcedit = lockedDircache.editor();
    try {
      if (id != null) {
        final ObjectLoader contLoader = db.newObjectReader().open(id);
        dcedit.add(new DirCacheEditor.PathEdit(path) {
          @Override
          public void apply(DirCacheEntry ent) {
            ent.setFileMode(FileMode.REGULAR_FILE);
            ent.setLength(contLoader.getSize());
            ent.setObjectId(id);
          }
        });
      } else
        dcedit.add(new DirCacheEditor.DeletePath(path));
    } finally {
      dcedit.commit();
    }
  }
View Full Code Here

      ConfigInvalidException, NoWorkTreeException, GitAPIException {
    final ObjectId id = ObjectId
        .fromString("abcd1234abcd1234abcd1234abcd1234abcd1234");
    final String path = "sub";
    DirCache cache = db.lockDirCache();
    DirCacheEditor editor = cache.editor();
    editor.add(new PathEdit(path) {

      public void apply(DirCacheEntry ent) {
        ent.setFileMode(FileMode.GITLINK);
        ent.setObjectId(id);
      }
    });
    editor.commit();

    SubmoduleWalk gen = SubmoduleWalk.forIndex(db);
    assertTrue(gen.next());
    assertEquals(path, gen.getPath());
    assertEquals(id, gen.getObjectId());
View Full Code Here

TOP

Related Classes of org.eclipse.jgit.dircache.DirCacheEditor$PathEdit

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.