From patchwork Fri Jun 7 01:07:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emily Shaffer X-Patchwork-Id: 10980629 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8D4FB14B6 for ; Fri, 7 Jun 2019 01:08:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7A49F28AC4 for ; Fri, 7 Jun 2019 01:08:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6D6E428ADD; Fri, 7 Jun 2019 01:08:59 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, USER_IN_DEF_DKIM_WL autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 176EC28AC4 for ; Fri, 7 Jun 2019 01:08:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727087AbfFGBI4 (ORCPT ); Thu, 6 Jun 2019 21:08:56 -0400 Received: from mail-ua1-f73.google.com ([209.85.222.73]:41541 "EHLO mail-ua1-f73.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725784AbfFGBI4 (ORCPT ); Thu, 6 Jun 2019 21:08:56 -0400 Received: by mail-ua1-f73.google.com with SMTP id a29so105797uah.8 for ; Thu, 06 Jun 2019 18:08:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=ezAByRz+Df2EkEWo74xlf1/fJ1g1mXu8fHuaGI964Z0=; b=h9fEj/iAnTCUy1/sCN5ZAWPlHcp8IF+Gvak638FRoFe6nxF8ca4BGhcOCoGCVGNw7V J9M9F2vdqpVvrBjNndXYCCoNgV9N02KZCSALt7coHHx9+HFMrmyZv63xDQhWP4E2KFQB xIgk1RsJ6m/OVQS94XhVa+RERBWM2sEglCFAY2nHtY8BA6MppJII5GRGTyC6YfesOLgo QN4KkZM+hWrIH43/ecTL16Vus+wnuyFgnzrTmJQhRotr+5XhBP75J8XSaEBXoeO6iMAQ XObuhyOj2uqQiUNFQmkh81QpOvNfLxNUTq8sLmiyN+RjFKZTJ8KIXfV3xI+i2yCJ5AdU eHDQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=ezAByRz+Df2EkEWo74xlf1/fJ1g1mXu8fHuaGI964Z0=; b=mDGOd2ya7SHgMpJDUmdS31EOxy8zGEGTRCnoONAN6FF7VEa6FmQspqOsRT1dWT8OEU pKphgnPiNMz9urqcshFeI/qbJD6/QkoSiPvQzIq2z1Lyf5cakjz+xLsUHRrMdmNqri4y aUM2cMSNWu16wE2rAOjabxGjDeLDhe7BGu5EcPYCiM1sLDszGCkCfISQa31WL+kpYe9I n0suJ2jf3PE5O28u0m4X4R1FTObauEoZJ4kkM/dYNEEKyBS5G51s0a3WDc4chRreW4Fa Nn7W/g6cMlca3ErYnlQ6pvk1FnDVfclTD5sv6dj/ncR22lDrWq2/Aitvj1XsE2tMlOIk xkjg== X-Gm-Message-State: APjAAAX39N/7+RwdvQL3Cp8N5e/fG/FgOIAkyo6K2AAhGyNegjgmf0pc V18ktq7NL0cyW1LqgsD8zJXz6oa8nzAb0ZG5m/eqDWBUzOtKbCIC1qD1D24buoCfZcvKSTdSlhF FzgKpETwdLLzPR0vNxIaezCva0L+oaDdQQekgIFMB2sNOxBQ0HUhTzoW+nX1RYM1Wm6zoT7FU9g == X-Google-Smtp-Source: APXvYqysB+/BS8BlKxWmqPxtz09olHql38g2j7xfp0wrcsVtqYhiz6hORXq2yM07SWFl7h7pnH7j9Po47+pqbfaB6bA= X-Received: by 2002:ab0:60d0:: with SMTP id g16mr24734886uam.85.1559869735754; Thu, 06 Jun 2019 18:08:55 -0700 (PDT) Date: Thu, 6 Jun 2019 18:07:59 -0700 In-Reply-To: <20190607010811.52944-1-emilyshaffer@google.com> Message-Id: <20190607010811.52944-2-emilyshaffer@google.com> Mime-Version: 1.0 References: <20190607010708.46654-1-emilyshaffer@google.com> <20190607010811.52944-1-emilyshaffer@google.com> X-Mailer: git-send-email 2.22.0.rc1.311.g5d7573a151-goog Subject: [RFC PATCH 01/13] walken: add infrastructure for revwalk demo From: Emily Shaffer To: git@vger.kernel.org Cc: Emily Shaffer Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Begin to add scaffolding for `git walken`, a toy command which we will teach to perform a number of revision walks, in order to demonstrate the mechanics of revision walking for developers new to the Git project. This commit is the beginning of an educational series which correspond to the tutorial in Documentation/MyFirstRevWalk.txt. Signed-off-by: Emily Shaffer --- Makefile | 1 + builtin.h | 1 + builtin/walken.c | 14 ++++++++++++++ 3 files changed, 16 insertions(+) create mode 100644 builtin/walken.c diff --git a/Makefile b/Makefile index 8a7e235352..a25d46c7a3 100644 --- a/Makefile +++ b/Makefile @@ -1143,6 +1143,7 @@ BUILTIN_OBJS += builtin/var.o BUILTIN_OBJS += builtin/verify-commit.o BUILTIN_OBJS += builtin/verify-pack.o BUILTIN_OBJS += builtin/verify-tag.o +BUILTIN_OBJS += builtin/walken.o BUILTIN_OBJS += builtin/worktree.o BUILTIN_OBJS += builtin/write-tree.o diff --git a/builtin.h b/builtin.h index ec7e0954c4..c919736c36 100644 --- a/builtin.h +++ b/builtin.h @@ -242,6 +242,7 @@ int cmd_var(int argc, const char **argv, const char *prefix); int cmd_verify_commit(int argc, const char **argv, const char *prefix); int cmd_verify_tag(int argc, const char **argv, const char *prefix); int cmd_version(int argc, const char **argv, const char *prefix); +int cmd_walken(int argc, const char **argv, const char *prefix); int cmd_whatchanged(int argc, const char **argv, const char *prefix); int cmd_worktree(int argc, const char **argv, const char *prefix); int cmd_write_tree(int argc, const char **argv, const char *prefix); diff --git a/builtin/walken.c b/builtin/walken.c new file mode 100644 index 0000000000..bfeaa5188d --- /dev/null +++ b/builtin/walken.c @@ -0,0 +1,14 @@ +/* + * "git walken" + * + * Part of the "My First Revision Walk" tutorial. + */ + +#include +#include "builtin.h" + +int cmd_walken(int argc, const char **argv, const char *prefix) +{ + printf(_("cmd_walken incoming...\n")); + return 0; +} From patchwork Fri Jun 7 01:08:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emily Shaffer X-Patchwork-Id: 10980631 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 688B892A for ; Fri, 7 Jun 2019 01:09:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 56ACA28AC4 for ; Fri, 7 Jun 2019 01:09:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4B46128ADD; Fri, 7 Jun 2019 01:09:02 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, USER_IN_DEF_DKIM_WL autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F04E128AC4 for ; Fri, 7 Jun 2019 01:09:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727211AbfFGBI7 (ORCPT ); Thu, 6 Jun 2019 21:08:59 -0400 Received: from mail-ot1-f74.google.com ([209.85.210.74]:49766 "EHLO mail-ot1-f74.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725784AbfFGBI7 (ORCPT ); Thu, 6 Jun 2019 21:08:59 -0400 Received: by mail-ot1-f74.google.com with SMTP id l7so192922otj.16 for ; Thu, 06 Jun 2019 18:08:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=ZngRkZ/rw04VhrmFATe317dWnDm4b+I+GMREhiidOPA=; b=PWCNFTo+/MDv/FETQBMPg1k27bhH8LW+jtGc9+4VvOFHh+dInLWaXGL/n98J9kAAWB IwvQB2oMEd4vFS+1msNvsb/6fbOqiqqWq8Aq1Xi3SbiKacTtav2V80shb6yRX8sCi0WN W5FMnwy84q45dtzyFJbQdgODJjFDmvY8TQ0LS8FZ6kw5n6wulYy8Yo33hLggpjHhp94u UWjiDfuuYuXOgXwNVoFM2YjGQYdLiQLeyUonpq6jdzcclDDS+FzCY1xwUS9HVUdFtM4l Vw+7ibEdyWJRCrrYaQ8LLPQhzQT/W8zCtf1EyPmdMlwdAXHkJ3Uhr8CsaVVExJgpxZ2n l7XQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=ZngRkZ/rw04VhrmFATe317dWnDm4b+I+GMREhiidOPA=; b=tENs0XPClHVi7sQMoO67YjuPmQiI3Wi4szkX5V3vA6BMLaIh8cPx2pG6Hhwb17FF9G mawmm57Zgug8oG3swRYJZC9a8oM8huWblayJvzMvn2S6VOHQs1nsi7RH5TARxLXDtdZv Iq5InWkPV3I5endGXO0y03ExxjUruTz98YzsSjzSJVmpwMUDMgKX0IbVyanharZl0Yzt TbWE62gI1LZs/IHNCeApsv2vtG97zNFbpTU1kfHcYrpGqyFSxhdBjapHb5D/xFb+dZ74 mduag7l8m7tZArPOixHUyFeEbqoCLj0KJtNvnghVqlTFgmdejTiZHev8/tnjsV2jU1+T LNbQ== X-Gm-Message-State: APjAAAUhuTS0BZhPu1W/h/s5VwcHsPaAblT2zp+di2+QVIwSr+43Xh2K pOAG0XH+A3n3Rl5NL4tOsxZHhcuEz4oUXRyTX6YYnDZR0MIujDySVuis4ZVdExlDGzj5jfn1Q4B lHb0Z2gTSOOVkQxgM3vB0o3SdXYaR4iwKjroNqjlhnt7wxUwjGIS7MXTT70yqwRTKQvkiXnCZjA == X-Google-Smtp-Source: APXvYqwTwMbOtCaw6F/qW0dU5+c5V6/GMEe4SU+sv4xj2oOVrChUTY47+omrZlPDxZJMmTtF/qNCZZ30t3ayK9RuNxw= X-Received: by 2002:aca:4e16:: with SMTP id c22mr2075840oib.161.1559869738064; Thu, 06 Jun 2019 18:08:58 -0700 (PDT) Date: Thu, 6 Jun 2019 18:08:00 -0700 In-Reply-To: <20190607010811.52944-1-emilyshaffer@google.com> Message-Id: <20190607010811.52944-3-emilyshaffer@google.com> Mime-Version: 1.0 References: <20190607010708.46654-1-emilyshaffer@google.com> <20190607010811.52944-1-emilyshaffer@google.com> X-Mailer: git-send-email 2.22.0.rc1.311.g5d7573a151-goog Subject: [RFC PATCH 02/13] walken: add usage to enable -h From: Emily Shaffer To: git@vger.kernel.org Cc: Emily Shaffer Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP One requirement of the Git test suite is that all commands support '-h', which is captured by parse_options(). In order to support this flag, add a short usage text to walken.c and invoke parse_options(). With this change, we can now add cmd_walken to the builtins set and expect tests to pass, so we'll do so - cmd_walken is now open for business. Signed-off-by: Emily Shaffer --- builtin/walken.c | 12 ++++++++++++ git.c | 1 + 2 files changed, 13 insertions(+) diff --git a/builtin/walken.c b/builtin/walken.c index bfeaa5188d..5ae7c7d93f 100644 --- a/builtin/walken.c +++ b/builtin/walken.c @@ -6,9 +6,21 @@ #include #include "builtin.h" +#include "parse-options.h" + +static const char * const walken_usage[] = { + N_("git walken"), + NULL, +}; int cmd_walken(int argc, const char **argv, const char *prefix) { + struct option options[] = { + OPT_END() + }; + + argc = parse_options(argc, argv, prefix, options, walken_usage, 0); + printf(_("cmd_walken incoming...\n")); return 0; } diff --git a/git.c b/git.c index 1bf9c94550..209c42836f 100644 --- a/git.c +++ b/git.c @@ -600,6 +600,7 @@ static struct cmd_struct commands[] = { { "verify-pack", cmd_verify_pack }, { "verify-tag", cmd_verify_tag, RUN_SETUP }, { "version", cmd_version }, + { "walken", cmd_walken, RUN_SETUP }, { "whatchanged", cmd_whatchanged, RUN_SETUP }, { "worktree", cmd_worktree, RUN_SETUP | NO_PARSEOPT }, { "write-tree", cmd_write_tree, RUN_SETUP }, From patchwork Fri Jun 7 01:08:01 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emily Shaffer X-Patchwork-Id: 10980633 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6DB8D92A for ; Fri, 7 Jun 2019 01:09:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5C31728AC4 for ; Fri, 7 Jun 2019 01:09:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 50FBD28ADD; Fri, 7 Jun 2019 01:09:04 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, USER_IN_DEF_DKIM_WL autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EA17028AC4 for ; Fri, 7 Jun 2019 01:09:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727336AbfFGBJB (ORCPT ); Thu, 6 Jun 2019 21:09:01 -0400 Received: from mail-qk1-f202.google.com ([209.85.222.202]:56218 "EHLO mail-qk1-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725784AbfFGBJB (ORCPT ); Thu, 6 Jun 2019 21:09:01 -0400 Received: by mail-qk1-f202.google.com with SMTP id i4so229773qkk.22 for ; Thu, 06 Jun 2019 18:09:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=OBydD6eL9VmS3BzqiNqy5emtEyKf3i9DZ26gosDHIaE=; b=jyOp+zzZ+E/7n5ldjXnh0aiDUh1YfX2XuCkt6XgCQiZqM54EiX0cXBDtx4FLLu2DqM sV6hBAckmGBm+9Km64fkeEwCxDd0r2k7Va4fWrPBQ5+ihIGmd5ZUZPsIuzLX2Jif8yJ7 f3S1eQjoL50VN8bHdNULwyMbtV+KmFH+edWIm2UjwMr8vjss+OV6+tAaTsg4Hlp2ad6n 8hT4cPTjSWkzdsW5OKoaO+YQAmLFR4QVcr0opjjRGzC9cgCAz/Sl4soU54G1cjwKg+Qk rUNFxqJ5LF1ALjnXa5zq+lKwcEe3TTI2sDHMpz1DXHQl4kkdMrzW4RJfYIZDM9oonzp+ yZ0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=OBydD6eL9VmS3BzqiNqy5emtEyKf3i9DZ26gosDHIaE=; b=M9ieAY+EAUHCTJ92ZbzScp/3mRLGKKiNyZNqzhHaNrDK/4P5dKj75w0Z7ZqeeIgUer INEvGjyFw+fFixBODLbvJLA3AfQprj2VvYhnE1u/+QvWuhaKVhnrIPd4B0vm1BD7LsOh zRnyjw3hFJN/JPwyixr/z0E0t3NqvBcuhe8SImrVtr/TTn43Y8E5r5Qu53+hc+8oegUR RP6vVgqkaRfCjm6rVwGqFbEFVo0TPq3hM4axETjFhTbaRbWiGCp9z74Ov068UiO/OoxP KBWugYYL+DTcOoppXhk1MdLlCIWUD7QM0tJWQV55Ohp61P05XL0DJ51JLWX3cPN0K8kN JPog== X-Gm-Message-State: APjAAAVUFCasIUP/UVYuFRS8uy57eCQoaC8BMZ5wQ6UIZ9U1DyHACJkU mel0RH8tO/HlbXPTDFPlzYjA25gQBAE3uscTk3m5G/wOxl17Ss6StHfzhy/rx0UcYhE6OXOsJ3Q d3b4GJ82uz4uyFBNJHnsbV2TgkZxzPzvkFvrdOI2uuvTaN+b/SU0CeD5BjjHvQesFxutR9g7Rew == X-Google-Smtp-Source: APXvYqzW+7ReCIdW3NW5Sqz7VFFDVwTHXCcBusSKmZSWVdTvo5vQ5b6Nquz3ehORrzSGjOr+F+RpACaROfXPYnBAj4U= X-Received: by 2002:ac8:94d:: with SMTP id z13mr15443984qth.137.1559869740616; Thu, 06 Jun 2019 18:09:00 -0700 (PDT) Date: Thu, 6 Jun 2019 18:08:01 -0700 In-Reply-To: <20190607010811.52944-1-emilyshaffer@google.com> Message-Id: <20190607010811.52944-4-emilyshaffer@google.com> Mime-Version: 1.0 References: <20190607010708.46654-1-emilyshaffer@google.com> <20190607010811.52944-1-emilyshaffer@google.com> X-Mailer: git-send-email 2.22.0.rc1.311.g5d7573a151-goog Subject: [RFC PATCH 03/13] walken: add placeholder to initialize defaults From: Emily Shaffer To: git@vger.kernel.org Cc: Emily Shaffer Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Eventually, we will want a good place to initialize default variables for use during our revision walk(s) in `git walken`. For now, there's nothing to do here, but let's add the scaffolding so that it's easy to tell where to put the setup later on. Signed-off-by: Emily Shaffer --- builtin/walken.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/builtin/walken.c b/builtin/walken.c index 5ae7c7d93f..dcee906556 100644 --- a/builtin/walken.c +++ b/builtin/walken.c @@ -13,6 +13,18 @@ static const char * const walken_usage[] = { NULL, }; +/* + * Within init_walken_defaults() we can call into other useful defaults to set + * in the global scope or on the_repository. It's okay to borrow from other + * functions which are doing something relatively similar to yours. + */ +static void init_walken_defaults(void) +{ + /* We don't actually need the same components `git log` does; leave this + * empty for now. + */ +} + int cmd_walken(int argc, const char **argv, const char *prefix) { struct option options[] = { @@ -21,6 +33,7 @@ int cmd_walken(int argc, const char **argv, const char *prefix) argc = parse_options(argc, argv, prefix, options, walken_usage, 0); + init_walken_defaults(); printf(_("cmd_walken incoming...\n")); return 0; } From patchwork Fri Jun 7 01:08:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emily Shaffer X-Patchwork-Id: 10980635 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id EFB8714B6 for ; Fri, 7 Jun 2019 01:09:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DCC1B28AC4 for ; Fri, 7 Jun 2019 01:09:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D17A728ADD; Fri, 7 Jun 2019 01:09:05 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, USER_IN_DEF_DKIM_WL autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 793B728AC4 for ; Fri, 7 Jun 2019 01:09:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727379AbfFGBJE (ORCPT ); Thu, 6 Jun 2019 21:09:04 -0400 Received: from mail-ot1-f73.google.com ([209.85.210.73]:51342 "EHLO mail-ot1-f73.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725784AbfFGBJD (ORCPT ); Thu, 6 Jun 2019 21:09:03 -0400 Received: by mail-ot1-f73.google.com with SMTP id h12so190155otn.18 for ; Thu, 06 Jun 2019 18:09:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=oJIjpnCSpSzYYh21eeU7c2+dddEDozm+4MtuwVQHXZY=; b=RR/rpOBAIvWrpwWO1x9vndZyKelj0s3d/huNZ2mmboZds3qF4qApdMKXS7ndUqsLBs vke8iN1BgaH2/eFf3UD8geDSTnrqWjwujOI+rpElUQk3lC4CI/a5+v8rTtuE9SRY78b1 fxVD/JSQYVltppzIgtK0rZB9eJPJ50KhsZJyONjW+bdWGi1+I1ky5BcVSQ+3saCXEks5 gEGLfqvUEBJmNoaQlE+jdRLjm5YFJXqUruUJIkfrgW23Zecxmzg6+NP9U9dOPEMVe7cb nBD3y9AEu28Gzvs08O2b90zkITm7EKypIboZh5KmCr70/Qjitt0XXRqRqa+vR3Fkv6S/ kyNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=oJIjpnCSpSzYYh21eeU7c2+dddEDozm+4MtuwVQHXZY=; b=odC4mlj9qs3dVpVrmzJrX+HwdrOZaEPKLDz0OfJ725hxYhforWQwSC/H0cvUiTOzCv W0I+uZNh+KwPaYhgjz9ubloGUX5szc8dxcyhwUyxPU7fOAesk1jmYdjuM0waRypewIKb JfwJGIl4rbAYGNMRt2LHzhTfu/4DPAaxeCJyJFkmHtdhlq1qZ/eaNgpCTg3BD7L9xPka ZlLKpgXjQpxcNG+jV7VPMNOhyGBS5gjvr15y39qYo/E2WeKvE2d1swUvm/+zT63bCTNA eRwsp6Uo7e6E6WQu3BnCNv5B6vuW2Xw79NyFrJvc9o7VY8F4nien8ZShvlXyd/m09Rh9 vo4g== X-Gm-Message-State: APjAAAVurvUgfEpigCHRwM4Ujuql0YAWlibu0R6/6BeWcDagVKeYRN6P xqgVyELTvSB/if9c32WAduOHrBmbHRgRqrGgSasaa/hdJOtPj+u/HInyCtsNSEuQ36eX11yJoSv xb4xxbrQg+DSdDCVt2ma67AH6rYfA8u6Ab5NGfjgV4bdbmmDYTIkA/hj3MEb72l3JK+jroI09ew == X-Google-Smtp-Source: APXvYqxFO91p/CaoEvkmuqV8zk4f8Wcw0ELANkxzPdGIk5uR2PkgiN0ziRlOy28dDGcTYXlpnCeM5HBP90m5TtP8mro= X-Received: by 2002:a9d:d17:: with SMTP id 23mr16986097oti.221.1559869742943; Thu, 06 Jun 2019 18:09:02 -0700 (PDT) Date: Thu, 6 Jun 2019 18:08:02 -0700 In-Reply-To: <20190607010811.52944-1-emilyshaffer@google.com> Message-Id: <20190607010811.52944-5-emilyshaffer@google.com> Mime-Version: 1.0 References: <20190607010708.46654-1-emilyshaffer@google.com> <20190607010811.52944-1-emilyshaffer@google.com> X-Mailer: git-send-email 2.22.0.rc1.311.g5d7573a151-goog Subject: [RFC PATCH 04/13] walken: add handler to git_config From: Emily Shaffer To: git@vger.kernel.org Cc: Emily Shaffer Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP For now, we have no configuration options we want to set up for ourselves, but in the future we may need to. At the very least, we should invoke git_default_config() for each config option; we will do so inside of a skeleton config callback so that we know where to add configuration handling later on when we need it. Signed-off-by: Emily Shaffer --- builtin/walken.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/builtin/walken.c b/builtin/walken.c index dcee906556..5d1666a5da 100644 --- a/builtin/walken.c +++ b/builtin/walken.c @@ -6,6 +6,7 @@ #include #include "builtin.h" +#include "config.h" #include "parse-options.h" static const char * const walken_usage[] = { @@ -25,6 +26,28 @@ static void init_walken_defaults(void) */ } +/* + * This method will be called back by git_config(). It is used to gather values + * from the configuration files available to Git. + * + * Each time git_config() finds a configuration file entry, it calls this + * callback. Then, this function should compare it to entries which concern us, + * and make settings changes as necessary. + * + * If we are called with a config setting we care about, we should use one of + * the helpers which exist in config.h to pull out the value for ourselves, i.e. + * git_config_string(...) or git_config_bool(...). + * + * If we don't match anything, we should pass it along to another stakeholder + * who may otherwise care - in log's case, grep, gpg, and diff-ui. For our case, + * we'll ignore everybody else. + */ +static int git_walken_config(const char *var, const char *value, void *cb) +{ + /* For now, let's not bother with anything. */ + return git_default_config(var, value, cb); +} + int cmd_walken(int argc, const char **argv, const char *prefix) { struct option options[] = { @@ -34,6 +57,9 @@ int cmd_walken(int argc, const char **argv, const char *prefix) argc = parse_options(argc, argv, prefix, options, walken_usage, 0); init_walken_defaults(); + + git_config(git_walken_config, NULL); + printf(_("cmd_walken incoming...\n")); return 0; } From patchwork Fri Jun 7 01:08:03 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emily Shaffer X-Patchwork-Id: 10980637 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8A2D314B6 for ; Fri, 7 Jun 2019 01:09:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 77E1628AC4 for ; Fri, 7 Jun 2019 01:09:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6C6EF28ADD; Fri, 7 Jun 2019 01:09:09 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, USER_IN_DEF_DKIM_WL autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 07E0228AC4 for ; Fri, 7 Jun 2019 01:09:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727605AbfFGBJH (ORCPT ); Thu, 6 Jun 2019 21:09:07 -0400 Received: from mail-qk1-f202.google.com ([209.85.222.202]:48872 "EHLO mail-qk1-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725784AbfFGBJH (ORCPT ); Thu, 6 Jun 2019 21:09:07 -0400 Received: by mail-qk1-f202.google.com with SMTP id w184so246531qka.15 for ; Thu, 06 Jun 2019 18:09:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=y4HjGDe3bxCzb0W8Y3JckXMbW1dC2Gj31sx9Q1n1qCg=; b=KorrtD4hT0k0reQHslBXSmwNLIZQlZGKaReHDpAuxUtOckqeCcOQ2ySEDBPojSbVsD DaPsZYQ4YinN7k+Ertg9VPWLo2taAjMuil4S7hzkZbymylyiqmdGZq+nvLy9raQgtqMx tZoPWunxfa3wGPGYuHlQeZFi9mlAQhuXF127ciZkyMrY5nXjhUoPgfaRvEwJQkzclNnW a8uWKckypfGWxMZNnGKe+1M+Ew8ifJThpACBJWG93F2nM6mN3wBW/EFrtZfGlDQU9UoO uZ1IZPo9iK6qpnw0vn92HwkI9zHcDdJZEX8sP9FhZpPT5C6rC67CGy2dMivQ9ZZWnywu LyuA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=y4HjGDe3bxCzb0W8Y3JckXMbW1dC2Gj31sx9Q1n1qCg=; b=pk0n/gKH4Aod/S0W4T+7JTJuiI/N/2Dmz22hISGdEod2PYIVVpOgsp763N7mo3q5BT 8cjznNLi478vFod+z3oELkslKN91HbRFzaCxnmdT9ol+CXiCYJrW1AS/DghD7AOrO9u5 9uM+cR6FOb7yUZ4E00QpWMQLZCpNSoULGqfqU15qYj+L1OdFwqstFIKnyhLmV5zzzcHi pKQwLjqC7exn7wyXRSqGhW5Gu2I29wyeAttyVW2XuMOCIOLsq2o2iKy4ZHRsPw9NhJgD hD0o4a+1XbLlvYs6xdkiqY30vXo9JLpKgygaLfhIjvt544o7rWzRea/ayezOp0xh9gFe h+ew== X-Gm-Message-State: APjAAAXffcihgwRFDTbt+WD5BMDsquyWVuv3SDfnGxTETCedRMDIywh4 GUqVoiOavm7UGQg7TNvYY7ioEq1NwudBjs3sTDAI2Mt1Gh+WVqh3EqtXJTo2vSqKgf9lpoU7zsH OdTzDkj1/Rz6MrR/fuUdX4C+fYvdfdf8p1vX3eYyRQc4n6ami8IomaGMFSzSIkQoEfvcnUy70ZA == X-Google-Smtp-Source: APXvYqyMn9eXPZredAhPY+EI082a0znfbkuJDNim4ssftMjIfxGtltcwb/T4t6qp/mijJ6odwVdBm6VcS8eAkz7X1lY= X-Received: by 2002:ae9:e842:: with SMTP id a63mr40166454qkg.143.1559869746689; Thu, 06 Jun 2019 18:09:06 -0700 (PDT) Date: Thu, 6 Jun 2019 18:08:03 -0700 In-Reply-To: <20190607010811.52944-1-emilyshaffer@google.com> Message-Id: <20190607010811.52944-6-emilyshaffer@google.com> Mime-Version: 1.0 References: <20190607010708.46654-1-emilyshaffer@google.com> <20190607010811.52944-1-emilyshaffer@google.com> X-Mailer: git-send-email 2.22.0.rc1.311.g5d7573a151-goog Subject: [RFC PATCH 05/13] walken: configure rev_info and prepare for walk From: Emily Shaffer To: git@vger.kernel.org Cc: Emily Shaffer Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP `struct rev_info` is what's used by the struct itself. `repo_init_revisions()` initializes the struct; then we need to set it up for the walk we want to perform, which is done in `final_rev_info_setup()`. The most important step here is adding the first object we want to walk to the pending array. Here, we take the easy road and use `add_head_to_pending()`; there is also a way to do it with `setup_revision_opt()` and `setup_revisions()` which we demonstrate but do not use. If we were to forget this step, the walk would do nothing - the pending queue would be checked, determined to be empty, and the walk would terminate immediately. Signed-off-by: Emily Shaffer --- builtin/walken.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/builtin/walken.c b/builtin/walken.c index 5d1666a5da..c101db38c7 100644 --- a/builtin/walken.c +++ b/builtin/walken.c @@ -6,6 +6,7 @@ #include #include "builtin.h" +#include "revision.h" #include "config.h" #include "parse-options.h" @@ -26,6 +27,35 @@ static void init_walken_defaults(void) */ } +/* + * cmd_log calls a second set of init after the repo_init_revisions call. We'll + * mirror those settings in post_repo_init_init. + */ +static void final_rev_info_setup(int argc, const char **argv, const char *prefix, + struct rev_info *rev) +{ + struct setup_revision_opt opt; + + /* setup_revision_opt is used to pass options to the setup_revisions() + * call. It's got some special items for submodules and other types of + * optimizations, but for now, we'll just point it to HEAD and call it + * good. First we should make sure to reset it. TODO: This is useful for + * more complicated stuff revisions, but a decent shortcut for the first + * pass is add_head_to_pending(). + */ + memset(&opt, 0, sizeof(opt)); + opt.def = "HEAD"; + opt.revarg_opt = REVARG_COMMITTISH; + //setup_revisions(argc, argv, rev, &opt); + + /* Let's force oneline format. */ + get_commit_format("oneline", rev); + rev->verbose_header = 1; + + /* add the HEAD to pending so we can start */ + add_head_to_pending(rev); +} + /* * This method will be called back by git_config(). It is used to gather values * from the configuration files available to Git. @@ -54,12 +84,24 @@ int cmd_walken(int argc, const char **argv, const char *prefix) OPT_END() }; + struct rev_info rev; + argc = parse_options(argc, argv, prefix, options, walken_usage, 0); init_walken_defaults(); git_config(git_walken_config, NULL); + /* Time to set up the walk. repo_init_revisions sets up rev_info with + * the defaults, but then you need to make some configuration settings + * to make it do what's special about your walk. + */ + repo_init_revisions(the_repository, &rev, prefix); + + /* Before we do the walk, we need to set a starting point. It's not + * coming from opt. */ + final_rev_info_setup(argc, argv, prefix, &rev); + printf(_("cmd_walken incoming...\n")); return 0; } From patchwork Fri Jun 7 01:08:04 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emily Shaffer X-Patchwork-Id: 10980639 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C9F3192A for ; Fri, 7 Jun 2019 01:09:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B723A28AC4 for ; Fri, 7 Jun 2019 01:09:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A861128ADD; Fri, 7 Jun 2019 01:09:11 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, USER_IN_DEF_DKIM_WL autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4BE2528AC4 for ; Fri, 7 Jun 2019 01:09:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727633AbfFGBJK (ORCPT ); Thu, 6 Jun 2019 21:09:10 -0400 Received: from mail-pl1-f201.google.com ([209.85.214.201]:40814 "EHLO mail-pl1-f201.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725784AbfFGBJK (ORCPT ); Thu, 6 Jun 2019 21:09:10 -0400 Received: by mail-pl1-f201.google.com with SMTP id 91so325922pla.7 for ; Thu, 06 Jun 2019 18:09:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=HPZL2HajTadRCgsrgYLXQhUvAinm7A/OFGdXxpVbbCA=; b=QqIo5wbpCOG9Hnakq74sOhvWmFEataqncBrAJn8Y8BFId7i+IqiByUclG40rzKpYzF JlvfSChg/ArzVd//KveZZnO/DNJUcKokdwI4xEyUNGVPL1sqP224bawKxU5zLpxFMvE+ 4LOgmtqRQz/u2Fwa7bEQgMVId4iClhSltYeJr/wsfP0MAvrAUSjK4TuBDCgkMQrIu6Nu 3TgFfhbS+gNKcEG0Bk7LVNz77F2VyfEOLUZJp1MAuCr9F1jldPwXQX+pLiPJg5wXECkE gMfaVXZJI6P4dAnJzJscH7BLJzLv1eRdRCZoD4WU+ew/7ufExjy3gQa34izJHu6gNcwX fNZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=HPZL2HajTadRCgsrgYLXQhUvAinm7A/OFGdXxpVbbCA=; b=F5qD8bwLiUnWgnk1iZZodGb9E0NPsFBL9qnLWyaIO26eZL/iEmZ8J6j0Mavj/0vuu0 5Dok3tSus4JCn2caC1Zr1geA4Ym9wyYynUDrBlpZv284BbmvhGDN3Kna1RJQL+UHVxUE Uh2WUez3G5qPNgBpBQpEdRIZiupbZxyXIkTwkHKbLxiXDK1yqD1jVzuH+KJ85BDaFGcT lKhom/74F3qSnVD/AA96cd4C27jTFcwsbTTqRDgiQSDUxVnzJIG6Ys+uNvVIlXlmg7Ii zHhEY5bC1qo5ssm5xCXvd9MUdB+NMWIRDKYV/T6okEXGjENXu5hTXZil/x/peCAcsI6i 275w== X-Gm-Message-State: APjAAAUioI88j+eifQ74zKL+qtFfw2/h3Tr0oHQkQ7Zavz6Zj7xUus2A 7KQMRcYJ6LZo9ttAoh0fG2WPUhiQRJnamFhEVQHGMe5fJgNRwRGVS765nfJymnkMNNGbSg58kw+ UhEriCId7nFBNlHIzyz5RgG64+Qvbyz8VIPdVn6hr4bdDvxXTc6n+uUkWt/ZqxiQHkl54T8WoUA == X-Google-Smtp-Source: APXvYqyEerY/P6atEjClIotsg7s6vvhj3AVRcAi/hz7apXwBErR1aUWzbzIdWB9PAsajzH/AsBVwTTbsW2pAv2tRyBQ= X-Received: by 2002:a63:e54d:: with SMTP id z13mr581094pgj.132.1559869748929; Thu, 06 Jun 2019 18:09:08 -0700 (PDT) Date: Thu, 6 Jun 2019 18:08:04 -0700 In-Reply-To: <20190607010811.52944-1-emilyshaffer@google.com> Message-Id: <20190607010811.52944-7-emilyshaffer@google.com> Mime-Version: 1.0 References: <20190607010708.46654-1-emilyshaffer@google.com> <20190607010811.52944-1-emilyshaffer@google.com> X-Mailer: git-send-email 2.22.0.rc1.311.g5d7573a151-goog Subject: [RFC PATCH 06/13] walken: perform our basic revision walk From: Emily Shaffer To: git@vger.kernel.org Cc: Emily Shaffer Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add the final steps needed and implement the walk loop itself. We add a method walken_commit_walk() which performs the final setup to revision.c and then iterates over commits from get_revision(). This basic walk only prints the subject line of each commit in the history. It is nearly equivalent to `git log --oneline`. Signed-off-by: Emily Shaffer --- builtin/walken.c | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/builtin/walken.c b/builtin/walken.c index c101db38c7..9cf19a24ab 100644 --- a/builtin/walken.c +++ b/builtin/walken.c @@ -7,8 +7,11 @@ #include #include "builtin.h" #include "revision.h" +#include "commit.h" #include "config.h" #include "parse-options.h" +#include "pretty.h" +#include "line-log.h" static const char * const walken_usage[] = { N_("git walken"), @@ -78,6 +81,39 @@ static int git_walken_config(const char *var, const char *value, void *cb) return git_default_config(var, value, cb); } +/* + * walken_commit_walk() is invoked by cmd_walken() after initialization. It + * does the commit walk only. + */ +static int walken_commit_walk(struct rev_info *rev) +{ + struct commit *commit; + struct strbuf prettybuf; + + strbuf_init(&prettybuf, 0); + + + /* prepare_revision_walk() gets the final steps ready for a revision + * walk. We check the return value for errors. */ + if (prepare_revision_walk(rev)) { + die(_("revision walk setup failed")); + } + + /* Now we can start the real commit walk. get_revision grabs the next + * revision based on the contents of rev. + */ + rev->diffopt.close_file = 0; + while ((commit = get_revision(rev)) != NULL) { + if (commit == NULL) + continue; + strbuf_reset(&prettybuf); + pp_commit_easy(CMIT_FMT_ONELINE, commit, &prettybuf); + printf(_("%s\n"), prettybuf.buf); + + } + return 0; +} + int cmd_walken(int argc, const char **argv, const char *prefix) { struct option options[] = { @@ -98,10 +134,15 @@ int cmd_walken(int argc, const char **argv, const char *prefix) */ repo_init_revisions(the_repository, &rev, prefix); + /* We can set our traversal flags here. */ + rev.always_show_header = 1; + /* Before we do the walk, we need to set a starting point. It's not * coming from opt. */ final_rev_info_setup(argc, argv, prefix, &rev); + walken_commit_walk(&rev); + printf(_("cmd_walken incoming...\n")); return 0; } From patchwork Fri Jun 7 01:08:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emily Shaffer X-Patchwork-Id: 10980641 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 28CFE14B6 for ; Fri, 7 Jun 2019 01:09:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1676C28AC4 for ; Fri, 7 Jun 2019 01:09:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0AEBA28ADD; Fri, 7 Jun 2019 01:09:14 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, USER_IN_DEF_DKIM_WL autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AB25D28AC4 for ; Fri, 7 Jun 2019 01:09:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727663AbfFGBJM (ORCPT ); Thu, 6 Jun 2019 21:09:12 -0400 Received: from mail-pf1-f202.google.com ([209.85.210.202]:37498 "EHLO mail-pf1-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725784AbfFGBJM (ORCPT ); Thu, 6 Jun 2019 21:09:12 -0400 Received: by mail-pf1-f202.google.com with SMTP id x18so303254pfj.4 for ; Thu, 06 Jun 2019 18:09:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=gA6z56v919bqdiDLMiR2LscBxFAIVVuC8++8ttiUOPI=; b=LiXmu2F/kGN9+Op9GJoPbt2UGxr4w2QUsIui34Yx+kXy/xur+tt6WQtEux5XrPXTL5 R8vqW7tjY2BgAznFFbij/imkbVYoelueFvnSZKwqAy1QBuIEMCvVANCgRtAw7f0LkyWM cLiJnrKLsIRS0TerjbCCCM5Xbk2NdhrG8goXMWAeIe/475ZxnvwpvXvJioNou4trS4UA mcCmQRxu/bpcRUbOaHGOuAUvS6UGTuexrmB0/jQW4fXjd5skXQoD5hIhyOSEQpSJlJtY GbUdR1KbVD8alPZZIHbtFJBs2piplmNyTX5iYi7uiFE+6o2cGePaTVOogGjpLLft8b0d OIhQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=gA6z56v919bqdiDLMiR2LscBxFAIVVuC8++8ttiUOPI=; b=Glr351Trp6A1cqSna6nJ9qlsHqSC/2ZxaKZVARj7nSy5ev4596gb2ZNBcMmSkwt3OV uUPEQpV8V40HTIZRL72xVVWRHU0AmboIxnpz1WxLTU/OuwEXi54uyGumeBrrznR3s8PU W3c5exjm7lSFhmS1ZOfwi5fylVaK5OCG8zA7YqMotHnOS/c+0gr4BoZH1Pndnu1HOf6s dg/ft2GXpw08unlnNADHuQZ3o+aesqtXyYW5swo9W8kWpz1yMc7RAjnkBK5LeLXInJp6 cPXQHYp/wl9+pGflcnY4IccDUSmnga7x+3O1S51xHspCmrbwVpz0JJte+MgQrQ6Jwdd4 1ofg== X-Gm-Message-State: APjAAAXCWwJ/MgOG3noC4yzh028P1RTzz3ydcUbLns/7QeAo+vJY24ln Jkfr/2SNOsfEPAhh/CAeRc2Dz+HLj2knUjZMzGnGbc65m4yqj4XtsNyRA2JGrdfTIeCmkPHYRzA l2k8ebnTIIpOtTiD+ZvF6E1lvDWcafhMS+pNDhT1uXqe1FPfNnhtiF/wooy3mYXWEBaLPKCDVSw == X-Google-Smtp-Source: APXvYqx3Uvc2ssESvoBGmWo+x5J2MxfLYqQ3DCPw+ZQGRklYGq3T/d50lDTVQWeiCLko1rFi1utzd1cL0haI7tG5XoU= X-Received: by 2002:a63:1516:: with SMTP id v22mr595360pgl.204.1559869751535; Thu, 06 Jun 2019 18:09:11 -0700 (PDT) Date: Thu, 6 Jun 2019 18:08:05 -0700 In-Reply-To: <20190607010811.52944-1-emilyshaffer@google.com> Message-Id: <20190607010811.52944-8-emilyshaffer@google.com> Mime-Version: 1.0 References: <20190607010708.46654-1-emilyshaffer@google.com> <20190607010811.52944-1-emilyshaffer@google.com> X-Mailer: git-send-email 2.22.0.rc1.311.g5d7573a151-goog Subject: [RFC PATCH 07/13] walken: filter for authors from gmail address From: Emily Shaffer To: git@vger.kernel.org Cc: Emily Shaffer Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In order to demonstrate how to create grep filters for revision walks, filter the walk performed by cmd_walken() to print only commits which are authored by someone with a gmail address. This commit demonstrates how to append a grep pattern to a rev_info.grep_filter, to teach new contributors how to create their own more generalized grep filters during revision walks. Signed-off-by: Emily Shaffer --- builtin/walken.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/builtin/walken.c b/builtin/walken.c index 9cf19a24ab..6c0f4e7b7a 100644 --- a/builtin/walken.c +++ b/builtin/walken.c @@ -12,6 +12,7 @@ #include "parse-options.h" #include "pretty.h" #include "line-log.h" +#include "grep.h" static const char * const walken_usage[] = { N_("git walken"), @@ -25,9 +26,8 @@ static const char * const walken_usage[] = { */ static void init_walken_defaults(void) { - /* We don't actually need the same components `git log` does; leave this - * empty for now. - */ + /* Needed by our grep filter. */ + init_grep_defaults(the_repository); } /* @@ -51,6 +51,10 @@ static void final_rev_info_setup(int argc, const char **argv, const char *prefix opt.revarg_opt = REVARG_COMMITTISH; //setup_revisions(argc, argv, rev, &opt); + /* Add a grep pattern to the author line in the header. */ + append_header_grep_pattern(&rev->grep_filter, GREP_HEADER_AUTHOR, "gmail"); + compile_grep_patterns(&rev->grep_filter); + /* Let's force oneline format. */ get_commit_format("oneline", rev); rev->verbose_header = 1; @@ -77,7 +81,7 @@ static void final_rev_info_setup(int argc, const char **argv, const char *prefix */ static int git_walken_config(const char *var, const char *value, void *cb) { - /* For now, let's not bother with anything. */ + grep_config(var, value, cb); return git_default_config(var, value, cb); } From patchwork Fri Jun 7 01:08:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emily Shaffer X-Patchwork-Id: 10980643 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A9F2C14B6 for ; Fri, 7 Jun 2019 01:09:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 985E728AC4 for ; Fri, 7 Jun 2019 01:09:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8CA3628ADD; Fri, 7 Jun 2019 01:09:16 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, USER_IN_DEF_DKIM_WL autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 435E728AC4 for ; Fri, 7 Jun 2019 01:09:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727687AbfFGBJP (ORCPT ); Thu, 6 Jun 2019 21:09:15 -0400 Received: from mail-qk1-f201.google.com ([209.85.222.201]:35185 "EHLO mail-qk1-f201.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725784AbfFGBJP (ORCPT ); Thu, 6 Jun 2019 21:09:15 -0400 Received: by mail-qk1-f201.google.com with SMTP id u128so271308qka.2 for ; Thu, 06 Jun 2019 18:09:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=UJylFcBhyWRhWp1/F3JaKHpmPKsqEpF5jeiskTNBO0I=; b=MasofLBAAhAunA4MGUandSdL73ZNdDIwkDEnGGDxXhM9kTfWQy5acUNaWUTWAh5Wab xuuSqqtJvvBncyQ7DcV9SOw2LsC6N9JqSfWg1q6xoL/MEsuxAqpsQNLwPNqHoCUY/o+C ONJLmua7X+r0XwJqlMigpdm3rrk7G7+wSwk7ZTC/PxTm6uDs10fAjltdDH0+UfuaBtlv D9wcvofaXK8H2TsVW56kI7QqO9fSqSzzzoYoZvmyxWcubgF3KdWKqXGc7vz0jHQQskDO kBen/D131spSqHkPb4geAonSL2+YVmUslyBH2UeiMHvz3Q/MYc/Y1paH8fm4uiDoXY6H g+FQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=UJylFcBhyWRhWp1/F3JaKHpmPKsqEpF5jeiskTNBO0I=; b=Fr2GQYgFIe8ZAFB9MkcwoUzo51W5CRfNhbyddeNvUHNASbV9xhV51tzfN+kuRLnmK7 vyCsTtUEX7nooCtTp1c7k6YVnZ9vAIYLC7Zn7DBv5pl544n70u3IxLpd+IzsC+oFAgJz jkm60iuUqOXvOAay/DpwR4BXOhQhQ+CSJDEsv+ANnDElXM/4mM8Wc1eH1hQ0xUKjPPem kwYbmxTY4tzATEhTaR/0n7Vva4B8zIplAaD4U7YuhbrlJC1w9FdtBYQirEHxPP16IkyO rSyuMJvfmEAQK11b4E8Fkkkh+NFVWw8ZAlV/amzv40ixz4DM67EkcujlqlSM+2jG1QE2 S47g== X-Gm-Message-State: APjAAAV5pklh0+JuRvL5gflsSHBP5gSsRxAMzfv7U3OebUCexQO/E9w8 eayhMvZ/ZjEl0GUmQwOgS4oAgO5X5rOD6iv6wdUEWnWQXe+nQNSsBn4yTiqnWPGi0hwBOr3ycBo GYCgiart3Vxoan/Z4xEgIZ7/OIqPF0abVsyoHMeyycGMzbJw3k9fHs8WaxcgeZz9xhKOtNGxmtQ == X-Google-Smtp-Source: APXvYqzt+VuBb0HUsAun0gmGCrxrQP7X7sKRm+M0Dgt/+f+5u3l6tC0M1ydQJp69Mm+xcn/rvBe0vfQzHm+5P3NIfWo= X-Received: by 2002:a37:5d44:: with SMTP id r65mr34681387qkb.73.1559869754043; Thu, 06 Jun 2019 18:09:14 -0700 (PDT) Date: Thu, 6 Jun 2019 18:08:06 -0700 In-Reply-To: <20190607010811.52944-1-emilyshaffer@google.com> Message-Id: <20190607010811.52944-9-emilyshaffer@google.com> Mime-Version: 1.0 References: <20190607010708.46654-1-emilyshaffer@google.com> <20190607010811.52944-1-emilyshaffer@google.com> X-Mailer: git-send-email 2.22.0.rc1.311.g5d7573a151-goog Subject: [RFC PATCH 08/13] walken: demonstrate various topographical sorts From: Emily Shaffer To: git@vger.kernel.org Cc: Emily Shaffer Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Order the revision walk by author or commit dates, to demonstrate how to apply topo_sort to a revision walk. While following the tutorial, new contributors are guided to run a walk with each sort and compare the results. Signed-off-by: Emily Shaffer --- builtin/walken.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/builtin/walken.c b/builtin/walken.c index 6c0f4e7b7a..716d31f04e 100644 --- a/builtin/walken.c +++ b/builtin/walken.c @@ -61,6 +61,11 @@ static void final_rev_info_setup(int argc, const char **argv, const char *prefix /* add the HEAD to pending so we can start */ add_head_to_pending(rev); + + /* Let's play with the sort order. */ + rev->topo_order = 1; + rev->sort_order = REV_SORT_BY_COMMIT_DATE; + /* rev->sort_order = REV_SORT_BY_AUTHOR_DATE; */ } /* From patchwork Fri Jun 7 01:08:07 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emily Shaffer X-Patchwork-Id: 10980645 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id F40F892A for ; Fri, 7 Jun 2019 01:09:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E257A28AC4 for ; Fri, 7 Jun 2019 01:09:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D6B4B28ADD; Fri, 7 Jun 2019 01:09:18 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, USER_IN_DEF_DKIM_WL autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 815FB28AC4 for ; Fri, 7 Jun 2019 01:09:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727711AbfFGBJR (ORCPT ); Thu, 6 Jun 2019 21:09:17 -0400 Received: from mail-yb1-f202.google.com ([209.85.219.202]:42242 "EHLO mail-yb1-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725784AbfFGBJR (ORCPT ); Thu, 6 Jun 2019 21:09:17 -0400 Received: by mail-yb1-f202.google.com with SMTP id 126so552442ybw.9 for ; Thu, 06 Jun 2019 18:09:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=QaKWisSBtMZItpyjKoSYeSiVegbyYujFfLU9nQDY6a8=; b=dcN9SnYwlO0BPgJGM/5WSfvAzmWhdNABbjuG9fz+ylxyZo7iQe4oY1BJiNjb6DUki0 F59A+SFPRxNBG6WThOR+H7ipjrXfB4Hr+NCxfYpqvHNK3D1GCQi54v2I/7Xw9x0Oyuvl E+77tbVZHXs/fXw3pW6BZredJzlChf7OEBlR0W5fOC3GuYlERHsv+H7wSXFtXdpPbwAG gaBd7fub/1NBtZUrKMBNXNhjwYjrvgE9hBQVcqWgM/R8qbrEKlIdNksYgBl7PtrpV4BK r1NcG4s9vWafCuNE6jDg1xOPSO+7gTVH+fvhqVzNOSJoAw+9ctVBvxW4AYx9fcw+eCyA 1VKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=QaKWisSBtMZItpyjKoSYeSiVegbyYujFfLU9nQDY6a8=; b=e/qrlOSwugh1+cyTGKh4wZTLGp/LMU+tQiVIHFrOhjGTldAS2o1ZxoWdNmdB1eN5De Si9p77jn5Qgq7KY/e6emIl2Vew40YiT64nDxz01fd/VIb75aX933PxgKYqpBLCDhvJGb XfzjTwflonNmI1+xTHVc2aR4aG22sKZM9is4CRP7/kmPujG3DkncjA5LkEQwtjHYSrgx SLrjWtwwazOu/EBOIT+/dUcp1hDi6Mw0MGptnUZ14sSL5w+rPuiBhq1Kkj6/2GDKmYwD SgD0nrR3eTTuOMlYuWf/y4TFrzshFl09o1FfhWxkLjPuTrjhvyWA2BtebhaMoqkg1HM/ hJKw== X-Gm-Message-State: APjAAAXOjXwhEqlU4WctQba4ZuxlcvgSAzNqFnX/MKUwOfMHSODeswzy p/KTvbjr8vDPjzLnx4CMko6B9umP6y4aL32gn9PXSAfAHa94+RnLRHroY99EEymiVwpla+ig1mj zUPU6pAN4w8Z7h1GQhrFtCC2Yy82sjqf9E0pic0vOJm0NAlhfelof0i5iNMVsymienJir/7H5hw == X-Google-Smtp-Source: APXvYqxvgBCsI5rLSLYJ+eeB6FdUQPutp0S/UKHnBPfKpnExn4Fl4mHoTNri0oN7uynXU2DenpIBZgf3M6Jwk9QlSLw= X-Received: by 2002:a0d:f144:: with SMTP id a65mr6009688ywf.42.1559869756599; Thu, 06 Jun 2019 18:09:16 -0700 (PDT) Date: Thu, 6 Jun 2019 18:08:07 -0700 In-Reply-To: <20190607010811.52944-1-emilyshaffer@google.com> Message-Id: <20190607010811.52944-10-emilyshaffer@google.com> Mime-Version: 1.0 References: <20190607010708.46654-1-emilyshaffer@google.com> <20190607010811.52944-1-emilyshaffer@google.com> X-Mailer: git-send-email 2.22.0.rc1.311.g5d7573a151-goog Subject: [RFC PATCH 09/13] walken: demonstrate reversing a revision walk list From: Emily Shaffer To: git@vger.kernel.org Cc: Emily Shaffer Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The final installment in the tutorial about sorting revision walk outputs. This commit reverses the commit list, so that we see newer commits last (handy since we aren't using a pager). It's important to note that rev->reverse needs to be set after add_head_to_pending() or before setup_revisions(). (This is mentioned in the accompanying tutorial.) Signed-off-by: Emily Shaffer --- builtin/walken.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/builtin/walken.c b/builtin/walken.c index 716d31f04e..86c8d29c48 100644 --- a/builtin/walken.c +++ b/builtin/walken.c @@ -61,6 +61,9 @@ static void final_rev_info_setup(int argc, const char **argv, const char *prefix /* add the HEAD to pending so we can start */ add_head_to_pending(rev); + + /* Reverse the order */ + rev->reverse = 1; /* Let's play with the sort order. */ rev->topo_order = 1; From patchwork Fri Jun 7 01:08:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emily Shaffer X-Patchwork-Id: 10980647 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id ECE2992A for ; Fri, 7 Jun 2019 01:09:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DB44128AC4 for ; Fri, 7 Jun 2019 01:09:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CF96028ADD; Fri, 7 Jun 2019 01:09:21 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, USER_IN_DEF_DKIM_WL autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 69F1D28AC4 for ; Fri, 7 Jun 2019 01:09:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727268AbfFGBJU (ORCPT ); Thu, 6 Jun 2019 21:09:20 -0400 Received: from mail-ot1-f74.google.com ([209.85.210.74]:33014 "EHLO mail-ot1-f74.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725784AbfFGBJU (ORCPT ); Thu, 6 Jun 2019 21:09:20 -0400 Received: by mail-ot1-f74.google.com with SMTP id b1so208628otk.0 for ; Thu, 06 Jun 2019 18:09:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=UhDe3AGtW0aj/mfMGFFr8w5xdqAujEsjGoZk3eHf7a0=; b=BqzX6hGUQ3LWeoI2pFpYWDfmCHgdZYhg5F19X9TA1jaFbaZ35L36FTWSf54T3fT+LE RNvvDvPXiPAFCUGPtESdBFNjqmKPGjBIFhA/wthdLpofthbzzimI2FZoV88pnsbgbeVk 3USvt424kSAzPBadnza4TeQ/w1aMtLcYa122A6aYGFHQBvEOyAUXoA0lEJ9FeP3brmQR 7r8ozJMMqjBZyUBZgqC4RZbI0d2tkPo1XaddALLIjEpccbqgYu1PvD+n9DZ1qbAusn6/ XLjzjm0pQuW2O8Hdshm6xu0eXyphojr3+d5QF9C8Tsich0jvf/kv/EFvCciyC8DJhCKY 1Weg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=UhDe3AGtW0aj/mfMGFFr8w5xdqAujEsjGoZk3eHf7a0=; b=kJ6HzsetnAtnQ4l6Pd+Fd1YpkPwN88F7pI7bAkvCuqBHAjSNSglLQUux4UYrCFl/t3 c7s0J4L+tX7naIIZdEUMX0PT2qKI8ffF0wrJqzvadxtBKwlFDVSHuswwBmQjv0sS58Fb aXymNgjs3jIPulrmxHa6jDedzi/aMYh8JLH4guJZChuwGvq3veng8W1gWfycCx558Nzx zQrpahYFhTfkz0+qgcd4cCNMteGBRc8Zg63ZHGK3/W6NRAWmiwHCbZT5Ra60R4NIf4gY 2WZXf9HhE0u/TnoyBtMIWPd0uga0R8AOdFIBfIiN36wamDd+s00PtChcDdHNpdRI3ocK NFMw== X-Gm-Message-State: APjAAAV+Bo3o345Fu0QQTblSDxG2nafEZ3yI9gupvCP/4x29ezUDRLyN cajTVvq3ekT8CVjQhvWFzPcw5hu0syEk/IDvu2Iu5YTu1QQSTdBL62Ff3PZojv+3KTySoIOkibT HhaeWn1WZBpgnUJWUZRmhPOWim6B3n9AXBXj1wKNE23XUZvUcOpe+NmpBbfoU0aDR/tarw5vt0A == X-Google-Smtp-Source: APXvYqzAfMsJrD+RZDnPgpyVUeKs5FQxfbHbg4FB3OkrmsNcTv3jATnMhLOcPg8ZUtgIj0V170xqwJkNF79496UGG7M= X-Received: by 2002:aca:3404:: with SMTP id b4mr2146422oia.11.1559869759607; Thu, 06 Jun 2019 18:09:19 -0700 (PDT) Date: Thu, 6 Jun 2019 18:08:08 -0700 In-Reply-To: <20190607010811.52944-1-emilyshaffer@google.com> Message-Id: <20190607010811.52944-11-emilyshaffer@google.com> Mime-Version: 1.0 References: <20190607010708.46654-1-emilyshaffer@google.com> <20190607010811.52944-1-emilyshaffer@google.com> X-Mailer: git-send-email 2.22.0.rc1.311.g5d7573a151-goog Subject: [RFC PATCH 10/13] walken: add unfiltered object walk from HEAD From: Emily Shaffer To: git@vger.kernel.org Cc: Emily Shaffer Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Provide a demonstration of a revision walk which traverses all types of object, not just commits. This type of revision walk is used for operations such as creating packfiles and performing fetches or clones, so it's useful to teach new developers how it works. For starters, only demonstrate the unfiltered version, as this will make the tutorial easier to follow. This commit is part of a tutorial on revision walking. Signed-off-by: Emily Shaffer --- builtin/walken.c | 79 ++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 77 insertions(+), 2 deletions(-) diff --git a/builtin/walken.c b/builtin/walken.c index 86c8d29c48..408af6c841 100644 --- a/builtin/walken.c +++ b/builtin/walken.c @@ -12,6 +12,7 @@ #include "parse-options.h" #include "pretty.h" #include "line-log.h" +#include "list-objects.h" #include "grep.h" static const char * const walken_usage[] = { @@ -19,6 +20,11 @@ static const char * const walken_usage[] = { NULL, }; +static int commit_count; +static int tag_count; +static int blob_count; +static int tree_count; + /* * Within init_walken_defaults() we can call into other useful defaults to set * in the global scope or on the_repository. It's okay to borrow from other @@ -93,6 +99,70 @@ static int git_walken_config(const char *var, const char *value, void *cb) return git_default_config(var, value, cb); } +static void walken_show_commit(struct commit *cmt, void *buf) +{ + commit_count++; +} + +static void walken_show_object(struct object *obj, const char *str, void *buf) +{ + switch (obj->type) { + case OBJ_TREE: + tree_count++; + break; + case OBJ_BLOB: + blob_count++; + break; + case OBJ_TAG: + tag_count++; + break; + case OBJ_COMMIT: + printf(_("Unexpectedly encountered a commit in " + "walken_show_object!\n")); + commit_count++; + break; + default: + printf(_("Unexpected object type %s!\n"), + type_name(obj->type)); + break; + } +} + +/* + * walken_object_walk() is invoked by cmd_walken() after initialization. It does + * a walk of all object types. + */ +static int walken_object_walk(struct rev_info *rev) +{ + struct list_objects_filter_options filter_options = {}; + struct oidset omitted; + oidset_init(&omitted, 0); + + printf("walken_object_walk beginning...\n"); + + rev->tree_objects = 1; + rev->blob_objects = 1; + rev->tag_objects = 1; + rev->tree_blobs_in_commit_order = 1; + rev->exclude_promisor_objects = 1; + + if (prepare_revision_walk(rev)) + die(_("revision walk setup failed")); + + commit_count = 0; + tag_count = 0; + blob_count = 0; + tree_count = 0; + + traverse_commit_list(rev, walken_show_commit, walken_show_object, NULL); + + printf(_("Object walk completed. Found %d commits, %d blobs, %d tags, " + "and %d trees.\n"), commit_count, blob_count, tag_count, + tree_count); + + return 0; +} + /* * walken_commit_walk() is invoked by cmd_walken() after initialization. It * does the commit walk only. @@ -151,9 +221,14 @@ int cmd_walken(int argc, const char **argv, const char *prefix) /* Before we do the walk, we need to set a starting point. It's not * coming from opt. */ - final_rev_info_setup(argc, argv, prefix, &rev); - walken_commit_walk(&rev); + if (1) { + add_head_to_pending(&rev); + walken_object_walk(&rev); + } else { + final_rev_info_setup(argc, argv, prefix, &rev); + walken_commit_walk(&rev); + } printf(_("cmd_walken incoming...\n")); return 0; From patchwork Fri Jun 7 01:08:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emily Shaffer X-Patchwork-Id: 10980649 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9E68D14B6 for ; Fri, 7 Jun 2019 01:09:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8D26128AC4 for ; Fri, 7 Jun 2019 01:09:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 816E328ADD; Fri, 7 Jun 2019 01:09:24 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, USER_IN_DEF_DKIM_WL autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 305FC28AC4 for ; Fri, 7 Jun 2019 01:09:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727721AbfFGBJX (ORCPT ); Thu, 6 Jun 2019 21:09:23 -0400 Received: from mail-pl1-f201.google.com ([209.85.214.201]:53343 "EHLO mail-pl1-f201.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725784AbfFGBJX (ORCPT ); Thu, 6 Jun 2019 21:09:23 -0400 Received: by mail-pl1-f201.google.com with SMTP id b24so312724plz.20 for ; Thu, 06 Jun 2019 18:09:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=DO6cP6nO+DkGhzWNGsy8vE5XwUrW039IjR1o5onjLDI=; b=Z4MIuzbk0s1KiZVZ5s2bSvZ1+F99vKczI6pcUPCrWbJIpC18rgSp0wyhiEkwKkbyFE aNDnn16VGuLWPZU1xQzPaW3B/C3wuhhMkrB2tiW9KGqkebHbJq+nAz77C50nLx3Q/zmj iGBXRO8sReTeQW8CjG6YkmaBkfM335NxWb3pOTyJJ9vA9hszsjO+jdNAOSIAdeayfLdH 9mLlAX5yViw6gdtx6mRlb3zu0eAfCH00cMoMhIrvWzUdOP0xb+xwmFPgZwt8pK+B80OL 8oOd2T1B1UvZ3+nThcowYBprAp/XcJ6HRhpgh61Xq5LcDNbblH6qhOwucMM7lgVl0HIU 3OHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=DO6cP6nO+DkGhzWNGsy8vE5XwUrW039IjR1o5onjLDI=; b=NVkkBmcn3OUHeWc1ZBfhYXzWur9VvmVl1vnKxU19IhFATjHhEmc2o+NzjbogBzWfE5 zCbnwGUPgdqzsRIRFrOKKPgOa67nl8se7N9f4tINEyrxeDhtCK2eCqptRL12IKrN2wDh T4SCrjl9khc2W60WMXb2Oo9JkizXIcdRLenN2ibx6e8oifHlnmJrTOMyH+D/PCCNf7Zh MWjySVfRGZuKSTpZAdPeYb8nP8cUN8liApDSMT1aLN/QrOmM2JRyJM7gRmlXMzh01lO3 ZOsjsfjmhrZAyDJ4F0+4jUZLvIrLSqwDEDakrdmfeOLpSa+DN/A6PJuIxvZYR+9ffsWj lshA== X-Gm-Message-State: APjAAAXnPPtLl0RrL5b8MkLTll4u9+UqQ/e/7j/0B2qsPnk72vCkPFff NIC3vmudDkDhAKLLyIWDd2KyTo/aC5dev1M8P7+6f8JHhUzUC4tm3FY8cFbiDGV2KvUSQSk9PM4 eyjtL6Q+tFi/OKUO2gO+FwCKSr2mRSfgGqONPItpTjWrZHdNBwky/eePhluepRIgNp9v1A9smCQ == X-Google-Smtp-Source: APXvYqxrkjD8oqJqNRygw6hKtXoHj6ZcUNBpeC/BFGm091Q2q+z8Z0Fs8lOqCJlOX8KAxXGzwaPAEzBeyf9ndQDnVko= X-Received: by 2002:a65:5ccb:: with SMTP id b11mr572539pgt.172.1559869761848; Thu, 06 Jun 2019 18:09:21 -0700 (PDT) Date: Thu, 6 Jun 2019 18:08:09 -0700 In-Reply-To: <20190607010811.52944-1-emilyshaffer@google.com> Message-Id: <20190607010811.52944-12-emilyshaffer@google.com> Mime-Version: 1.0 References: <20190607010708.46654-1-emilyshaffer@google.com> <20190607010811.52944-1-emilyshaffer@google.com> X-Mailer: git-send-email 2.22.0.rc1.311.g5d7573a151-goog Subject: [RFC PATCH 11/13] walken: add filtered object walk From: Emily Shaffer To: git@vger.kernel.org Cc: Emily Shaffer Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Demonstrate how filter specs can be used when performing a revision walk of all object types. In this case, tree depth is used. Contributors who are following the revision walking tutorial will be encouraged to run the revision walk with and without the filter in order to compare the number of objects seen in each case. Signed-off-by: Emily Shaffer --- builtin/walken.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/builtin/walken.c b/builtin/walken.c index 408af6c841..f2c98bcd6b 100644 --- a/builtin/walken.c +++ b/builtin/walken.c @@ -13,6 +13,7 @@ #include "pretty.h" #include "line-log.h" #include "list-objects.h" +#include "list-objects-filter-options.h" #include "grep.h" static const char * const walken_usage[] = { @@ -154,7 +155,22 @@ static int walken_object_walk(struct rev_info *rev) blob_count = 0; tree_count = 0; - traverse_commit_list(rev, walken_show_commit, walken_show_object, NULL); + if (1) { + /* Unfiltered: */ + printf(_("Unfiltered object walk.\n")); + traverse_commit_list(rev, walken_show_commit, + walken_show_object, NULL); + } else { + printf(_("Filtered object walk with filterspec 'tree:1'.\n")); + /* + * We can parse a tree depth of 1 to demonstrate the kind of + * filtering that could occur eg during shallow cloning. + */ + parse_list_objects_filter(&filter_options, "tree:1"); + + traverse_commit_list_filtered(&filter_options, rev, + walken_show_commit, walken_show_object, NULL, &omitted); + } printf(_("Object walk completed. Found %d commits, %d blobs, %d tags, " "and %d trees.\n"), commit_count, blob_count, tag_count, From patchwork Fri Jun 7 01:08:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emily Shaffer X-Patchwork-Id: 10980651 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E9FEF14B6 for ; Fri, 7 Jun 2019 01:09:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D813C28AC4 for ; Fri, 7 Jun 2019 01:09:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CC96A28ADD; Fri, 7 Jun 2019 01:09:27 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, USER_IN_DEF_DKIM_WL autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7E3FE28AC4 for ; Fri, 7 Jun 2019 01:09:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727768AbfFGBJ0 (ORCPT ); Thu, 6 Jun 2019 21:09:26 -0400 Received: from mail-vk1-f202.google.com ([209.85.221.202]:38860 "EHLO mail-vk1-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725784AbfFGBJ0 (ORCPT ); Thu, 6 Jun 2019 21:09:26 -0400 Received: by mail-vk1-f202.google.com with SMTP id q191so149549vkh.5 for ; Thu, 06 Jun 2019 18:09:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=2hd/7vgoTSTtZbgrss4lNyuf40Z0SlsWEf0GCTpiPV0=; b=gElfw3nxMKx7XifK/nYTw7AMwNg6quXPmll7awXXiiOQScby3fxBkvJmMKoFmH8fqu nit4tiI/VKnD8R7OChtDlZ4ZAsUkp2Fvw1lDysRND5ia8a/wrEWbx4A9XkBc0AsK/N+j wtayaqZRj0Iput7B2d2tizjOVZbdvVWJnbm0n4tPjJVElz8T+J7AldjovkO2A/f94iKx YGE2FO00epHrDtWeJlxfrbgK5rUw7/BMF9Thz1s/h1fc8mqp1Hs45XdgyHiCEg2gXv1T JaRTnXiWz9jn4d2oFWNYC9Y+30IUIiAbXm/4fvREDh0Fh8nF5cIav2SS6S2gD4Gf/tN6 t1aA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=2hd/7vgoTSTtZbgrss4lNyuf40Z0SlsWEf0GCTpiPV0=; b=I+9Cmpwx8H8q6IWh96PcPACkNe/deQjDnI/NBYEcEFe68+Y1mGYxGs/qX6ck6gs+lF WkoT754PaIKRKBI47jg6sjLxm08xqRslRvJWvLe+5+hqHr5NzuHYKoco2ejZrtlqIpNZ 7Wp3XNo+k4fO2CUEdkMEnRmtkKfRvSVX3yhOig5V8aLhLOhTOXfNLNDIMK+8EM8wO8wR L35luPWmKTy7VK6A4bnYs17Jo+StHvmY4oiNe2aQTxB2fAohqNY83D9gk99HYqybWZCi tNurBb8TaR9ubfYNdRa4NGoTZZbVkjQiwhaCuHQMGb8u4tlZ6hE0HKMkjtTsOXZq7gBs XEmg== X-Gm-Message-State: APjAAAVQyDlps9Av+smYAPqLPRz1WPbp8CTApkxhTUozwnlhmgO0jDXR soCYYDDcG5KTs3y3EkrWHRgO1r3mXTYxJ79VkNujaiUbVEqlB3t+CnUL61ekX84Qk64cJJQcchY PBCTy4yfL8EiUhggCTzZ4bbHJPw8gVUF7NxnhRiKgcuKd5bq59uCY6wUpXu5ZImyvlmWWHcojhQ == X-Google-Smtp-Source: APXvYqzf1M88N6RLF4htxc6grnYttxRMKA1ZWCdTCEm8R+mKiQdLKJQV76E8gDBM7sQ6KZz8kZUITgCFlKwXflUWgog= X-Received: by 2002:ab0:1004:: with SMTP id f4mr17827103uab.79.1559869764551; Thu, 06 Jun 2019 18:09:24 -0700 (PDT) Date: Thu, 6 Jun 2019 18:08:10 -0700 In-Reply-To: <20190607010811.52944-1-emilyshaffer@google.com> Message-Id: <20190607010811.52944-13-emilyshaffer@google.com> Mime-Version: 1.0 References: <20190607010708.46654-1-emilyshaffer@google.com> <20190607010811.52944-1-emilyshaffer@google.com> X-Mailer: git-send-email 2.22.0.rc1.311.g5d7573a151-goog Subject: [RFC PATCH 12/13] walken: count omitted objects From: Emily Shaffer To: git@vger.kernel.org Cc: Emily Shaffer Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP It may be illuminating to see which objects were not included within a given filter. This also demonstrates, since filter-spec "tree:1" is used, that the 'omitted' list contains all objects which are omitted, not just the first objects which were omitted - that is, it continues to dereference omitted trees and commits. This is part of a tutorial on performing revision walks. Signed-off-by: Emily Shaffer --- builtin/walken.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/builtin/walken.c b/builtin/walken.c index f2c98bcd6b..d93725ee88 100644 --- a/builtin/walken.c +++ b/builtin/walken.c @@ -137,6 +137,9 @@ static int walken_object_walk(struct rev_info *rev) { struct list_objects_filter_options filter_options = {}; struct oidset omitted; + struct oidset_iter oit; + struct object_id *oid = NULL; + int omitted_count = 0; oidset_init(&omitted, 0); printf("walken_object_walk beginning...\n"); @@ -172,9 +175,15 @@ static int walken_object_walk(struct rev_info *rev) walken_show_commit, walken_show_object, NULL, &omitted); } + /* Count the omitted objects. */ + oidset_iter_init(&omitted, &oit); + + while ((oid = oidset_iter_next(&oit))) + omitted_count++; + printf(_("Object walk completed. Found %d commits, %d blobs, %d tags, " - "and %d trees.\n"), commit_count, blob_count, tag_count, - tree_count); + "and %d trees; %d omitted objects.\n"), commit_count, + blob_count, tag_count, tree_count, omitted_count); return 0; } From patchwork Fri Jun 7 01:08:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emily Shaffer X-Patchwork-Id: 10980653 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9732492A for ; Fri, 7 Jun 2019 01:09:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 85D2828AC4 for ; Fri, 7 Jun 2019 01:09:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7A12528ADD; Fri, 7 Jun 2019 01:09:30 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, USER_IN_DEF_DKIM_WL autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6A04C28AC4 for ; Fri, 7 Jun 2019 01:09:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727782AbfFGBJ2 (ORCPT ); Thu, 6 Jun 2019 21:09:28 -0400 Received: from mail-qt1-f202.google.com ([209.85.160.202]:48758 "EHLO mail-qt1-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725784AbfFGBJ2 (ORCPT ); Thu, 6 Jun 2019 21:09:28 -0400 Received: by mail-qt1-f202.google.com with SMTP id q13so488617qtj.15 for ; Thu, 06 Jun 2019 18:09:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=/b3fJha4NM5K/TtuszksBb/HFoPjGHpcomOcmLu4Xts=; b=E3llYSPW/la4DRslopFlTe8SlOR5cstuE3N7ohZbRTaU1pp+q87RiC5xQzEXl95Qio SGGZLKrv297YzxWIKzLhDhQdkwVHEMkdJwELuBeHF3dOKrITr02v4Uw+5DfhZRezAqT6 UHeGCTqK60ZpSgNa1yTXqgtEfhFOiBTva08Ji9jqC4fGbt+H4BrTr3BVku357wWFaN87 8ThofDpj+XfGe/IeTHZspLQcZT7yCvoPXptK98poJu/P1rFyANx4pI2tz2v1JAwsTF41 3tzUqDxt3Ayyxq6EdueUPs0d9Gj5X3H746QpyB7EUhkseLDNVgKPyqE4Ps5mPRLF/vBZ H80g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=/b3fJha4NM5K/TtuszksBb/HFoPjGHpcomOcmLu4Xts=; b=KiAqjKQ6N14nXn7ZWWTqkvz1514OxEa3jQCgxmvNLiZlnVAZMQCEPGwB1IhHGzXQeh dxeKvoqDju7HBo2yHiSLNkgLoS2H0cuci25DbDJKwzp5y7W2KhvY7mEBbXDYmeWvl9D1 HcEjY9t2/wBLGZ2keyH7F792SjbjXJ2HfCKl0uPFVdhteuP6cHzv8yOtjNBL3xH/oqXJ d0/BClARr1wrvOtDdOMvcyNbo1H3Lu3GGlwfw8zVGwk+9JfF8QbIRgeU2cnrbK9gtaKS RqiCCaxCOt2T1Io2Zt3dMTPwt+ELcVkdo3TP0dcj1v3ta6VBlmZCcx7oFHDZ4VZpY5Mp lOfQ== X-Gm-Message-State: APjAAAWOKM2kdsJ2lpyOKHlMAkChV49aQERuuUUJIJSNbPamnh14z5DV vYAzBZnmtaVubunnEUB5hBAa9+bVxJl0QLTmL8CnRuWCqTLUvYalYiNHlWmzEKfZo9o0VJPlMd3 DMrcwi1G14Z5x5CFE6JTqIlJ+DJ4cU+RDDb7xdZMITYfwjFpwg29MuipCayft6hkQk5c/XbM7YA == X-Google-Smtp-Source: APXvYqyFjdEosH0GauAD2ENpmQoABGqhXB+InOWCLLU0Co3JmLkeaaRRLkyloqZBPIKa6lmADrM+XplQhVyTmU0Md2o= X-Received: by 2002:ae9:f209:: with SMTP id m9mr21201343qkg.251.1559869767025; Thu, 06 Jun 2019 18:09:27 -0700 (PDT) Date: Thu, 6 Jun 2019 18:08:11 -0700 In-Reply-To: <20190607010811.52944-1-emilyshaffer@google.com> Message-Id: <20190607010811.52944-14-emilyshaffer@google.com> Mime-Version: 1.0 References: <20190607010708.46654-1-emilyshaffer@google.com> <20190607010811.52944-1-emilyshaffer@google.com> X-Mailer: git-send-email 2.22.0.rc1.311.g5d7573a151-goog Subject: [RFC PATCH 13/13] walken: reverse the object walk order From: Emily Shaffer To: git@vger.kernel.org Cc: Emily Shaffer Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Demonstrate that just like commit walks, object walks can have their order reversed. Additionally, add verbose logging of objects encountered in order to let contributors prove to themselves that the walk has actually been reversed. With this commit, `git walken` becomes extremely chatty - it's recommended to pipe the output through `head` or `tail` or to redirect it into a file. Signed-off-by: Emily Shaffer --- builtin/walken.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/builtin/walken.c b/builtin/walken.c index d93725ee88..4bfee3a2d7 100644 --- a/builtin/walken.c +++ b/builtin/walken.c @@ -102,11 +102,13 @@ static int git_walken_config(const char *var, const char *value, void *cb) static void walken_show_commit(struct commit *cmt, void *buf) { + printf(_("commit: %s\n"), oid_to_hex(&cmt->object.oid)); commit_count++; } static void walken_show_object(struct object *obj, const char *str, void *buf) { + printf(_("%s: %s\n"), type_name(obj->type), oid_to_hex(&obj->oid)); switch (obj->type) { case OBJ_TREE: tree_count++; @@ -149,6 +151,7 @@ static int walken_object_walk(struct rev_info *rev) rev->tag_objects = 1; rev->tree_blobs_in_commit_order = 1; rev->exclude_promisor_objects = 1; + rev->reverse = 1; if (prepare_revision_walk(rev)) die(_("revision walk setup failed"));