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.
11 #include "test-tool.h"
14 #include "repository.h"
18 static void print_commit(struct commit
*commit
)
20 struct strbuf sb
= STRBUF_INIT
;
21 struct pretty_print_context ctx
= {0};
22 ctx
.date_mode
.type
= DATE_NORMAL
;
23 repo_format_commit_message(the_repository
, commit
, " %m %s", &sb
,
25 printf("%s\n", sb
.buf
);
29 static int run_revision_walk(void)
32 struct commit
*commit
;
33 const char *argv
[] = {NULL
, "--all", NULL
};
34 int argc
= ARRAY_SIZE(argv
) - 1;
37 repo_init_revisions(the_repository
, &rev
, NULL
);
38 setup_revisions(argc
, argv
, &rev
, NULL
);
39 if (prepare_revision_walk(&rev
))
40 die("revision walk setup failed");
42 while ((commit
= get_revision(&rev
)) != NULL
) {
47 reset_revision_walk();
48 release_revisions(&rev
);
52 int cmd__revision_walking(int argc
, const char **argv
)
57 setup_git_directory();
59 if (!strcmp(argv
[1], "run-twice")) {
61 if (!run_revision_walk())
64 if (!run_revision_walk())
70 fprintf(stderr
, "check usage\n");