@@ -41,6 +41,7 @@ Open up a new file `builtin/walken.c` and set up the command handler:
4141 */
4242
4343#include "builtin.h"
44+ #include "trace.h"
4445
4546int cmd_walken(int argc, const char **argv, const char *prefix)
4647{
@@ -49,12 +50,13 @@ int cmd_walken(int argc, const char **argv, const char *prefix)
4950}
5051----
5152
52- NOTE: `trace_printf()` differs from `printf()` in that it can be turned on or
53- off at runtime. For the purposes of this tutorial, we will write `walken` as
54- though it is intended for use as a "plumbing" command: that is, a command which
55- is used primarily in scripts, rather than interactively by humans (a "porcelain"
56- command). So we will send our debug output to `trace_printf()` instead. When
57- running, enable trace output by setting the environment variable `GIT_TRACE`.
53+ NOTE: `trace_printf()`, defined in `trace.h`, differs from `printf()` in
54+ that it can be turned on or off at runtime. For the purposes of this
55+ tutorial, we will write `walken` as though it is intended for use as
56+ a "plumbing" command: that is, a command which is used primarily in
57+ scripts, rather than interactively by humans (a "porcelain" command).
58+ So we will send our debug output to `trace_printf()` instead.
59+ When running, enable trace output by setting the environment variable `GIT_TRACE`.
5860
5961Add usage text and `-h` handling, like all subcommands should consistently do
6062(our test suite will notice and complain if you fail to do so).
@@ -341,6 +343,10 @@ the walk loop below the `prepare_revision_walk()` call within your
341343`walken_commit_walk()`:
342344
343345----
346+ #include "pretty.h"
347+
348+ ...
349+
344350static void walken_commit_walk(struct rev_info *rev)
345351{
346352 struct commit *commit;
@@ -754,6 +760,10 @@ reachable objects are walked in order to populate the list.
754760First, add the `struct oidset` and related items we will use to iterate it:
755761
756762----
763+ #include "oidset.h"
764+
765+ ...
766+
757767static void walken_object_walk(
758768 ...
759769
@@ -805,6 +815,10 @@ just walks of commits. First, we'll make our handlers chattier - modify
805815go:
806816
807817----
818+ #include "hex.h"
819+
820+ ...
821+
808822static void walken_show_commit(struct commit *cmt, void *buf)
809823{
810824 trace_printf("commit: %s\n", oid_to_hex(&cmt->object.oid));
0 commit comments