Skip to content

Commit 60f9bc3

Browse files
committed
Merge branch 'lo/my-first-ow-doc-update'
Doc update to the more recent world order. * lo/my-first-ow-doc-update: MyFirstContribution: add walken.c to meson.build MyFirstContribution: use struct repository in examples
2 parents 16bd9f2 + b257adb commit 60f9bc3

File tree

1 file changed

+24
-11
lines changed

1 file changed

+24
-11
lines changed

Documentation/MyFirstObjectWalk.adoc

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ Open up a new file `builtin/walken.c` and set up the command handler:
4343
#include "builtin.h"
4444
#include "trace.h"
4545
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)
4747
{
4848
trace_printf(_("cmd_walken incoming...\n"));
4949
return 0;
@@ -86,7 +86,7 @@ int cmd_walken(int argc, const char **argv, const char *prefix)
8686
Also add the relevant line in `builtin.h` near `cmd_whatchanged()`:
8787

8888
----
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);
9090
----
9191

9292
Include the command in `git.c` in `commands[]` near the entry for `whatchanged`,
@@ -96,10 +96,23 @@ maintaining alphabetical ordering:
9696
{ "walken", cmd_walken, RUN_SETUP },
9797
----
9898

99-
Add it to the `Makefile` near the line for `builtin/worktree.o`:
99+
Add an entry for the new command in the both the Make and Meson build system,
100+
before the entry for `worktree`:
100101

102+
- In the `Makefile`:
101103
----
104+
...
102105
BUILTIN_OBJS += builtin/walken.o
106+
...
107+
----
108+
109+
- In the `meson.build` file:
110+
----
111+
builtin_sources = [
112+
...
113+
'builtin/walken.c',
114+
...
115+
]
103116
----
104117

105118
Build and test out your command, without forgetting to ensure the `DEVELOPER`
@@ -193,7 +206,7 @@ initialization functions.
193206

194207
Next, we should have a look at any relevant configuration settings (i.e.,
195208
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
209+
callback to `repo_config()`; within that callback, you can also invoke methods
197210
from other components you may need that need to intercept these options. Your
198211
callback will be invoked once per each configuration value which Git knows about
199212
(global, local, worktree, etc.).
@@ -221,14 +234,14 @@ static int git_walken_config(const char *var, const char *value,
221234
}
222235
----
223236

224-
Make sure to invoke `git_config()` with it in your `cmd_walken()`:
237+
Make sure to invoke `repo_config()` with it in your `cmd_walken()`:
225238

226239
----
227-
int cmd_walken(int argc, const char **argv, const char *prefix)
240+
int cmd_walken(int argc, const char **argv, const char *prefix, struct repository *repo)
228241
{
229242
...
230243
231-
git_config(git_walken_config, NULL);
244+
repo_config(repo, git_walken_config, NULL);
232245
233246
...
234247
}
@@ -250,14 +263,14 @@ We'll also need to include the `revision.h` header:
250263
251264
...
252265
253-
int cmd_walken(int argc, const char **argv, const char *prefix)
266+
int cmd_walken(int argc, const char **argv, const char *prefix, struct repository *repo)
254267
{
255268
/* This can go wherever you like in your declarations.*/
256269
struct rev_info rev;
257270
...
258271
259-
/* This should go after the git_config() call. */
260-
repo_init_revisions(the_repository, &rev, prefix);
272+
/* This should go after the repo_config() call. */
273+
repo_init_revisions(repo, &rev, prefix);
261274
262275
...
263276
}
@@ -305,7 +318,7 @@ Then let's invoke `final_rev_info_setup()` after the call to
305318
`repo_init_revisions()`:
306319

307320
----
308-
int cmd_walken(int argc, const char **argv, const char *prefix)
321+
int cmd_walken(int argc, const char **argv, const char *prefix, struct repository *repo)
309322
{
310323
...
311324

0 commit comments

Comments
 (0)