From patchwork Wed Oct 27 14:05:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Cai X-Patchwork-Id: 12587409 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E8347C433FE for ; Wed, 27 Oct 2021 14:05:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C9A2560F6F for ; Wed, 27 Oct 2021 14:05:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242395AbhJ0OIC (ORCPT ); Wed, 27 Oct 2021 10:08:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38386 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242388AbhJ0OIA (ORCPT ); Wed, 27 Oct 2021 10:08:00 -0400 Received: from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com [IPv6:2a00:1450:4864:20::42a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 553FBC061745 for ; Wed, 27 Oct 2021 07:05:34 -0700 (PDT) Received: by mail-wr1-x42a.google.com with SMTP id k7so4322130wrd.13 for ; Wed, 27 Oct 2021 07:05:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=vF4oUcGtBQ7rtIPiKXj0P5iXeyH657HIik8HUHMPXB8=; b=NTkyxvV/pkE1sRB46yKsWbRMvMVpRGs3CZqCmKotzg3M/LNY46xvtBAeMkFIG+fL7Z GacXz3H4F6dr6EuQ4P6Qd1smrhybRYWIveFKLcilSDfurbcO2dpY3VPILia2QupIt3ts fMTT/d6Q8NAsVOYAOqqji2rMPUpQUZrWNOf6U5D6LEimdnD7cOVM6mZW1XvXkHMH1AKb AJF0SFuQQzIOOG03iByBaJhEKBZ9ugV0Q+aw2QH/1jgOCiTXfqJhN9YbY/QUsuMEBejc 43gV3y0QqclH6txV2TsECBElXADUmzp53SK0X3uRCr19lukMXs68BBkoSAu6j/4mvZOF B9cQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=vF4oUcGtBQ7rtIPiKXj0P5iXeyH657HIik8HUHMPXB8=; b=LZuJhQ4X1K41fFCUF+xuDslTMYrgLfimud9D/J1m7Fll8egStdXmgb83KfkwjSVR5E SnGKNCjgfPgjDIZQz26q9yevX4UZrxFPuyFsf6m35mCrKr4CgPlU7bQC6ZU9sry0ZkZf CV1vPKe79ltmmw7HWOEuCIbP7Htt2KzlgRgO+ZyRQCNxreMVoylgm/P2Nz9oDdfhKbit TqKCAXxcvIHLWpwMwbozFKK+yp2jKyQOLdMBvc9HZQblVwSnc9NZOpFTEDqyQr9sP4Jk 5VBX27niSlYvoPwWLsTT01wmpBR/TrmW6ApNaS20iO7V1ZfxIidbm9QjtK4hZ9ogiKoa ArUw== X-Gm-Message-State: AOAM5329+f6X096AazP4YCjAo8e7iO6d/UVP6PFI+blBkS+pgOWFumXl JTMcMCXQn5lG6UcYRR3tdJKspPApj1I= X-Google-Smtp-Source: ABdhPJx4+Js1BVPWYWx/dSqNmsalxJjV7P4FjXEMTbQhDJJDO8lwHy+n/ifc9hZsJqCf3fOIm4fb1Q== X-Received: by 2002:a5d:5287:: with SMTP id c7mr42236158wrv.236.1635343533014; Wed, 27 Oct 2021 07:05:33 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id n68sm3477096wmn.13.2021.10.27.07.05.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Oct 2021 07:05:32 -0700 (PDT) Message-Id: <6c95f11f110be63dafa10dde5067b6e7eeff1a53.1635343531.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Wed, 27 Oct 2021 14:05:30 +0000 Subject: [PATCH 1/2] docs: fix places that break compliation in MyFirstObjectWalk Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: John Cai , John Cai Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: John Cai From: John Cai 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. Signed-off-by: John Cai --- Documentation/MyFirstObjectWalk.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Documentation/MyFirstObjectWalk.txt b/Documentation/MyFirstObjectWalk.txt index 45eb84d8b48..bf0a7c1f766 100644 --- a/Documentation/MyFirstObjectWalk.txt +++ b/Documentation/MyFirstObjectWalk.txt @@ -65,7 +65,7 @@ int cmd_walken(int argc, const char **argv, const char *prefix) const char * const walken_usage[] = { N_("git walken"), NULL, - } + }; struct option options[] = { OPT_END() }; @@ -697,7 +697,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 }; ... ---- From patchwork Wed Oct 27 14:05:31 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Cai X-Patchwork-Id: 12587411 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A0BD2C433F5 for ; Wed, 27 Oct 2021 14:05:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7216760F9B for ; Wed, 27 Oct 2021 14:05:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242397AbhJ0OID (ORCPT ); Wed, 27 Oct 2021 10:08:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38390 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242390AbhJ0OIA (ORCPT ); Wed, 27 Oct 2021 10:08:00 -0400 Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0C75AC061767 for ; Wed, 27 Oct 2021 07:05:35 -0700 (PDT) Received: by mail-wm1-x32e.google.com with SMTP id v127so2724273wme.5 for ; Wed, 27 Oct 2021 07:05:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=lPtZCIP3Tmd+3Ce5USCL4gbojw2Uo3bHRPnJQQ3xCYM=; b=oM5D+djz9eCwaOKRs+LN8KNyha03bqL1cuikqfVWN5i4V86vuJPB+j5ZH+YB8X52My uvux4HaIZGJHHIHt9LhuXlKsRneIn+UANYf7wvC2xI4x/x4MFDXdtSvel9kDPe9i+b5r Wn0BMhd7eQC1IE25jO+sWf4r5gobxRF51v6o20EPRknINOG64JGiNqXO65QSIJm+d9zE oXRGBEbuPKE2FZJF25dZIDU4McAz1OwzdzoldWypOvMszWZWH4LdbvylHacR/PnYHh4V xQ1XLu94tT2zGCfPiLhU1bmxVbS/mNAZDIKo6fmyPEMiZnVS010xGEWX11U302Z8BJZA hkHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=lPtZCIP3Tmd+3Ce5USCL4gbojw2Uo3bHRPnJQQ3xCYM=; b=SuX2/tHtmpzfHEVooGCQfp+y6yeej53CyESjAKnp1d5Xni8EW4zRnSRPMB0h0TO/xd TRnWNbnhPxOMpebzcskhHIaylzC7uGbdONCnzucXa4D7JcjjNHRhYyUo8Iq08QosGT7d TFAAk2r0vP55HJHwXTlpH2R1AndbH/hnyhFiKtJOPkfzG7Qbomtt8My3lVe0aDnQ0APl Nb6LsGmH9c0X5FQMmBD8E/JLPl5cF4oz0CDnI9FIX9mSj1yDW54b2UG/+dLc88qsDU8v LxCpUyUfnTkEFsMtVtbDKfkadQGAqxKwNyg1h1qdJCcF1s0+b2fBpYgfwDFatSOcC97U SlSg== X-Gm-Message-State: AOAM530f9wYOWMrIeXJCpeMuMBxyZ2hHlIRdZGt4QKPndB5UPSyGQHUM 8YfEJydcJSbtW8/QRQi6hchoo76l+Xw= X-Google-Smtp-Source: ABdhPJyPM+c2b6AbSk4bLfEKjWklRCaZLP6Mz4IITa+YBCMfFw3T9qgQJfK/SdJQrG7xpJR/lliubQ== X-Received: by 2002:a7b:c5d9:: with SMTP id n25mr6031280wmk.139.1635343533629; Wed, 27 Oct 2021 07:05:33 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id m31sm3493729wms.25.2021.10.27.07.05.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Oct 2021 07:05:33 -0700 (PDT) Message-Id: <33cd9b2e8a675bf79132d312da8b7d8f4a2b84a3.1635343531.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Wed, 27 Oct 2021 14:05:31 +0000 Subject: [PATCH 2/2] docs: add headers in MyFirstObjectWalk Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: John Cai , John Cai Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: John Cai From: John Cai 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 --- Documentation/MyFirstObjectWalk.txt | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/Documentation/MyFirstObjectWalk.txt b/Documentation/MyFirstObjectWalk.txt index bf0a7c1f766..ba8cca91b97 100644 --- 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 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). +(our test suite will notice and complain if you fail to do so). We'll need to include +the "parse-options.h" header. ---- +#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,