# Project idea: github-like diff view

5 messages from 2014-04-20 to 2014-04-22. Participants: Duy Nguyen, Jeff King, Felipe Contreras.
Thread: https://gitlist.dev/t/36450

## Duy Nguyen, 2014-04-20 09:58

Subject: Project idea: github-like diff view
Message-ID: <CACsJy8CQxPrqs31nBvr_oPRD3EJ6Hu-Lq=++7nWpxx5BQZYi8Q@mail.gmail.com>
URL: https://gitlist.dev/e/CACsJy8CQxPrqs31nBvr_oPRD3EJ6Hu-Lq%3D%2B%2B7nWpxx5BQZYi8Q%40mail.gmail.com

```
When you view a commit from github, it shows extra info besides
standard unified diff format:

- the column number of each line (useful for jumping directly to that
line without manual counting from @@ line)
- --color-words within unified diff format, using background color to
show what part of the line has changed. This is only enabled for
1-line changes.

These can be implemented and seem useful, especially the --color-words
item. Once you get familiar with diff.c I suppose you could implement
both in a week (the first probably takes just a day).
-- 
Duy

```

## Jeff King, 2014-04-20 14:46

Subject: Re: Project idea: github-like diff view
Message-ID: <20140420144620.GA16596@sigill.intra.peff.net>
URL: https://gitlist.dev/e/20140420144620.GA16596%40sigill.intra.peff.net
In-Reply-To: <CACsJy8CQxPrqs31nBvr_oPRD3EJ6Hu-Lq=++7nWpxx5BQZYi8Q@mail.gmail.com>

```
On Sun, Apr 20, 2014 at 04:58:28PM +0700, Duy Nguyen wrote:

> - --color-words within unified diff format, using background color to
> show what part of the line has changed. This is only enabled for
> 1-line changes.

See contrib/diff-highlight.

-Peff

```

## Duy Nguyen, 2014-04-22 09:59

Subject: Re: Project idea: github-like diff view
Message-ID: <CACsJy8DnJeZ-43Ydg_j00CO6=6NOA1wdzQ+EwCX6idrUOLn8gA@mail.gmail.com>
URL: https://gitlist.dev/e/CACsJy8DnJeZ-43Ydg_j00CO6%3D6NOA1wdzQ%2BEwCX6idrUOLn8gA%40mail.gmail.com
In-Reply-To: <20140420144620.GA16596@sigill.intra.peff.net>

```
On Sun, Apr 20, 2014 at 9:46 PM, Jeff King <peff@peff.net> wrote:
> On Sun, Apr 20, 2014 at 04:58:28PM +0700, Duy Nguyen wrote:
>
>> - --color-words within unified diff format, using background color to
>> show what part of the line has changed. This is only enabled for
>> 1-line changes.
>
> See contrib/diff-highlight.

Thanks. I'd rather have it built in core git still. I'll try to see if
I can rewrite it in C. Else, any objection to promote it to a core
helper and setup pager automatically? We can have a config key to turn
it off, but if git diff is colored, then it could be on by default.
-- 
Duy

```

## Jeff King, 2014-04-22 15:59

Subject: Re: Project idea: github-like diff view
Message-ID: <20140422155901.GA13663@sigill.intra.peff.net>
URL: https://gitlist.dev/e/20140422155901.GA13663%40sigill.intra.peff.net
In-Reply-To: <CACsJy8DnJeZ-43Ydg_j00CO6=6NOA1wdzQ+EwCX6idrUOLn8gA@mail.gmail.com>

```
On Tue, Apr 22, 2014 at 04:59:17PM +0700, Duy Nguyen wrote:

> On Sun, Apr 20, 2014 at 9:46 PM, Jeff King <peff@peff.net> wrote:
> > On Sun, Apr 20, 2014 at 04:58:28PM +0700, Duy Nguyen wrote:
> >
> >> - --color-words within unified diff format, using background color to
> >> show what part of the line has changed. This is only enabled for
> >> 1-line changes.
> >
> > See contrib/diff-highlight.
> 
> Thanks. I'd rather have it built in core git still. I'll try to see if
> I can rewrite it in C. Else, any objection to promote it to a core
> helper and setup pager automatically? We can have a config key to turn
> it off, but if git diff is colored, then it could be on by default.

If you are going to write it as part of git, it would be interesting to
try using a real word-diff to find the inter-line changes, instead of
the "front and back match" heuristic that the script uses. I know there
are some cases that would look better, like:

  -foo(buf, len);
  +foo(obj->buf, obj->len);

but I suspect some cases would also look worse. It would be interesting
to experiment with, though.

-Peff

```

## Felipe Contreras, 2014-04-22 16:11

Subject: Re: Project idea: github-like diff view
Message-ID: <535694c23647e_3e5aed730839@nysa.notmuch>
URL: https://gitlist.dev/e/535694c23647e_3e5aed730839%40nysa.notmuch
In-Reply-To: <CACsJy8DnJeZ-43Ydg_j00CO6=6NOA1wdzQ+EwCX6idrUOLn8gA@mail.gmail.com>

```
Duy Nguyen wrote:
> On Sun, Apr 20, 2014 at 9:46 PM, Jeff King <peff@peff.net> wrote:
> > On Sun, Apr 20, 2014 at 04:58:28PM +0700, Duy Nguyen wrote:
> >
> >> - --color-words within unified diff format, using background color to
> >> show what part of the line has changed. This is only enabled for
> >> 1-line changes.
> >
> > See contrib/diff-highlight.
> 
> Thanks. I'd rather have it built in core git still. I'll try to see if
> I can rewrite it in C. Else, any objection to promote it to a core
> helper and setup pager automatically? We can have a config key to turn
> it off, but if git diff is colored, then it could be on by default.

Having so many tools that should be rewritten to C, I don't see why anybody
should spent time rewriting scripts that are not part of the core and for the
most part do their job already.

-- 
Felipe Contreras

```
