diff options
| author | Junio C Hamano <gitster@pobox.com> | 2025-07-29 09:28:50 -0700 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2025-07-29 09:28:50 -0700 |
| commit | 393fa4b64b12da3d3fdcefb02739bb1e82291dcc (patch) | |
| tree | 37d9676a25f69b289f6d738642a43ae68d8b140e /add-patch.c | |
| parent | Merge branch 'ps/config-wo-the-repository' into next (diff) | |
| parent | add-patch: add diff.context command line overrides (diff) | |
| download | git-393fa4b64b12da3d3fdcefb02739bb1e82291dcc.tar.gz git-393fa4b64b12da3d3fdcefb02739bb1e82291dcc.zip | |
Merge branch 'lm/add-p-context' into next
"git add/etc -p" now honors diff.context configuration variable,
and learns to honor -U<n> option.
* lm/add-p-context:
add-patch: add diff.context command line overrides
add-patch: respect diff.context configuration
t: use test_config in t4055
t: use test_grep in t3701 and t4055
Diffstat (limited to 'add-patch.c')
| -rw-r--r-- | add-patch.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/add-patch.c b/add-patch.c index 95c67d8c80..302e6ba7d9 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, @@ -1760,14 +1763,15 @@ soft_increment: } int run_add_p(struct repository *r, enum add_p_mode mode, - const char *revision, const struct pathspec *ps) + struct add_p_opt *o, const char *revision, + const struct pathspec *ps) { struct add_p_state s = { { r }, STRBUF_INIT, STRBUF_INIT, STRBUF_INIT, STRBUF_INIT }; size_t i, binary_count = 0; - init_add_i_state(&s.s, r); + init_add_i_state(&s.s, r, o); if (mode == ADD_P_STASH) s.mode = &patch_mode_stash; |
