예제 #1
0
void shortlog_add_commit(struct shortlog *log, struct commit *commit)
{
    const char *author = NULL, *buffer;

    buffer = commit->buffer;
    while (*buffer && *buffer != '\n') {
        const char *eol = strchr(buffer, '\n');

        if (eol == NULL)
            eol = buffer + strlen(buffer);
        else
            eol++;

        if (!prefixcmp(buffer, "author "))
            author = buffer + 7;
        buffer = eol;
    }
    if (!author)
        die("Missing author: %s",
            sha1_to_hex(commit->object.sha1));
    if (log->user_format) {
        struct strbuf buf = STRBUF_INIT;

        pretty_print_commit(CMIT_FMT_USERFORMAT, commit, &buf,
                            DEFAULT_ABBREV, "", "", DATE_NORMAL, 0);
        insert_one_record(log, author, buf.buf);
        strbuf_release(&buf);
        return;
    }
    if (*buffer)
        buffer++;
    insert_one_record(log, author, !*buffer ? "<none>" : buffer);
}
예제 #2
0
파일: shortlog.c 프로젝트: Nowher2/git
void shortlog_add_commit(struct shortlog *log, struct commit *commit)
{
	struct strbuf author = STRBUF_INIT;
	struct strbuf oneline = STRBUF_INIT;
	struct pretty_print_context ctx = {0};
	const char *fmt;

	ctx.fmt = CMIT_FMT_USERFORMAT;
	ctx.abbrev = log->abbrev;
	ctx.print_email_subject = 1;
	ctx.date_mode.type = DATE_NORMAL;
	ctx.output_encoding = get_log_output_encoding();

	fmt = log->committer ?
		(log->email ? "%cN <%cE>" : "%cN") :
		(log->email ? "%aN <%aE>" : "%aN");

	format_commit_message(commit, fmt, &author, &ctx);
	if (!log->summary) {
		if (log->user_format)
			pretty_print_commit(&ctx, commit, &oneline);
		else
			format_commit_message(commit, "%s", &oneline, &ctx);
	}

	insert_one_record(log, author.buf, oneline.len ? oneline.buf : "<none>");

	strbuf_release(&author);
	strbuf_release(&oneline);
}
예제 #3
0
파일: shortlog.c 프로젝트: Nowher2/git
static void read_from_stdin(struct shortlog *log)
{
	struct strbuf author = STRBUF_INIT;
	struct strbuf mapped_author = STRBUF_INIT;
	struct strbuf oneline = STRBUF_INIT;
	static const char *author_match[2] = { "Author: ", "author " };
	static const char *committer_match[2] = { "Commit: ", "committer " };
	const char **match;

	match = log->committer ? committer_match : author_match;
	while (strbuf_getline_lf(&author, stdin) != EOF) {
		const char *v;
		if (!skip_prefix(author.buf, match[0], &v) &&
		    !skip_prefix(author.buf, match[1], &v))
			continue;
		while (strbuf_getline_lf(&oneline, stdin) != EOF &&
		       oneline.len)
			; /* discard headers */
		while (strbuf_getline_lf(&oneline, stdin) != EOF &&
		       !oneline.len)
			; /* discard blanks */

		strbuf_reset(&mapped_author);
		if (parse_stdin_author(log, &mapped_author, v) < 0)
			continue;

		insert_one_record(log, mapped_author.buf, oneline.buf);
	}
	strbuf_release(&author);
	strbuf_release(&mapped_author);
	strbuf_release(&oneline);
}
예제 #4
0
static void read_from_stdin(struct shortlog *log)
{
    char author[1024], oneline[1024];

    while (fgets(author, sizeof(author), stdin) != NULL) {
        if (!(author[0] == 'A' || author[0] == 'a') ||
                prefixcmp(author + 1, "uthor: "))
            continue;
        while (fgets(oneline, sizeof(oneline), stdin) &&
                oneline[0] != '\n')
            ; /* discard headers */
        while (fgets(oneline, sizeof(oneline), stdin) &&
                oneline[0] == '\n')
            ; /* discard blanks */
        insert_one_record(log, author + 8, oneline);
    }
}
예제 #5
0
파일: shortlog.c 프로젝트: AndSoAway/git
void shortlog_add_commit(struct shortlog *log, struct commit *commit)
{
	const char *author = NULL, *buffer;
	struct strbuf buf = STRBUF_INIT;
	struct strbuf ufbuf = STRBUF_INIT;

	pp_commit_easy(CMIT_FMT_RAW, commit, &buf);
	buffer = buf.buf;
	while (*buffer && *buffer != '\n') {
		const char *eol = strchr(buffer, '\n');

		if (eol == NULL)
			eol = buffer + strlen(buffer);
		else
			eol++;

		if (starts_with(buffer, "author "))
			author = buffer + 7;
		buffer = eol;
	}
	if (!author) {
		warning(_("Missing author: %s"),
		    oid_to_hex(&commit->object.oid));
		return;
	}
	if (log->user_format) {
		struct pretty_print_context ctx = {0};
		ctx.fmt = CMIT_FMT_USERFORMAT;
		ctx.abbrev = log->abbrev;
		ctx.subject = "";
		ctx.after_subject = "";
		ctx.date_mode.type = DATE_NORMAL;
		ctx.output_encoding = get_log_output_encoding();
		pretty_print_commit(&ctx, commit, &ufbuf);
		buffer = ufbuf.buf;
	} else if (*buffer) {
		buffer++;
	}
	insert_one_record(log, author, !*buffer ? "<none>" : buffer);
	strbuf_release(&ufbuf);
	strbuf_release(&buf);
}
예제 #6
0
void shortlog_add_commit(struct shortlog *log, struct commit *commit)
{
	const char *author = NULL, *buffer;
	struct strbuf buf = STRBUF_INIT;
	struct strbuf ufbuf = STRBUF_INIT;
	struct pretty_print_context ctx = {0};

	pretty_print_commit(CMIT_FMT_RAW, commit, &buf, &ctx);
	buffer = buf.buf;
	while (*buffer && *buffer != '\n') {
		const char *eol = strchr(buffer, '\n');

		if (eol == NULL)
			eol = buffer + strlen(buffer);
		else
			eol++;

		if (!prefixcmp(buffer, "author "))
			author = buffer + 7;
		buffer = eol;
	}
	if (!author)
		die("Missing author: %s",
		    sha1_to_hex(commit->object.sha1));
	if (log->user_format) {
		struct pretty_print_context ctx = {0};
		ctx.abbrev = DEFAULT_ABBREV;
		ctx.subject = "";
		ctx.after_subject = "";
		ctx.date_mode = DATE_NORMAL;
		pretty_print_commit(CMIT_FMT_USERFORMAT, commit, &ufbuf, &ctx);
		buffer = ufbuf.buf;
	} else if (*buffer) {
		buffer++;
	}
	insert_one_record(log, author, !*buffer ? "<none>" : buffer);
	strbuf_release(&ufbuf);
	strbuf_release(&buf);
}