Re: [PATCH] Color support added to git-add--interactive.

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Jean-Luc Herren <jlh@...>
Cc: <git@...>
Date: Saturday, October 13, 2007 - 1:14 pm

El 13/10/2007, a las 18:38, Jean-Luc Herren escribió:


Yes, I saw that the other functions didn't use prototypes and I agree  
that consistency would be a good thing. I liked the idea of it in  
this case because it makes explicit the fact that the function takes  
two params plus a third, optional one. So definitely not necessary,  
but a preference of mine. In any case, a change to all the other  
functions is a question for a separate patch.


Yes, I actually did write it that way first but then my doubts about  
Perl made me write it the longer way; but if they are equivalent then  
I prefer the shorter way.


True. I had may brain in the C-world.


Again, I actually wrote it that way the first time, and then changed  
it, this time because I thought they were the same. Like I said, not  
a perl hacker.


You're probably right, although it is also duplicating the work  
that's already done elsewhere. In general I favor making the simplest  
change that would work, and tweaking a few of the regexes did look  
simpler than re-implementing the colorization logic.

But the approach you suggest might be more robust, perhaps, seeing as  
there's not much to the diff output. As far as I can tell there are  
really only five or six different things to look for, and they'd be  
fairly easy to catch:

- lines beginning with "@@ " (hunk headers)

- lines beginning with "+" (insertions)

- lines beginning with "-" (deletions)

- lines beginning with " " (context lines, no color)

- lines beginning with "\" (things like "\ No newline at end of  
file", again, no color)

- everything else; ie. the diff header stuff (eg "diff --git a/foo b/ 
foo")

The only special cases seem to be the "+++" and "---" lines in the  
header, which look like insertions and deletions when they're not.

Trickier would be the highlighting of dubious whitespace, and that's  
when it starts to sound like re-inventing the wheel and duplicating  
the logic for the detection that's defined elsewhere (possibly in  
diff-lib.c? haven't found the exact spot yet).


Yes, that was one of the things I didn't like about the sloppy  
regexes. I couldn't really make them any stricter though because I  
wasn't confident about the range of possible characters that might be  
included in the escape sequences.


Yeah, well I didn't choose the colours and I didn't really want to  
get into it. Before being considered for inclusion a patch like this  
would need to tap in to the existing config settings for color.diff  
and color.diff.<slot> anyway...

Wincent



-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH] Color support added to git-add--interactive., Dan Zwell, (Sat Oct 13, 12:13 am)
Re: [PATCH] Color support added to git-add--interactive., Johannes Schindelin, (Sat Oct 13, 8:25 am)
Re: [PATCH] Color support added to git-add--interactive., Frank Lichtenheld, (Sat Oct 13, 8:49 am)
Re: [PATCH] Color support added to git-add--interactive., Wincent Colaiuta, (Sat Oct 13, 10:45 am)
Re: [PATCH] Color support added to git-add--interactive., Johannes Schindelin, (Sat Oct 13, 12:38 pm)
Re: [PATCH] Color support added to git-add--interactive., Jean-Luc Herren, (Sat Oct 13, 12:38 pm)
Re: [PATCH] Color support added to git-add--interactive., Wincent Colaiuta, (Sat Oct 13, 1:14 pm)
Re: [PATCH] Color support added to git-add--interactive., Andreas Ericsson, (Sat Oct 13, 2:31 pm)
Re: [PATCH] Color support added to git-add--interactive., Wincent Colaiuta, (Sat Oct 13, 4:36 pm)
Re: [PATCH] Color support added to git-add--interactive., Jean-Luc Herren, (Sat Oct 13, 6:23 pm)
[PATCH 0/3] Adding colors to git-add--interactive, Dan Zwell, (Sat Nov 10, 10:21 pm)
[PATCH 0/3] Adding colors to git-add--interactive, Dan Zwell, (Sat Nov 10, 8:01 pm)
[PATCH 0/5] Colors for git-add--interactive, Dan Zwell, (Thu Nov 22, 6:54 am)
Re: [PATCH 0/5] Colors for git-add--interactive, Junio C Hamano, (Thu Nov 22, 3:20 pm)
Re: [PATCH 0/5] Colors for git-add--interactive, Jeff King, (Thu Nov 22, 7:57 am)
Re: [PATCH 0/3] Adding colors to git-add--interactive, Junio C Hamano, (Sun Nov 11, 4:23 am)