[PATCH 0/2] Make diff plumbing commands respect the indentHeuristic.
- From
Marc Branchaud <marcnarc@xiplink.com>
- Date
- Apr 27, 2017, 20:50 UTC
- Message-ID
- <20170427205037.1787-1-marcnarc@xiplink.com>
- In-Reply-To
- <19607a03-71e0-440b-7213-64d25f6fa8da@xiplink.com>
So here's my attempt at fixing this.
The thing I was missing is that init_revisions() calls diff_setup(), which sets the xdl options. It's therefore necessary to have the diff_indent_heuristic flag set before calling init_revisions().
A naive way to get the indentHeuristic config option respected in the diff-* plumbing commands is to make them use the git_diff_heuristic_config() callback right at the start of their main cmd functions.
But I did not like that for two reasons:
* It would make these commands invoke git_config() twice.
* It doesn't avoid the problem if/when someone creates a new diff-something plumbing command, and forgets to set the diff_indent_heuristic flag before calling init_revisions().
So instead I chose to make the indentHeuristic option part of diff's basic configuration, and in each of the diff plumbing commands I moved the call to git_config() before the call to init_revisions().
This still doesn't really future-proof things for possible new diff plumbing commands, because someone could still invoke init_revisions() before setting up diff's basic configuration. But I don't see an obvious way of ensuring that the diff_indent_heuristic flag is respected regardless of when diff_setup() is invoked.
M.
Marc Branchaud (2): Make the indent heuristic part of diff's basic configuration. Have the diff-* builtins configure diff before initializing revisions.
builtin/diff-files.c | 2 +- builtin/diff-index.c | 2 +- builtin/diff-tree.c | 2 +- diff.c | 6 +++--- 4 files changed, 6 insertions(+), 6 deletions(-)