git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Marcel Partap <mpartap@gmx.net>
To: git@vger.kernel.org
Cc: mpartap@gmx.net
Subject: [PATCH] add -p: obey diff.noprefix option if set
Date: Sat,  4 Mar 2023 13:39:00 +0100	[thread overview]
Message-ID: <20230304123900.358048-1-mpartap@gmx.net> (raw)

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 <mpartap@gmx.net>
---
 add-patch.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git add-patch.c add-patch.c
index a86a92e164..520faae9cb 100644
--- 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 struct pathspec *ps)
 	size_t file_diff_alloc = 0, i, color_arg_index;
 	struct file_diff *file_diff = NULL;
 	struct hunk *hunk = NULL;
-	int res;
+	int res, noprefix;

 	strvec_pushv(&args, s->mode->diff_cmd);
 	if (diff_algorithm)
 		strvec_pushf(&args, "--diff-algorithm=%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,
--
2.38.1


             reply	other threads:[~2023-03-04 12:39 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-04 12:39 Marcel Partap [this message]
2023-03-06  8:40 ` [PATCH] add -p: obey diff.noprefix option if set Jeff King
2023-03-06  9:39   ` Phillip Wood
2023-03-06 10:31     ` Jeff King

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230304123900.358048-1-mpartap@gmx.net \
    --to=mpartap@gmx.net \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).