*/
#include "builtin.h"
+ #include "trace.h"
int cmd_walken(int argc, const char **argv, const char *prefix)
{
}
----
- NOTE: `trace_printf()` differs from `printf()` in that it can be turned on or
- off at runtime. For the purposes of this tutorial, we will write `walken` as
- though it is intended for use as a "plumbing" command: that is, a command which
- is used primarily in scripts, rather than interactively by humans (a "porcelain"
- command). So we will send our debug output to `trace_printf()` instead. When
- running, enable trace output by setting the environment variable `GIT_TRACE`.
+ NOTE: `trace_printf()`, defined in `trace.h`, differs from `printf()` in
+ that it can be turned on or off at runtime. For the purposes of this
+ tutorial, we will write `walken` as though it is intended for use as
+ a "plumbing" command: that is, a command which is used primarily in
+ scripts, rather than interactively by humans (a "porcelain" command).
+ So we will send our debug output to `trace_printf()` instead.
+ When running, enable trace output by setting the environment variable `GIT_TRACE`.
Add usage text and `-h` handling, like all subcommands should consistently do
(our test suite will notice and complain if you fail to do so).
`nr` represents the number of `rev_cmdline_entry` present in the array.
-`alloc` is used by the `ALLOC_GROW` macro. Check `cache.h` - this variable is
+`alloc` is used by the `ALLOC_GROW` macro. Check `alloc.h` - this variable is
used to track the allocated size of the list.
Per entry, we find:
`walken_commit_walk()`:
----
+ #include "pretty.h"
+
+ ...
+
static void walken_commit_walk(struct rev_info *rev)
{
struct commit *commit;
First, add the `struct oidset` and related items we will use to iterate it:
----
+ #include "oidset.h"
+
+ ...
+
static void walken_object_walk(
...
go:
----
+ #include "hex.h"
+
+ ...
+
static void walken_show_commit(struct commit *cmt, void *buf)
{
trace_printf("commit: %s\n", oid_to_hex(&cmt->object.oid));