Merge branch 'vd/adjust-mfow-doc-to-updated-headers'

Code snippets in a tutorial document no longer compiled after
recent header shuffling, which have been corrected.

* vd/adjust-mfow-doc-to-updated-headers:
  docs: add necessary headers to Documentation/MFOW.txt
maint
Junio C Hamano 2023-07-17 11:30:42 -07:00
commit d5bb430ec6
1 changed files with 20 additions and 6 deletions

View File

@ -41,6 +41,7 @@ Open up a new file `builtin/walken.c` and set up the command handler:
*/ */


#include "builtin.h" #include "builtin.h"
#include "trace.h"


int cmd_walken(int argc, const char **argv, const char *prefix) int cmd_walken(int argc, const char **argv, const char *prefix)
{ {
@ -49,12 +50,13 @@ 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 NOTE: `trace_printf()`, defined in `trace.h`, differs from `printf()` in
off at runtime. For the purposes of this tutorial, we will write `walken` as that it can be turned on or off at runtime. For the purposes of this
though it is intended for use as a "plumbing" command: that is, a command which tutorial, we will write `walken` as though it is intended for use as
is used primarily in scripts, rather than interactively by humans (a "porcelain" a "plumbing" command: that is, a command which is used primarily in
command). So we will send our debug output to `trace_printf()` instead. When scripts, rather than interactively by humans (a "porcelain" command).
running, enable trace output by setting the environment variable `GIT_TRACE`. 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 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). (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
`walken_commit_walk()`: `walken_commit_walk()`:


---- ----
#include "pretty.h"

...

static void walken_commit_walk(struct rev_info *rev) static void walken_commit_walk(struct rev_info *rev)
{ {
struct commit *commit; struct commit *commit;
@ -754,6 +760,10 @@ reachable objects are walked in order to populate the list.
First, add the `struct oidset` and related items we will use to iterate it: First, add the `struct oidset` and related items we will use to iterate it:


---- ----
#include "oidset.h"

...

static void walken_object_walk( static void walken_object_walk(
... ...


@ -805,6 +815,10 @@ just walks of commits. First, we'll make our handlers chattier - modify
go: go:


---- ----
#include "hex.h"

...

static void walken_show_commit(struct commit *cmt, void *buf) static void walken_show_commit(struct commit *cmt, void *buf)
{ {
trace_printf("commit: %s\n", oid_to_hex(&cmt->object.oid)); trace_printf("commit: %s\n", oid_to_hex(&cmt->object.oid));