2 * test-revision-walking.c: test revision walking API.
4 * (C) 2012 Heiko Voigt <hvoigt@hvoigt.net>
6 * This code is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
16 static void print_commit(struct commit *commit)
18 struct strbuf sb = STRBUF_INIT;
19 struct pretty_print_context ctx = {0};
20 ctx.date_mode.type = DATE_NORMAL;
21 format_commit_message(commit, " %m %s", &sb, &ctx);
22 printf("%s\n", sb.buf);
26 static int run_revision_walk(void)
29 struct commit *commit;
30 const char *argv[] = {NULL, "--all", NULL};
31 int argc = ARRAY_SIZE(argv) - 1;
34 init_revisions(&rev, NULL);
35 setup_revisions(argc, argv, &rev, NULL);
36 if (prepare_revision_walk(&rev))
37 die("revision walk setup failed");
39 while ((commit = get_revision(&rev)) != NULL) {
44 reset_revision_walk();
48 int main(int argc, char **argv)
53 setup_git_directory();
55 if (!strcmp(argv[1], "run-twice")) {
57 if (!run_revision_walk())
60 if (!run_revision_walk())
66 fprintf(stderr, "check usage\n");