git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v2 06/11] add -i (built-in): use correct names to load color.diff.* config

From
Johannes Schindelin via GitGitGadget <gitgitgadget@gmail.com>
Date
Nov 11, 2020, 12:28 UTC
Message-ID
<dcd2ffc4586960386eb8a517ff9478a8975d428c.1605097704.git.gitgitgadget@gmail.com>
In-Reply-To
<pull.785.v2.git.1605097704.gitgitgadget@gmail.com>
From: Johannes Schindelin <johannes.schindelin@gmx.de>

The builtin version of add-interactive mistakenly loads diff colors from color.interactive.* instead of color.diff.*. It also accidentally spells `frag` as `fraginfo`.

Let's fix that.

Note also that we don't respect the historical `diff.color.*`. The perl version never did, and those have been deprecated since 2007.

Reported-by: Philippe Blain <levraiphilippeblain@gmail.com>
Co-authored-by: Jeff King <peff@peff.net>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
 add-interactive.c | 23 +++++++++++++----------
 1 file changed, 13 insertions(+), 10 deletions(-)
diff --git a/add-interactive.c b/add-interactive.c
index f3a1d7456e..9126684348 100644
--- a/add-interactive.c
+++ b/add-interactive.c
@@ -12,10 +12,10 @@
 #include "prompt.h"
 
 static void init_color(struct repository *r, struct add_i_state *s,
-		       const char *slot_name, char *dst,
+		       const char *section_and_slot, char *dst,
 		       const char *default_color)
 {
-	char *key = xstrfmt("color.interactive.%s", slot_name);
+	char *key = xstrfmt("color.%s", section_and_slot);
 	const char *value;
 
 	if (!s->use_color)
@@ -40,17 +40,20 @@ void init_add_i_state(struct add_i_state *s, struct repository *r)
 			git_config_colorbool("color.interactive", value);
 	s->use_color = want_color(s->use_color);
 
-	init_color(r, s, "header", s->header_color, GIT_COLOR_BOLD);
-	init_color(r, s, "help", s->help_color, GIT_COLOR_BOLD_RED);
-	init_color(r, s, "prompt", s->prompt_color, GIT_COLOR_BOLD_BLUE);
-	init_color(r, s, "error", s->error_color, GIT_COLOR_BOLD_RED);
-	init_color(r, s, "fraginfo", s->fraginfo_color,
+	init_color(r, s, "interactive.header", s->header_color, GIT_COLOR_BOLD);
+	init_color(r, s, "interactive.help", s->help_color, GIT_COLOR_BOLD_RED);
+	init_color(r, s, "interactive.prompt", s->prompt_color,
+		   GIT_COLOR_BOLD_BLUE);
+	init_color(r, s, "interactive.error", s->error_color,
+		   GIT_COLOR_BOLD_RED);
+
+	init_color(r, s, "diff.frag", s->fraginfo_color,
 		   diff_get_color(s->use_color, DIFF_FRAGINFO));
-	init_color(r, s, "context", s->context_color,
+	init_color(r, s, "diff.context", s->context_color,
 		diff_get_color(s->use_color, DIFF_CONTEXT));
-	init_color(r, s, "old", s->file_old_color,
+	init_color(r, s, "diff.old", s->file_old_color,
 		diff_get_color(s->use_color, DIFF_FILE_OLD));
-	init_color(r, s, "new", s->file_new_color,
+	init_color(r, s, "diff.new", s->file_new_color,
 		diff_get_color(s->use_color, DIFF_FILE_NEW));
 
 	strlcpy(s->reset_color,
-- 
gitgitgadget
Previous: Johannes SchindelinNext: Johannes Schindelin via GitGitGadget
Message 37 of 66 in “Fix color handling in git add -i”
  1. 0/9 Fix color handling in git add -iJohannes Schindelin via GitGitGadget, Nov 10, 2020
  2. 1/9 add -i (built-in): do show an error message for incorrect inputsJohannes Schindelin via GitGitGadget, Nov 10, 2020
  3. 2/9 add -i (built-in): send error messages to stderrJohannes Schindelin via GitGitGadget, Nov 10, 2020
  4. 7/9 add -i (built-in): use the same indentation as the Perl versionJohannes Schindelin via GitGitGadget, Nov 10, 2020
  5. 8/9 add -i (Perl version): include indentation in the colored headerJohannes Schindelin via GitGitGadget, Nov 10, 2020
  6. 9/9 add -i: verify in the tests that colors can be overriddenJohannes Schindelin via GitGitGadget, Nov 10, 2020
  7. Jeff KingNov 11, 2020
  8. Johannes SchindelinNov 11, 2020
  9. Jeff KingNov 11, 2020
  10. Johannes SchindelinNov 12, 2020
  11. Jeff KingNov 12, 2020
  12. Johannes SchindelinNov 15, 2020
  13. Jeff KingNov 17, 2020
  14. 5/9 add -i (built-in): use correct names to load color.diff.* configJohannes Schindelin via GitGitGadget, Nov 10, 2020
  15. 3/9 add -i: use `reset_color` consistentlyJohannes Schindelin via GitGitGadget, Nov 10, 2020
  16. 6/9 add -p (built-in): do not color the progress indicator separatelyJohannes Schindelin via GitGitGadget, Nov 10, 2020
  17. 4/9 add -i (built-in): prevent the `reset` "color" from being configuredJohannes Schindelin via GitGitGadget, Nov 10, 2020
  18. Jeff KingNov 11, 2020
  19. 00/11 Fix color handling in git add -iJohannes Schindelin via GitGitGadget, Nov 11, 2020
  20. 01/11 add -i (built-in): do show an error message for incorrect inputsJohannes Schindelin via GitGitGadget, Nov 11, 2020
  21. 07/11 add -p (built-in): do not color the progress indicator separatelyJohannes Schindelin via GitGitGadget, Nov 11, 2020
  22. Phillip WoodNov 13, 2020
  23. Johannes SchindelinNov 13, 2020
  24. Phillip WoodNov 13, 2020
  25. Johannes SchindelinNov 15, 2020
  26. 08/11 add -i (built-in): use the same indentation as the Perl versionJohannes Schindelin via GitGitGadget, Nov 11, 2020
  27. 10/11 add -p: prefer color.diff.context over color.diff.plainJohannes Schindelin via GitGitGadget, Nov 11, 2020
  28. Philippe BlainNov 13, 2020
  29. Johannes SchindelinNov 15, 2020
  30. Phillip WoodNov 13, 2020
  31. Johannes SchindelinNov 16, 2020
  32. 09/11 add -i (Perl version): include indentation in the colored headerJohannes Schindelin via GitGitGadget, Nov 11, 2020
  33. Phillip WoodNov 13, 2020
  34. Johannes SchindelinNov 13, 2020
  35. Phillip WoodNov 13, 2020
  36. Johannes SchindelinNov 15, 2020
  37. 06/11 add -i (built-in): use correct names to load color.diff.* configJohannes Schindelin via GitGitGadget, Nov 11, 2020
  38. 11/11 add -i: verify in the tests that colors can be overriddenJohannes Schindelin via GitGitGadget, Nov 11, 2020
  39. 05/11 add -i (built-in): prevent the `reset` "color" from being configuredJohannes Schindelin via GitGitGadget, Nov 11, 2020
  40. 02/11 add -i (built-in): send error messages to stderrJohannes Schindelin via GitGitGadget, Nov 11, 2020
  41. 03/11 add -p (built-in): imitate `xdl_format_hunk_hdr()` generating hunk headersJohannes Schindelin via GitGitGadget, Nov 11, 2020
  42. 04/11 add -i: use `reset_color` consistentlyJohannes Schindelin via GitGitGadget, Nov 11, 2020
  43. Phillip WoodNov 13, 2020
  44. Johannes SchindelinNov 13, 2020
  45. Phillip WoodNov 13, 2020
  46. Johannes SchindelinNov 15, 2020
  47. Jeff KingNov 11, 2020
  48. Johannes SchindelinNov 12, 2020
  49. Jeff KingNov 12, 2020
  50. Johannes SchindelinNov 15, 2020
  51. Jeff KingNov 17, 2020
  52. 00/11 Fix color handling in git add -iJohannes Schindelin via GitGitGadget, Nov 16, 2020
  53. 01/11 add -i (built-in): do show an error message for incorrect inputsJohannes Schindelin via GitGitGadget, Nov 16, 2020
  54. 02/11 add -i (built-in): send error messages to stderrJohannes Schindelin via GitGitGadget, Nov 16, 2020
  55. 03/11 add -p (built-in): imitate `xdl_format_hunk_hdr()` generating hunk headersJohannes Schindelin via GitGitGadget, Nov 16, 2020
  56. 04/11 add -i: use `reset_color` consistentlyJohannes Schindelin via GitGitGadget, Nov 16, 2020
  57. 05/11 add -i (built-in): prevent the `reset` "color" from being configuredJohannes Schindelin via GitGitGadget, Nov 16, 2020
  58. 06/11 add -i (built-in): use correct names to load color.diff.* configJohannes Schindelin via GitGitGadget, Nov 16, 2020
  59. 08/11 add -i (built-in): use the same indentation as the Perl versionJohannes Schindelin via GitGitGadget, Nov 16, 2020
  60. 07/11 add -p (built-in): do not color the progress indicator separatelyJohannes Schindelin via GitGitGadget, Nov 16, 2020
  61. 11/11 add -i: verify in the tests that colors can be overriddenJohannes Schindelin via GitGitGadget, Nov 16, 2020
  62. 09/11 add -i (Perl version): color header to match the C versionJohannes Schindelin via GitGitGadget, Nov 16, 2020
  63. 10/11 add -p: prefer color.diff.context over color.diff.plainJohannes Schindelin via GitGitGadget, Nov 16, 2020
  64. Jeff KingNov 17, 2020
  65. Jeff KingNov 17, 2020
  66. Junio C HamanoNov 25, 2020

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.