コード例 #1
0
ファイル: RefDirectory.java プロジェクト: spearce/jgit
  void delete(RefDirectoryUpdate update) throws IOException {
    Ref dst = update.getRef();
    String name = dst.getName();

    // Write the packed-refs file using an atomic update. We might
    // wind up reading it twice, before and after the lock, to ensure
    // we don't miss an edit made externally.
    final PackedRefList packed = getPackedRefs();
    if (packed.contains(name)) {
      LockFile lck = new LockFile(packedRefsFile);
      if (!lck.lock()) throw new LockFailedException(packedRefsFile);
      try {
        PackedRefList cur = readPackedRefs();
        int idx = cur.find(name);
        if (0 <= idx) commitPackedRefs(lck, cur.remove(idx), packed);
      } finally {
        lck.unlock();
      }
    }

    RefList<LooseRef> curLoose, newLoose;
    do {
      curLoose = looseRefs.get();
      int idx = curLoose.find(name);
      if (idx < 0) break;
      newLoose = curLoose.remove(idx);
    } while (!looseRefs.compareAndSet(curLoose, newLoose));

    int levels = levelsIn(name) - 2;
    delete(logWriter.logFor(name), levels);
    if (dst.getStorage().isLoose()) {
      update.unlock();
      delete(fileFor(name), levels);
    }

    modCnt.incrementAndGet();
    fireRefsChanged();
  }
コード例 #2
0
ファイル: RefDirectory.java プロジェクト: spearce/jgit
 void log(final RefUpdate update, final String msg, final boolean deref) throws IOException {
   logWriter.log(update, msg, deref);
 }
コード例 #3
0
ファイル: RefDirectory.java プロジェクト: spearce/jgit
 public void create() throws IOException {
   FileUtils.mkdir(refsDir);
   FileUtils.mkdir(new File(refsDir, R_HEADS.substring(R_REFS.length())));
   FileUtils.mkdir(new File(refsDir, R_TAGS.substring(R_REFS.length())));
   logWriter.create();
 }