コード例 #1
0
ファイル: ui-stats.c プロジェクト: 5victor/cgit
/* Walk the commit DAG and collect number of commits per author per
 * timeperiod into a nested string_list collection.
 */
struct string_list collect_stats(struct cgit_context *ctx,
	struct cgit_period *period)
{
	struct string_list authors;
	struct rev_info rev;
	struct commit *commit;
	const char *argv[] = {NULL, ctx->qry.head, NULL, NULL, NULL, NULL};
	int argc = 3;
	time_t now;
	long i;
	struct tm *tm;
	char tmp[11];

	time(&now);
	tm = gmtime(&now);
	period->trunc(tm);
	for (i = 1; i < period->count; i++)
		period->dec(tm);
	strftime(tmp, sizeof(tmp), "%Y-%m-%d", tm);
	argv[2] = xstrdup(fmt("--since=%s", tmp));
	if (ctx->qry.path) {
		argv[3] = "--";
		argv[4] = ctx->qry.path;
		argc += 2;
	}
	init_revisions(&rev, NULL);
	rev.abbrev = DEFAULT_ABBREV;
	rev.commit_format = CMIT_FMT_DEFAULT;
	rev.max_parents = 1;
	rev.verbose_header = 1;
	rev.show_root_diff = 0;
	setup_revisions(argc, argv, &rev, NULL);
	prepare_revision_walk(&rev);
	memset(&authors, 0, sizeof(authors));
	while ((commit = get_revision(&rev)) != NULL) {
		add_commit(&authors, commit, period);
		free(commit->buffer);
		free_commit_list(commit->parents);
	}
	return authors;
}
コード例 #2
0
ファイル: parsemeta.c プロジェクト: hhirsch/netrek
static int add_key(W_Event *data)
{
  if (data->key == '\r') {
    add_commit();
    add_init();
    add_redraw();
  } else if (data->key == 21) {
    add_init();
    add_redraw();
  } else if (data->key == 8 || data->key == '\177') {
    if (add_offset > 0) {
      add_buffer[add_offset-1] = '\0';
      add_offset--;
      add_redraw();
    }
  } else if (add_offset < (LINE-1)) {
    add_buffer[add_offset+1] = '\0';
    add_buffer[add_offset] = data->key;
    add_offset++;
    add_redraw();
  }
  return 0;
}