Alex
Alex

Reputation: 247

Git word-diff to html

how would you convert the output of git diff --word-diff to html (using Python preferably)?

Upvotes: 3

Views: 991

Answers (2)

Jonathan W.
Jonathan W.

Reputation: 145

As mentioned in dvicino's answer, using aha works well. In my case, I needed to additionally use --color with git diff --word-diff:

git diff --word-diff --color | aha

The need to use --color is a little perplexing, because git diff --word-diff makes coloured output without --color. But apparently the output isn't sufficiently ANSI-coded for aha to "adapt" it to HTML.

In my specific case, I'm using something more like the following, and it works exactly as expected.

git diff --word-diff --color [revisionhash] | aha --black --word-wrap > diff.html

(I'm adding a full answer in addition to my comment, because I was unable to find any answers that indicted that --color is needed. Maybe it's a system-specific thing, but perhaps others will find this useful.)

Upvotes: 0

dvicino
dvicino

Reputation: 1509

You can pipe a call to aha (a tool that converts colored terminal text to html). Something like this:

git diff --word-diff | aha

If you using debian, you can download it from this link: http://packages.debian.org/sid/aha Hope it helps.

Upvotes: 1

Related Questions