From: "Robin H\. Johnson" <robbat2@gentoo.org>
To: git@vger.kernel.org
Cc: junkio@cox.net, Robin@orbis-terrarum.net,
H.Johnson@orbis-terrarum.net, <robbat2@gentoo.org>
Subject: [PATCH 1/2] Add custom subject prefix support to format-patch (take 3)
Date: Wed, 11 Apr 2007 16:58:07 -0700 [thread overview]
Message-ID: <1176335888349-git-send-email-robbat2@gentoo.org> (raw)
In-Reply-To: <11763358884124-git-send-email-robbat2@gentoo.org>
From: Robin H. Johnson <robbat2@gentoo.org>
Add a new option to git-format-patch, entitled --subject-prefix that allows
control of the subject prefix '[PATCH]'. Using this option, the text 'PATCH' is
replaced with whatever input is provided to the option. This allows easily
generating patches like '[PATCH 2.6.21-rc3]' or properly numbered series like
'[-mm3 PATCH N/M]'. This patch provides the implementation and documentation.
Signed-off-by: Robin H. Johnson <robbat2@gentoo.org>
---
Documentation/git-format-patch.txt | 17 ++++++++++++-----
builtin-log.c | 10 ++++++++--
log-tree.c | 14 ++++++++++----
revision.h | 1 +
4 files changed, 31 insertions(+), 11 deletions(-)
diff --git a/Documentation/git-format-patch.txt b/Documentation/git-format-patch.txt
index 111d7c6..9965745 100644
--- a/Documentation/git-format-patch.txt
+++ b/Documentation/git-format-patch.txt
@@ -10,11 +10,12 @@ SYNOPSIS
--------
[verse]
'git-format-patch' [-n | -k] [-o <dir> | --stdout] [--thread]
- [--attach[=<boundary>] | --inline[=<boundary>]]
- [-s | --signoff] [<common diff options>] [--start-number <n>]
- [--in-reply-to=Message-Id] [--suffix=.<sfx>]
- [--ignore-if-in-upstream]
- <since>[..<until>]
+ [--attach[=<boundary>] | --inline[=<boundary>]]
+ [-s | --signoff] [<common diff options>]
+ [--start-number <n>] [--in-reply-to=Message-Id]
+ [--suffix=.<sfx>] [--ignore-if-in-upstream]
+ [--subject-prefix=Subject-Prefix]
+ <since>[..<until>]
DESCRIPTION
-----------
@@ -98,6 +99,12 @@ include::diff-options.txt[]
patches being generated, and any patch that matches is
ignored.
+--subject-prefix=<Subject-Prefix>::
+ Instead of the standard '[PATCH]' prefix in the subject
+ line, instead use '[<Subject-Prefix>]'. This
+ allows for useful naming of a patch series, and can be
+ combined with the --numbered option.
+
--suffix=.<sfx>::
Instead of using `.patch` as the suffix for generated
filenames, use specifed suffix. A common alternative is
diff --git a/builtin-log.c b/builtin-log.c
index 71df957..4a4890a 100644
--- a/builtin-log.c
+++ b/builtin-log.c
@@ -417,6 +417,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
int numbered = 0;
int start_number = -1;
int keep_subject = 0;
+ int subject_prefix = 0;
int ignore_if_in_upstream = 0;
int thread = 0;
const char *in_reply_to = NULL;
@@ -434,6 +435,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
rev.ignore_merges = 1;
rev.diffopt.msg_sep = "";
rev.diffopt.recursive = 1;
+ rev.subject_prefix = "PATCH";
rev.extra_headers = extra_headers;
@@ -509,8 +511,10 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
if (i == argc)
die("Need a Message-Id for --in-reply-to");
in_reply_to = argv[i];
- }
- else if (!prefixcmp(argv[i], "--suffix="))
+ } else if (!prefixcmp(argv[i], "--subject-prefix=")) {
+ subject_prefix = 1;
+ rev.subject_prefix = argv[i] + 17;
+ } else if (!prefixcmp(argv[i], "--suffix="))
fmt_patch_suffix = argv[i] + 9;
else
argv[j++] = argv[i];
@@ -521,6 +525,8 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
start_number = 1;
if (numbered && keep_subject)
die ("-n and -k are mutually exclusive.");
+ if (keep_subject && subject_prefix)
+ die ("--subject-prefix and -k are mutually exclusive.");
argc = setup_revisions(argc, argv, &rev, "HEAD");
if (argc > 1)
diff --git a/log-tree.c b/log-tree.c
index 8797aa1..dad5513 100644
--- a/log-tree.c
+++ b/log-tree.c
@@ -165,14 +165,20 @@ void show_log(struct rev_info *opt, const char *sep)
if (opt->total > 0) {
static char buffer[64];
snprintf(buffer, sizeof(buffer),
- "Subject: [PATCH %0*d/%d] ",
+ "Subject: [%s %0*d/%d] ",
+ opt->subject_prefix,
digits_in_number(opt->total),
opt->nr, opt->total);
subject = buffer;
- } else if (opt->total == 0)
- subject = "Subject: [PATCH] ";
- else
+ } else if (opt->total == 0) {
+ static char buffer[256];
+ snprintf(buffer, sizeof(buffer),
+ "Subject: [%s] ",
+ opt->subject_prefix);
+ subject = buffer;
+ } else {
subject = "Subject: ";
+ }
printf("From %s Mon Sep 17 00:00:00 2001\n", sha1);
if (opt->message_id)
diff --git a/revision.h b/revision.h
index 55e6b53..5f3f628 100644
--- a/revision.h
+++ b/revision.h
@@ -78,6 +78,7 @@ struct rev_info {
const char *add_signoff;
const char *extra_headers;
const char *log_reencode;
+ const char *subject_prefix;
int no_inline;
/* Filter by commit log message */
--
1.5.1
next prev parent reply other threads:[~2007-04-11 23:58 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-04-11 23:58 git-format-patch --subject-prefix support Robin H. Johnson
2007-04-11 23:58 ` Robin H. Johnson [this message]
2007-04-11 23:58 ` [PATCH 2/2] Add testcase for format-patch --subject-prefix (take 3) Robin H. Johnson
2007-04-12 0:35 ` git-format-patch --subject-prefix support Junio C Hamano
2007-04-12 0:54 ` Julian Phillips
2007-04-12 1:52 ` Junio C Hamano
2007-04-12 10:04 ` Junio C Hamano
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=1176335888349-git-send-email-robbat2@gentoo.org \
--to=robbat2@gentoo.org \
--cc=H.Johnson@orbis-terrarum.net \
--cc=Robin@orbis-terrarum.net \
--cc=git@vger.kernel.org \
--cc=junkio@cox.net \
/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).