Skip to content

Commit dbd2144

Browse files
arobengitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 05dcd69 commit dbd2144

6 files changed

+76
-3
lines changed

Documentation/git-format-patch.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,12 +126,13 @@ not add any suffix.
126126
CONFIGURATION
127127
-------------
128128
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.
131131

132132
------------
133133
[format]
134134
headers = "Organization: git-foo\n"
135+
subjectprefix = CHANGE
135136
suffix = .txt
136137
------------
137138

builtin-log.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,7 @@ static int istitlechar(char c)
265265

266266
static char *extra_headers = NULL;
267267
static int extra_headers_size = 0;
268+
static const char *fmt_patch_subject_prefix = "PATCH";
268269
static const char *fmt_patch_suffix = ".patch";
269270

270271
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)
290291
if (!strcmp(var, "diff.color") || !strcmp(var, "color.diff")) {
291292
return 0;
292293
}
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+
293301
return git_log_config(var, value);
294302
}
295303

@@ -459,6 +467,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
459467
rev.diffopt.msg_sep = "";
460468
rev.diffopt.recursive = 1;
461469

470+
rev.subject_prefix = fmt_patch_subject_prefix;
462471
rev.extra_headers = extra_headers;
463472

464473
/*

revision.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -667,7 +667,6 @@ void init_revisions(struct rev_info *revs, const char *prefix)
667667
revs->min_age = -1;
668668
revs->skip_count = -1;
669669
revs->max_count = -1;
670-
revs->subject_prefix = "PATCH";
671670

672671
revs->prune_fn = NULL;
673672
revs->prune_data = NULL;

t/t4013-diff-various.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,8 @@ format-patch --inline --stdout initial..side
242242
format-patch --inline --stdout initial..master^
243243
format-patch --inline --stdout initial..master
244244
format-patch --inline --stdout --subject-prefix=TESTCASE initial..master
245+
config format.subjectprefix DIFFERENT_PREFIX
246+
format-patch --inline --stdout initial..master^^
245247
246248
diff --abbrev initial..side
247249
diff -r initial..side
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
$ git config format.subjectprefix DIFFERENT_PREFIX
2+
$
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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 <[email protected]>
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+
$

0 commit comments

Comments
 (0)