diff options
author | Johannes Schindelin <johannes.schindelin@gmx.de> | 2020-01-14 19:43:46 +0100 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2020-01-15 21:06:16 +0100 |
commit | 08b1ea4c39b08b76fe2d1240ccbf6077ef19226a (patch) | |
tree | 5b5594a85ade0187b7d8cf7a115f86a129ae9506 /add-patch.c | |
parent | built-in add -p: support interactive.diffFilter (diff) | |
download | git-08b1ea4c39b08b76fe2d1240ccbf6077ef19226a.tar.xz git-08b1ea4c39b08b76fe2d1240ccbf6077ef19226a.zip |
built-in add -p: handle diff.algorithm
The Perl version of `git add -p` reads the config setting
`diff.algorithm` and if set, uses it to generate the diff using the
specified algorithm.
This patch ports that functionality to the C version.
Note: just like `git-add--interactive.perl`, we do _not_ respect this
config setting in `git add -i`'s `diff` command, but _only_ in the
`patch` command.
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'add-patch.c')
-rw-r--r-- | add-patch.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/add-patch.c b/add-patch.c index 78bde41df0..8f2ee8688b 100644 --- a/add-patch.c +++ b/add-patch.c @@ -360,6 +360,7 @@ static int is_octal(const char *p, size_t len) static int parse_diff(struct add_p_state *s, const struct pathspec *ps) { struct argv_array args = ARGV_ARRAY_INIT; + const char *diff_algorithm = s->s.interactive_diff_algorithm; struct strbuf *plain = &s->plain, *colored = NULL; struct child_process cp = CHILD_PROCESS_INIT; char *p, *pend, *colored_p = NULL, *colored_pend = NULL, marker = '\0'; @@ -369,6 +370,8 @@ static int parse_diff(struct add_p_state *s, const struct pathspec *ps) int res; argv_array_pushv(&args, s->mode->diff_cmd); + if (diff_algorithm) + argv_array_pushf(&args, "--diff-algorithm=%s", diff_algorithm); if (s->revision) { struct object_id oid; argv_array_push(&args, |