New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix up example code in MyFirstObjectWalk tutorial #1063
fix up example code in MyFirstObjectWalk tutorial #1063
Conversation
Welcome to GitGitGadgetHi @john-cai, and welcome to GitGitGadget, the GitHub App to send patch series to the Git mailing list from GitHub Pull Requests. Please make sure that your Pull Request has a good description, as it will be used as cover letter. Also, it is a good idea to review the commit messages one last time, as the Git project expects them in a quite specific form:
It is in general a good idea to await the automated test ("Checks") in this Pull Request before contributing the patches, e.g. to avoid trivial issues such as unportable code. Contributing the patchesBefore you can contribute the patches, your GitHub username needs to be added to the list of permitted users. Any already-permitted user can do that, by adding a comment to your PR of the form Both the person who commented An alternative is the channel
Once on the list of permitted usernames, you can contribute the patches to the Git mailing list by adding a PR comment If you want to see what email(s) would be sent for a After you submit, GitGitGadget will respond with another comment that contains the link to the cover letter mail in the Git mailing list archive. Please make sure to monitor the discussion in that thread and to address comments and suggestions (while the comments and suggestions will be mirrored into the PR by GitGitGadget, you will still want to reply via mail). If you do not want to subscribe to the Git mailing list just to be able to respond to a mail, you can download the mbox from the Git mailing list archive (click the curl -g --user "<EMailAddress>:<Password>" \
--url "imaps://imap.gmail.com/INBOX" -T /path/to/raw.txt To iterate on your change, i.e. send a revised patch or patch series, you will first want to (force-)push to the same branch. You probably also want to modify your Pull Request description (or title). It is a good idea to summarize the revision by adding something like this to the cover letter (read: by editing the first comment on the PR, i.e. the PR description):
To send a new iteration, just add another PR comment with the contents: Need help?New contributors who want advice are encouraged to join git-mentoring@googlegroups.com, where volunteers who regularly contribute to Git are willing to answer newbie questions, give advice, or otherwise provide mentoring to interested contributors. You must join in order to post or view messages, but anyone can join. You may also be able to find help in real time in the developer IRC channel, |
There is an issue in commit 13c8383: |
/allow |
User john-cai is now allowed to use GitGitGadget. |
e4c86fd
to
83634bd
Compare
/preview |
Preview email sent as pull.1063.git.1634787278370.gitgitgadget@gmail.com |
efe1703
to
33cd9b2
Compare
/submit |
Submitted as pull.1063.git.1635343531.gitgitgadget@gmail.com To fetch this version into
To fetch this version to local tag
|
@@ -65,7 +65,7 @@ int cmd_walken(int argc, const char **argv, const char *prefix) | |||
const char * const walken_usage[] = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On the Git mailing list, Eric Sunshine wrote (reply to this):
On Wed, Oct 27, 2021 at 10:05 AM John Cai via GitGitGadget
<gitgitgadget@gmail.com> wrote:
> docs: fix places that break compliation in MyFirstObjectWalk
s/compliation/compilation/
> Two errors in the example code caused compilation failures due to
> a missing semi-colon as well as initialization with an empty struct.
> This commit fixes that to make the MyFirstObjectWalk tutorial easier to
> follow.
s/semi-colon/semicolon/ would also be appropriate for the rest of the
project (but not terribly important in a commit message).
> Signed-off-by: John Cai <johncai86@gmail.com>
The patch itself makes perfect sense. Thanks.
User |
Documentation/MyFirstObjectWalk.txt
Outdated
@@ -57,15 +57,20 @@ command). So we will send our debug output to `trace_printf()` instead. When | |||
running, enable trace output by setting the environment variable `GIT_TRACE`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On the Git mailing list, Eric Sunshine wrote (reply to this):
On Wed, Oct 27, 2021 at 10:05 AM John Cai via GitGitGadget
<gitgitgadget@gmail.com> wrote:
> In several places, headers need to be included or else the code won't
> compile. Since this is the first object walk, it would be nice to
> include them in the tutorial to make it easier to follow.
>
> Signed-off-by: John Cai <johncai86@gmail.com>
> ---
> diff --git a/Documentation/MyFirstObjectWalk.txt b/Documentation/MyFirstObjectWalk.txt
> @@ -57,9 +57,14 @@ command). So we will send our debug output to `trace_printf()` instead. When
> Add usage text and `-h` handling, like all subcommands should consistently do
> -(our test suite will notice and complain if you fail to do so).
> +(our test suite will notice and complain if you fail to do so). We'll need to include
> +the "parse-options.h" header.
Makes sense, but we should probably typeset these consistently with
backticks rather than double quotes...
> @@ -195,9 +200,13 @@ Similarly to the default values, we don't have anything to do here yet
> -Add a new function to `builtin/walken.c`:
> +Add a new function to `builtin/walken.c`. We'll also need to include the "config.h" header:
... just as `builtin/walken.c` is typeset with backticks (as are other
pathnames in this document).
> @@ -229,8 +238,14 @@ typically done by calling `repo_init_revisions()` with the repository you intend
> -Add the `struct rev_info` and the `repo_init_revisions()` call:
> +Add the `struct rev_info` and the `repo_init_revisions()` call. We'll also need to include
> +the "revision.h" header:
And so on through the remainder of the patch.
Thanks.
User |
Documentation/MyFirstObjectWalk.txt
Outdated
@@ -57,15 +57,20 @@ command). So we will send our debug output to `trace_printf()` instead. When | |||
running, enable trace output by setting the environment variable `GIT_TRACE`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On the Git mailing list, Junio C Hamano wrote (reply to this):
"John Cai via GitGitGadget" <gitgitgadget@gmail.com> writes:
> Add usage text and `-h` handling, like all subcommands should consistently do
> -(our test suite will notice and complain if you fail to do so).
> +(our test suite will notice and complain if you fail to do so). We'll need to include
> +the "parse-options.h" header.
OK, but wrap this overlong line. All the lines updated by this
patch, except the one in the last hunk, have become overly long.
[jc: cc'ed the primary author of the document to sanity checking]
Thanks.
>
> ----
> +#include "parse-options.h"
> +
> +...
> +
> int cmd_walken(int argc, const char **argv, const char *prefix)
> {
> const char * const walken_usage[] = {
> @@ -195,9 +200,13 @@ Similarly to the default values, we don't have anything to do here yet
> ourselves; however, we should call `git_default_config()` if we aren't calling
> any other existing config callbacks.
>
> -Add a new function to `builtin/walken.c`:
> +Add a new function to `builtin/walken.c`. We'll also need to include the "config.h" header:
>
> ----
> +#include "config.h"
> +
> +...
> +
> static int git_walken_config(const char *var, const char *value, void *cb)
> {
> /*
> @@ -229,8 +238,14 @@ typically done by calling `repo_init_revisions()` with the repository you intend
> to target, as well as the `prefix` argument of `cmd_walken` and your `rev_info`
> struct.
>
> -Add the `struct rev_info` and the `repo_init_revisions()` call:
> +Add the `struct rev_info` and the `repo_init_revisions()` call. We'll also need to include
> +the "revision.h" header:
> +
> ----
> +#include "revision.h"
> +
> +...
> +
> int cmd_walken(int argc, const char **argv, const char *prefix)
> {
> /* This can go wherever you like in your declarations.*/
> @@ -624,9 +639,14 @@ static void walken_object_walk(struct rev_info *rev)
> ----
>
> Let's start by calling just the unfiltered walk and reporting our counts.
> -Complete your implementation of `walken_object_walk()`:
> +Complete your implementation of `walken_object_walk()`. We'll also need to
> +include the "list-objects.h" header.
>
> ----
> +#include "list-objects.h"
> +
> +...
> +
> traverse_commit_list(rev, walken_show_commit, walken_show_object, NULL);
>
> printf("commits %d\nblobs %d\ntags %d\ntrees %d\n", commit_count,
8561388
to
7268f00
Compare
/submit |
Submitted as pull.1063.v2.git.1635530296.gitgitgadget@gmail.com To fetch this version into
To fetch this version to local tag
|
@@ -58,14 +58,15 @@ running, enable trace output by setting the environment variable `GIT_TRACE`. | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On the Git mailing list, Eric Sunshine wrote (reply to this):
On Fri, Oct 29, 2021 at 1:58 PM John Cai via GitGitGadget
<gitgitgadget@gmail.com> wrote:
> Two errors in the example code caused compilation failures due to
> a missing semicolon as well as initialization with an empty struct.
> This commit fixes that to make the MyFirstObjectWalk tutorial easier to
> follow.
>
> Signed-off-by: John Cai <johncai86@gmail.com>
> ---
> diff --git a/Documentation/MyFirstObjectWalk.txt b/Documentation/MyFirstObjectWalk.txt
> @@ -58,6 +58,7 @@ running, enable trace output by setting the environment variable `GIT_TRACE`.
> Add usage text and `-h` handling, like all subcommands should consistently do
> (our test suite will notice and complain if you fail to do so).
> +We'll need to include the `parse-options.h` header.
It seems like this change belongs in patch [2/2].
> @@ -65,7 +66,7 @@ int cmd_walken(int argc, const char **argv, const char *prefix)
> const char * const walken_usage[] = {
> N_("git walken"),
> NULL,
> - }
> + };
Whereas, this change correctly resides in patch [1/2].
> struct option options[] = {
> OPT_END()
> };
> @@ -195,7 +196,8 @@ Similarly to the default values, we don't have anything to do here yet
> ourselves; however, we should call `git_default_config()` if we aren't calling
> any other existing config callbacks.
>
> -Add a new function to `builtin/walken.c`:
> +Add a new function to `builtin/walken.c`.
> +We'll also need to include the `config.h` header:
Should be in patch [2/2].
> @@ -229,7 +231,9 @@ typically done by calling `repo_init_revisions()` with the repository you intend
> to target, as well as the `prefix` argument of `cmd_walken` and your `rev_info`
> struct.
>
> -Add the `struct rev_info` and the `repo_init_revisions()` call:
> +Add the `struct rev_info` and the `repo_init_revisions()` call.
> +We'll also need to include the `revision.h` header:
Patch [2/2].
> @@ -624,7 +628,8 @@ static void walken_object_walk(struct rev_info *rev)
> Let's start by calling just the unfiltered walk and reporting our counts.
> -Complete your implementation of `walken_object_walk()`:
> +Complete your implementation of `walken_object_walk()`.
> +We'll also need to include the `list-objects.h` header.
Also patch [2/2].
> @@ -697,7 +702,7 @@ First, we'll need to `#include "list-objects-filter-options.h"` and set up the
> static void walken_object_walk(struct rev_info *rev)
> {
> - struct list_objects_filter_options filter_options = {};
> + struct list_objects_filter_options filter_options = { 0 };
Good, this change belongs here in patch [1/2].
Two errors in the example code caused compilation failures due to a missing semicolon as well as initialization with an empty struct. This commit fixes that to make the MyFirstObjectWalk tutorial easier to follow. Signed-off-by: John Cai <johncai86@gmail.com>
In several places, headers need to be included or else the code won't compile. Since this is the first object walk, it would be nice to include them in the tutorial to make it easier to follow. Signed-off-by: John Cai <johncai86@gmail.com>
7268f00
to
1535671
Compare
/preview |
This patch series was integrated into seen via git@7fa2d61. |
This patch series was integrated into seen via git@5cdd9e0. |
There was a status update in the "Cooking" section about the branch Doc update. Will merge to 'next'? |
This patch series was integrated into seen via git@113b16f. |
This patch series was integrated into seen via git@83edef6. |
This patch series was integrated into seen via git@0015c4b. |
This patch series was integrated into seen via git@44a8058. |
This patch series was integrated into seen via git@d1b7fa7. |
This patch series was integrated into seen via git@261bf12. |
This patch series was integrated into seen via git@7953802. |
There was a status update in the "Cooking" section about the branch Doc update. Will merge to 'next'. |
This patch series was integrated into seen via git@3f5e8e5. |
There was a status update in the "Cooking" section about the branch Doc update. Will merge to 'next'. |
This patch series was integrated into seen via git@5ca9c29. |
This patch series was integrated into seen via git@e9b8a12. |
This patch series was integrated into next via git@43a5c1e. |
This patch series was integrated into seen via git@c6f1dc5. |
There was a status update in the "Cooking" section about the branch Doc update. Will merge to 'master'. source: <pull.1063.v3.git.1635537163.gitgitgadget@gmail.com> |
This patch series was integrated into seen via git@fbd370a. |
This patch series was integrated into seen via git@95375b0. |
There was a status update in the "Cooking" section about the branch Doc update. Will merge to 'master'. source: <pull.1063.v3.git.1635537163.gitgitgadget@gmail.com> |
This patch series was integrated into seen via git@8ca859b. |
There was a status update in the "Graduated to 'master'" section about the branch Doc update. source: <pull.1063.v3.git.1635537163.gitgitgadget@gmail.com> |
This patch series was integrated into seen via git@3d2dce1. |
This patch series was integrated into next via git@3d2dce1. |
This patch series was integrated into master via git@3d2dce1. |
Closed via 3d2dce1. |
MyFirstObjectWalk tutorial was missing directives to add some header
files. Also fixes some initialization code.
Changes since v1:
Changes since v2:
cc: Eric Sunshine sunshine@sunshineco.com