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

Re: [PATCH 5/5] format-patch: add format.noprefix option

From
Junio C Hamano <gitster@pobox.com>
Date
Mar 9, 2023, 17:00 UTC
Message-ID
<xmqq5yb9dfn2.fsf@gitster.g>
In-Reply-To
<ZAl41V7n77ej844x@coredump.intra.peff.net>
Jeff King <peff@peff.net> writes:
Show 7 quoted lines
> A more backwards-compatible way of doing the transition would be to have
> format.noprefix default to diff.noprefix when it's not set. But that
> doesn't really help the "accidental" problem; people would have to
> manually set format.noprefix=false. And it's unlikely that anybody
> really wants format.noprefix=true in the first place. I'm adding it here
> mostly as an escape hatch, not because anybody has expressed any
> interest in it.

I tend to agree that this is closing the barn door after the horse escaped for projects who did use diff.noprefix because it is their preference to exchange prefix-free patches.

The other direction we could go is to tie the default p-value specified centrally for both producer and consumer. If the project wants no-prefix patches so much that the contributors use it in their own diff by setting diff.noprefix in their configuration, the project would be perfectly happy if format-patch sent prefix-less patches honoring the configuration, and if apply took prefix-less patches honoring the configuration, all honoring diff.noprefix.

But that is the other extreme.

I wonder if the consumer side should be made configurable for completeness, though.

Here is how "apply.pValue" configuration variable would look like. Projects whose members want diff.noprefix set can standardise on using that and then receiving end configured to match with this.

---
 apply.c       | 5 +++++
 cache.h       | 1 +
 environment.c | 1 +
 3 files changed, 7 insertions(+)
diff --git c/apply.c w/apply.c
index 5cc5479c9c..20645fc9af 100644
--- c/apply.c
+++ w/apply.c
@@ -33,6 +33,7 @@ static void git_apply_config(void)
 {
 	git_config_get_string("apply.whitespace", &apply_default_whitespace);
 	git_config_get_string("apply.ignorewhitespace", &apply_default_ignorewhitespace);
+	git_config_get_int("apply.pValue", &apply_default_p_value);
 	git_config(git_xmerge_config, NULL);
 }
 
@@ -112,6 +113,10 @@ int init_apply_state(struct apply_state *state,
 		return -1;
 	if (apply_default_ignorewhitespace && parse_ignorewhitespace_option(state, apply_default_ignorewhitespace))
 		return -1;
+	if (0 <= apply_default_p_value) {
+		state->p_value = apply_default_p_value;
+		state->p_value_known = 1;
+	}
 	return 0;
 }
 
diff --git c/cache.h w/cache.h
index 12789903e8..05efa9dc52 100644
--- c/cache.h
+++ w/cache.h
@@ -967,6 +967,7 @@ extern int assume_unchanged;
 extern int prefer_symlink_refs;
 extern int warn_ambiguous_refs;
 extern int warn_on_object_refname_ambiguity;
+extern int apply_default_p_value;
 extern char *apply_default_whitespace;
 extern char *apply_default_ignorewhitespace;
 extern const char *git_attributes_file;
diff --git c/environment.c w/environment.c
index 1ee3686fd8..b82ad370b4 100644
--- c/environment.c
+++ w/environment.c
@@ -38,6 +38,7 @@ const char *git_commit_encoding;
 const char *git_log_output_encoding;
 char *apply_default_whitespace;
 char *apply_default_ignorewhitespace;
+int apply_default_p_value = -1; /* unspecified */
 const char *git_attributes_file;
 const char *git_hooks_path;
 int zlib_compression_level = Z_BEST_SPEED;
Previous: Jeff KingNext: Jeff King
Message 21 of 30 in “Better suggestions when git-am(1) fails”
  1. Alejandro ColomarMar 8, 2023
  2. Jeff KingMar 9, 2023
  3. Jeff KingMar 9, 2023
  4. 1/5 diff: factor out src/dst prefix setupJeff King, Mar 9, 2023
  5. Alejandro ColomarMar 9, 2023
  6. 2/5 t4013: add tests for diff prefix optionsJeff King, Mar 9, 2023
  7. 3/5 diff: add --default-prefix optionJeff King, Mar 9, 2023
  8. Alejandro ColomarMar 9, 2023
  9. Junio C HamanoMar 9, 2023
  10. Jeff KingMar 10, 2023
  11. Junio C HamanoMar 10, 2023
  12. Jeff KingMar 13, 2023
  13. Junio C HamanoMar 13, 2023
  14. Junio C HamanoMar 13, 2023
  15. Jeff KingMar 13, 2023
  16. 4/5 format-patch: do not respect diff.noprefixJeff King, Mar 9, 2023
  17. Alejandro ColomarMar 9, 2023
  18. Junio C HamanoMar 9, 2023
  19. Jeff KingMar 10, 2023
  20. 5/5 format-patch: add format.noprefix optionJeff King, Mar 9, 2023
  21. Junio C HamanoMar 9, 2023
  22. Jeff KingMar 10, 2023
  23. Alejandro ColomarMar 9, 2023
  24. Junio C HamanoMar 9, 2023
  25. Jeff KingMar 10, 2023
  26. Junio C HamanoMar 9, 2023
  27. Jeff KingMar 10, 2023
  28. Junio C HamanoMar 10, 2023
  29. Jeff KingMar 13, 2023
  30. Junio C HamanoMar 13, 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.