@matheusbsbs / matheus-bagliano / commits / dbd2144736
Fork 0

format-patch: Add format.subjectprefix config option

This change lets you use the format.subjectprefix config option to override the default subject prefix. Signed-off-by: Adam Roben <aroben@apple.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Adam Roben committed Jul 1, 2007 at 17:48 UTC dbd21447361364d646f3972738a475a92f711513
6 files changed +76 -3
Documentation/git-format-patch.txt
+3 -2
@@ -126,12 +126,13 @@ not add any suffix.
126 CONFIGURATION
127 -------------
128 You can specify extra mail header lines to be added to each
129 -message in the repository configuration. Also you can specify
130 -the default suffix different from the built-in one:
129 +message in the repository configuration. You can also specify
130 +new defaults for the subject prefix and file suffix.
131
132 ------------
133 [format]
134 headers = "Organization: git-foo\n"
135 + subjectprefix = CHANGE
136 suffix = .txt
137 ------------
138
builtin-log.c
+9
@@ -265,6 +265,7 @@ static int istitlechar(char c)
265
266 static char *extra_headers = NULL;
267 static int extra_headers_size = 0;
268 +static const char *fmt_patch_subject_prefix = "PATCH";
269 static const char *fmt_patch_suffix = ".patch";
270
271 static int git_format_config(const char *var, const char *value)
@@ -290,6 +291,13 @@ static int git_format_config(const char *var, const char *value)
291 if (!strcmp(var, "diff.color") || !strcmp(var, "color.diff")) {
292 return 0;
293 }
294 + if (!strcmp(var, "format.subjectprefix")) {
295 + if (!value)
296 + die("format.subjectprefix without value");
297 + fmt_patch_subject_prefix = xstrdup(value);
298 + return 0;
299 + }
300 +
301 return git_log_config(var, value);
302 }
303
@@ -459,6 +467,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
467 rev.diffopt.msg_sep = "";
468 rev.diffopt.recursive = 1;
469
470 + rev.subject_prefix = fmt_patch_subject_prefix;
471 rev.extra_headers = extra_headers;
472
473 /*
revision.c
-1
@@ -667,7 +667,6 @@ void init_revisions(struct rev_info *revs, const char *prefix)
667 revs->min_age = -1;
668 revs->skip_count = -1;
669 revs->max_count = -1;
670 - revs->subject_prefix = "PATCH";
670
671 revs->prune_fn = NULL;
672 revs->prune_data = NULL;
t/t4013-diff-various.sh
+2
@@ -242,6 +242,8 @@ format-patch --inline --stdout initial..side
242 format-patch --inline --stdout initial..master^
243 format-patch --inline --stdout initial..master
244 format-patch --inline --stdout --subject-prefix=TESTCASE initial..master
245 +config format.subjectprefix DIFFERENT_PREFIX
246 +format-patch --inline --stdout initial..master^^
247
248 diff --abbrev initial..side
249 diff -r initial..side
t/t4013/diff.config_format.subjectprefix_DIFFERENT_PREFIX new
+2
@@ -0,0 +1,2 @@
1 +$ git config format.subjectprefix DIFFERENT_PREFIX
2 +$
t/t4013/diff.format-patch_--inline_--stdout_initial..master^^ new
+60
@@ -0,0 +1,60 @@
1 +$ git format-patch --inline --stdout initial..master^^
2 +From 1bde4ae5f36c8d9abe3a0fce0c6aab3c4a12fe44 Mon Sep 17 00:00:00 2001
3 +From: A U Thor <author@example.com>
4 +Date: Mon, 26 Jun 2006 00:01:00 +0000
5 +Subject: [DIFFERENT_PREFIX] Second
6 +MIME-Version: 1.0
7 +Content-Type: multipart/mixed; boundary="------------g-i-t--v-e-r-s-i-o-n"
8 +
9 +This is a multi-part message in MIME format.
10 +--------------g-i-t--v-e-r-s-i-o-n
11 +Content-Type: text/plain; charset=UTF-8; format=fixed
12 +Content-Transfer-Encoding: 8bit
13 +
14 +
15 +This is the second commit.
16 +---
17 + dir/sub | 2 ++
18 + file0 | 3 +++
19 + file2 | 3 ---
20 + 3 files changed, 5 insertions(+), 3 deletions(-)
21 + delete mode 100644 file2
22 +--------------g-i-t--v-e-r-s-i-o-n
23 +Content-Type: text/x-patch; name="1bde4ae5f36c8d9abe3a0fce0c6aab3c4a12fe44.diff"
24 +Content-Transfer-Encoding: 8bit
25 +Content-Disposition: inline; filename="1bde4ae5f36c8d9abe3a0fce0c6aab3c4a12fe44.diff"
26 +
27 +diff --git a/dir/sub b/dir/sub
28 +index 35d242b..8422d40 100644
29 +--- a/dir/sub
30 ++++ b/dir/sub
31 +@@ -1,2 +1,4 @@
32 + A
33 + B
34 ++C
35 ++D
36 +diff --git a/file0 b/file0
37 +index 01e79c3..b414108 100644
38 +--- a/file0
39 ++++ b/file0
40 +@@ -1,3 +1,6 @@
41 + 1
42 + 2
43 + 3
44 ++4
45 ++5
46 ++6
47 +diff --git a/file2 b/file2
48 +deleted file mode 100644
49 +index 01e79c3..0000000
50 +--- a/file2
51 ++++ /dev/null
52 +@@ -1,3 +0,0 @@
53 +-1
54 +-2
55 +-3
56 +
57 +--------------g-i-t--v-e-r-s-i-o-n--
58 +
59 +
60 +$