summaryrefslogtreecommitdiffstats
path: root/MyFirstObjectWalk.html
diff options
context:
space:
mode:
Diffstat (limited to 'MyFirstObjectWalk.html')
-rw-r--r--MyFirstObjectWalk.html36
1 files changed, 25 insertions, 11 deletions
diff --git a/MyFirstObjectWalk.html b/MyFirstObjectWalk.html
index 264a831d3..e9e6052ef 100644
--- a/MyFirstObjectWalk.html
+++ b/MyFirstObjectWalk.html
@@ -735,7 +735,7 @@ asciidoc.install();
<body class="article">
<div id="header">
<h1>My First Object Walk</h1>
-<span id="revdate">2023-07-14</span>
+<span id="revdate">2023-07-17</span>
</div>
<div id="content">
<div class="sect1">
@@ -794,6 +794,7 @@ Open up a new file <code>builtin/walken.c</code> and set up the command handler:
*/
#include "builtin.h"
+#include "trace.h"
int cmd_walken(int argc, const char **argv, const char *prefix)
{
@@ -806,12 +807,13 @@ int cmd_walken(int argc, const char **argv, const char *prefix)
<td class="icon">
<div class="title">Note</div>
</td>
-<td class="content"><code>trace_printf()</code> differs from <code>printf()</code> in that it can be turned on or
-off at runtime. For the purposes of this tutorial, we will write <code>walken</code> 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 <code>trace_printf()</code> instead. When
-running, enable trace output by setting the environment variable <code>GIT_TRACE</code>.</td>
+<td class="content"><code>trace_printf()</code>, defined in <code>trace.h</code>, differs from <code>printf()</code> in
+that it can be turned on or off at runtime. For the purposes of this
+tutorial, we will write <code>walken</code> 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 <code>trace_printf()</code> instead.
+When running, enable trace output by setting the environment variable <code>GIT_TRACE</code>.</td>
</tr></table>
</div>
<div class="paragraph"><p>Add usage text and <code>-h</code> handling, like all subcommands should consistently do
@@ -1128,7 +1130,11 @@ the walk loop below the <code>prepare_revision_walk()</code> call within your
<code>walken_commit_walk()</code>:</p></div>
<div class="listingblock">
<div class="content">
-<pre><code>static void walken_commit_walk(struct rev_info *rev)
+<pre><code>#include "pretty.h"
+
+...
+
+static void walken_commit_walk(struct rev_info *rev)
{
struct commit *commit;
struct strbuf prettybuf = STRBUF_INIT;
@@ -1568,7 +1574,11 @@ reachable objects are walked in order to populate the list.</p></div>
<div class="paragraph"><p>First, add the <code>struct oidset</code> and related items we will use to iterate it:</p></div>
<div class="listingblock">
<div class="content">
-<pre><code>static void walken_object_walk(
+<pre><code>#include "oidset.h"
+
+...
+
+static void walken_object_walk(
...
struct oidset omitted;
@@ -1616,7 +1626,11 @@ just walks of commits. First, we&#8217;ll make our handlers chattier - modify
go:</p></div>
<div class="listingblock">
<div class="content">
-<pre><code>static void walken_show_commit(struct commit *cmt, void *buf)
+<pre><code>#include "hex.h"
+
+...
+
+static void walken_show_commit(struct commit *cmt, void *buf)
{
trace_printf("commit: %s\n", oid_to_hex(&amp;cmt-&gt;object.oid));
commit_count++;
@@ -1723,7 +1737,7 @@ Changed the display order of the filtered object walk
<div id="footer">
<div id="footer-text">
Last updated
- 2023-06-30 12:48:29 PDT
+ 2023-07-17 11:51:48 PDT
</div>
</div>
</body>