pretty: split color parsing into a separate function
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
7e77df39bf
commit
fcabc2d91c
29
pretty.c
29
pretty.c
@ -954,19 +954,10 @@ static int format_reflog_person(struct strbuf *sb,
|
||||
return format_person_part(sb, part, ident, strlen(ident), dmode);
|
||||
}
|
||||
|
||||
static size_t format_commit_one(struct strbuf *sb, /* in UTF-8 */
|
||||
static size_t parse_color(struct strbuf *sb, /* in UTF-8 */
|
||||
const char *placeholder,
|
||||
void *context)
|
||||
struct format_commit_context *c)
|
||||
{
|
||||
struct format_commit_context *c = context;
|
||||
const struct commit *commit = c->commit;
|
||||
const char *msg = c->message;
|
||||
struct commit_list *p;
|
||||
int h1, h2;
|
||||
|
||||
/* these are independent of the commit */
|
||||
switch (placeholder[0]) {
|
||||
case 'C':
|
||||
if (placeholder[1] == '(') {
|
||||
const char *begin = placeholder + 2;
|
||||
const char *end = strchr(begin, ')');
|
||||
@ -999,6 +990,22 @@ static size_t format_commit_one(struct strbuf *sb, /* in UTF-8 */
|
||||
return 6;
|
||||
} else
|
||||
return 0;
|
||||
}
|
||||
|
||||
static size_t format_commit_one(struct strbuf *sb, /* in UTF-8 */
|
||||
const char *placeholder,
|
||||
void *context)
|
||||
{
|
||||
struct format_commit_context *c = context;
|
||||
const struct commit *commit = c->commit;
|
||||
const char *msg = c->message;
|
||||
struct commit_list *p;
|
||||
int h1, h2;
|
||||
|
||||
/* these are independent of the commit */
|
||||
switch (placeholder[0]) {
|
||||
case 'C':
|
||||
return parse_color(sb, placeholder, c);
|
||||
case 'n': /* newline */
|
||||
strbuf_addch(sb, '\n');
|
||||
return 1;
|
||||
|
Reference in New Issue
Block a user