class UIGit extends VCS implements IVCS {

  @Override
  public InputStream open( String file, String commitId ) {
    if ( commitId.equals( WORKINGTREE ) ) {
      String baseDirectory = getDirectory();
      String filePath = baseDirectory + Const.FILE_SEPARATOR + file;
      try {
        return new FileInputStream( new File( filePath ) );
      } catch ( FileNotFoundException e ) {
        e.printStackTrace();
      }
      return null;
    }
    RevCommit commit = resolve( commitId );
    RevTree tree = commit.getTree();
    try ( TreeWalk tw = new TreeWalk( git.getRepository() ) ) {
      tw.addTree( tree );
      tw.setFilter( PathFilter.create( file ) );
      tw.setRecursive( true );
      tw.next();
      ObjectLoader loader = git.getRepository().open( tw.getObjectId( 0 ) );
      return loader.openStream();
    } catch ( MissingObjectException e ) {
      e.printStackTrace();
    } catch ( IncorrectObjectTypeException e ) {
      e.printStackTrace();
    } catch ( CorruptObjectException e ) {
      e.printStackTrace();
    } catch ( IOException e ) {
      e.printStackTrace();
    }
    return null;
  }

}