Colourise git-branch output

I wanted to have a visual indication of which branches are local and
which are remote in git-branch -a output; however Junio was concerned
that someone might be using the output in a script.  This patch
addresses the problem by colouring the git-branch output - which in
"auto" mode won't be activated.

I've based it off the colouring code for builtin-diff.c; which means
there is a branch color configuration variable that needs setting to
something before the color will appear.

The colour parameter is "color.branch" rather than "branch.color" to
avoid clashing with the default namespace for default branch merge
definitions.

This patch chooses green for local, red for remote and bold green for
current.

Signed-off-by: Andy Parkins <andyparkins@gmail.com>
Signed-off-by: Junio C Hamano <junkio@cox.net>
1 file changed
tree: 4a058582dde034ca8145999660f3b4f9c189b453
  1. arm/
  2. compat/
  3. contrib/
  4. Documentation/
  5. gitweb/
  6. mozilla-sha1/
  7. perl/
  8. ppc/
  9. t/
  10. templates/
  11. xdiff/
  12. .gitignore
  13. alloc.c
  14. archive-tar.c
  15. archive-zip.c
  16. archive.h
  17. base85.c
  18. blob.c
  19. blob.h
  20. builtin-add.c
  21. builtin-annotate.c
  22. builtin-apply.c
  23. builtin-archive.c
  24. builtin-blame.c
  25. builtin-branch.c
  26. builtin-cat-file.c
  27. builtin-check-ref-format.c
  28. builtin-checkout-index.c
  29. builtin-commit-tree.c
  30. builtin-count-objects.c
  31. builtin-diff-files.c
  32. builtin-diff-index.c
  33. builtin-diff-stages.c
  34. builtin-diff-tree.c
  35. builtin-diff.c
  36. builtin-fmt-merge-msg.c
  37. builtin-for-each-ref.c
  38. builtin-grep.c
  39. builtin-init-db.c
  40. builtin-log.c
  41. builtin-ls-files.c
  42. builtin-ls-tree.c
  43. builtin-mailinfo.c
  44. builtin-mailsplit.c
  45. builtin-mv.c
  46. builtin-name-rev.c
  47. builtin-pack-objects.c
  48. builtin-pack-refs.c
  49. builtin-prune-packed.c
  50. builtin-prune.c
  51. builtin-push.c
  52. builtin-read-tree.c
  53. builtin-repo-config.c
  54. builtin-rev-list.c
  55. builtin-rev-parse.c
  56. builtin-rm.c
  57. builtin-runstatus.c
  58. builtin-shortlog.c
  59. builtin-show-branch.c
  60. builtin-show-ref.c
  61. builtin-stripspace.c
  62. builtin-symbolic-ref.c
  63. builtin-tar-tree.c
  64. builtin-unpack-objects.c
  65. builtin-update-index.c
  66. builtin-update-ref.c
  67. builtin-upload-archive.c
  68. builtin-verify-pack.c
  69. builtin-write-tree.c
  70. builtin.h
  71. cache-tree.c
  72. cache-tree.h
  73. cache.h
  74. check-builtins.sh
  75. check-racy.c
  76. color.c
  77. color.h
  78. combine-diff.c
  79. commit.c
  80. commit.h
  81. config.c
  82. config.mak.in
  83. configure.ac
  84. connect.c
  85. convert-objects.c
  86. copy.c
  87. COPYING
  88. csum-file.c
  89. csum-file.h
  90. ctype.c
  91. daemon.c
  92. date.c
  93. delta.h
  94. describe.c
  95. diff-delta.c
  96. diff-lib.c
  97. diff.c
  98. diff.h
  99. diffcore-break.c
  100. diffcore-delta.c
  101. diffcore-order.c
  102. diffcore-pickaxe.c
  103. diffcore-rename.c
  104. diffcore.h
  105. dir.c
  106. dir.h
  107. dump-cache-tree.c
  108. entry.c
  109. environment.c
  110. exec_cmd.c
  111. exec_cmd.h
  112. fetch-pack.c
  113. fetch.c
  114. fetch.h
  115. fsck-objects.c
  116. generate-cmdlist.sh
  117. git-am.sh
  118. git-applymbox.sh
  119. git-applypatch.sh
  120. git-archimport.perl
  121. git-bisect.sh
  122. git-checkout.sh
  123. git-clean.sh
  124. git-clone.sh
  125. git-commit.sh
  126. git-compat-util.h
  127. git-cvsexportcommit.perl
  128. git-cvsimport.perl
  129. git-cvsserver.perl
  130. git-fetch.sh
  131. git-instaweb.sh
  132. git-lost-found.sh
  133. git-ls-remote.sh
  134. git-merge-octopus.sh
  135. git-merge-one-file.sh
  136. git-merge-ours.sh
  137. git-merge-resolve.sh
  138. git-merge-stupid.sh
  139. git-merge.sh
  140. git-p4import.py
  141. git-parse-remote.sh
  142. git-pull.sh
  143. git-quiltimport.sh
  144. git-rebase.sh
  145. git-relink.perl
  146. git-repack.sh
  147. git-request-pull.sh
  148. git-rerere.perl
  149. git-reset.sh
  150. git-resolve.sh
  151. git-revert.sh
  152. git-send-email.perl
  153. git-sh-setup.sh
  154. git-svn.perl
  155. git-svnimport.perl
  156. git-tag.sh
  157. git-verify-tag.sh
  158. GIT-VERSION-GEN
  159. git.c
  160. git.spec.in
  161. gitk
  162. grep.c
  163. grep.h
  164. hash-object.c
  165. help.c
  166. http-fetch.c
  167. http-push.c
  168. http.c
  169. http.h
  170. ident.c
  171. imap-send.c
  172. index-pack.c
  173. INSTALL
  174. interpolate.c
  175. interpolate.h
  176. list-objects.c
  177. list-objects.h
  178. local-fetch.c
  179. lockfile.c
  180. log-tree.c
  181. log-tree.h
  182. Makefile
  183. merge-base.c
  184. merge-file.c
  185. merge-index.c
  186. merge-recursive.c
  187. merge-tree.c
  188. mktag.c
  189. mktree.c
  190. object-refs.c
  191. object.c
  192. object.h
  193. pack-check.c
  194. pack-redundant.c
  195. pack.h
  196. pager.c
  197. patch-delta.c
  198. patch-id.c
  199. path-list.c
  200. path-list.h
  201. path.c
  202. peek-remote.c
  203. pkt-line.c
  204. pkt-line.h
  205. quote.c
  206. quote.h
  207. read-cache.c
  208. README
  209. receive-pack.c
  210. refs.c
  211. refs.h
  212. revision.c
  213. revision.h
  214. rsh.c
  215. rsh.h
  216. run-command.c
  217. run-command.h
  218. send-pack.c
  219. server-info.c
  220. setup.c
  221. sha1_file.c
  222. sha1_name.c
  223. shell.c
  224. show-index.c
  225. sideband.c
  226. sideband.h
  227. ssh-fetch.c
  228. ssh-pull.c
  229. ssh-push.c
  230. ssh-upload.c
  231. strbuf.c
  232. strbuf.h
  233. tag.c
  234. tag.h
  235. tar.h
  236. test-date.c
  237. test-delta.c
  238. test-sha1.c
  239. test-sha1.sh
  240. trace.c
  241. tree-diff.c
  242. tree-walk.c
  243. tree-walk.h
  244. tree.c
  245. tree.h
  246. unpack-file.c
  247. unpack-trees.c
  248. unpack-trees.h
  249. update-server-info.c
  250. upload-pack.c
  251. usage.c
  252. var.c
  253. write_or_die.c
  254. wt-status.c
  255. wt-status.h
  256. xdiff-interface.c
  257. xdiff-interface.h