MyFirstContribution: use struct repository in examples

Add the parameter `struct repository *repo` to the cmd_walken function. Since commit 9b1cb5070f (builtin: add a repository parameter for builtin functions, 2024-09-13), all the cmd_* have the `repo` parameter and new commands must follow this convention, so the documentation should also be changed. Change the `git_config` calls to `repo_config`, also passing the `repo` parameter, as since 036876a106 (config: hide functions using `the_repository` by default, 2024-08-13) the non-repo config functions are no longer recommended as they use the global `repository` variable. Helped-by: Karthik Nayak <karthik.188@gmail.com> Signed-off-by: Lucas Seiki Oshiro <lucasseikioshiro@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Lucas Seiki Oshiro committed Jun 2, 2025 at 17:50 UTC 08c3aaf5bad99128a8bfb451bf7b56c447ad5e86
1 file changed +10 -10
Documentation/MyFirstObjectWalk.adoc
+10 -10
@@ -43,7 +43,7 @@ Open up a new file `builtin/walken.c` and set up the command handler:
43 #include "builtin.h"
44 #include "trace.h"
45
46 -int cmd_walken(int argc, const char **argv, const char *prefix)
46 +int cmd_walken(int argc, const char **argv, const char *prefix, struct repository *repo)
47 {
48 trace_printf(_("cmd_walken incoming...\n"));
49 return 0;
@@ -86,7 +86,7 @@ int cmd_walken(int argc, const char **argv, const char *prefix)
86 Also add the relevant line in `builtin.h` near `cmd_whatchanged()`:
87
88 ----
89 -int cmd_walken(int argc, const char **argv, const char *prefix);
89 +int cmd_walken(int argc, const char **argv, const char *prefix, struct repository *repo);
90 ----
91
92 Include the command in `git.c` in `commands[]` near the entry for `whatchanged`,
@@ -193,7 +193,7 @@ initialization functions.
193
194 Next, we should have a look at any relevant configuration settings (i.e.,
195 settings readable and settable from `git config`). This is done by providing a
196 -callback to `git_config()`; within that callback, you can also invoke methods
196 +callback to `repo_config()`; within that callback, you can also invoke methods
197 from other components you may need that need to intercept these options. Your
198 callback will be invoked once per each configuration value which Git knows about
199 (global, local, worktree, etc.).
@@ -221,14 +221,14 @@ static int git_walken_config(const char *var, const char *value,
221 }
222 ----
223
224 -Make sure to invoke `git_config()` with it in your `cmd_walken()`:
224 +Make sure to invoke `repo_config()` with it in your `cmd_walken()`:
225
226 ----
227 -int cmd_walken(int argc, const char **argv, const char *prefix)
227 +int cmd_walken(int argc, const char **argv, const char *prefix, struct repository *repo)
228 {
229 ...
230
231 - git_config(git_walken_config, NULL);
231 + repo_config(repo, git_walken_config, NULL);
232
233 ...
234 }
@@ -250,14 +250,14 @@ We'll also need to include the `revision.h` header:
250
251 ...
252
253 -int cmd_walken(int argc, const char **argv, const char *prefix)
253 +int cmd_walken(int argc, const char **argv, const char *prefix, struct repository *repo)
254 {
255 /* This can go wherever you like in your declarations.*/
256 struct rev_info rev;
257 ...
258
259 - /* This should go after the git_config() call. */
260 - repo_init_revisions(the_repository, &rev, prefix);
259 + /* This should go after the repo_config() call. */
260 + repo_init_revisions(repo, &rev, prefix);
261
262 ...
263 }
@@ -305,7 +305,7 @@ Then let's invoke `final_rev_info_setup()` after the call to
305 `repo_init_revisions()`:
306
307 ----
308 -int cmd_walken(int argc, const char **argv, const char *prefix)
308 +int cmd_walken(int argc, const char **argv, const char *prefix, struct repository *repo)
309 {
310 ...
311