docs: replace git_config to repo_config
Since this document was written, the built-in API has been updated a few times, but the document was left stale. Adjust to the current best practices by calling repo_config() on the repository instance the subcommand implementation receives as a parameter, instead of calling git_config() that used to be the common practice. Signed-off-by: K Jayatheerth <jayatheerthkulkarni2005@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
K Jayatheerth committed
May 18, 2025 at 13:13 UTC
7649d316ce1b71911dce71fdffd843a71732b827
1 file changed
+10
-9
Documentation/MyFirstContribution.adoc
+10
-9
@@ -322,7 +322,8 @@ on the command line, including the name of our command. (If `prefix` is empty
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"`. Then, add the following bits to the
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
----
@@ -330,18 +331,18 @@ function body:
331
332
...
333
333
- git_config(git_default_config, NULL);
334
- if (git_config_get_string_tmp("user.name", &cfg_name) > 0)
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
340
-`git_config()` will grab the configuration from config files known to Git and
341
-apply standard precedence rules. `git_config_get_string_tmp()` will look up
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
344
-about how to use `git_config()`) in `Documentation/technical/api-config.adoc`.
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
@@ -374,7 +375,7 @@ status_init_config(&s, git_status_config);
375
----
376
377
But as we drill down, we can find that `status_init_config()` wraps a call
377
-to `git_config()`. Let's modify the code we wrote in the previous commit.
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
@@ -390,8 +391,8 @@ prepare it, and print its contents:
391
392
...
393
393
- wt_status_prepare(the_repository, &status);
394
- git_config(git_default_config, &status);
394
+ wt_status_prepare(repo, &status);
395
+ repo_config(repo, git_default_config, &status);
396
397
...
398