Program: 91504
Project: 91504
Buggy source:
private ITypedElement getHeadTypedElement(final IFile baseFile) throws IOException {
  final RepositoryMapping mapping=RepositoryMapping.getMapping(baseFile.getProject());
  final Repository repository=mapping.getRepository();
  final String gitPath=mapping.getRepoRelativePath(baseFile);
  DirCache dc=repository.lockDirCache();
  final DirCacheEntry entry=dc.getEntry(gitPath);
  dc.unlock();
  if (entry == null) {
    return new GitCompareFileRevisionEditorInput.EmptyTypedElement(NLS.bind(UIText.CompareWithIndexAction_FileNotInIndex,baseFile.getName()));
  }
  IFileRevision nextFile=GitFileRevision.inIndex(repository,gitPath);
  String encoding=CompareUtils.getResourceEncoding(baseFile);
  final EditableRevision next=new EditableRevision(nextFile,encoding);
  IContentChangeListener listener=new IContentChangeListener(){
    public void contentChanged(    IContentChangeNotifier source){
      final byte[] newContent=next.getModifiedContent();
      DirCache cache=null;
      try {
        cache=repository.lockDirCache();
        DirCacheEditor editor=cache.editor();
        editor.add(new PathEdit(gitPath){
          @Override public void apply(          DirCacheEntry ent){
            ent.copyMetaData(entry);
            ObjectInserter inserter=repository.newObjectInserter();
            ent.copyMetaData(entry);
            ent.setLength(newContent.length);
            ent.setLastModified(System.currentTimeMillis());
            InputStream in=new ByteArrayInputStream(newContent);
            try {
              ent.setObjectId(inserter.insert(Constants.OBJ_BLOB,newContent.length,in));
              inserter.flush();
            }
 catch (            IOException ex) {
              throw new RuntimeException(ex);
            }
 finally {
              try {
                in.close();
              }
 catch (              IOException e) {
              }
            }
          }
        }
);
        try {
          editor.commit();
        }
 catch (        RuntimeException e) {
          if (e.getCause() instanceof IOException)           throw (IOException)e.getCause();
 else           throw e;
        }
      }
 catch (      IOException e) {
        Activator.handleError(UIText.CompareWithIndexAction_errorOnAddToIndex,e,true);
      }
 finally {
        if (cache != null)         cache.unlock();
      }
    }
  }
;
  next.addContentChangeListener(listener);
  return next;
}

Fixed version (ground truth):
private ITypedElement getHeadTypedElement(final IFile baseFile) throws IOException {
  final RepositoryMapping mapping=RepositoryMapping.getMapping(baseFile.getProject());
  final Repository repository=mapping.getRepository();
  final String gitPath=mapping.getRepoRelativePath(baseFile);
  DirCache dc=repository.lockDirCache();
  final DirCacheEntry entry=dc.getEntry(gitPath);
  dc.unlock();
  if (entry == null) {
    return new GitCompareFileRevisionEditorInput.EmptyTypedElement(NLS.bind(UIText.CompareWithIndexAction_FileNotInIndex,baseFile.getName()));
  }
  IFileRevision nextFile=GitFileRevision.inIndex(repository,gitPath);
  String encoding=CompareCoreUtils.getResourceEncoding(baseFile);
  final EditableRevision next=new EditableRevision(nextFile,encoding);
  IContentChangeListener listener=new IContentChangeListener(){
    public void contentChanged(    IContentChangeNotifier source){
      final byte[] newContent=next.getModifiedContent();
      DirCache cache=null;
      try {
        cache=repository.lockDirCache();
        DirCacheEditor editor=cache.editor();
        editor.add(new PathEdit(gitPath){
          @Override public void apply(          DirCacheEntry ent){
            ent.copyMetaData(entry);
            ObjectInserter inserter=repository.newObjectInserter();
            ent.copyMetaData(entry);
            ent.setLength(newContent.length);
            ent.setLastModified(System.currentTimeMillis());
            InputStream in=new ByteArrayInputStream(newContent);
            try {
              ent.setObjectId(inserter.insert(Constants.OBJ_BLOB,newContent.length,in));
              inserter.flush();
            }
 catch (            IOException ex) {
              throw new RuntimeException(ex);
            }
 finally {
              try {
                in.close();
              }
 catch (              IOException e) {
              }
            }
          }
        }
);
        try {
          editor.commit();
        }
 catch (        RuntimeException e) {
          if (e.getCause() instanceof IOException)           throw (IOException)e.getCause();
 else           throw e;
        }
      }
 catch (      IOException e) {
        Activator.handleError(UIText.CompareWithIndexAction_errorOnAddToIndex,e,true);
      }
 finally {
        if (cache != null)         cache.unlock();
      }
    }
  }
;
  next.addContentChangeListener(listener);
  return next;
}