From: Junio C Hamano <gitster@pobox.com>
To: Vinayak Dev <vinayakdev.sci@gmail.com>, Elijah Newren <newren@gmail.com>
Cc: nasamuffin@google.com, git@vger.kernel.org
Subject: Re: [PATCH] docs: include "trace.h" in MyFirstObjectWalk.txt
Date: Thu, 29 Jun 2023 14:13:12 -0700 [thread overview]
Message-ID: <xmqqjzvm7z13.fsf@gitster.g> (raw)
In-Reply-To: <20230629185238.58961-1-vinayakdev.sci@gmail.com> (Vinayak Dev's message of "Fri, 30 Jun 2023 00:22:38 +0530")
Vinayak Dev <vinayakdev.sci@gmail.com> writes:
[jc: including Elijah, who owns a few topics of the recent past that
shuffled header files, to recipients].
> In Documentation/MyFirstObjectWalk.txt, the function
> trace_printf() is used to enable trace output.
> However, the file "trace.h" is not included, which
> produces an error when the code from the tutorial is
> compiled, with the compiler complaining that the
> function is not defined before usage. Therefore, add
> an include for "trace.h" in the tutorial.
>
> Signed-off-by: Vinayak Dev <vinayakdev.sci@gmail.com>
> ---
> Documentation/MyFirstObjectWalk.txt | 14 ++++++++------
> 1 file changed, 8 insertions(+), 6 deletions(-)
>
> diff --git a/Documentation/MyFirstObjectWalk.txt b/Documentation/MyFirstObjectWalk.txt
> index eee513e86f..c3a23eb100 100644
> --- a/Documentation/MyFirstObjectWalk.txt
> +++ b/Documentation/MyFirstObjectWalk.txt
> @@ -41,6 +41,7 @@ Open up a new file `builtin/walken.c` and set up the command handler:
> */
>
> #include "builtin.h"
> +#include "trace.h"
>
> int cmd_walken(int argc, const char **argv, const char *prefix)
> {
OK.
> @@ -49,12 +50,13 @@ int cmd_walken(int argc, const char **argv, const char *prefix)
> }
> ----
>
> -NOTE: `trace_printf()` differs from `printf()` in that it can be turned on or
> -off at runtime. For the purposes of this tutorial, we will write `walken` as
> -though it is intended for use as a "plumbing" command: that is, a command which
> -is used primarily in scripts, rather than interactively by humans (a "porcelain"
> -command). So we will send our debug output to `trace_printf()` instead. When
> -running, enable trace output by setting the environment variable `GIT_TRACE`.
> +NOTE: `trace_printf()`, defined in `trace.h`, differs from `printf()` in
> +that it can be turned on or off at runtime. For the purposes of this
> +tutorial, we will write `walken` as though it is intended for use as
> +a "plumbing" command: that is, a command which is used primarily in
> +scripts, rather than interactively by humans (a "porcelain" command).
> +So we will send our debug output to `trace_printf()` instead.
> +When running, enable trace output by setting the environment variable `GIT_TRACE`.
All of the above may be good currently, but as soon as somebody does
another round of header shuffling, we risk a very similar breakage.
It is a good time to think about ways to avoid that, while the pain
is fresh in our mind.
One "cop out" thing we can do to limit the damage may be to loosen
the text in the "NOTE:", so that it does *NOT* mention exact header
files the API functions appear and let the readers learn from the
source themselves, with "git grep" helping their way. Or tone down
"defined in X" somehow to hint that these details may change.
More effective things that would involve higher implementation cost
(but will reduce maintenance cost) would be to actually make sure
that those who update the API will notice that they are breaking
these samples when they develop their series.
In https://lore.kernel.org/git/xmqq1qhu9ifp.fsf@gitster.g/, I've
floated some strawman ideas but people may be able to invent better
ways.
next prev parent reply other threads:[~2023-06-29 21:13 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-29 18:52 [PATCH] docs: include "trace.h" in MyFirstObjectWalk.txt Vinayak Dev
2023-06-29 21:13 ` Junio C Hamano [this message]
2023-06-30 6:09 ` Vinayak Dev
2023-06-30 16:25 ` Junio C Hamano
2023-06-30 16:50 ` Vinayak Dev
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqqjzvm7z13.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=nasamuffin@google.com \
--cc=newren@gmail.com \
--cc=vinayakdev.sci@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox