private String getObjectIdOfCommit() throws Exception {
   String branch = repository.getFullBranch();
   if (ObjectId.isId(branch)) return branch;
   if (branch.startsWith(Constants.R_REFS)) {
     RevCommit commit = revWalk.parseCommit(repository.resolve(branch));
     return commit.getId().getName();
   }
   if (branch.startsWith(Constants.R_TAGS)) {
     RevTag tag = revWalk.parseTag(repository.resolve(branch));
     return tag.getObject().getId().name();
   }
   throw new IllegalStateException("Can't resolve commit");
 }
  private Image decorateImage(final Image image, Object element) {

    RepositoryTreeNode node = (RepositoryTreeNode) element;
    switch (node.getType()) {
      case TAG:
        // fall through
      case ADDITIONALREF:
        // fall through
      case REF:
        // if the branch or tag is checked out,
        // we want to decorate the corresponding
        // node with a little check indicator
        String refName = ((Ref) node.getObject()).getName();
        Ref leaf = ((Ref) node.getObject()).getLeaf();

        String branchName;
        String compareString;

        try {
          branchName = node.getRepository().getFullBranch();
          if (branchName == null) return image;
          if (refName.startsWith(Constants.R_HEADS)) {
            // local branch: HEAD would be on the branch
            compareString = refName;
          } else if (refName.startsWith(Constants.R_TAGS)) {
            // tag: HEAD would be on the commit id to which the tag is
            // pointing
            ObjectId id = node.getRepository().resolve(refName);
            if (id == null) return image;
            RevWalk rw = new RevWalk(node.getRepository());
            RevTag tag = rw.parseTag(id);
            compareString = tag.getObject().name();

          } else if (refName.startsWith(Constants.R_REMOTES)) {
            // remote branch: HEAD would be on the commit id to which
            // the branch is pointing
            ObjectId id = node.getRepository().resolve(refName);
            if (id == null) return image;
            RevWalk rw = new RevWalk(node.getRepository());
            RevCommit commit = rw.parseCommit(id);
            compareString = commit.getId().name();
          } else if (refName.equals(Constants.HEAD)) return getDecoratedImage(image);
          else {
            String leafname = leaf.getName();
            if (leafname.startsWith(Constants.R_REFS)
                && leafname.equals(node.getRepository().getFullBranch()))
              return getDecoratedImage(image);
            else if (leaf.getObjectId().equals(node.getRepository().resolve(Constants.HEAD)))
              return getDecoratedImage(image);
            // some other symbolic reference
            return image;
          }
        } catch (IOException e1) {
          return image;
        }

        if (compareString.equals(branchName)) {
          return getDecoratedImage(image);
        }

        return image;

      default:
        return image;
    }
  }