@@ -41,6 +41,7 @@ Open up a new file `builtin/walken.c` and set up the command handler:
41
41
*/
42
42
43
43
#include "builtin.h"
44
+ #include "trace.h"
44
45
45
46
int cmd_walken(int argc, const char **argv, const char *prefix)
46
47
{
@@ -49,12 +50,13 @@ int cmd_walken(int argc, const char **argv, const char *prefix)
49
50
}
50
51
----
51
52
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`.
58
60
59
61
Add usage text and `-h` handling, like all subcommands should consistently do
60
62
(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
341
343
`walken_commit_walk()`:
342
344
343
345
----
346
+ #include "pretty.h"
347
+
348
+ ...
349
+
344
350
static void walken_commit_walk(struct rev_info *rev)
345
351
{
346
352
struct commit *commit;
@@ -754,6 +760,10 @@ reachable objects are walked in order to populate the list.
754
760
First, add the `struct oidset` and related items we will use to iterate it:
755
761
756
762
----
763
+ #include "oidset.h"
764
+
765
+ ...
766
+
757
767
static void walken_object_walk(
758
768
...
759
769
@@ -805,6 +815,10 @@ just walks of commits. First, we'll make our handlers chattier - modify
805
815
go:
806
816
807
817
----
818
+ #include "hex.h"
819
+
820
+ ...
821
+
808
822
static void walken_show_commit(struct commit *cmt, void *buf)
809
823
{
810
824
trace_printf("commit: %s\n", oid_to_hex(&cmt->object.oid));
0 commit comments