git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] add -p: obey diff.noprefix option if set

From
Marcel Partap <mpartap@gmx.net>
Date
Mar 4, 2023, 12:39 UTC
Message-ID
<20230304123900.358048-1-mpartap@gmx.net>

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
Next: Jeff King
Message 1 of 4 in “add -p: obey diff.noprefix option if set”
  1. add -p: obey diff.noprefix option if setMarcel Partap, Mar 4, 2023
  2. Jeff KingMar 6, 2023
  3. Phillip WoodMar 6, 2023
  4. Jeff KingMar 6, 2023

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.