git@vger.kernel.org list mirror (unofficial, one of many)
 help / color / mirror / code / Atom feed
d693aa1744e7c95e8532f579c346a94e82bf8503 blob 939 bytes (raw)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
 
#include "diff.h"
#include "log-tree.h"
#include "color.h"
#include "format-support.h"

static int istitlechar(char c)
{
	return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') ||
		(c >= '0' && c <= '9') || c == '.' || c == '_';
}

void format_sanitized_subject(struct strbuf *sb, const char *msg, size_t len)
{
	char *r = xmemdupz(msg, len);
	size_t trimlen;
	size_t start_len = sb->len;
	int space = 2;
	int i;

	for (i = 0; i < len; i++) {
		if (r[i] == '\n')
			r[i] = ' ';
		if (istitlechar(r[i])) {
			if (space == 1)
				strbuf_addch(sb, '-');
			space = 0;
			strbuf_addch(sb, r[i]);
			if (r[i] == '.')
				while (r[i+1] == '.')
					i++;
		} else
			space |= 1;
	}
	free(r);

	/* trim any trailing '.' or '-' characters */
	trimlen = 0;
	while (sb->len - trimlen > start_len &&
		(sb->buf[sb->len - 1 - trimlen] == '.'
		|| sb->buf[sb->len - 1 - trimlen] == '-'))
		trimlen++;
	strbuf_remove(sb, sb->len - trimlen, trimlen);
}
debug log:

solving d693aa1744 ...
found d693aa1744 in https://public-inbox.org/git/9dc619b44888024201d9ae1f83a4b34c81fa693f.1595882588.git.gitgitgadget@gmail.com/ ||
	https://public-inbox.org/git/7a64495f99ec97258687695d41d106e3f946d551.1597687822.git.gitgitgadget@gmail.com/ ||
	https://public-inbox.org/git/1c43f55d7c1d5a16031115d5de56b5a5302b5597.1596664306.git.gitgitgadget@gmail.com/

applying [1/3] https://public-inbox.org/git/9dc619b44888024201d9ae1f83a4b34c81fa693f.1595882588.git.gitgitgadget@gmail.com/
diff --git a/format-support.c b/format-support.c
new file mode 100644
index 0000000000..d693aa1744

Checking patch format-support.c...
Applied patch format-support.c cleanly.

skipping https://public-inbox.org/git/7a64495f99ec97258687695d41d106e3f946d551.1597687822.git.gitgitgadget@gmail.com/ for d693aa1744
skipping https://public-inbox.org/git/1c43f55d7c1d5a16031115d5de56b5a5302b5597.1596664306.git.gitgitgadget@gmail.com/ for d693aa1744
index at:
100644 d693aa1744e7c95e8532f579c346a94e82bf8503	format-support.c

Code repositories for project(s) associated with this inbox:

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).