diff options
| author | Jeff King <peff@peff.net> | 2025-09-16 16:22:26 -0400 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2025-09-16 13:37:06 -0700 |
| commit | 5e9ddd3c0652ad4e16cc33525d611e23f61dc6a5 (patch) | |
| tree | 66b954e6eca02369a6d13035247320c94f6a5e09 /Documentation/technical/commit-graph.adoc | |
| parent | 955000d91718eee5abd005dd43ed035a5115d870 (diff) | |
pretty: use format_commit_context.auto_color as colorbool
When we see "%C(auto)" as a format placeholder, we evaluate the "color"
field of our pretty_print_context to decide whether we want color. The
auto_color field of format_commit_context then stores the boolean result
of want_color(), telling us the yes/no of whether we want color.
But the resulting field is passed to various functions which expect a
git_colorbool, like diff_get_color(), that will then pass it to
want_color() again. It's not wrong to do so, since want_color() is
idempotent. But it makes it harder to reason about the types, since we
sometimes confuse colorbools and strict booleans.
Let's instead store auto_color as the original colorbool itself. We'll
have to make sure it is passed through want_color() when it is
evaluated, but there is only one such spot (right next to where we
assign it!). Every other caller just ends up passing it to get
diff_get_color() either directly or through another helper.
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'Documentation/technical/commit-graph.adoc')
0 files changed, 0 insertions, 0 deletions
