Skip to content

Commit 7649d31

Browse files
jayatheerthkulkarnigitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent a1dcf6b commit 7649d31

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

Documentation/MyFirstContribution.adoc

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -322,26 +322,27 @@ on the command line, including the name of our command. (If `prefix` is empty
322322
for you, try `cd Documentation/ && ../bin-wrappers/git psuh`). That's not so
323323
helpful. So what other context can we get?
324324

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:
326327
function body:
327328

328329
----
329330
const char *cfg_name;
330331
331332
...
332333
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))
335336
printf(_("No name is found in config\n"));
336337
else
337338
printf(_("Your name: %s\n"), cfg_name);
338339
----
339340

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
342343
a specific key ("user.name") and give you the value. There are a number of
343344
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`.
345346

346347
You should see that the name printed matches the one you see when you run:
347348

@@ -374,7 +375,7 @@ status_init_config(&s, git_status_config);
374375
----
375376

376377
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.
378379

379380
Be sure to include the header to allow you to use `struct wt_status`:
380381

@@ -390,8 +391,8 @@ prepare it, and print its contents:
390391
391392
...
392393
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);
395396
396397
...
397398

0 commit comments

Comments
 (0)