Skip to content

Commit 3d2dce1

Browse files
committed
Merge branch 'jc/fix-first-object-walk'
Doc update. * jc/fix-first-object-walk: docs: add headers in MyFirstObjectWalk docs: fix places that break compilation in MyFirstObjectWalk
2 parents b5e7f5e + 7d1b866 commit 3d2dce1

File tree

1 file changed

+26
-5
lines changed

1 file changed

+26
-5
lines changed

Documentation/MyFirstObjectWalk.txt

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,19 @@ running, enable trace output by setting the environment variable `GIT_TRACE`.
5858

5959
Add usage text and `-h` handling, like all subcommands should consistently do
6060
(our test suite will notice and complain if you fail to do so).
61+
We'll need to include the `parse-options.h` header.
6162

6263
----
64+
#include "parse-options.h"
65+
66+
...
67+
6368
int cmd_walken(int argc, const char **argv, const char *prefix)
6469
{
6570
const char * const walken_usage[] = {
6671
N_("git walken"),
6772
NULL,
68-
}
73+
};
6974
struct option options[] = {
7075
OPT_END()
7176
};
@@ -195,9 +200,14 @@ Similarly to the default values, we don't have anything to do here yet
195200
ourselves; however, we should call `git_default_config()` if we aren't calling
196201
any other existing config callbacks.
197202

198-
Add a new function to `builtin/walken.c`:
203+
Add a new function to `builtin/walken.c`.
204+
We'll also need to include the `config.h` header:
199205

200206
----
207+
#include "config.h"
208+
209+
...
210+
201211
static int git_walken_config(const char *var, const char *value, void *cb)
202212
{
203213
/*
@@ -229,8 +239,14 @@ typically done by calling `repo_init_revisions()` with the repository you intend
229239
to target, as well as the `prefix` argument of `cmd_walken` and your `rev_info`
230240
struct.
231241

232-
Add the `struct rev_info` and the `repo_init_revisions()` call:
242+
Add the `struct rev_info` and the `repo_init_revisions()` call.
243+
We'll also need to include the `revision.h` header:
244+
233245
----
246+
#include "revision.h"
247+
248+
...
249+
234250
int cmd_walken(int argc, const char **argv, const char *prefix)
235251
{
236252
/* This can go wherever you like in your declarations.*/
@@ -624,9 +640,14 @@ static void walken_object_walk(struct rev_info *rev)
624640
----
625641

626642
Let's start by calling just the unfiltered walk and reporting our counts.
627-
Complete your implementation of `walken_object_walk()`:
643+
Complete your implementation of `walken_object_walk()`.
644+
We'll also need to include the `list-objects.h` header.
628645

629646
----
647+
#include "list-objects.h"
648+
649+
...
650+
630651
traverse_commit_list(rev, walken_show_commit, walken_show_object, NULL);
631652

632653
printf("commits %d\nblobs %d\ntags %d\ntrees %d\n", commit_count,
@@ -697,7 +718,7 @@ First, we'll need to `#include "list-objects-filter-options.h"` and set up the
697718
----
698719
static void walken_object_walk(struct rev_info *rev)
699720
{
700-
struct list_objects_filter_options filter_options = {};
721+
struct list_objects_filter_options filter_options = { 0 };
701722

702723
...
703724
----

0 commit comments

Comments
 (0)