Exemple #1
0
static void
add_pager_refs(struct view *view, const char *commit_id)
{
	char buf[SIZEOF_STR];
	const struct ref *list;
	size_t bufpos = 0;
	const char *sep = "Refs: ";

	list = get_ref_list(commit_id);
	if (!list) {
		if (view_has_flags(view, VIEW_ADD_DESCRIBE_REF) && refs_contain_tag())
			add_line_text(view, sep, LINE_PP_REFS);
		return;
	}

	for (; list; list = list->next) {
		const struct ref *ref = list;
		const struct ref_format *fmt = get_ref_format(opt_reference_format, ref);

		if (!string_format_from(buf, &bufpos, "%s%s%s%s", sep,
					fmt->start, ref->name, fmt->end))
			return;
		sep = ", ";
	}

	if (bufpos == 0)
		return;

	add_line_text(view, buf, LINE_PP_REFS);
}
Exemple #2
0
static bool
draw_refs(struct view *view, struct view_column *column, const struct ref_list *refs)
{
	size_t i;

	if (!column->opt.commit_title.refs || !refs)
		return FALSE;

	for (i = 0; i < refs->size; i++) {
		struct ref *ref = refs->refs[i];
		enum line_type type = get_line_type_from_ref(ref);
		const struct ref_format *format = get_ref_format(ref);

		if (draw_formatted(view, type, "%s%s%s", format->start, ref->name, format->end))
			return TRUE;

		if (draw_text(view, LINE_DEFAULT, " "))
			return TRUE;
	}

	return FALSE;
}
Exemple #3
0
static bool
draw_refs(struct view *view, struct view_column *column, const struct ref *refs)
{
	if (!column->opt.commit_title.refs || !refs)
		return false;

	for (; refs; refs = refs->next) {
		const struct ref *ref = refs;
		enum line_type type = get_line_type_from_ref(ref);
		const struct ref_format *format = get_ref_format(opt_reference_format, ref);

		if (!strcmp(format->start, "hide:") && !*format->end)
			continue;

		if (draw_formatted(view, type, "%s%s%s", format->start, ref->name, format->end))
			return true;

		if (draw_text(view, LINE_DEFAULT, " "))
			return true;
	}

	return false;
}