threads / rfc / 5976

[RFC] Syntax highlighting for combined diff

Subject: [RFC] Syntax highlighting for combined diff

## tl;dr

6 messages between Oct 21, 2006 and Oct 21, 2006.

replies: 5people: 2as markdown or json

Jakub Narebski· Oct 21, 2006, 00:35 UTC · lore
Linus Torvalds wrote in "Re: VCS comparison table"
> And "gitweb" does consider the first parent special, since it shows diffs 
> against that one (although I've argued that it probably shouldn't, and 
> that there should be some way to show branches against arbitrary parents)

So the question is how to color combined diff format (what should be syntax highlighting for combined diff format). If branches columns have only pluses we use the same color as for adding line in ordinary diff; if branches column consist only of minuses we use the same color as for removing line in ordinary diff. Can there be mixture of plusses and minuses? How git-diff --color solves this?

Should we in gitweb output change color slightly depending on number of plusses or minuses?

-- 
Jakub Narebski
Warsaw, Poland
ShadeHawk on #git
Junio C Hamano· Oct 21, 2006, 07:48 UTC · re: Jakub Narebski · lore

Re: [RFC] Syntax highlighting for combined diff

Jakub Narebski <jnareb@gmail.com> writes:
Show 6 quoted lines
> So the question is how to color combined diff format (what should be syntax
> highlighting for combined diff format). If branches columns have only
> pluses we use the same color as for adding line in ordinary diff; if
> branches column consist only of minuses we use the same color as for
> removing line in ordinary diff. Can there be mixture of plusses and
> minuses? How git-diff --color solves this?
UTSL ;-).

Otherwise (iow, if you refuse to use the source), you could cheat and let "git diff" do the coloring for you, and then regexp replace the output. You could even use the same coloring logic for normal diff if you did so.

Jakub Narebski· Oct 21, 2006, 08:49 UTC · re: Junio C Hamano · lore

Re: [RFC] Syntax highlighting for combined diff

Junio C Hamano wrote:
Show 15 quoted lines
> Jakub Narebski <jnareb@gmail.com> writes:
> 
>> So the question is how to color combined diff format (what should be syntax
>> highlighting for combined diff format). If branches columns have only
>> pluses we use the same color as for adding line in ordinary diff; if
>> branches column consist only of minuses we use the same color as for
>> removing line in ordinary diff. Can there be mixture of plusses and
>> minuses? How git-diff --color solves this?
> 
> UTSL ;-).
> 
> Otherwise (iow, if you refuse to use the source), you could
> cheat and let "git diff" do the coloring for you, and then
> regexp replace the output.  You could even use the same coloring
> logic for normal diff if you did so.

Do I understand code correctly, and the last '+' or '-' in the parents column means?

        for (i = 0; i < ecbdata->nparents && len; i++) {
                if (line[i] == '-')
                        color = DIFF_FILE_OLD;
                else if (line[i] == '+')
                        color = DIFF_FILE_NEW;
        }
Anyone who wrote this code, could you answer me, please?
-- 
Jakub Narebski
Poland
Junio C Hamano· Oct 21, 2006, 09:41 UTC · re: Jakub Narebski · lore

Re: [RFC] Syntax highlighting for combined diff

Jakub Narebski <jnareb@gmail.com> writes:
Show 11 quoted lines
> Do I understand code correctly, and the last '+' or '-'
> in the parents column means?
>
>         for (i = 0; i < ecbdata->nparents && len; i++) {
>                 if (line[i] == '-')
>                         color = DIFF_FILE_OLD;
>                 else if (line[i] == '+')
>                         color = DIFF_FILE_NEW;
>         }
>
> Anyone who wrote this code, could you answer me, please?

The "up to ecbdata->nparents" is Johannes in cd112ce. But you are looking at a wrong code, I am afraid, if your original question was about the combined format (there is a comment about the codepath dealing only with two-way diffs by Johannes, above the part you quoted). The output for combined diff is coming from combine-diff.c:dump_sline().

Combined diff output logic pretty much guarantees that you never will see plus and minus on the same line.

Jakub Narebski· Oct 21, 2006, 10:02 UTC · re: Junio C Hamano · lore

Re: [RFC] Syntax highlighting for combined diff

Junio C Hamano wrote:
Show 20 quoted lines
> Jakub Narebski <jnareb@gmail.com> writes:
> 
> > Do I understand code correctly, and the last '+' or '-'
> > in the parents column means?
> >
> >         for (i = 0; i < ecbdata->nparents && len; i++) {
> >                 if (line[i] == '-')
> >                         color = DIFF_FILE_OLD;
> >                 else if (line[i] == '+')
> >                         color = DIFF_FILE_NEW;
> >         }
> >
> > Anyone who wrote this code, could you answer me, please?
> 
> The "up to ecbdata->nparents" is Johannes in cd112ce.  But you
> are looking at a wrong code, I am afraid, if your original
> question was about the combined format (there is a comment about
> the codepath dealing only with two-way diffs by Johannes, above
> the part you quoted).  The output for combined diff is coming
> from combine-diff.c:dump_sline().

I was asking both about combined diff format, and how it is colored by git-diff --color, to add colored combined diff output to gitweb.

> Combined diff output logic pretty much guarantees that you never
> will see plus and minus on the same line.
That's enough for me.
Any other ideas how combined commitdiff should look like in gitweb?
-- 
Jakub Narebski
Poland
Junio C Hamano· Oct 21, 2006, 10:40 UTC · re: Jakub Narebski · lore

Re: [RFC] Syntax highlighting for combined diff

Jakub Narebski <jnareb@gmail.com> writes:
Show 24 quoted lines
> Junio C Hamano wrote:
>> Jakub Narebski <jnareb@gmail.com> writes:
>> 
>> > Do I understand code correctly, and the last '+' or '-'
>> > in the parents column means?
>> >
>> >         for (i = 0; i < ecbdata->nparents && len; i++) {
>> >                 if (line[i] == '-')
>> >                         color = DIFF_FILE_OLD;
>> >                 else if (line[i] == '+')
>> >                         color = DIFF_FILE_NEW;
>> >         }
>> >
>> > Anyone who wrote this code, could you answer me, please?
>> 
>> The "up to ecbdata->nparents" is Johannes in cd112ce.  But you
>> are looking at a wrong code, I am afraid, if your original
>> question was about the combined format (there is a comment about
>> the codepath dealing only with two-way diffs by Johannes, above
>> the part you quoted).  The output for combined diff is coming
>> from combine-diff.c:dump_sline().
>
> I was asking both about combined diff format, and how it is colored
> by git-diff --color, to add colored combined diff output to gitweb.

I was answering about both. dump_sline() implements both format and coloring.

> Any other ideas how combined commitdiff should look like in gitweb?

Combined or no combined, one thing that mildly irritates me sometimes is that there does not seem to be an easy and obvious way to do a rough equivalent of typing SPACE repeatedly while viewing "git log -p".

In other words, I think it would be a nice addition to have "go to commitdiff page of this parent" links near the top on the commitdiff page.

← back to recent threads