* git-format-patch --subject-prefix support. @ 2007-04-11 23:58 Robin H. Johnson 2007-04-11 23:58 ` [PATCH 1/2] Add custom subject prefix support to format-patch (take 3) Robin H. Johnson 2007-04-12 0:35 ` git-format-patch --subject-prefix support Junio C Hamano 0 siblings, 2 replies; 7+ messages in thread From: Robin H. Johnson @ 2007-04-11 23:58 UTC (permalink / raw) To: git; +Cc: junkio 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]'. 1/2 - Implementation and documentation 2/2 - Test case ^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 1/2] Add custom subject prefix support to format-patch (take 3) 2007-04-11 23:58 git-format-patch --subject-prefix support Robin H. Johnson @ 2007-04-11 23:58 ` Robin H. Johnson 2007-04-11 23:58 ` [PATCH 2/2] Add testcase for format-patch --subject-prefix " Robin H. Johnson 2007-04-12 0:35 ` git-format-patch --subject-prefix support Junio C Hamano 1 sibling, 1 reply; 7+ messages in thread From: Robin H. Johnson @ 2007-04-11 23:58 UTC (permalink / raw) To: git; +Cc: junkio, Robin, H.Johnson, robbat2 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 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 2/2] Add testcase for format-patch --subject-prefix (take 3) 2007-04-11 23:58 ` [PATCH 1/2] Add custom subject prefix support to format-patch (take 3) Robin H. Johnson @ 2007-04-11 23:58 ` Robin H. Johnson 0 siblings, 0 replies; 7+ messages in thread From: Robin H. Johnson @ 2007-04-11 23:58 UTC (permalink / raw) To: git; +Cc: junkio, Robin, H.Johnson, robbat2 From: Robin H. Johnson <robbat2@gentoo.org> Add testcase for format-patch --subject-prefix support. Signed-off-by: Robin H. Johnson <robbat2@gentoo.org> --- t/t4013-diff-various.sh | 1 + ...tdout_--subject-prefix=TESTCASE_initial..master | 164 ++++++++++++++++++++ 2 files changed, 165 insertions(+), 0 deletions(-) create mode 100644 t/t4013/diff.format-patch_--inline_--stdout_--subject-prefix=TESTCASE_initial..master diff --git a/t/t4013-diff-various.sh b/t/t4013-diff-various.sh index 488e075..8f4c29a 100755 --- a/t/t4013-diff-various.sh +++ b/t/t4013-diff-various.sh @@ -241,6 +241,7 @@ format-patch --attach --stdout initial..master format-patch --inline --stdout initial..side format-patch --inline --stdout initial..master^ format-patch --inline --stdout initial..master +format-patch --inline --stdout --subject-prefix=TESTCASE initial..master diff --abbrev initial..side diff -r initial..side diff --git a/t/t4013/diff.format-patch_--inline_--stdout_--subject-prefix=TESTCASE_initial..master b/t/t4013/diff.format-patch_--inline_--stdout_--subject-prefix=TESTCASE_initial..master new file mode 100644 index 0000000..a8093be --- /dev/null +++ b/t/t4013/diff.format-patch_--inline_--stdout_--subject-prefix=TESTCASE_initial..master @@ -0,0 +1,164 @@ +$ git format-patch --inline --stdout --subject-prefix=TESTCASE initial..master +From 1bde4ae5f36c8d9abe3a0fce0c6aab3c4a12fe44 Mon Sep 17 00:00:00 2001 +From: A U Thor <author@example.com> +Date: Mon, 26 Jun 2006 00:01:00 +0000 +Subject: [TESTCASE] Second +MIME-Version: 1.0 +Content-Type: multipart/mixed; boundary="------------g-i-t--v-e-r-s-i-o-n" + +This is a multi-part message in MIME format. +--------------g-i-t--v-e-r-s-i-o-n +Content-Type: text/plain; charset=UTF-8; format=fixed +Content-Transfer-Encoding: 8bit + + +This is the second commit. +--- + dir/sub | 2 ++ + file0 | 3 +++ + file2 | 3 --- + 3 files changed, 5 insertions(+), 3 deletions(-) + delete mode 100644 file2 +--------------g-i-t--v-e-r-s-i-o-n +Content-Type: text/x-patch; name="1bde4ae5f36c8d9abe3a0fce0c6aab3c4a12fe44.diff" +Content-Transfer-Encoding: 8bit +Content-Disposition: inline; filename="1bde4ae5f36c8d9abe3a0fce0c6aab3c4a12fe44.diff" + +diff --git a/dir/sub b/dir/sub +index 35d242b..8422d40 100644 +--- a/dir/sub ++++ b/dir/sub +@@ -1,2 +1,4 @@ + A + B ++C ++D +diff --git a/file0 b/file0 +index 01e79c3..b414108 100644 +--- a/file0 ++++ b/file0 +@@ -1,3 +1,6 @@ + 1 + 2 + 3 ++4 ++5 ++6 +diff --git a/file2 b/file2 +deleted file mode 100644 +index 01e79c3..0000000 +--- a/file2 ++++ /dev/null +@@ -1,3 +0,0 @@ +-1 +-2 +-3 + +--------------g-i-t--v-e-r-s-i-o-n-- + + + +From 9a6d4949b6b76956d9d5e26f2791ec2ceff5fdc0 Mon Sep 17 00:00:00 2001 +From: A U Thor <author@example.com> +Date: Mon, 26 Jun 2006 00:02:00 +0000 +Subject: [TESTCASE] Third +MIME-Version: 1.0 +Content-Type: multipart/mixed; boundary="------------g-i-t--v-e-r-s-i-o-n" + +This is a multi-part message in MIME format. +--------------g-i-t--v-e-r-s-i-o-n +Content-Type: text/plain; charset=UTF-8; format=fixed +Content-Transfer-Encoding: 8bit + +--- + dir/sub | 2 ++ + file1 | 3 +++ + 2 files changed, 5 insertions(+), 0 deletions(-) + create mode 100644 file1 +--------------g-i-t--v-e-r-s-i-o-n +Content-Type: text/x-patch; name="9a6d4949b6b76956d9d5e26f2791ec2ceff5fdc0.diff" +Content-Transfer-Encoding: 8bit +Content-Disposition: inline; filename="9a6d4949b6b76956d9d5e26f2791ec2ceff5fdc0.diff" + +diff --git a/dir/sub b/dir/sub +index 8422d40..cead32e 100644 +--- a/dir/sub ++++ b/dir/sub +@@ -2,3 +2,5 @@ A + B + C + D ++E ++F +diff --git a/file1 b/file1 +new file mode 100644 +index 0000000..b1e6722 +--- /dev/null ++++ b/file1 +@@ -0,0 +1,3 @@ ++A ++B ++C + +--------------g-i-t--v-e-r-s-i-o-n-- + + + +From c7a2ab9e8eac7b117442a607d5a9b3950ae34d5a Mon Sep 17 00:00:00 2001 +From: A U Thor <author@example.com> +Date: Mon, 26 Jun 2006 00:03:00 +0000 +Subject: [TESTCASE] Side +MIME-Version: 1.0 +Content-Type: multipart/mixed; boundary="------------g-i-t--v-e-r-s-i-o-n" + +This is a multi-part message in MIME format. +--------------g-i-t--v-e-r-s-i-o-n +Content-Type: text/plain; charset=UTF-8; format=fixed +Content-Transfer-Encoding: 8bit + +--- + dir/sub | 2 ++ + file0 | 3 +++ + file3 | 4 ++++ + 3 files changed, 9 insertions(+), 0 deletions(-) + create mode 100644 file3 +--------------g-i-t--v-e-r-s-i-o-n +Content-Type: text/x-patch; name="c7a2ab9e8eac7b117442a607d5a9b3950ae34d5a.diff" +Content-Transfer-Encoding: 8bit +Content-Disposition: inline; filename="c7a2ab9e8eac7b117442a607d5a9b3950ae34d5a.diff" + +diff --git a/dir/sub b/dir/sub +index 35d242b..7289e35 100644 +--- a/dir/sub ++++ b/dir/sub +@@ -1,2 +1,4 @@ + A + B ++1 ++2 +diff --git a/file0 b/file0 +index 01e79c3..f4615da 100644 +--- a/file0 ++++ b/file0 +@@ -1,3 +1,6 @@ + 1 + 2 + 3 ++A ++B ++C +diff --git a/file3 b/file3 +new file mode 100644 +index 0000000..7289e35 +--- /dev/null ++++ b/file3 +@@ -0,0 +1,4 @@ ++A ++B ++1 ++2 + +--------------g-i-t--v-e-r-s-i-o-n-- + + +$ -- 1.5.1 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: git-format-patch --subject-prefix support. 2007-04-11 23:58 git-format-patch --subject-prefix support Robin H. Johnson 2007-04-11 23:58 ` [PATCH 1/2] Add custom subject prefix support to format-patch (take 3) Robin H. Johnson @ 2007-04-12 0:35 ` Junio C Hamano 2007-04-12 0:54 ` Julian Phillips 1 sibling, 1 reply; 7+ messages in thread From: Junio C Hamano @ 2007-04-12 0:35 UTC (permalink / raw) To: Robin H. Johnson; +Cc: git, junkio "Robin H\. Johnson" <robbat2@gentoo.org> writes: > 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]'. > > 1/2 - Implementation and documentation > 2/2 - Test case I suspect this is a job for send-email, not format-patch. List? ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: git-format-patch --subject-prefix support. 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 0 siblings, 1 reply; 7+ messages in thread From: Julian Phillips @ 2007-04-12 0:54 UTC (permalink / raw) To: Junio C Hamano; +Cc: Robin H. Johnson, git On Wed, 11 Apr 2007, Junio C Hamano wrote: > "Robin H\. Johnson" <robbat2@gentoo.org> writes: > >> 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]'. >> >> 1/2 - Implementation and documentation >> 2/2 - Test case > > I suspect this is a job for send-email, not format-patch. List? Surely though, send-email is simply a helper for sending patches generated by format-patch? Is there any reason to deny the ability to set the prefix to those who don't use send-email but do use format-patch? (Personally I found send-email to be cumbersome and confusing, so I've stopped using it ...) It's format-patch that applies the current "[PATCH]" prefix anyway ... -- Julian --- Death, when unnecessary, is a tragic thing. -- Flint, "Requiem for Methuselah", stardate 5843.7 ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: git-format-patch --subject-prefix support. 2007-04-12 0:54 ` Julian Phillips @ 2007-04-12 1:52 ` Junio C Hamano 2007-04-12 10:04 ` Junio C Hamano 0 siblings, 1 reply; 7+ messages in thread From: Junio C Hamano @ 2007-04-12 1:52 UTC (permalink / raw) To: Julian Phillips; +Cc: Robin H. Johnson, git Julian Phillips <julian@quantumfyre.co.uk> writes: > On Wed, 11 Apr 2007, Junio C Hamano wrote: > >> "Robin H\. Johnson" <robbat2@gentoo.org> writes: >> >>> 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]'. >>> >>> 1/2 - Implementation and documentation >>> 2/2 - Test case >> >> I suspect this is a job for send-email, not format-patch. List? > > Surely though, send-email is simply a helper for sending patches > generated by format-patch? Is there any reason to deny the ability to > set the prefix to those who don't use send-email but do use > format-patch? (Personally I found send-email to be cumbersome and > confusing, so I've stopped using it ...) > > It's format-patch that applies the current "[PATCH]" prefix anyway ... I was more worried about people's scripts who postprocess format-patch output, relying on the '[PATCH]' to be there. But they should be using -k to suppress it anyway, so this addition should be Ok. Somebody needs to verify that mailinfo groks e-mails correctly even when they have "Subject: [random garbage] title" though. ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: git-format-patch --subject-prefix support. 2007-04-12 1:52 ` Junio C Hamano @ 2007-04-12 10:04 ` Junio C Hamano 0 siblings, 0 replies; 7+ messages in thread From: Junio C Hamano @ 2007-04-12 10:04 UTC (permalink / raw) To: Robin H. Johnson; +Cc: git Junio C Hamano <junkio@cox.net> writes: > Julian Phillips <julian@quantumfyre.co.uk> writes: > >> On Wed, 11 Apr 2007, Junio C Hamano wrote: >> >>> "Robin H\. Johnson" <robbat2@gentoo.org> writes: >>> >>>> 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]'. >>>> >>>> 1/2 - Implementation and documentation >>>> 2/2 - Test case Gaah. I applied it, pushed the results out and then found breakage. How much I hate these random and non-essential "mean well to enhance usability" patches X-<... In the meantime, I think this should fix it. Please test well. -- >8 -- Fix git {log,show,...} --pretty=email An earlier --subject-prefix forgot that format-patch is not the only codepath that added the "[PATCH]" prefix, breaking everybody else in the log family. Signed-off-by: Junio C Hamano <junkio@cox.net> --- builtin-log.c | 1 - revision.c | 1 + 2 files changed, 1 insertions(+), 1 deletions(-) diff --git a/builtin-log.c b/builtin-log.c index 4a4890a..ffc269a 100644 --- a/builtin-log.c +++ b/builtin-log.c @@ -435,7 +435,6 @@ 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; diff --git a/revision.c b/revision.c index 486393c..37f1eab 100644 --- a/revision.c +++ b/revision.c @@ -567,6 +567,7 @@ void init_revisions(struct rev_info *revs, const char *prefix) revs->min_age = -1; revs->skip_count = -1; revs->max_count = -1; + revs->subject_prefix = "PATCH"; revs->prune_fn = NULL; revs->prune_data = NULL; ^ permalink raw reply related [flat|nested] 7+ messages in thread
end of thread, other threads:[~2007-04-12 10:04 UTC | newest] Thread overview: 7+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2007-04-11 23:58 git-format-patch --subject-prefix support Robin H. Johnson 2007-04-11 23:58 ` [PATCH 1/2] Add custom subject prefix support to format-patch (take 3) Robin H. Johnson 2007-04-11 23:58 ` [PATCH 2/2] Add testcase for format-patch --subject-prefix " 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
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).