diff options
| author | Jeff King <peff@peff.net> | 2023-03-09 01:12:37 -0500 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2023-03-09 08:37:27 -0800 |
| commit | 8d5213decff887b2d950b732e37b7abad6f8d450 (patch) | |
| tree | 89813311250026a5efbb0509ffd2f0e553fd8fe6 /builtin | |
| parent | format-patch: do not respect diff.noprefix (diff) | |
| download | git-8d5213decff887b2d950b732e37b7abad6f8d450.tar.gz git-8d5213decff887b2d950b732e37b7abad6f8d450.zip | |
format-patch: add format.noprefix option
The previous commit dropped support for diff.noprefix in format-patch.
While this will do the right thing in most cases (where sending patches
without a prefix was an accidental side effect of the sender preferring
to see their local patches without prefixes), it left no good option for
a project or workflow where you really do want to send patches without
prefixes. You'd be stuck using "--no-prefix" for every invocation.
So let's add a config option specific to format-patch that enables this
behavior. That gives people who have such a workflow a way to get what
they want, but makes it hard to accidentally trigger it.
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.
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin')
| -rw-r--r-- | builtin/log.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/builtin/log.c b/builtin/log.c index eaf511aab8..b1f59062f4 100644 --- a/builtin/log.c +++ b/builtin/log.c @@ -56,6 +56,7 @@ static int stdout_mboxrd; static const char *fmt_patch_subject_prefix = "PATCH"; static int fmt_patch_name_max = FORMAT_PATCH_NAME_MAX_DEFAULT; static const char *fmt_pretty; +static int format_no_prefix; static const char * const builtin_log_usage[] = { N_("git log [<options>] [<revision-range>] [[--] <path>...]"), @@ -1084,6 +1085,10 @@ static int git_format_config(const char *var, const char *value, void *cb) stdout_mboxrd = git_config_bool(var, value); return 0; } + if (!strcmp(var, "format.noprefix")) { + format_no_prefix = 1; + return 0; + } /* * ignore some porcelain config which would otherwise be parsed by @@ -2002,6 +2007,9 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix) s_r_opt.def = "HEAD"; s_r_opt.revarg_opt = REVARG_COMMITTISH; + if (format_no_prefix) + diff_set_noprefix(&rev.diffopt); + if (default_attach) { rev.mime_boundary = default_attach; rev.no_inline = 1; |
