diff mbox series

[v2,1/2] docs: fix places that break compilation in MyFirstObjectWalk

Message ID 5c9deaf0bccfe158c7f410f084529850a33b7fd0.1635530296.git.gitgitgadget@gmail.com (mailing list archive)
State Superseded
Headers show
Series fix up example code in MyFirstObjectWalk tutorial | expand

Commit Message

John Cai Oct. 29, 2021, 5:58 p.m. UTC
From: John Cai <johncai86@gmail.com>

Two errors in the example code caused compilation failures due to
a missing semicolon as well as initialization with an empty struct.
This commit fixes that to make the MyFirstObjectWalk tutorial easier to
follow.

Signed-off-by: John Cai <johncai86@gmail.com>
---
 Documentation/MyFirstObjectWalk.txt | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

Comments

Eric Sunshine Oct. 29, 2021, 6:04 p.m. UTC | #1
On Fri, Oct 29, 2021 at 1:58 PM John Cai via GitGitGadget
<gitgitgadget@gmail.com> wrote:
> Two errors in the example code caused compilation failures due to
> a missing semicolon as well as initialization with an empty struct.
> This commit fixes that to make the MyFirstObjectWalk tutorial easier to
> follow.
>
> Signed-off-by: John Cai <johncai86@gmail.com>
> ---
> diff --git a/Documentation/MyFirstObjectWalk.txt b/Documentation/MyFirstObjectWalk.txt
> @@ -58,6 +58,7 @@ 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).
> +We'll need to include the `parse-options.h` header.

It seems like this change belongs in patch [2/2].

> @@ -65,7 +66,7 @@ int cmd_walken(int argc, const char **argv, const char *prefix)
>         const char * const walken_usage[] = {
>                 N_("git walken"),
>                 NULL,
> -       }
> +       };

Whereas, this change correctly resides in patch [1/2].

>         struct option options[] = {
>                 OPT_END()
>         };
> @@ -195,7 +196,8 @@ Similarly to the default values, we don't have anything to do here yet
>  ourselves; however, we should call `git_default_config()` if we aren't calling
>  any other existing config callbacks.
>
> -Add a new function to `builtin/walken.c`:
> +Add a new function to `builtin/walken.c`.
> +We'll also need to include the `config.h` header:

Should be in patch [2/2].

> @@ -229,7 +231,9 @@ typically done by calling `repo_init_revisions()` with the repository you intend
>  to target, as well as the `prefix` argument of `cmd_walken` and your `rev_info`
>  struct.
>
> -Add the `struct rev_info` and the `repo_init_revisions()` call:
> +Add the `struct rev_info` and the `repo_init_revisions()` call.
> +We'll also need to include the `revision.h` header:

Patch [2/2].

> @@ -624,7 +628,8 @@ static void walken_object_walk(struct rev_info *rev)
>  Let's start by calling just the unfiltered walk and reporting our counts.
> -Complete your implementation of `walken_object_walk()`:
> +Complete your implementation of `walken_object_walk()`.
> +We'll also need to include the `list-objects.h` header.

Also patch [2/2].

> @@ -697,7 +702,7 @@ First, we'll need to `#include "list-objects-filter-options.h"` and set up the
>  static void walken_object_walk(struct rev_info *rev)
>  {
> -       struct list_objects_filter_options filter_options = {};
> +       struct list_objects_filter_options filter_options = { 0 };

Good, this change belongs here in patch [1/2].
diff mbox series

Patch

diff --git a/Documentation/MyFirstObjectWalk.txt b/Documentation/MyFirstObjectWalk.txt
index 45eb84d8b48..e22615105c0 100644
--- a/Documentation/MyFirstObjectWalk.txt
+++ b/Documentation/MyFirstObjectWalk.txt
@@ -58,6 +58,7 @@  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).
+We'll need to include the `parse-options.h` header.
 
 ----
 int cmd_walken(int argc, const char **argv, const char *prefix)
@@ -65,7 +66,7 @@  int cmd_walken(int argc, const char **argv, const char *prefix)
 	const char * const walken_usage[] = {
 		N_("git walken"),
 		NULL,
-	}
+	};
 	struct option options[] = {
 		OPT_END()
 	};
@@ -195,7 +196,8 @@  Similarly to the default values, we don't have anything to do here yet
 ourselves; however, we should call `git_default_config()` if we aren't calling
 any other existing config callbacks.
 
-Add a new function to `builtin/walken.c`:
+Add a new function to `builtin/walken.c`.
+We'll also need to include the `config.h` header:
 
 ----
 static int git_walken_config(const char *var, const char *value, void *cb)
@@ -229,7 +231,9 @@  typically done by calling `repo_init_revisions()` with the repository you intend
 to target, as well as the `prefix` argument of `cmd_walken` and your `rev_info`
 struct.
 
-Add the `struct rev_info` and the `repo_init_revisions()` call:
+Add the `struct rev_info` and the `repo_init_revisions()` call.
+We'll also need to include the `revision.h` header:
+
 ----
 int cmd_walken(int argc, const char **argv, const char *prefix)
 {
@@ -624,7 +628,8 @@  static void walken_object_walk(struct rev_info *rev)
 ----
 
 Let's start by calling just the unfiltered walk and reporting our counts.
-Complete your implementation of `walken_object_walk()`:
+Complete your implementation of `walken_object_walk()`.
+We'll also need to include the `list-objects.h` header.
 
 ----
 	traverse_commit_list(rev, walken_show_commit, walken_show_object, NULL);
@@ -697,7 +702,7 @@  First, we'll need to `#include "list-objects-filter-options.h"` and set up the
 ----
 static void walken_object_walk(struct rev_info *rev)
 {
-	struct list_objects_filter_options filter_options = {};
+	struct list_objects_filter_options filter_options = { 0 };
 
 	...
 ----