Add 'git format-patch --to=' option and 'format.to' configuration variable.
Has the same functionality as the '--cc' option and 'format.cc' configuration variable but for the "To:" email header. Half of the code to support this was already there. With email the To: header usually more important than the Cc: header. [jc: tests are by Stephen Boyd] Signed-off-by: Steven Drake <sdrake@xnet.co.nz> Signed-off-by: Stephen Boyd <bebarino@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Steven Drake committed
Feb 17, 2010 at 12:39 UTC
ae6c098f158dd306462024c5cb137b8f7f65cfbd
3 files changed
+38
-3
Documentation/git-format-patch.txt
+8
-3
@@ -18,7 +18,7 @@ SYNOPSIS
18
[--in-reply-to=Message-Id] [--suffix=.<sfx>]
19
[--ignore-if-in-upstream]
20
[--subject-prefix=Subject-Prefix]
21
- [--cc=<email>]
21
+ [--to=<email>] [--cc=<email>]
22
[--cover-letter]
23
[<common diff options>]
24
[ <since> | <revision range> ]
@@ -162,6 +162,10 @@ will want to ensure that threading is disabled for `git send-email`.
162
allows for useful naming of a patch series, and can be
163
combined with the `--numbered` option.
164
165
+--to=<email>::
166
+ Add a `To:` header to the email headers. This is in addition
167
+ to any configured headers, and may be used multiple times.
168
+
169
--cc=<email>::
170
Add a `Cc:` header to the email headers. This is in addition
171
to any configured headers, and may be used multiple times.
@@ -202,8 +206,8 @@ CONFIGURATION
206
-------------
207
You can specify extra mail header lines to be added to each message,
208
defaults for the subject prefix and file suffix, number patches when
205
-outputting more than one patch, add "Cc:" headers, configure attachments,
206
-and sign off patches with configuration variables.
209
+outputting more than one patch, add "To" or "Cc:" headers, configure
210
+attachments, and sign off patches with configuration variables.
211
212
------------
213
[format]
@@ -211,6 +215,7 @@ and sign off patches with configuration variables.
215
subjectprefix = CHANGE
216
suffix = .txt
217
numbered = auto
218
+ to = <email>
219
cc = <email>
220
attach [ = mime-boundary-string ]
221
signoff = true
builtin-log.c
+16
@@ -504,6 +504,13 @@ static int git_format_config(const char *var, const char *value, void *cb)
504
}
505
if (!strcmp(var, "format.suffix"))
506
return git_config_string(&fmt_patch_suffix, var, value);
507
+ if (!strcmp(var, "format.to")) {
508
+ if (!value)
509
+ return config_error_nonbool(var);
510
+ ALLOC_GROW(extra_to, extra_to_nr + 1, extra_to_alloc);
511
+ extra_to[extra_to_nr++] = xstrdup(value);
512
+ return 0;
513
+ }
514
if (!strcmp(var, "format.cc")) {
515
if (!value)
516
return config_error_nonbool(var);
@@ -875,6 +882,13 @@ static int header_callback(const struct option *opt, const char *arg, int unset)
882
return 0;
883
}
884
885
+static int to_callback(const struct option *opt, const char *arg, int unset)
886
+{
887
+ ALLOC_GROW(extra_to, extra_to_nr + 1, extra_to_alloc);
888
+ extra_to[extra_to_nr++] = xstrdup(arg);
889
+ return 0;
890
+}
891
+
892
static int cc_callback(const struct option *opt, const char *arg, int unset)
893
{
894
ALLOC_GROW(extra_cc, extra_cc_nr + 1, extra_cc_alloc);
@@ -939,6 +953,8 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
953
{ OPTION_CALLBACK, 0, "add-header", NULL, "header",
954
"add email header", PARSE_OPT_NONEG,
955
header_callback },
956
+ { OPTION_CALLBACK, 0, "to", NULL, "email", "add To: header",
957
+ PARSE_OPT_NONEG, to_callback },
958
{ OPTION_CALLBACK, 0, "cc", NULL, "email", "add Cc: header",
959
PARSE_OPT_NONEG, cc_callback },
960
OPT_STRING(0, "in-reply-to", &in_reply_to, "message-id",
t/t4014-format-patch.sh
+14
@@ -143,6 +143,20 @@ test_expect_success 'configuration headers and command line headers' '
143
grep "^ *S. E. Cipient <scipient@example.com>\$" patch7
144
'
145
146
+test_expect_success 'command line To: header' '
147
+
148
+ git config --unset-all format.headers &&
149
+ git format-patch --to="R. E. Cipient <rcipient@example.com>" --stdout master..side | sed -e "/^\$/q" >patch8 &&
150
+ grep "^To: R. E. Cipient <rcipient@example.com>\$" patch8
151
+'
152
+
153
+test_expect_success 'configuration To: header' '
154
+
155
+ git config format.to "R. E. Cipient <rcipient@example.com>" &&
156
+ git format-patch --stdout master..side | sed -e "/^\$/q" >patch9 &&
157
+ grep "^To: R. E. Cipient <rcipient@example.com>\$" patch9
158
+'
159
+
160
test_expect_success 'multiple files' '
161
162
rm -rf patches/ &&