* [PATCH v4 0/3] Update MyFirstContribution.adoc to follow modern practices
@ 2025-05-18 7:43 K Jayatheerth
2025-05-18 7:43 ` [PATCH v4 1/3] docs: remove unused mentoring mailing list reference K Jayatheerth
` (3 more replies)
0 siblings, 4 replies; 6+ messages in thread
From: K Jayatheerth @ 2025-05-18 7:43 UTC (permalink / raw)
To: git; +Cc: gitster, jayatheerthkulkarni2005, nasamuffin
The following changes are made to MyFirstContribution.adoc
to make the tutorial follow modern git practices.
The tutorial codes actually help newbies like myself to actually know what is going on
in the source code as the Git source code is vast.
Therefore these patches.
K Jayatheerth (3):
docs: remove unused mentoring mailing list reference
docs: clarify cmd_psuh signature and explain UNUSED macro
docs: replace git_config to repo_config
Documentation/MyFirstContribution.adoc | 55 +++++++++++++++-----------
1 file changed, 33 insertions(+), 22 deletions(-)
--
2.49.GIT
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v4 1/3] docs: remove unused mentoring mailing list reference
2025-05-18 7:43 [PATCH v4 0/3] Update MyFirstContribution.adoc to follow modern practices K Jayatheerth
@ 2025-05-18 7:43 ` K Jayatheerth
2025-05-18 7:43 ` [PATCH v4 2/3] docs: clarify cmd_psuh signature and explain UNUSED macro K Jayatheerth
` (2 subsequent siblings)
3 siblings, 0 replies; 6+ messages in thread
From: K Jayatheerth @ 2025-05-18 7:43 UTC (permalink / raw)
To: git; +Cc: gitster, jayatheerthkulkarni2005, nasamuffin
The git-mentoring group was initially created to help newcomers
with their development itches. However, in practice,
most of their questions were already being addressed
directly on the mailing list, and contributors consistently
received helpful responses there.
Remove the mentoring group details from the Documentation.
Signed-off-by: K Jayatheerth <jayatheerthkulkarni2005@gmail.com>
---
Documentation/MyFirstContribution.adoc | 8 --------
1 file changed, 8 deletions(-)
diff --git a/Documentation/MyFirstContribution.adoc b/Documentation/MyFirstContribution.adoc
index ca1d688c9b..ef190d8748 100644
--- a/Documentation/MyFirstContribution.adoc
+++ b/Documentation/MyFirstContribution.adoc
@@ -40,14 +40,6 @@ the list by sending an email to <git+subscribe@vger.kernel.org>
The https://lore.kernel.org/git[archive] of this mailing list is
available to view in a browser.
-==== https://groups.google.com/forum/#!forum/git-mentoring[git-mentoring@googlegroups.com]
-
-This mailing list is targeted to new contributors and was created as a place to
-post questions and receive answers outside of the public eye of the main list.
-Veteran contributors who are especially interested in helping mentor newcomers
-are present on the list. In order to avoid search indexers, group membership is
-required to view messages; anyone can join and no approval is required.
-
==== https://web.libera.chat/#git-devel[#git-devel] on Libera Chat
This IRC channel is for conversations between Git contributors. If someone is
--
2.49.GIT
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH v4 2/3] docs: clarify cmd_psuh signature and explain UNUSED macro
2025-05-18 7:43 [PATCH v4 0/3] Update MyFirstContribution.adoc to follow modern practices K Jayatheerth
2025-05-18 7:43 ` [PATCH v4 1/3] docs: remove unused mentoring mailing list reference K Jayatheerth
@ 2025-05-18 7:43 ` K Jayatheerth
2025-05-19 17:55 ` Junio C Hamano
2025-05-18 7:43 ` [PATCH v4 3/3] docs: replace git_config to repo_config K Jayatheerth
2025-05-19 17:54 ` [PATCH v4 0/3] Update MyFirstContribution.adoc to follow modern practices Junio C Hamano
3 siblings, 1 reply; 6+ messages in thread
From: K Jayatheerth @ 2025-05-18 7:43 UTC (permalink / raw)
To: git; +Cc: gitster, jayatheerthkulkarni2005, nasamuffin
The sample program, as written, would no longer build for at least two
reasons:
- Since this document was first written, the calling convention
to subcommand implementation has changed, and now cmd_psuh()
needs to accept the fourth parameter, repository.
- These days, compiler warning options for developers include
one that detects and complains about unused parameters, so
ones that are deliberately unused have to be marked as such.
Update the old-style examples to adjust to the current
practices, with explanations as needed.
Signed-off-by: K Jayatheerth <jayatheerthkulkarni2005@gmail.com>
---
Documentation/MyFirstContribution.adoc | 28 +++++++++++++++++++++-----
1 file changed, 23 insertions(+), 5 deletions(-)
diff --git a/Documentation/MyFirstContribution.adoc b/Documentation/MyFirstContribution.adoc
index ef190d8748..da15d43d1f 100644
--- a/Documentation/MyFirstContribution.adoc
+++ b/Documentation/MyFirstContribution.adoc
@@ -142,15 +142,31 @@ command in `builtin/psuh.c`. Create that file, and within it, write the entry
point for your command in a function matching the style and signature:
----
-int cmd_psuh(int argc, const char **argv, const char *prefix)
+int cmd_psuh(int argc UNUSED, const char **argv UNUSED,
+ const char *prefix UNUSED, struct repository *repo UNUSED)
----
+A few things to note:
+
+* A subcommand implementation takes its command line arguments
+ in `int argc` + `const char **argv`, like `main()` would.
+
+* It also takes two extra parameters, `prefix` and `repo`. What
+ they mean will not be discussed until much later.
+
+* Because this first example will not use any of the parameters,
+ your compiler will give warnings on unused parameters. As the
+ list of these four parameters is mandated by the API to add
+ new built-in commands, you cannot omit them. Instead, you add
+ `UNUSED` to each of them to tell the compiler that you *know*
+ you are not (yet) using it.
+
We'll also need to add the declaration of psuh; open up `builtin.h`, find the
declaration for `cmd_pull`, and add a new line for `psuh` immediately before it,
in order to keep the declarations alphabetically sorted:
----
-int cmd_psuh(int argc, const char **argv, const char *prefix);
+int cmd_psuh(int argc, const char **argv, const char *prefix, struct repository *repo);
----
Be sure to `#include "builtin.h"` in your `psuh.c`. You'll also need to
@@ -166,7 +182,8 @@ Throughout the tutorial, we will mark strings for translation as necessary; you
should also do so when writing your user-facing commands in the future.
----
-int cmd_psuh(int argc, const char **argv, const char *prefix)
+int cmd_psuh(int argc UNUSED, const char **argv UNUSED,
+ const char *prefix UNUSED, struct repository *repo UNUSED)
{
printf(_("Pony saying hello goes here.\n"));
return 0;
@@ -279,8 +296,9 @@ on the reference implementation linked at the top of this document.
It's probably useful to do at least something besides printing out a string.
Let's start by having a look at everything we get.
-Modify your `cmd_psuh` implementation to dump the args you're passed, keeping
-existing `printf()` calls in place:
+Modify your `cmd_psuh` implementation to dump the args you're passed,
+keeping existing `printf()` calls in place; because the args are now
+used, remove the `UNUSED` macro from them:
----
int i;
--
2.49.GIT
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH v4 3/3] docs: replace git_config to repo_config
2025-05-18 7:43 [PATCH v4 0/3] Update MyFirstContribution.adoc to follow modern practices K Jayatheerth
2025-05-18 7:43 ` [PATCH v4 1/3] docs: remove unused mentoring mailing list reference K Jayatheerth
2025-05-18 7:43 ` [PATCH v4 2/3] docs: clarify cmd_psuh signature and explain UNUSED macro K Jayatheerth
@ 2025-05-18 7:43 ` K Jayatheerth
2025-05-19 17:54 ` [PATCH v4 0/3] Update MyFirstContribution.adoc to follow modern practices Junio C Hamano
3 siblings, 0 replies; 6+ messages in thread
From: K Jayatheerth @ 2025-05-18 7:43 UTC (permalink / raw)
To: git; +Cc: gitster, jayatheerthkulkarni2005, nasamuffin
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>
---
Documentation/MyFirstContribution.adoc | 19 ++++++++++---------
1 file changed, 10 insertions(+), 9 deletions(-)
diff --git a/Documentation/MyFirstContribution.adoc b/Documentation/MyFirstContribution.adoc
index da15d43d1f..08a3137101 100644
--- a/Documentation/MyFirstContribution.adoc
+++ b/Documentation/MyFirstContribution.adoc
@@ -322,7 +322,8 @@ on the command line, including the name of our command. (If `prefix` is empty
for you, try `cd Documentation/ && ../bin-wrappers/git psuh`). That's not so
helpful. So what other context can we get?
-Add a line to `#include "config.h"`. Then, add the following bits to the
+Add a line to `#include "config.h"` and `#include "repository.h"`.
+Then, add the following bits to the function body:
function body:
----
@@ -330,18 +331,18 @@ function body:
...
- git_config(git_default_config, NULL);
- if (git_config_get_string_tmp("user.name", &cfg_name) > 0)
+ repo_config(repo, git_default_config, NULL);
+ if (repo_config_get_string_tmp(repo, "user.name", &cfg_name))
printf(_("No name is found in config\n"));
else
printf(_("Your name: %s\n"), cfg_name);
----
-`git_config()` will grab the configuration from config files known to Git and
-apply standard precedence rules. `git_config_get_string_tmp()` will look up
+`repo_config()` will grab the configuration from config files known to Git and
+apply standard precedence rules. `repo_config_get_string_tmp()` will look up
a specific key ("user.name") and give you the value. There are a number of
single-key lookup functions like this one; you can see them all (and more info
-about how to use `git_config()`) in `Documentation/technical/api-config.adoc`.
+about how to use `repo_config()`) in `Documentation/technical/api-config.adoc`.
You should see that the name printed matches the one you see when you run:
@@ -374,7 +375,7 @@ status_init_config(&s, git_status_config);
----
But as we drill down, we can find that `status_init_config()` wraps a call
-to `git_config()`. Let's modify the code we wrote in the previous commit.
+to `repo_config()`. Let's modify the code we wrote in the previous commit.
Be sure to include the header to allow you to use `struct wt_status`:
@@ -390,8 +391,8 @@ prepare it, and print its contents:
...
- wt_status_prepare(the_repository, &status);
- git_config(git_default_config, &status);
+ wt_status_prepare(repo, &status);
+ repo_config(repo, git_default_config, &status);
...
--
2.49.GIT
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v4 0/3] Update MyFirstContribution.adoc to follow modern practices
2025-05-18 7:43 [PATCH v4 0/3] Update MyFirstContribution.adoc to follow modern practices K Jayatheerth
` (2 preceding siblings ...)
2025-05-18 7:43 ` [PATCH v4 3/3] docs: replace git_config to repo_config K Jayatheerth
@ 2025-05-19 17:54 ` Junio C Hamano
3 siblings, 0 replies; 6+ messages in thread
From: Junio C Hamano @ 2025-05-19 17:54 UTC (permalink / raw)
To: K Jayatheerth; +Cc: git, nasamuffin
K Jayatheerth <jayatheerthkulkarni2005@gmail.com> writes:
> The following changes are made to MyFirstContribution.adoc
> to make the tutorial follow modern git practices.
>
> The tutorial codes actually help newbies like myself to actually know what is going on
> in the source code as the Git source code is vast.
>
> Therefore these patches.
>
> K Jayatheerth (3):
> docs: remove unused mentoring mailing list reference
> docs: clarify cmd_psuh signature and explain UNUSED macro
> docs: replace git_config to repo_config
>
> Documentation/MyFirstContribution.adoc | 55 +++++++++++++++-----------
> 1 file changed, 33 insertions(+), 22 deletions(-)
Looking much better. Will queue.
Thanks.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v4 2/3] docs: clarify cmd_psuh signature and explain UNUSED macro
2025-05-18 7:43 ` [PATCH v4 2/3] docs: clarify cmd_psuh signature and explain UNUSED macro K Jayatheerth
@ 2025-05-19 17:55 ` Junio C Hamano
0 siblings, 0 replies; 6+ messages in thread
From: Junio C Hamano @ 2025-05-19 17:55 UTC (permalink / raw)
To: K Jayatheerth; +Cc: git, nasamuffin
K Jayatheerth <jayatheerthkulkarni2005@gmail.com> writes:
> diff --git a/Documentation/MyFirstContribution.adoc b/Documentation/MyFirstContribution.adoc
> index ef190d8748..da15d43d1f 100644
> --- a/Documentation/MyFirstContribution.adoc
> +++ b/Documentation/MyFirstContribution.adoc
> @@ -142,15 +142,31 @@ command in `builtin/psuh.c`. Create that file, and within it, write the entry
> ...
> ----
> -int cmd_psuh(int argc, const char **argv, const char *prefix)
> +int cmd_psuh(int argc UNUSED, const char **argv UNUSED,
I removed the new trailing whitespace on this line while queuing, so
no need to resend only to fix this.
Thanks.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2025-05-19 17:55 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-18 7:43 [PATCH v4 0/3] Update MyFirstContribution.adoc to follow modern practices K Jayatheerth
2025-05-18 7:43 ` [PATCH v4 1/3] docs: remove unused mentoring mailing list reference K Jayatheerth
2025-05-18 7:43 ` [PATCH v4 2/3] docs: clarify cmd_psuh signature and explain UNUSED macro K Jayatheerth
2025-05-19 17:55 ` Junio C Hamano
2025-05-18 7:43 ` [PATCH v4 3/3] docs: replace git_config to repo_config K Jayatheerth
2025-05-19 17:54 ` [PATCH v4 0/3] Update MyFirstContribution.adoc to follow modern practices Junio C Hamano
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).