diff --git a/lib/git/diff/inline_callback.rb b/lib/git/diff/inline_callback.rb
new file mode 100644
index 000000000..02c06a4ee
--- /dev/null
+++ b/lib/git/diff/inline_callback.rb
@@ -0,0 +1,77 @@
+module Git
+ module Diff
+ class InlineCallback < ::Diff::Renderer::Base
+ def addline(line)
+ "
+ |
+ |
+ #{line.new_number} |
+ #{render_line(line)} |
+
"
+ end
+
+ def remline(line)
+ "
+ |
+ #{line.old_number} |
+ |
+ #{render_line(line)} |
+
"
+ end
+
+ def modline(line)
+ "
+ |
+ #{line.old_number} |
+ #{line.new_number} |
+ #{render_line(line)} |
+
"
+ end
+
+ def unmodline(line)
+ "
+ |
+ #{line.old_number} |
+ #{line.new_number} |
+ #{render_line(line)} |
+
"
+ end
+
+ def sepline(line)
+ "
+ |
+ … |
+ … |
+ |
+
"
+ end
+
+ def nonewlineline(line)
+ "
+ |
+ #{line.old_number} |
+ #{line.new_number} |
+ #{render_line(line)} |
+
"
+ end
+
+ protected
+ def escape(str)
+ str.to_s.gsub('&', '&').gsub('<', '<').gsub('>', '>').gsub('"', '"')
+ end
+
+ def render_line(line)
+ res = ''
+ if line.inline_changes?
+ prefix, changed, postfix = line.segments.map{|segment| escape(segment) }
+ res += "#{prefix}#{changed}#{postfix}"
+ else
+ res += escape(line)
+ end
+ res += ''
+
+ res
+ end
+ end
+ end
+end