Git fork

Merge branch 'kj/my-first-contribution-updates'

Doc updates.

* kj/my-first-contribution-updates:
docs: replace git_config to repo_config
docs: clarify cmd_psuh signature and explain UNUSED macro
docs: remove unused mentoring mailing list reference

+33 -22
+33 -22
Documentation/MyFirstContribution.adoc
··· 40 The https://lore.kernel.org/git[archive] of this mailing list is 41 available to view in a browser. 42 43 - ==== https://groups.google.com/forum/#!forum/git-mentoring[git-mentoring@googlegroups.com] 44 - 45 - This mailing list is targeted to new contributors and was created as a place to 46 - post questions and receive answers outside of the public eye of the main list. 47 - Veteran contributors who are especially interested in helping mentor newcomers 48 - are present on the list. In order to avoid search indexers, group membership is 49 - required to view messages; anyone can join and no approval is required. 50 - 51 ==== https://web.libera.chat/#git-devel[#git-devel] on Libera Chat 52 53 This IRC channel is for conversations between Git contributors. If someone is ··· 150 point for your command in a function matching the style and signature: 151 152 ---- 153 - int cmd_psuh(int argc, const char **argv, const char *prefix) 154 ---- 155 156 We'll also need to add the declaration of psuh; open up `builtin.h`, find the 157 declaration for `cmd_pull`, and add a new line for `psuh` immediately before it, 158 in order to keep the declarations alphabetically sorted: 159 160 ---- 161 - int cmd_psuh(int argc, const char **argv, const char *prefix); 162 ---- 163 164 Be sure to `#include "builtin.h"` in your `psuh.c`. You'll also need to ··· 174 should also do so when writing your user-facing commands in the future. 175 176 ---- 177 - int cmd_psuh(int argc, const char **argv, const char *prefix) 178 { 179 printf(_("Pony saying hello goes here.\n")); 180 return 0; ··· 287 It's probably useful to do at least something besides printing out a string. 288 Let's start by having a look at everything we get. 289 290 - Modify your `cmd_psuh` implementation to dump the args you're passed, keeping 291 - existing `printf()` calls in place: 292 293 ---- 294 int i; ··· 312 for you, try `cd Documentation/ && ../bin-wrappers/git psuh`). That's not so 313 helpful. So what other context can we get? 314 315 - Add a line to `#include "config.h"`. Then, add the following bits to the 316 function body: 317 318 ---- ··· 320 321 ... 322 323 - git_config(git_default_config, NULL); 324 - if (git_config_get_string_tmp("user.name", &cfg_name) > 0) 325 printf(_("No name is found in config\n")); 326 else 327 printf(_("Your name: %s\n"), cfg_name); 328 ---- 329 330 - `git_config()` will grab the configuration from config files known to Git and 331 - apply standard precedence rules. `git_config_get_string_tmp()` will look up 332 a specific key ("user.name") and give you the value. There are a number of 333 single-key lookup functions like this one; you can see them all (and more info 334 - about how to use `git_config()`) in `Documentation/technical/api-config.adoc`. 335 336 You should see that the name printed matches the one you see when you run: 337 ··· 364 ---- 365 366 But as we drill down, we can find that `status_init_config()` wraps a call 367 - to `git_config()`. Let's modify the code we wrote in the previous commit. 368 369 Be sure to include the header to allow you to use `struct wt_status`: 370 ··· 380 381 ... 382 383 - wt_status_prepare(the_repository, &status); 384 - git_config(git_default_config, &status); 385 386 ... 387
··· 40 The https://lore.kernel.org/git[archive] of this mailing list is 41 available to view in a browser. 42 43 ==== https://web.libera.chat/#git-devel[#git-devel] on Libera Chat 44 45 This IRC channel is for conversations between Git contributors. If someone is ··· 142 point for your command in a function matching the style and signature: 143 144 ---- 145 + int cmd_psuh(int argc UNUSED, const char **argv UNUSED, 146 + const char *prefix UNUSED, struct repository *repo UNUSED) 147 ---- 148 149 + A few things to note: 150 + 151 + * A subcommand implementation takes its command line arguments 152 + in `int argc` + `const char **argv`, like `main()` would. 153 + 154 + * It also takes two extra parameters, `prefix` and `repo`. What 155 + they mean will not be discussed until much later. 156 + 157 + * Because this first example will not use any of the parameters, 158 + your compiler will give warnings on unused parameters. As the 159 + list of these four parameters is mandated by the API to add 160 + new built-in commands, you cannot omit them. Instead, you add 161 + `UNUSED` to each of them to tell the compiler that you *know* 162 + you are not (yet) using it. 163 + 164 We'll also need to add the declaration of psuh; open up `builtin.h`, find the 165 declaration for `cmd_pull`, and add a new line for `psuh` immediately before it, 166 in order to keep the declarations alphabetically sorted: 167 168 ---- 169 + int cmd_psuh(int argc, const char **argv, const char *prefix, struct repository *repo); 170 ---- 171 172 Be sure to `#include "builtin.h"` in your `psuh.c`. You'll also need to ··· 182 should also do so when writing your user-facing commands in the future. 183 184 ---- 185 + int cmd_psuh(int argc UNUSED, const char **argv UNUSED, 186 + const char *prefix UNUSED, struct repository *repo UNUSED) 187 { 188 printf(_("Pony saying hello goes here.\n")); 189 return 0; ··· 296 It's probably useful to do at least something besides printing out a string. 297 Let's start by having a look at everything we get. 298 299 + Modify your `cmd_psuh` implementation to dump the args you're passed, 300 + keeping existing `printf()` calls in place; because the args are now 301 + used, remove the `UNUSED` macro from them: 302 303 ---- 304 int i; ··· 322 for you, try `cd Documentation/ && ../bin-wrappers/git psuh`). That's not so 323 helpful. So what other context can we get? 324 325 + Add a line to `#include "config.h"` and `#include "repository.h"`. 326 + Then, add the following bits to the function body: 327 function body: 328 329 ---- ··· 331 332 ... 333 334 + repo_config(repo, git_default_config, NULL); 335 + if (repo_config_get_string_tmp(repo, "user.name", &cfg_name)) 336 printf(_("No name is found in config\n")); 337 else 338 printf(_("Your name: %s\n"), cfg_name); 339 ---- 340 341 + `repo_config()` will grab the configuration from config files known to Git and 342 + apply standard precedence rules. `repo_config_get_string_tmp()` will look up 343 a specific key ("user.name") and give you the value. There are a number of 344 single-key lookup functions like this one; you can see them all (and more info 345 + about how to use `repo_config()`) in `Documentation/technical/api-config.adoc`. 346 347 You should see that the name printed matches the one you see when you run: 348 ··· 375 ---- 376 377 But as we drill down, we can find that `status_init_config()` wraps a call 378 + to `repo_config()`. Let's modify the code we wrote in the previous commit. 379 380 Be sure to include the header to allow you to use `struct wt_status`: 381 ··· 391 392 ... 393 394 + wt_status_prepare(repo, &status); 395 + repo_config(repo, git_default_config, &status); 396 397 ... 398