Textconv and hilight.rb

I’ve been assessing the possibility of adding textconv support to gitlab. There are quite a few issues, but for starters I am having trouble figuring out the purpose of the below code in hilight.rb:

      def highlight_line(diff_line)
        return unless diff_file && diff_file.diff_refs

        rich_line =
          if diff_line.unchanged? || diff_line.added?
            new_lines[diff_line.new_pos - 1]&.html_safe
          elsif diff_line.removed?
            old_lines[diff_line.old_pos - 1]&.html_safe

        # Only update text if line is found. This will prevent
        # issues with submodules given the line only exists in diff content.
        if rich_line
          line_prefix = diff_line.text =~ /\A(.)/ ? $1 : ' '

If I am reading it right it is going back to the original blobs to find the line of text to display, rather than using the line of text already embedded in the diff output. What is the purpose of this? It must be something significant as there is a HUGE cost to doing this in terms of additional gitaly calls and memory consumption (bringing every line of the source files rather than just the changed lines). Also from my perspective this precludes adding support for textconv without changes to the gitaly server as the files are actually retrieved with a batch cat-file operation, which does not support textconv at all.

Commenting out this code shows that, for many use cases, it doesn’t seem to make any difference at all to the actual output. And it makes textconv work for diffs!

Would love to get some input from someone more experienced with the gitlab codebase on this.