Skip to content

Commit 341a196

Browse files
committed
Merge branch 'jc/fmt-merge-msg-suppress-destination' into master
"git merge" learned to selectively omit " into <branch>" at the end of the title of default merge message with merge.suppressDest configuration. * jc/fmt-merge-msg-suppress-destination: fmt-merge-msg: allow merge destination to be omitted again Revert "fmt-merge-msg: stop treating `master` specially"
2 parents e8ab941 + 6e6029a commit 341a196

30 files changed

+159
-94
lines changed

Documentation/config/fmt-merge-msg.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,15 @@ merge.log::
88
most the specified number of one-line descriptions from the
99
actual commits that are being merged. Defaults to false, and
1010
true is a synonym for 20.
11+
12+
merge.suppressDest::
13+
By adding a glob that matches the names of integration
14+
branches to this multi-valued configuration variable, the
15+
default merge message computed for merges into these
16+
integration branches will omit " into <branch name>" from
17+
its title.
18+
+
19+
An element with an empty value can be used to clear the list
20+
of globs accumulated from previous configuration entries.
21+
When there is no `merge.suppressDest` variable defined, the
22+
default value of `master` is used for backward compatibility.

fmt-merge-msg.c

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
#include "commit-reach.h"
1111

1212
static int use_branch_desc;
13+
static int suppress_dest_pattern_seen;
14+
static struct string_list suppress_dest_patterns = STRING_LIST_INIT_DUP;
1315

1416
int fmt_merge_msg_config(const char *key, const char *value, void *cb)
1517
{
@@ -22,6 +24,14 @@ int fmt_merge_msg_config(const char *key, const char *value, void *cb)
2224
merge_log_config = DEFAULT_MERGE_LOG_LEN;
2325
} else if (!strcmp(key, "merge.branchdesc")) {
2426
use_branch_desc = git_config_bool(key, value);
27+
} else if (!strcmp(key, "merge.suppressdest")) {
28+
if (!value)
29+
return config_error_nonbool(key);
30+
if (!*value)
31+
string_list_clear(&suppress_dest_patterns, 0);
32+
else
33+
string_list_append(&suppress_dest_patterns, value);
34+
suppress_dest_pattern_seen = 1;
2535
} else {
2636
return git_default_config(key, value, cb);
2737
}
@@ -403,6 +413,24 @@ static void shortlog(const char *name,
403413
string_list_clear(&subjects, 0);
404414
}
405415

416+
/*
417+
* See if dest_branch matches with any glob pattern on the
418+
* suppress_dest_patterns list.
419+
*
420+
* We may want to also allow negative matches e.g. ":!glob" like we do
421+
* for pathspec, but for now, let's keep it simple and stupid.
422+
*/
423+
static int dest_suppressed(const char *dest_branch)
424+
{
425+
struct string_list_item *item;
426+
427+
for_each_string_list_item(item, &suppress_dest_patterns) {
428+
if (!wildmatch(item->string, dest_branch, WM_PATHNAME))
429+
return 1;
430+
}
431+
return 0;
432+
}
433+
406434
static void fmt_merge_msg_title(struct strbuf *out,
407435
const char *current_branch)
408436
{
@@ -451,7 +479,9 @@ static void fmt_merge_msg_title(struct strbuf *out,
451479
strbuf_addf(out, " of %s", srcs.items[i].string);
452480
}
453481

454-
strbuf_addf(out, " into %s\n", current_branch);
482+
if (!dest_suppressed(current_branch))
483+
strbuf_addf(out, " into %s", current_branch);
484+
strbuf_addch(out, '\n');
455485
}
456486

