diff options
| author | Leon Michalak <leonmichalak6@gmail.com> | 2025-07-29 07:01:50 +0000 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2025-07-29 08:52:45 -0700 |
| commit | 2b0a2db2c0bf4870592656e8f50876957db8660c (patch) | |
| tree | 0a135457df2cec75e8bc75c44ef37f885db5f24f /add-patch.c | |
| parent | t: use test_config in t4055 (diff) | |
| download | git-2b0a2db2c0bf4870592656e8f50876957db8660c.tar.gz git-2b0a2db2c0bf4870592656e8f50876957db8660c.zip | |
add-patch: respect diff.context configuration
Various builtins that use add-patch infrastructure do not respect
the user's diff.context and diff.interHunkContext file configurations.
The user may be used to seeing their diffs with customized context size,
but not in the patches "git add -p" shows them to pick from.
Teach add-patch infrastructure to read these configuration variables and
pass their values when spawning the underlying plumbing commands as
their command line option.
Signed-off-by: Leon Michalak <leonmichalak6@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'add-patch.c')
| -rw-r--r-- | add-patch.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/add-patch.c b/add-patch.c index 95c67d8c80..b0125b51ba 100644 --- a/add-patch.c +++ b/add-patch.c @@ -414,7 +414,6 @@ static int normalize_marker(const char *p) static int parse_diff(struct add_p_state *s, const struct pathspec *ps) { struct strvec args = STRVEC_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'; @@ -424,8 +423,12 @@ static int parse_diff(struct add_p_state *s, const struct pathspec *ps) int res; strvec_pushv(&args, s->mode->diff_cmd); - if (diff_algorithm) - strvec_pushf(&args, "--diff-algorithm=%s", diff_algorithm); + if (s->s.context != -1) + strvec_pushf(&args, "--unified=%i", s->s.context); + if (s->s.interhunkcontext != -1) + strvec_pushf(&args, "--inter-hunk-context=%i", s->s.interhunkcontext); + if (s->s.interactive_diff_algorithm) + strvec_pushf(&args, "--diff-algorithm=%s", s->s.interactive_diff_algorithm); if (s->revision) { struct object_id oid; strvec_push(&args, |
