Adding colors to git-add--interactive
Get series with b4
b4 am [email protected]Versions newest first
- v1 Latest3 patches 1 replyIn review
Patches in v1 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/3 | Added basic color support to git add --interactiveDocumentation/ git-add--interactive.perl | +7 | 0 replies | |
| 2/3 | Let git-add--interactive read colors from .gitconfigDocumentation/ git-add--interactive.perl perl/ | +62 | 0 replies | |
| 3/3 | Added diff hunk coloring to git-add--interactivegit-add--interactive.perl | +50 | 1 reply |
Reviews trailers per patch
No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.
Cover letter [PATCH 0/3] Adding colors to git-add--interactive
[Note: I'm resending this because it looks like this e-mail didn't go out properly. Sorry for duplicates.]
A bit of a recap--this feature was
requested by a user a few weeks ago, and I wrote a short patch that implemented partial coloring. The main criticisms of this patch were:
- The name of the configuration key to turn on interactive coloring was not well chosen.
- The color attribute synonyms "clear" and "reset" were used interchangeably, though "reset" is what the rest of git uses.
- The colors were not user-settable.
When the above were fixed, the new patch garnered the following criticism:
- The color names accepted in .gitconfig were perl color names (to be fed to Term::ANSIColor), and this was not consistent with the rest of git. For example, "red blue ul" would have to be written, "red on_blue underline".
Fixing this (the colors could not be converted by a regex, but had to be parsed) was very libraryish, and also a little confusing. I was given a suggestion or two about how to make it more readable. This parsing also needed to be added to Git.pm instead of git-add--interactive.perl.
In the next iteration, all of the above were fixed, but as Jeff King pointed out, I was printing $color before the beginning of a string, and printing $clear at the end, which allowed ${COLOR}text\n${RESET}, which looks bad on some terminals.
Last iteration, it was pointed out that print_colored must take a file handle to pave the way for pager support, and Junio Hamano and Jeff King both gave suggestions as to how, and Junio sent me few changes that allow printing colored diffs in addition to prompts. I ended up making changes so that the two color functions can be used with perl's print():
print colored($color, "some text")
print color_diff_hunk($hunk)
This way, file handles can be added directly to the print calls, when support for $PAGER is added.
Let me know if other things need correction.
Dan