Skip to content

Commit 73ccb91

Browse files
committed
Merge branch 'ae/maint-mailinfo-rm-only-one-patch-marker'
* ae/maint-mailinfo-rm-only-one-patch-marker: mailinfo: Remove only one set of square brackets
2 parents 6edd149 + 650d30d commit 73ccb91

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

builtin-mailinfo.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,8 @@ static void cleanup_subject(struct strbuf *subject)
221221
{
222222
char *pos;
223223
size_t remove;
224+
int brackets_removed = 0;
225+
224226
while (subject->len) {
225227
switch (*subject->buf) {
226228
case 'r': case 'R':
@@ -235,10 +237,15 @@ static void cleanup_subject(struct strbuf *subject)
235237
strbuf_remove(subject, 0, 1);
236238
continue;
237239
case '[':
240+
/* remove only one set of square brackets */
241+
if (brackets_removed)
242+
break;
243+
238244
if ((pos = strchr(subject->buf, ']'))) {
239245
remove = pos - subject->buf;
240246
if (remove <= (subject->len - remove) * 2) {
241247
strbuf_remove(subject, 0, remove + 1);
248+
brackets_removed = 1;
242249
continue;
243250
}
244251
} else

t/t5100/info0012

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Author: Dmitriy Blinov
22
3-
Subject: Изменён список пакетов необходимых для сборки
3+
Subject: [Navy-patches] Изменён список пакетов необходимых для сборки
44
Date: Wed, 12 Nov 2008 17:54:41 +0300
55

t/t5100/sample.mbox

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,7 @@ MIME-Version: 1.0
514514
Content-Type: text/plain;
515515
charset=utf-8
516516
Content-Transfer-Encoding: 8bit
517-
Subject: [Navy-patches] [PATCH]
517+
Subject: [PATCH] [Navy-patches]
518518
=?utf-8?b?0JjQt9C80LXQvdGR0L0g0YHQv9C40YHQvtC6INC/0LA=?=
519519
=?utf-8?b?0LrQtdGC0L7QsiDQvdC10L7QsdGF0L7QtNC40LzRi9GFINC00LvRjyA=?=
520520
=?utf-8?b?0YHQsdC+0YDQutC4?=

0 commit comments

Comments
 (0)