From git Sat Mar 04 12:39:00 2023 From: Marcel Partap Date: Sat, 04 Mar 2023 12:39:00 +0000 To: git Subject: [PATCH] add -p: obey diff.noprefix option if set Message-Id: <20230304123900.358048-1-mpartap () gmx ! net> X-MARC-Message: https://marc.info/?l=git&m=167793355001250 If the user has set the diff.noprefix option, he likely will expect this display setting to also apply when interactively adding hunks. Signed-off-by: Marcel Partap =2D-- add-patch.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git add-patch.c add-patch.c index a86a92e164..520faae9cb 100644 =2D-- add-patch.c +++ add-patch.c @@ -1,4 +1,5 @@ #include "cache.h" +#include "config.h" #include "add-interactive.h" #include "strbuf.h" #include "run-command.h" @@ -404,11 +405,13 @@ static int parse_diff(struct add_p_state *s, const s= truct pathspec *ps) size_t file_diff_alloc =3D 0, i, color_arg_index; struct file_diff *file_diff =3D NULL; struct hunk *hunk =3D NULL; - int res; + int res, noprefix; strvec_pushv(&args, s->mode->diff_cmd); if (diff_algorithm) strvec_pushf(&args, "--diff-algorithm=3D%s", diff_algorithm); + if (!git_config_get_bool("diff.noprefix", &noprefix) && noprefix) + strvec_pushf(&args, "--no-prefix"); if (s->revision) { struct object_id oid; strvec_push(&args, =2D- 2.38.1