457487
static void fmt_tag_signature(struct strbuf *tagbuf,
@@ -596,6 +626,9 @@ int fmt_merge_msg(struct strbuf *in, struct strbuf *out,
596626
void *current_branch_to_free;
597627
struct merge_parents merge_parents;
598628

629+
if (!suppress_dest_pattern_seen)
630+
string_list_append(&suppress_dest_patterns, "master");
631+
599632
memset(&merge_parents, 0, sizeof(merge_parents));
600633

601634
/* get current branch */

t/t1507-rev-parse-upstream.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ test_expect_success 'merge my-side@{u} records the correct name' '
137137
git branch -t new my-side@{u} &&
138138
git merge -s ours new@{u} &&
139139
git show -s --pretty=tformat:%s >actual &&
140-
echo "Merge remote-tracking branch ${SQ}origin/side${SQ} into master" >expect &&
140+
echo "Merge remote-tracking branch ${SQ}origin/side${SQ}" >expect &&
141141
test_cmp expect actual
142142
)
143143
'

t/t4013-diff-various.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,12 +117,12 @@ test_expect_success setup '
117117

118118
: <<\EOF
119119
! [initial] Initial
120-
* [master] Merge branch 'side' into master
120+
* [master] Merge branch 'side'
121121
! [rearrange] Rearranged lines in dir/sub
122122
! [side] Side
123123
----
124124
+ [rearrange] Rearranged lines in dir/sub
125-
- [master] Merge branch 'side' into master
125+
- [master] Merge branch 'side'
126126
* + [side] Side
127127
* [master^] Third
128128
* [master~2] Second

t/t4013/diff.log_--decorate=full_--all

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ Merge: 9a6d494 c7a2ab9
3131
Author: A U Thor <[email protected]>
3232
Date: Mon Jun 26 00:04:00 2006 +0000
3333

34-
Merge branch 'side' into master
34+
Merge branch 'side'
3535

3636
commit c7a2ab9e8eac7b117442a607d5a9b3950ae34d5a (refs/heads/side)
3737
Author: A U Thor <[email protected]>

t/t4013/diff.log_--decorate_--all

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ Merge: 9a6d494 c7a2ab9
3131
Author: A U Thor <[email protected]>
3232
Date: Mon Jun 26 00:04:00 2006 +0000
3333

34-
Merge branch 'side' into master
34+
Merge branch 'side'
3535

3636
commit c7a2ab9e8eac7b117442a607d5a9b3950ae34d5a (side)
3737
Author: A U Thor <[email protected]>

t/t4013/diff.log_--patch-with-stat_--summary_master_--_dir_

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Merge: 9a6d494 c7a2ab9
44
Author: A U Thor <[email protected]>
55
Date: Mon Jun 26 00:04:00 2006 +0000
66

7-
Merge branch 'side' into master
7+
Merge branch 'side'
88

99
commit c7a2ab9e8eac7b117442a607d5a9b3950ae34d5a
1010
Author: A U Thor <[email protected]>

t/t4013/diff.log_--patch-with-stat_master

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Merge: 9a6d494 c7a2ab9
44
Author: A U Thor <[email protected]>
55
Date: Mon Jun 26 00:04:00 2006 +0000
66

7-
Merge branch 'side' into master
7+
Merge branch 'side'
88

99
commit c7a2ab9e8eac7b117442a607d5a9b3950ae34d5a
1010
Author: A U Thor <[email protected]>

t/t4013/diff.log_--patch-with-stat_master_--_dir_

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Merge: 9a6d494 c7a2ab9
44
Author: A U Thor <[email protected]>
55
Date: Mon Jun 26 00:04:00 2006 +0000
66

7-
Merge branch 'side' into master
7+
Merge branch 'side'
88

99
commit c7a2ab9e8eac7b117442a607d5a9b3950ae34d5a
1010
Author: A U Thor <[email protected]>

t/t4013/diff.log_--root_--cc_--patch-with-stat_--summary_master

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Merge: 9a6d494 c7a2ab9
44
Author: A U Thor <[email protected]>
55
Date: Mon Jun 26 00:04:00 2006 +0000
66

7-
Merge branch 'side' into master
7+
Merge branch 'side'
88

99
dir/sub | 2 ++
1010
file0 | 3 +++

t/t4013/diff.log_--root_--patch-with-stat_--summary_master

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Merge: 9a6d494 c7a2ab9
44
Author: A U Thor <[email protected]>
55
Date: Mon Jun 26 00:04:00 2006 +0000
66

7-
Merge branch 'side' into master
7+
Merge branch 'side'
88

99
commit c7a2ab9e8eac7b117442a607d5a9b3950ae34d5a
1010
Author: A U Thor <[email protected]>

t/t4013/diff.log_--root_--patch-with-stat_master

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Merge: 9a6d494 c7a2ab9
44
Author: A U Thor <[email protected]>
55
Date: Mon Jun 26 00:04:00 2006 +0000
66

7-
Merge branch 'side' into master
7+
Merge branch 'side'
88

99
commit c7a2ab9e8eac7b117442a607d5a9b3950ae34d5a
1010
Author: A U Thor <[email protected]>

t/t4013/diff.log_--root_-c_--patch-with-stat_--summary_master

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Merge: 9a6d494 c7a2ab9
44
Author: A U Thor <[email protected]>
55
Date: Mon Jun 26 00:04:00 2006 +0000
66

7-
Merge branch 'side' into master
7+
Merge branch 'side'
88

99
dir/sub | 2 ++
1010
file0 | 3 +++

t/t4013/diff.log_--root_-p_master

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Merge: 9a6d494 c7a2ab9
44
Author: A U Thor <[email protected]>
55
Date: Mon Jun 26 00:04:00 2006 +0000
66

7-
Merge branch 'side' into master
7+
Merge branch 'side'
88

99
commit c7a2ab9e8eac7b117442a607d5a9b3950ae34d5a
1010
Author: A U Thor <[email protected]>

t/t4013/diff.log_--root_master

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Merge: 9a6d494 c7a2ab9
44
Author: A U Thor <[email protected]>
55
Date: Mon Jun 26 00:04:00 2006 +0000
66

7-
Merge branch 'side' into master
7+
Merge branch 'side'
88

99
commit c7a2ab9e8eac7b117442a607d5a9b3950ae34d5a
1010
Author: A U Thor <[email protected]>

t/t4013/diff.log_-m_-p_--first-parent_master

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Merge: 9a6d494 c7a2ab9
44
Author: A U Thor <[email protected]>
55
Date: Mon Jun 26 00:04:00 2006 +0000
66

7-
Merge branch 'side' into master
7+
Merge branch 'side'
88

99
diff --git a/dir/sub b/dir/sub
1010
index cead32e..992913c 100644

t/t4013/diff.log_-m_-p_master

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Merge: 9a6d494 c7a2ab9
44
Author: A U Thor <[email protected]>
55
Date: Mon Jun 26 00:04:00 2006 +0000
66

7-
Merge branch 'side' into master
7+
Merge branch 'side'
88

99
diff --git a/dir/sub b/dir/sub
1010
index cead32e..992913c 100644
@@ -33,7 +33,7 @@ Merge: 9a6d494 c7a2ab9
3333
Author: A U Thor <[email protected]>
3434
Date: Mon Jun 26 00:04:00 2006 +0000
3535

36-
Merge branch 'side' into master
36+
Merge branch 'side'
3737

3838
diff --git a/dir/sub b/dir/sub
3939
index 7289e35..992913c 100644

t/t4013/diff.log_-p_--first-parent_master

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Merge: 9a6d494 c7a2ab9
44
Author: A U Thor <[email protected]>
55
Date: Mon Jun 26 00:04:00 2006 +0000
66

7-
Merge branch 'side' into master
7+
Merge branch 'side'
88

99
commit 9a6d4949b6b76956d9d5e26f2791ec2ceff5fdc0
1010
Author: A U Thor <[email protected]>

t/t4013/diff.log_-p_master

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Merge: 9a6d494 c7a2ab9
44
Author: A U Thor <[email protected]>
55
Date: Mon Jun 26 00:04:00 2006 +0000
66

7-
Merge branch 'side' into master
7+
Merge branch 'side'
88

99
commit c7a2ab9e8eac7b117442a607d5a9b3950ae34d5a
1010
Author: A U Thor <[email protected]>

t/t4013/diff.log_master

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Merge: 9a6d494 c7a2ab9
44
Author: A U Thor <[email protected]>
55
Date: Mon Jun 26 00:04:00 2006 +0000
66

7-
Merge branch 'side' into master
7+
Merge branch 'side'
88

99
commit c7a2ab9e8eac7b117442a607d5a9b3950ae34d5a
1010
Author: A U Thor <[email protected]>

t/t4013/diff.show_--first-parent_master

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Merge: 9a6d494 c7a2ab9
44
Author: A U Thor <[email protected]>
55
Date: Mon Jun 26 00:04:00 2006 +0000
66

7-
Merge branch 'side' into master
7+
Merge branch 'side'
88

99
diff --git a/dir/sub b/dir/sub
1010
index cead32e..992913c 100644

t/t4013/diff.show_-c_master

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Merge: 9a6d494 c7a2ab9
44
Author: A U Thor <[email protected]>
55
Date: Mon Jun 26 00:04:00 2006 +0000
66

7-
Merge branch 'side' into master
7+
Merge branch 'side'
88

99
diff --combined dir/sub
1010
index cead32e,7289e35..992913c

t/t4013/diff.show_-m_master

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Merge: 9a6d494 c7a2ab9
44
Author: A U Thor <[email protected]>
55
Date: Mon Jun 26 00:04:00 2006 +0000
66

7-
Merge branch 'side' into master
7+
Merge branch 'side'
88

99
diff --git a/dir/sub b/dir/sub
1010
index cead32e..992913c 100644
@@ -33,7 +33,7 @@ Merge: 9a6d494 c7a2ab9
3333
Author: A U Thor <[email protected]>
3434
Date: Mon Jun 26 00:04:00 2006 +0000
3535

36-
Merge branch 'side' into master
36+
Merge branch 'side'
3737

3838
diff --git a/dir/sub b/dir/sub
3939
index 7289e35..992913c 100644

t/t4013/diff.show_master

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Merge: 9a6d494 c7a2ab9
44
Author: A U Thor <[email protected]>
55
Date: Mon Jun 26 00:04:00 2006 +0000
66

7-
Merge branch 'side' into master
7+
Merge branch 'side'
88

99
diff --cc dir/sub
1010
index cead32e,7289e35..992913c

t/t4013/diff.whatchanged_--root_--cc_--patch-with-stat_--summary_master

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Merge: 9a6d494 c7a2ab9
44
Author: A U Thor <[email protected]>
55
Date: Mon Jun 26 00:04:00 2006 +0000
66

7-
Merge branch 'side' into master
7+
Merge branch 'side'
88

99
dir/sub | 2 ++
1010
file0 | 3 +++

t/t4013/diff.whatchanged_--root_-c_--patch-with-stat_--summary_master

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Merge: 9a6d494 c7a2ab9
44
Author: A U Thor <[email protected]>
55
Date: Mon Jun 26 00:04:00 2006 +0000
66

7-
Merge branch 'side' into master
7+
Merge branch 'side'
88

99
dir/sub | 2 ++
1010
file0 | 3 +++

0 commit comments

Comments
 (0)