git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 2/2] docs: add headers in MyFirstObjectWalk

From
Junio C Hamano <gitster@pobox.com>
Date
Oct 27, 2021, 21:17 UTC
Message-ID
<xmqqk0hyupzo.fsf@gitster.g>
In-Reply-To
<33cd9b2e8a675bf79132d312da8b7d8f4a2b84a3.1635343531.git.gitgitgadget@gmail.com>
"John Cai via GitGitGadget" <gitgitgadget@gmail.com> writes:
>  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). We'll need to include
> +the "parse-options.h" header.

OK, but wrap this overlong line. All the lines updated by this patch, except the one in the last hunk, have become overly long.

[jc: cc'ed the primary author of the document to sanity checking]
Thanks.
Show 56 quoted lines
>  
>  ----
> +#include "parse-options.h"
> +
> +...
> +
>  int cmd_walken(int argc, const char **argv, const char *prefix)
>  {
>  	const char * const walken_usage[] = {
> @@ -195,9 +200,13 @@ 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:
>  
>  ----
> +#include "config.h"
> +
> +...
> +
>  static int git_walken_config(const char *var, const char *value, void *cb)
>  {
>  	/*
> @@ -229,8 +238,14 @@ 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:
> +
>  ----
> +#include "revision.h"
> +
> +...
> +
>  int cmd_walken(int argc, const char **argv, const char *prefix)
>  {
>  	/* This can go wherever you like in your declarations.*/
> @@ -624,9 +639,14 @@ 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.
>  
>  ----
> +#include "list-objects.h"
> +
> +...
> +
>  	traverse_commit_list(rev, walken_show_commit, walken_show_object, NULL);
>  
>  	printf("commits %d\nblobs %d\ntags %d\ntrees %d\n", commit_count,
Previous: Eric SunshineNext: Bagas Sanjaya
Message 6 of 16 in “fix up example code in MyFirstObjectWalk tutorial”
  1. 0/2 fix up example code in MyFirstObjectWalk tutorialJohn Cai via GitGitGadget, Oct 27, 2021
  2. 1/2 docs: fix places that break compliation in MyFirstObjectWalkJohn Cai via GitGitGadget, Oct 27, 2021
  3. Eric SunshineOct 27, 2021
  4. 2/2 docs: add headers in MyFirstObjectWalkJohn Cai via GitGitGadget, Oct 27, 2021
  5. Eric SunshineOct 27, 2021
  6. Junio C HamanoOct 27, 2021
  7. Bagas SanjayaOct 30, 2021
  8. Eric SunshineOct 30, 2021
  9. 0/2 fix up example code in MyFirstObjectWalk tutorialJohn Cai via GitGitGadget, Oct 29, 2021
  10. 1/2 docs: fix places that break compilation in MyFirstObjectWalkJohn Cai via GitGitGadget, Oct 29, 2021
  11. Eric SunshineOct 29, 2021
  12. 2/2 docs: add headers in MyFirstObjectWalkJohn Cai via GitGitGadget, Oct 29, 2021
  13. 0/2 fix up example code in MyFirstObjectWalk tutorialJohn Cai via GitGitGadget, Oct 29, 2021
  14. 1/2 docs: fix places that break compilation in MyFirstObjectWalkJohn Cai via GitGitGadget, Oct 29, 2021
  15. 2/2 docs: add headers in MyFirstObjectWalkJohn Cai via GitGitGadget, Oct 29, 2021
  16. Eric SunshineOct 29, 2021

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.