fmt-merge-msg: use pretty.c routines
This command duplicates functionality of the '%s' pretty format. Simplify the code a bit by using the pretty printing routine instead of open-coding it here. Signed-off-by: Stephen Boyd <bebarino@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
6d6f6e68c3
commit
15cb500786
@ -185,6 +185,7 @@ static void shortlog(const char *name, unsigned char *sha1,
|
|||||||
struct object *branch;
|
struct object *branch;
|
||||||
struct list subjects = { NULL, NULL, 0, 0 };
|
struct list subjects = { NULL, NULL, 0, 0 };
|
||||||
int flags = UNINTERESTING | TREESAME | SEEN | SHOWN | ADDED;
|
int flags = UNINTERESTING | TREESAME | SEEN | SHOWN | ADDED;
|
||||||
|
struct strbuf sb = STRBUF_INIT;
|
||||||
|
|
||||||
branch = deref_tag(parse_object(sha1), sha1_to_hex(sha1), 40);
|
branch = deref_tag(parse_object(sha1), sha1_to_hex(sha1), 40);
|
||||||
if (!branch || branch->type != OBJ_COMMIT)
|
if (!branch || branch->type != OBJ_COMMIT)
|
||||||
@ -198,7 +199,7 @@ static void shortlog(const char *name, unsigned char *sha1,
|
|||||||
if (prepare_revision_walk(rev))
|
if (prepare_revision_walk(rev))
|
||||||
die("revision walk setup failed");
|
die("revision walk setup failed");
|
||||||
while ((commit = get_revision(rev)) != NULL) {
|
while ((commit = get_revision(rev)) != NULL) {
|
||||||
char *oneline, *bol, *eol;
|
struct pretty_print_context ctx = {0};
|
||||||
|
|
||||||
/* ignore merges */
|
/* ignore merges */
|
||||||
if (commit->parents && commit->parents->next)
|
if (commit->parents && commit->parents->next)
|
||||||
@ -208,30 +209,16 @@ static void shortlog(const char *name, unsigned char *sha1,
|
|||||||
if (subjects.nr > limit)
|
if (subjects.nr > limit)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
bol = strstr(commit->buffer, "\n\n");
|
format_commit_message(commit, "%s", &sb, &ctx);
|
||||||
if (bol) {
|
strbuf_ltrim(&sb);
|
||||||
unsigned char c;
|
|
||||||
do {
|
|
||||||
c = *++bol;
|
|
||||||
} while (isspace(c));
|
|
||||||
if (!c)
|
|
||||||
bol = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!bol) {
|
if (!sb.len)
|
||||||
append_to_list(&subjects, xstrdup(sha1_to_hex(
|
append_to_list(&subjects, xstrdup(sha1_to_hex(
|
||||||
commit->object.sha1)),
|
commit->object.sha1)),
|
||||||
NULL);
|
NULL);
|
||||||
continue;
|
else
|
||||||
}
|
append_to_list(&subjects, strbuf_detach(&sb, NULL),
|
||||||
|
NULL);
|
||||||
eol = strchr(bol, '\n');
|
|
||||||
if (eol) {
|
|
||||||
oneline = xmemdupz(bol, eol - bol);
|
|
||||||
} else {
|
|
||||||
oneline = xstrdup(bol);
|
|
||||||
}
|
|
||||||
append_to_list(&subjects, oneline, NULL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count > limit)
|
if (count > limit)
|
||||||
|
Loading…
Reference in New Issue
Block a user