From patchwork Mon Jul 1 20:20: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: 11026655 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 E24A7746 for ; Mon, 1 Jul 2019 20:20:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C9B202870B for ; Mon, 1 Jul 2019 20:20:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BE08E28741; Mon, 1 Jul 2019 20:20:29 +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 442BC28725 for ; Mon, 1 Jul 2019 20:20:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726738AbfGAUUZ (ORCPT ); Mon, 1 Jul 2019 16:20:25 -0400 Received: from mail-pg1-f202.google.com ([209.85.215.202]:36233 "EHLO mail-pg1-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726586AbfGAUUZ (ORCPT ); Mon, 1 Jul 2019 16:20:25 -0400 Received: by mail-pg1-f202.google.com with SMTP id s4so8207693pgr.3 for ; Mon, 01 Jul 2019 13:20: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=h5tPu6j20EkRGmVU+jgtTRm2YSQXSICHUxEy38FikbE=; b=dZVFrhGwRaQQ1LuJ2V7jGJ+ykxsvb4dPC56EA7nINtcAbXLPMVcs9uQRJsjhhyM4C3 lF1IffU3WVDEzVeC40uZDURMcuAnA3MDxqjdIJdYyUSypTSb875FnB5ayZ8Y2gUBzTFN NlTQhFnZvbdK2RDOeW/hR2nZpiuDnHzdH6gBWKrLFRtw2PU7nGLR78aaKsChw4E+lNQb yvA+JdmyD5Q+V171uujuxuSh0lvhgpxogrdvbAvWaWrFUVymP8xptU6vPkkkky6fW+FY ri7OHg9hgNcXLIdWvh3njzrvtIdrr5V0NdB8Sl0AOzx2KD/pBuV2kfAfEJJ7qJ8fVzYI AkSQ== 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=h5tPu6j20EkRGmVU+jgtTRm2YSQXSICHUxEy38FikbE=; b=WYjohMLwR+6/D0lbbGWoWfk8RXgDgFAsJ/69gRillYIlELySX9muVyTfeaJjZWkVVe e8KoizYdD0j1a/Wvf61KcQFiygmUOaQ6wXPjXapS6QM00F3WmgIjdoAqLeN5hLQ/rW5t S5coPycaH4xI+fpUYY4pTCyUQW5OQ54CktboZO/21i2F6qI+gM1n3HLv6MKyYaHT1gRl OBFUJ8k2rHJaoVx55hTUNJztYbh2YGKpAmtvFiZhBf/K97sQhnxGlBA23FUdK4/T6G5q mfOi7VNdaGfkAwP0LnaeXptds54R/QJaBL8zSZn8MdEluh4gbJFQf43vuxiq0SCUeyR7 yvKw== X-Gm-Message-State: APjAAAXvA4HEqP5JdkHAzua1r55bM7g7lRP716WVy7o0g56XZAORIPNP IsE25ziFSdj4qG2bIZA07mhiwrlRRM7qfdsrTsZBHNut5kfVW0AD3xO4Eexah/qRp+VWM0Fe9ym rPd7CFSIXmvXvXSoQ3dSxlADomL90OyK0rPfOJxLjThf0c8GBQEGeCGCHOukSYq7c752OcZKoLw == X-Google-Smtp-Source: APXvYqw1yMYoVw1WVFSq0RVzAyq6cLzkM2wdV/6YH7z2JHYNAtZ3VbdZ3YL1QyXoCmnKT2urqUVp3qbSJTPP3NNcKVk= X-Received: by 2002:a63:5765:: with SMTP id h37mr8974312pgm.183.1562012424385; Mon, 01 Jul 2019 13:20:24 -0700 (PDT) Date: Mon, 1 Jul 2019 13:20:02 -0700 In-Reply-To: <20190701202014.34480-1-emilyshaffer@google.com> Message-Id: <20190701202014.34480-2-emilyshaffer@google.com> Mime-Version: 1.0 References: <20190701201934.30321-1-emilyshaffer@google.com> <20190701202014.34480-1-emilyshaffer@google.com> X-Mailer: git-send-email 2.22.0.410.gd8fdbe21b5-goog Subject: [RFC PATCH v3 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 Change-Id: I64297621919412f54701e111366e99c4ef0feae3 --- Makefile | 1 + builtin.h | 1 + builtin/walken.c | 18 ++++++++++++++++++ 3 files changed, 20 insertions(+) create mode 100644 builtin/walken.c diff --git a/Makefile b/Makefile index f58bf14c7b..5bac1dbf8d 100644 --- a/Makefile +++ b/Makefile @@ -1137,6 +1137,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..db3ca50b04 --- /dev/null +++ b/builtin/walken.c @@ -0,0 +1,18 @@ +/* + * "git walken" + * + * Part of the "My First Revision Walk" tutorial. + */ + +#include "builtin.h" + +int cmd_walken(int argc, const char **argv, const char *prefix) +{ + /* + * This line is "human-readable" and we are writing a plumbing command, + * so we localize it and use the trace library to print only when + * the GIT_TRACE environment variable is set. + */ + trace_printf(_("cmd_walken incoming...\n")); + return 0; +} From patchwork Mon Jul 1 20:20: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: 11026661 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 B679E746 for ; Mon, 1 Jul 2019 20:20:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9F73426E3E for ; Mon, 1 Jul 2019 20:20:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8FDCE27FA8; Mon, 1 Jul 2019 20:20:32 +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 83F4726E3E for ; Mon, 1 Jul 2019 20:20:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726816AbfGAUUa (ORCPT ); Mon, 1 Jul 2019 16:20:30 -0400 Received: from mail-qk1-f202.google.com ([209.85.222.202]:51357 "EHLO mail-qk1-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726586AbfGAUUa (ORCPT ); Mon, 1 Jul 2019 16:20:30 -0400 Received: by mail-qk1-f202.google.com with SMTP id s25so14613479qkj.18 for ; Mon, 01 Jul 2019 13:20:29 -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=jSQvFaYx8OknHgkQjx11dVbZwuTNKQ0OGKIEhOezOSc=; b=tcu32lbgfhr/V4kBI3vJYVa1WX42CwaqjjXPb49oDSYoufjlARA2XW9J/AYg/eSlM2 H3Hz4e/EaZhUsMRdPt5OKCKi34Dzi1SEWVEL6F47boAxbAtgcOy3c09AAScTF2KniaAW ZbF9sgfWx7qyjxZA/BJXUW8vXf3tFUn8qAE3c9mFirv03FqIzmBKRDuG8TYtZ/OgI5Bh SmBMNaLYjnhJobO0KC/81ZZyemgRuhNL9FRQgxJwgbQ7KbqJMjEsarszbNr/LSR2whXq kaeS38hWwMkIFFa+zKpTmvarAE8yQmhw2iG/MGCIbT7H/CepMMIR5O+L9IuB5TvjMcVC TkfQ== 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=jSQvFaYx8OknHgkQjx11dVbZwuTNKQ0OGKIEhOezOSc=; b=CZF1zOIKoeihhhbLGsmEHDi0a7Ee3dCRea43UEnKXH1felL7Mn0h12hHcixJ21MT6G ix9yTI6Yw67DhNMPe8WN9ZA26WekgroZdZ3TDB58IHTUL9XeHq/VtItPwT3bQIoLnlGo pSb5xXdzwB2jveNYrHJsj2I82RWgkUVS2xguklPw47pelesSuWKNL0x1l7b/+W1FPPtg fCJDjl1Bk9QYSrO+zPfisHAgloge2KfcWOKciYO097y2FWbOpsOSM0DnBgeLdl03JYNN tmlkJXgP8CKFOGIgGcvpy9dwo8SjCzwjP8x77ARHUwJ9MBHu5zOVego3sjRaVP9CrPaK 6y6A== X-Gm-Message-State: APjAAAXjYPqDl1Lx7uORnVll8iM++6hgSv9EhYgg3u3HjybLoMrUn8iX A4khL+sLq+VpEaDrhIwgdLEvC3HaI8hJTCU+EGkMWFsLCTG8eNa0JDP4JElobP3SFrFQwhVeh0C E9ASPAUpArRRQTOsICJQNzPbtJdY3uyc6JzpqdQCWG2gss6yxa8beDpZjojsM5vzAMw14A100qA == X-Google-Smtp-Source: APXvYqx7DwHpPTRbgX31B1k0sEHUL987WqrHykXif3uEoKBPdReguVa0CRecElvOs92vxM9D5/mX7UM6wShztCl/TSU= X-Received: by 2002:a37:c45:: with SMTP id 66mr22014245qkm.31.1562012429511; Mon, 01 Jul 2019 13:20:29 -0700 (PDT) Date: Mon, 1 Jul 2019 13:20:04 -0700 In-Reply-To: <20190701202014.34480-1-emilyshaffer@google.com> Message-Id: <20190701202014.34480-4-emilyshaffer@google.com> Mime-Version: 1.0 References: <20190701201934.30321-1-emilyshaffer@google.com> <20190701202014.34480-1-emilyshaffer@google.com> X-Mailer: git-send-email 2.22.0.410.gd8fdbe21b5-goog Subject: [RFC PATCH v3 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 | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/builtin/walken.c b/builtin/walken.c index dd55f3b350..19657b5e31 100644 --- a/builtin/walken.c +++ b/builtin/walken.c @@ -8,6 +8,19 @@ #include "parse-options.h" +/* + * 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) { /* @@ -29,6 +42,8 @@ int cmd_walken(int argc, const char **argv, const char *prefix) */ argc = parse_options(argc, argv, prefix, options, walken_usage, 0); + init_walken_defaults(); + /* * This line is "human-readable" and we are writing a plumbing command, * so we localize it and use the trace library to print only when From patchwork Mon Jul 1 20:20: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: 11026663 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 74DEA746 for ; Mon, 1 Jul 2019 20:20:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6901926E3E for ; Mon, 1 Jul 2019 20:20:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5AE6A27FA8; Mon, 1 Jul 2019 20:20:34 +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 F12C726E3E for ; Mon, 1 Jul 2019 20:20:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726859AbfGAUUd (ORCPT ); Mon, 1 Jul 2019 16:20:33 -0400 Received: from mail-qt1-f201.google.com ([209.85.160.201]:54632 "EHLO mail-qt1-f201.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726586AbfGAUUc (ORCPT ); Mon, 1 Jul 2019 16:20:32 -0400 Received: by mail-qt1-f201.google.com with SMTP id r57so14365365qtj.21 for ; Mon, 01 Jul 2019 13:20:32 -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=c8xROOoy7OcOqiVdstCH/iWg1ZGb/TGPkK7Dlp8iY2w=; b=I1GNsZHcDfbO0G6dymYNnHv1hn1ez8BhWfnEEICivIrzWLf8gg8ZrFCYWloJDPn506 MoiJxFhg9nC9sJJHSM83Eq1vapW21FTa0Pe4Acuwt581Lwk9r3DIhu/STqS4dX4ckQld W2XR2cCj8Z7TK5t6W6Nq2+j6rPOgrT/ec/mAF7y65n7zC2KKU4Nn6+tZZ/wypLnT9k5a 9YGl3/tZmLR2pbYYtZuUiTT4DNuLPIwQWaWRhF16rKrdF8bQRCBwbcNiwEuXHOQ57eFk 3XeYIP1Sw3B+S8tM5AKLLKuyEfWxsLdraDDy7y2nYUWqSvvz+GoeJjBwMCBlWdAx6+u2 ZX5g== 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=c8xROOoy7OcOqiVdstCH/iWg1ZGb/TGPkK7Dlp8iY2w=; b=C6LqG5G/0/imWZ/D4Ul8cjQt0pAQoQ/MPTSf4866jv4R/DHcE+79yqkBSosjqblt0V L5ayUMVVezMm0RRDQtW+RLGrTeobcH8t3AEKXAv7k9N77RnLxBxt1qLvmkMu2l0mqwdy ZQLAyEMDAJO0dFgjqaGEK6KpO8EGNZneQxwIiiX0YaNfYMsb/NnhkWkW16VvoGcmX3Ja WEy7fA6axVYNvswJNPmbu4T5TFtMqIJVDa45wjBtvUtqbB5EHJMVM6/UEcHfthwv0WHG xdNrPMC5VUN3DeOaMBg+Pao2h1d3uT/ZHnLOQa9WC1Ge1iR82EMC0j0xccdIofrXoKGQ oxkw== X-Gm-Message-State: APjAAAWH1MVsZEVyktefv9FQ5+D1Q/Wc5c2NxFJN3KbIX+8AAA7lfS9y HL5FHv7vqDlOax4izlCQqPKrxlBxcoXDmlUSI8erxHmdbQVcJIT7vk37qI9u94yrOB7OieV3WwM btesG/KL7oBvjO66+xcCkWJGZqEnSszyHoV1te59EWp82pxYa8DuMYPJVL3ffSnLsqQUU8672MA == X-Google-Smtp-Source: APXvYqyL+sIxqcaufTqkTHrI3tPujMAG4MReEQmhmSOvDFtAgdZg23gP5YE3F+PpaZarlPsjjUX2U1zdrttZTmD+kc8= X-Received: by 2002:ac8:156:: with SMTP id f22mr21774808qtg.58.1562012431791; Mon, 01 Jul 2019 13:20:31 -0700 (PDT) Date: Mon, 1 Jul 2019 13:20:05 -0700 In-Reply-To: <20190701202014.34480-1-emilyshaffer@google.com> Message-Id: <20190701202014.34480-5-emilyshaffer@google.com> Mime-Version: 1.0 References: <20190701201934.30321-1-emilyshaffer@google.com> <20190701202014.34480-1-emilyshaffer@google.com> X-Mailer: git-send-email 2.22.0.410.gd8fdbe21b5-goog Subject: [RFC PATCH v3 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 | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/builtin/walken.c b/builtin/walken.c index 19657b5e31..e53c42ea18 100644 --- a/builtin/walken.c +++ b/builtin/walken.c @@ -5,6 +5,7 @@ */ #include "builtin.h" +#include "config.h" #include "parse-options.h" @@ -16,11 +17,36 @@ static void init_walken_defaults(void) { /* - * We don't actually need the same components `git log` does; leave this - * empty for now. + * We don't use any other components or have settings to initialize, so + * leave this empty. */ } +/* + * 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, we don't have any custom configuration, so fall back on the + * default config. + */ + return git_default_config(var, value, cb); +} + int cmd_walken(int argc, const char **argv, const char *prefix) { /* @@ -44,6 +70,8 @@ int cmd_walken(int argc, const char **argv, const char *prefix) init_walken_defaults(); + git_config(git_walken_config, NULL); + /* * This line is "human-readable" and we are writing a plumbing command, * so we localize it and use the trace library to print only when From patchwork Mon Jul 1 20:20: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: 11026665 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 ABC3714C0 for ; Mon, 1 Jul 2019 20:20:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9D3DC27F81 for ; Mon, 1 Jul 2019 20:20:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9186928066; Mon, 1 Jul 2019 20:20:40 +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 2A06627F81 for ; Mon, 1 Jul 2019 20:20:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726968AbfGAUUi (ORCPT ); Mon, 1 Jul 2019 16:20:38 -0400 Received: from mail-vk1-f201.google.com ([209.85.221.201]:38431 "EHLO mail-vk1-f201.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726642AbfGAUUf (ORCPT ); Mon, 1 Jul 2019 16:20:35 -0400 Received: by mail-vk1-f201.google.com with SMTP id u202so3910066vku.5 for ; Mon, 01 Jul 2019 13:20:34 -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=ZqS/0TlHfrtjHVcRz25wK1cSiHaTc/U2bYD0raG+XV8=; b=J5zSFIRYsgxfRUbzuJJKFCdJqVSpTyI+z6F1S1fCMFz4JQsM0+yJI8Eu1xPhuZ5utn 1DnM2Cq3s6fCjiHMoTQ7843J332LEUX3w11s+WFYAvwh5wBkPFkVG+dS0tUFi1OJaCs8 usum6wKgBq1GOAZ8Kycs7RO3IaWuBxQGK6vlqgDtyk8b3yZ2FLIBTWmy2TU1IS1f77FH YtLOHIFZ3flNglfRlc6TvNj5SeI4SrO/iGE8Sj7xTjezkx/oigtVQ8pXknvJgYMotbKz b4XHDHDu4zWMmAuSUn1gzTn2/dUG2o5DsfLByG1R+J5V+wx1ZGHXKqFAIF829Oo3Fxh5 Or9A== 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=ZqS/0TlHfrtjHVcRz25wK1cSiHaTc/U2bYD0raG+XV8=; b=fX85FLfd/eXocEvXCMganBJmhFR7/XXVy0mFyx7hna8uWi6TfhPHmHM8HR0Us52nE2 QoMEsmygIV9mJNO19Prz1j9lV7Jg4LkTpz4F6Y6GBTbzMkatFL8QfEFcxoItKIuca8nR qtj5lDWvcO0Kt5ilbZ5Axos/NxmkaamxObV4JP9zLxzh/rIsii8x66fFA0klLscs7Tnt +48WrcIaMlN+IFTQqB2ZPxhUfMh0v+vSUyyJi4TrkMrddqoe4BX1kftNPWZuhE8qgWU+ KnN5nxxDEhWvK8qi5ZePEkirKRYaEue60NKHZeiGR9zqqqAGJImK1w85lb53+Cw+OQJf NpdQ== X-Gm-Message-State: APjAAAXYiUAQPUqBnl4DKl8AdYmrQfHC6JwAqMjmNMpgW7mgAdtKI9IK HFkIv/xsqASFBCuonCJB9WLBjbicUqbnPnJZKPovDXIfhypXHDiK9LzQxm/0HdHHofm1AcsiFRp FWDZqvOYQVTwwoKBC8b+THAKXUyjb7DVvkCng1GNv+oP9A/UF/KDJv9QG/HAgymnhCriJo5JzlQ == X-Google-Smtp-Source: APXvYqyqzef/n5jYmI2CBRobUiAMBn4XHUHrybI/CI27WRfyP3obHTN2hDe2Eg1qnHkM+oimSIuWt+Jys5f3zwU4VuI= X-Received: by 2002:a1f:2896:: with SMTP id o144mr3522476vko.73.1562012434285; Mon, 01 Jul 2019 13:20:34 -0700 (PDT) Date: Mon, 1 Jul 2019 13:20:06 -0700 In-Reply-To: <20190701202014.34480-1-emilyshaffer@google.com> Message-Id: <20190701202014.34480-6-emilyshaffer@google.com> Mime-Version: 1.0 References: <20190701201934.30321-1-emilyshaffer@google.com> <20190701202014.34480-1-emilyshaffer@google.com> X-Mailer: git-send-email 2.22.0.410.gd8fdbe21b5-goog Subject: [RFC PATCH v3 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 walk 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 Change-Id: I76754b740227cf17a449f3f536dbbe37031e6f9a --- builtin/walken.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/builtin/walken.c b/builtin/walken.c index e53c42ea18..333d9ecc5e 100644 --- a/builtin/walken.c +++ b/builtin/walken.c @@ -5,6 +5,7 @@ */ #include "builtin.h" +#include "revision.h" #include "config.h" #include "parse-options.h" @@ -22,6 +23,40 @@ static void init_walken_defaults(void) */ } +/* + * Perform configuration for commit walk here. Within this function we set a + * starting point, and can customize our walk in various ways. + */ +static void final_rev_info_setup(int argc, const char **argv, const char *prefix, + struct rev_info *rev) +{ + /* + * Optional: + * 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. First we + * should make sure to reset it. This is useful for more complicated + * stuff but a decent shortcut for the first pass is + * add_head_to_pending(). + */ + + /* + * struct setup_revision_opt opt; + + * memset(&opt, 0, sizeof(opt)); + * opt.def = "HEAD"; + * opt.revarg_opt = REVARG_COMMITTISH; + * setup_revisions(argc, argv, rev, &opt); + */ + + /* add the HEAD to pending so we can start */ + add_head_to_pending(rev); + + /* Let's force oneline format. */ + get_commit_format("oneline", rev); + rev->verbose_header = 1; +} + /* * This method will be called back by git_config(). It is used to gather values * from the configuration files available to Git. @@ -62,6 +97,8 @@ int cmd_walken(int argc, const char **argv, const char *prefix) OPT_END() }; + struct rev_info rev; + /* * parse_options() handles showing usage if incorrect options are * provided, or if '-h' is passed. @@ -72,6 +109,19 @@ int cmd_walken(int argc, const char **argv, const char *prefix) 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 by giving it + * something to go in `pending` - that happens in here + */ + final_rev_info_setup(argc, argv, prefix, &rev); + /* * This line is "human-readable" and we are writing a plumbing command, * so we localize it and use the trace library to print only when From patchwork Mon Jul 1 20:20: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: 11026667 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 3315A1510 for ; Mon, 1 Jul 2019 20:20:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 261D327FA8 for ; Mon, 1 Jul 2019 20:20:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1A62F2807B; Mon, 1 Jul 2019 20:20:41 +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 B09B627FA8 for ; Mon, 1 Jul 2019 20:20:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726974AbfGAUUj (ORCPT ); Mon, 1 Jul 2019 16:20:39 -0400 Received: from mail-qt1-f201.google.com ([209.85.160.201]:52016 "EHLO mail-qt1-f201.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726586AbfGAUUi (ORCPT ); Mon, 1 Jul 2019 16:20:38 -0400 Received: by mail-qt1-f201.google.com with SMTP id x1so14360720qtj.18 for ; Mon, 01 Jul 2019 13:20:37 -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=3jiY5HwMMNkeEqYlQkZcQlwTdu0r39u5zLFFfkdRJJI=; b=m1DQnq7T6E12E65kUFJct7aCy8z1qlCCBfIdhVX4ImgjzOXQYy1Ps0z+if+wqX3cMc 3UinyJL6OGStRJrOunASyh3CVXw18shp7QuDFH1CqkXzib5JXVq4+XE/SQwd6jJ0PWjE 1QLWcqRHZI/dw0GGSmCjNcMlDM+NdoMk6JnMHrBMlKFzvz41ZADnXQ/rlGAbirWskA88 X8ArmZg9zJhjhRe0Kx3Pw/jmARmPcXWYEt0G++qe1odIu3PxmKWLB1yOm1MqcgpjajbE dhADGIGcrWBhoImYHTdtVAceG7mhMfUcsO1/bvSJvTU+cdEJoROQKq3Ds7kBXB31AuB6 SgXA== 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=3jiY5HwMMNkeEqYlQkZcQlwTdu0r39u5zLFFfkdRJJI=; b=DSh43GVy0FBatyZqRqsvoQKQai9Ph6jz+F2N1ptBnZM3pfICZB5gH0t9iXjQ2RtdUu YJ9uOWZ0IepM8DtqjvLvuhYopwWG7cOzfGox8KTlJgsKMKBqvEXbaoHJjTA5gvHrTHjz lBGOBcWTyCr2Tkh98UV9ULiDa+fNqITF+GGuL5pA2AkIBDetucyKXqArw2KV5COOBz8V APZkecKs/c1GelugXSU2wG2LS40EtPWRmOge7X4WthsFl79rFPa/sARZuY/BJCaCM9JR 1+6JvVuRbz0aA2SJsq2VdW0OCybBf6S1/Ivz07WT/hERwy+ATuNKAWZFNRUv/t7y6Da7 6hXA== X-Gm-Message-State: APjAAAXj9RfP2RM6ExdDWor4/vuolYQGazWrkaEz2xioA9FozTGMgZ6K NX0OWNWPs4oZ+y6xvfCYjc2viqCDn2usO+Bu1Iod320BfScR1IhHRN3UjsrzyAZgQs0hHtlD4m0 1c1VE3Xam2kOC65t8nxa60UU7wOdops85DE1mzDb/09MeSxjSwiPk5U0lvmAT7C8H5hiwGi8S9Q == X-Google-Smtp-Source: APXvYqzgTlQMHn5wqtIHVT030a7UoFRj2NopnBziD/80ajMfX/E1CmHdFz5URdna3kRcUongTrXZBLUb3iE8HLCsMok= X-Received: by 2002:a37:9f12:: with SMTP id i18mr21906876qke.111.1562012437193; Mon, 01 Jul 2019 13:20:37 -0700 (PDT) Date: Mon, 1 Jul 2019 13:20:07 -0700 In-Reply-To: <20190701202014.34480-1-emilyshaffer@google.com> Message-Id: <20190701202014.34480-7-emilyshaffer@google.com> Mime-Version: 1.0 References: <20190701201934.30321-1-emilyshaffer@google.com> <20190701202014.34480-1-emilyshaffer@google.com> X-Mailer: git-send-email 2.22.0.410.gd8fdbe21b5-goog Subject: [RFC PATCH v3 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 Change-Id: If6dc5f3c9d14df077b99e42806cf790c96191582 --- builtin/walken.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/builtin/walken.c b/builtin/walken.c index 333d9ecc5e..f116bb6fca 100644 --- a/builtin/walken.c +++ b/builtin/walken.c @@ -6,8 +6,11 @@ #include "builtin.h" #include "revision.h" +#include "commit.h" #include "config.h" #include "parse-options.h" +#include "pretty.h" +#include "line-log.h" /* @@ -82,6 +85,40 @@ 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 + * performs the actual commit walk. + */ +static void walken_commit_walk(struct rev_info *rev) +{ + struct commit *commit; + struct strbuf prettybuf = STRBUF_INIT; + + /* + * 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. + */ + while ((commit = get_revision(rev))) { + strbuf_reset(&prettybuf); + pp_commit_easy(CMIT_FMT_ONELINE, commit, &prettybuf); + /* + * We expect this part of the output to be machine-parseable - + * one commit message per line - so we send it to stdout. + */ + puts(prettybuf.buf); + } + + strbuf_release(&prettybuf); +} + int cmd_walken(int argc, const char **argv, const char *prefix) { /* @@ -116,12 +153,17 @@ 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 by giving it * something to go in `pending` - that happens in here */ final_rev_info_setup(argc, argv, prefix, &rev); + walken_commit_walk(&rev); + /* * This line is "human-readable" and we are writing a plumbing command, * so we localize it and use the trace library to print only when From patchwork Mon Jul 1 20:20: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: 11026669 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 F0DD4746 for ; Mon, 1 Jul 2019 20:20:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E637927F81 for ; Mon, 1 Jul 2019 20:20:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DABC72807B; Mon, 1 Jul 2019 20:20:44 +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 C809027F81 for ; Mon, 1 Jul 2019 20:20:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726982AbfGAUUm (ORCPT ); Mon, 1 Jul 2019 16:20:42 -0400 Received: from mail-ua1-f73.google.com ([209.85.222.73]:35675 "EHLO mail-ua1-f73.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726586AbfGAUUk (ORCPT ); Mon, 1 Jul 2019 16:20:40 -0400 Received: by mail-ua1-f73.google.com with SMTP id s1so2591165uao.2 for ; Mon, 01 Jul 2019 13:20:40 -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=c9OZMoGPdDKVD8tl0a0+KZuqPEgrAymzY/dja2wJLR8=; b=REFHKiq5vV0RgEqH55RfnK5iirFzEUsHB3b5nxKM3UPdv5QJZ4VyFuj2FoHMk1gSIf x6q8ZPTwHqiSrmxbtz5sjUWq5M+UfHLW9YBSCvNyveSBN/sOCSyGCha8llMXsVV26+KT samORpdZmiuGGHIGg8XQHEVJhS3LfRUff5vKP0yPQeNu8fEZ2tWpFLKcy5SjETw5WyK5 vfOzzxMFTt7gyXMVcplxfVbR4mjBjI86/tE+GJCNuvEysrZDIIf8DYZxjn5+QSMOUEmL qbku4+dpTib4t3ge959LXUyznZhqoCKh1Q6P3snCfJdVdTu7xPKK7MswEzZ4KB9PGTXY gzfg== 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=c9OZMoGPdDKVD8tl0a0+KZuqPEgrAymzY/dja2wJLR8=; b=U6vQwT2B5KZl6PQhV2zzU6zuloG4eXZUGMibg39TDzRzY/dJh361rgwDVR1BTnhjYa 2i0Alm11vd9tSfd/q9RLHOC6f0DtSshGsZz0nmoQZhC5HjFLd/Eu5F6j8IDC/i5/COL1 95Kam3T40Ad9pc4JUBDSu5fFuKe5uYurTOvLI7BVhZU81PRi7ysgEUVX4k3bZmHFMb1T 3kFKHxFmr1c/BV598WtgmGjLZTPgCNhL01hGK9Ys4flS1bEUgdORvSfUAm3Bvxz2lX7B H1jsW3e2DAXjXOgYEmd6CZgZreYDhUDMLNRQyRERrzpC/vqpvIVEsKqp4g3HNw5ah1Ks bhNw== X-Gm-Message-State: APjAAAVeA6tfiRHzeANYmURSlfoCH7nPReIi++3c6SCdWoJqSBY0OxTc /LDlQBf6j6FTvI/wRigFdABDwEF0zt003fJEF6HmpqXdDdCMRwU8QQ6/kXk6cWaGQclECx3DbO3 eKYmaEOPOs/N7/4WnLShkBkldQ0E/MKOfkGcItlMegLCt7aPgdwi6cIUcfpVXW8enGmFG+CQjFg == X-Google-Smtp-Source: APXvYqzv0Z0ijQq+L25qDZi1AzUDcFCORYOmSwZjO4XU6FtTi4l+9XMwWWoXoTyttS9OBLKEy229Pq2PW2PzhFxM0Uc= X-Received: by 2002:ab0:3119:: with SMTP id e25mr14824111ual.96.1562012439698; Mon, 01 Jul 2019 13:20:39 -0700 (PDT) Date: Mon, 1 Jul 2019 13:20:08 -0700 In-Reply-To: <20190701202014.34480-1-emilyshaffer@google.com> Message-Id: <20190701202014.34480-8-emilyshaffer@google.com> Mime-Version: 1.0 References: <20190701201934.30321-1-emilyshaffer@google.com> <20190701202014.34480-1-emilyshaffer@google.com> X-Mailer: git-send-email 2.22.0.410.gd8fdbe21b5-goog Subject: [RFC PATCH v3 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 | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/builtin/walken.c b/builtin/walken.c index f116bb6fca..a600f88cf6 100644 --- a/builtin/walken.c +++ b/builtin/walken.c @@ -11,6 +11,7 @@ #include "parse-options.h" #include "pretty.h" #include "line-log.h" +#include "grep.h" /* @@ -20,10 +21,8 @@ */ static void init_walken_defaults(void) { - /* - * We don't use any other components or have settings to initialize, so - * leave this empty. - */ + /* Needed by our grep filter. */ + init_grep_defaults(the_repository); } /* @@ -55,6 +54,10 @@ 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); + /* Apply a 'grep' pattern to the 'author' 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; @@ -78,10 +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, we don't have any custom configuration, so fall back on the - * default config. - */ + grep_config(var, value, cb); return git_default_config(var, value, cb); } From patchwork Mon Jul 1 20:20: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: 11026671 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 52DD01510 for ; Mon, 1 Jul 2019 20:20:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 48DCF27FA8 for ; Mon, 1 Jul 2019 20:20:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3D5A128066; Mon, 1 Jul 2019 20:20:45 +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 D640927FA8 for ; Mon, 1 Jul 2019 20:20:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726985AbfGAUUn (ORCPT ); Mon, 1 Jul 2019 16:20:43 -0400 Received: from mail-pg1-f201.google.com ([209.85.215.201]:36236 "EHLO mail-pg1-f201.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726979AbfGAUUn (ORCPT ); Mon, 1 Jul 2019 16:20:43 -0400 Received: by mail-pg1-f201.google.com with SMTP id s4so8208115pgr.3 for ; Mon, 01 Jul 2019 13:20:42 -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=C0JM8iml0Y7b/nw5glrRKi3q0dLchCPJJi/QjsWiaII=; b=C3IDvDdw1HcnhTMMNCDoO2io07kd9+NJlSlyXj96j3Vptm/LVI5Lclm38wgK61uYgI XHzzd3yzx3tP12CdO+Xp0jzSNMj7ENONbnlFBdYartR9LoBvLo0LH50ulYx5k7SLO0tH N1RxXcrC0u3uNk2nSYDmJDRUPP4GDvVCk2ULz6ZxmHkrt16jKDX1ijA45/MZudRdh+qD WV212y150oR8rC7c6Hn8kAkuD43O6YDYEycOqJWUEfAGdSHwElAZM+nHmf31FzHH0Kz5 Uhpz5JfxXvV5IJl4zd/EHy3QYIif9Ct58ziJDuOdxlFlkWJXse2TFOyQ1pYsE4H/G0XI o/+A== 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=C0JM8iml0Y7b/nw5glrRKi3q0dLchCPJJi/QjsWiaII=; b=kTQ/92RZ3j/RzUWZjEFHSTZ1LyyRKrT6jVhgRIuprsrBlcEe6cpY/Ph/JmNNCfXoPA RfkUDR00ynrZITFekuBUJ2cvQynX3htdQR6MYnKwPnkYsCcySZV/7rmcCfSZtjerFZM0 blPXCXqjYBotr56ja7ACwpnSpwSgko4Kr9wG/lvd9zNtUKCdrICrTkL+D5Ey3fI9xaha +rUsASreVcHD/TdcunS6kn73aacDYKeozqLuEGjhtNKWM2ZOis11U/v6GTv5JW55sj7y LHXDz02NLWOjvYbSwiGwYHW2LkAyuoGqko+JrWYFCq1NRuuvwyCEfTnE71lt9o2XLCam EufQ== X-Gm-Message-State: APjAAAXWmny9rQc5PFeZp4EvMqNk4c3XK8yTU4Anlt57fGm5OGsBVSWw kqRz+NhvO50rx9jTs96tXsK5USs2cEGoHPcLyYredY/mkil0Bo6t4uPFEPAjGTy0G5Rnu0E/g2B bykVyU920flalw2Ix/PUhocsjpaBQB1SsD1j9nlPV7Kz8YfJ6z/rSsT5mD0u7buwPhKjAKE3rkg == X-Google-Smtp-Source: APXvYqxjv9DsaL4JptVMz9zgyRYSKWH4Xkk0ly9BpGGEitVwLIX0CGXzQeWmF1e65iv6a04N6s8XAMDRPg04Wu33NKc= X-Received: by 2002:a63:b547:: with SMTP id u7mr27427016pgo.322.1562012442030; Mon, 01 Jul 2019 13:20:42 -0700 (PDT) Date: Mon, 1 Jul 2019 13:20:09 -0700 In-Reply-To: <20190701202014.34480-1-emilyshaffer@google.com> Message-Id: <20190701202014.34480-9-emilyshaffer@google.com> Mime-Version: 1.0 References: <20190701201934.30321-1-emilyshaffer@google.com> <20190701202014.34480-1-emilyshaffer@google.com> X-Mailer: git-send-email 2.22.0.410.gd8fdbe21b5-goog Subject: [RFC PATCH v3 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 Change-Id: I7ce2f3e8a77c42001293637ae209087afec4ce2c --- builtin/walken.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/builtin/walken.c b/builtin/walken.c index a600f88cf6..b334f61e69 100644 --- a/builtin/walken.c +++ b/builtin/walken.c @@ -61,6 +61,13 @@ static void final_rev_info_setup(int argc, const char **argv, const char *prefix /* Let's force oneline format. */ get_commit_format("oneline", rev); rev->verbose_header = 1; + + /* Let's play with the sort order. */ + rev->topo_order = 1; + + /* Toggle between these and observe the difference. */ + rev->sort_order = REV_SORT_BY_COMMIT_DATE; + /* rev->sort_order = REV_SORT_BY_AUTHOR_DATE; */ } /* From patchwork Mon Jul 1 20:20: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: 11026673 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 95956746 for ; Mon, 1 Jul 2019 20:20:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 89B2E27FA8 for ; Mon, 1 Jul 2019 20:20:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7E3EB28066; Mon, 1 Jul 2019 20:20:48 +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 6EECD27FA8 for ; Mon, 1 Jul 2019 20:20:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726987AbfGAUUq (ORCPT ); Mon, 1 Jul 2019 16:20:46 -0400 Received: from mail-yb1-f202.google.com ([209.85.219.202]:45341 "EHLO mail-yb1-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726869AbfGAUUp (ORCPT ); Mon, 1 Jul 2019 16:20:45 -0400 Received: by mail-yb1-f202.google.com with SMTP id y3so963926ybg.12 for ; Mon, 01 Jul 2019 13:20:45 -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=JdDhJ4Uf2SlYgtWqySb3cKF6BNzumNx1IauuV4GcFIY=; b=dEvP6cQuupXLAg1DNnU/cO0OO0hteU6TAU0RhG0u4St6K4XQxateTH3VuGGq7Stmmv wA2vqIgSTeBWyavvkru5RduhLsFegURSdIBA/Aw2FiHtu8CCMpNtio8quFg3zYibGNRS ir/dBpeyzOjebVc5AtJFoumKc+u1jubj6aejIfjxwYre2KkgSvs4zZ9ydYOFC5izNWXm ltmmlKumylw/eSMc5Yh8bm4WdlkTvRvcWKnp58gwdz83X49jWfGTqz0650AOhTpZwaOe soTNLWr8fItfroVwlcI9w0/lgPB5jAgyeqzhIWuq+TRr8inUgfK7L0U4RiROrVFN1RW9 VCGA== 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=JdDhJ4Uf2SlYgtWqySb3cKF6BNzumNx1IauuV4GcFIY=; b=KqHlWRdaPND1PJDXUMl+iHiiAVNmjdPW5FLpzquuvz6skX/ZHCm33v8igkRp1JpZ8w TqPLX7zJYCW5zavk9xzfvSMHOWdCuZDXgWQSVIHc7htyVdOPO83R0JIHTakQKuXPeWCw jY/Ai+iS6MU5LhuobhRrO3VslACW2bx1JQfmp4kXHVuSfSzvh2d+vuBUZdfT1qLWPVCB eUkxEmLFXVgxFmR+EtME5dCh4QDrpCs5M2gW2PhHg4+CYk8yiiIbsOo5Ndihh5GPvRe2 e8htjX12e4kNeNX8D5nEmI8NXqWWbCSPmKCc7iXsMT6fo8+uPjXEcucLUsn1rvoIGql0 S/ow== X-Gm-Message-State: APjAAAUj+W0blYThHqCA2crpH1U/aPtwQv9geuDgRH86O0taYgRBoC8A h7tkfg4NZRn3o42wdCe6SYLyOfRPLEAfcb/BhNBJFzcrRiZrUkQa7UC/kQUlJMT8q2RBRkp9UFV oVnmzJ1Ot11cw5lKlYPHRcpaUMTOddDItkVFN2gQjiUoXStbmOlKoWq0V+6X0omQFUiWNjon0KQ == X-Google-Smtp-Source: APXvYqyWWRw65u90WMB/NYYZXtTzTFxhrB3FNW27ubAAJLoumS653JzXj0znYTC8Bkfid0rS7+mtZEsgckblLe/QZKA= X-Received: by 2002:a0d:d74f:: with SMTP id z76mr15433670ywd.40.1562012444665; Mon, 01 Jul 2019 13:20:44 -0700 (PDT) Date: Mon, 1 Jul 2019 13:20:10 -0700 In-Reply-To: <20190701202014.34480-1-emilyshaffer@google.com> Message-Id: <20190701202014.34480-10-emilyshaffer@google.com> Mime-Version: 1.0 References: <20190701201934.30321-1-emilyshaffer@google.com> <20190701202014.34480-1-emilyshaffer@google.com> X-Mailer: git-send-email 2.22.0.410.gd8fdbe21b5-goog Subject: [RFC PATCH v3 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). 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 b334f61e69..03a50158fb 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 /* Let's force oneline format. */ get_commit_format("oneline", rev); rev->verbose_header = 1; + + /* Reverse the order */ + rev->reverse = 1; /* Let's play with the sort order. */ rev->topo_order = 1; From patchwork Mon Jul 1 20:20: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: 11026675 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 0BF04746 for ; Mon, 1 Jul 2019 20:20:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 00A4527FA8 for ; Mon, 1 Jul 2019 20:20:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E9AFB28066; Mon, 1 Jul 2019 20:20:49 +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 7C11227FA8 for ; Mon, 1 Jul 2019 20:20:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726996AbfGAUUs (ORCPT ); Mon, 1 Jul 2019 16:20:48 -0400 Received: from mail-pf1-f201.google.com ([209.85.210.201]:33981 "EHLO mail-pf1-f201.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726869AbfGAUUs (ORCPT ); Mon, 1 Jul 2019 16:20:48 -0400 Received: by mail-pf1-f201.google.com with SMTP id i2so9453302pfe.1 for ; Mon, 01 Jul 2019 13:20:47 -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=Q5QeI0tDEWjThRt/IPSRYbL/y6mt0+UXqsgB2FHUb/g=; b=AzyMNgX+8UG5h1rHuSv6+HOu/s+6XLCKZq1hMtL2CUvx5wPHcyNASTM7C4HmcN+6Gk oCJRMHo5J+D4PvhB2WckUuDNNjF4ALBz1dFPHTQn8/DJAt8TQeSyBzihu+Bs8TNbj/I0 /fCGC1FbZg0eHEdAZJvjrcPn5MDHxT3KvutxVIsi7DvmP4FDOL9ZsUI7HICV7C7X8zJ4 6mCD7AIl2kUkg0QDMkoh5F2U01ZoKOHvL46f6CWarwlJmB2hK5VsFTJkAC8nv+EVwEpp gNzS0/qxrXsKnkuj4MpFeSh044bFLI0EicE8lmVtxXv942kSxC7DFnaezgh90j+hfwEN GM5w== 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=Q5QeI0tDEWjThRt/IPSRYbL/y6mt0+UXqsgB2FHUb/g=; b=VFlMwWKhFpwnOx0+uWCMC6ubH14Ra60O9kPSM2LLruWKCr7YSTUJOs9NFTyszrWk/w iCqzG7F/NHtMi2RcoNKrA7qc4OlrgKJeoj0GTJ/gfsZ0IaQH+oX7HAKkpQUpo1SKDSsJ xsuBcvj/XGky/qwHhNdAF4Hn2MuW1o+9j1LwpVRA/i+AVHitruRNNGl9Nskk/VHOyJ6B W7oKrtkUblWm4OmSD/QgNU4bDwkHn32HaPyT1/+lQv5i2+qqV26vL5LBd6HN1IjlGMXo uuTJ7PXnLjXi9aPXpeUYL5hcZ8LCcJ/CF+ckxxY53BhRpdGKUZTaoMCVSwVFKgYDUDUb aiMQ== X-Gm-Message-State: APjAAAVZ4ygPLPMw23GtrATVfhwVvN00JUiFW7EGdSYJzCkJed2DEBqy g8S+sGaGTsumpKqpewJ0bbChs7BQkehsOHGx0egbwqNDF3rcvbTcQictzPlO+/39nDWnDRBf3vQ 2mshJSoeQ7eDni3C0tbG2ge2do8g/q2eVesoNvtsX6hL3l6SpTjTw/cVpyhies6UUlfXIY75TIA == X-Google-Smtp-Source: APXvYqz0Ncg4A2G5qKtf/0ttpoG0maKcKERMUFOzctY4vTG0yXhKi5W7/OjGnzRwdy4eL/r4sMW6dU67FLTwvgkAjaY= X-Received: by 2002:a65:51c8:: with SMTP id i8mr3244026pgq.116.1562012446916; Mon, 01 Jul 2019 13:20:46 -0700 (PDT) Date: Mon, 1 Jul 2019 13:20:11 -0700 In-Reply-To: <20190701202014.34480-1-emilyshaffer@google.com> Message-Id: <20190701202014.34480-11-emilyshaffer@google.com> Mime-Version: 1.0 References: <20190701201934.30321-1-emilyshaffer@google.com> <20190701202014.34480-1-emilyshaffer@google.com> X-Mailer: git-send-email 2.22.0.410.gd8fdbe21b5-goog Subject: [RFC PATCH v3 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 Change-Id: If3b11652ba011b28d29b1c3984dac4a3f80a5f53 --- builtin/walken.c | 91 ++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 85 insertions(+), 6 deletions(-) diff --git a/builtin/walken.c b/builtin/walken.c index 03a50158fb..b613102cfb 100644 --- a/builtin/walken.c +++ b/builtin/walken.c @@ -11,9 +11,15 @@ #include "parse-options.h" #include "pretty.h" #include "line-log.h" +#include "list-objects.h" #include "grep.h" +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 @@ -95,6 +101,74 @@ 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: + /* + * BUG() is used to warn developers when they've made a change + * which breaks some relied-upon behavior of Git. In this case, + * we're telling developers that we don't expect commits to be + * routed as objects during an object walk. BUG() messages + * should not be localized. + */ + BUG("unexpected commit object in walken_show_object\n"); + default: + /* + * This statement will only be hit if a new object type is added + * to Git; we BUG() to tell developers that the new object type + * needs to be handled and counted here. + */ + BUG("unexpected object type %s in walken_show_object\n"), + type_name(obj->type); + } +} + +/* + * walken_object_walk() is invoked by cmd_walken() after initialization. It does + * a walk of all object types. + */ +static void walken_object_walk(struct rev_info *rev) +{ + 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); + + /* + * This print statement is designed to be script-parseable. Script + * authors will rely on the output not to change, so we will not + * localize this string. It will go to stdout directly. + */ + printf("commits %d\n blobs %d\n tags %d\n trees %d\n", commit_count, + blob_count, tag_count, tree_count); +} + /* * walken_commit_walk() is invoked by cmd_walken() after initialization. It * performs the actual commit walk. @@ -166,13 +240,18 @@ int cmd_walken(int argc, const char **argv, const char *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 by giving it - * something to go in `pending` - that happens in here - */ - final_rev_info_setup(argc, argv, prefix, &rev); - walken_commit_walk(&rev); + if (1) { + add_head_to_pending(&rev); + walken_object_walk(&rev); + } else { + /* + * Before we do the walk, we need to set a starting point by giving it + * something to go in `pending` - that happens in here + */ + final_rev_info_setup(argc, argv, prefix, &rev); + walken_commit_walk(&rev); + } /* * This line is "human-readable" and we are writing a plumbing command, From patchwork Mon Jul 1 20:20:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emily Shaffer X-Patchwork-Id: 11026677 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 0B52B746 for ; Mon, 1 Jul 2019 20:20:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F234427FA8 for ; Mon, 1 Jul 2019 20:20:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E6B8E28066; Mon, 1 Jul 2019 20:20:51 +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 8F73427FA8 for ; Mon, 1 Jul 2019 20:20:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727003AbfGAUUu (ORCPT ); Mon, 1 Jul 2019 16:20:50 -0400 Received: from mail-qt1-f202.google.com ([209.85.160.202]:36321 "EHLO mail-qt1-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726869AbfGAUUu (ORCPT ); Mon, 1 Jul 2019 16:20:50 -0400 Received: by mail-qt1-f202.google.com with SMTP id q26so14470672qtr.3 for ; Mon, 01 Jul 2019 13:20:49 -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=iggI4uXbtuezPewTv42o/1zrQdC/TfeIzWrcWRx3Pc4=; b=mw/EMohk4NZ74lSNX9K2UoXhVI+sgUkwrYElV3g63IYjz56ovEUtDlfHd0gra7GKUG VbdLssGuGnX6MxrXXsYRD3n56qH+W++QKNi22RcgLgQjubJ3lBrUMf6ROLWYEhTwZLJN 1ueormaNWc4Sn0SGsCHj1/9RmekaYE9itwhUrUGqFTs/fEG6ARMVFsiiNIU+1I1MdSH6 /SJz7DkSh5UUltw+EFjPpEyYdx8tvkQR+ladpaKWkdvNlO8fkbR7Vsqq4nTs5FEubznQ 4nwH5PgMkI8utavNjpoWzH/CyuUWvFHlpr99hpHIEyz5M/gSXMMrP5xutglb4+DYufxM mG+w== 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=iggI4uXbtuezPewTv42o/1zrQdC/TfeIzWrcWRx3Pc4=; b=NEPTOIC6VoalHrlOOCC6HiRPbzA0l5jZEkN5oPpsejQYB/RVIv3uzMM14DlVIuMhhk Dcy0Ueb0yE9n8oRBp30/ZO4MkoJYfHzg31yurT9asl/Paigj8bp52B+TDpLNmDc0DPVj //Zp14LH/+BnCEbzqvflVkSlFu4hOUwcuRw11Q98uVLwO+5DHMXYAgQWoTD65eL8zu89 b90j+Aiz+disHlEwn20tLCuEgUf0fqxIOTTHvwtoX6w7IPDlVNk2cPjFnJDeWY914Gad S6lv3cOSJBaYcU7fkRYEhWZw+5VsyPLcrUr3r6Mt3xPzBC1nMI14wW3OVuSbqddZy8kH zrlw== X-Gm-Message-State: APjAAAUSMvhGSChHz1JFN1mgYjbuD89/+EcoaB4t+1D1URb3aO/QuLlp /3n9ABqBQ7ox5IuM/rsE+d46EynOgHB7aXKcyOFTpwXeoEL3R/6JuaighgeUbPtUdkVoYWiDL3r skEGXhmaI/olORl5e49wi81+Hac35/xXZ3pO7m3TLSCdfVxEi9tF+LWWUf1lS9NaBB44/8IsIKA == X-Google-Smtp-Source: APXvYqyUkBHkyipN8mpZSkwZ488l+lNwnylYK6m8HPtsqwyTuLPiu/nFUKyf7HFPnOoSURx5SXWVZkI+G07Hm8mXQ7I= X-Received: by 2002:ac8:2f96:: with SMTP id l22mr22284659qta.188.1562012449401; Mon, 01 Jul 2019 13:20:49 -0700 (PDT) Date: Mon, 1 Jul 2019 13:20:12 -0700 In-Reply-To: <20190701202014.34480-1-emilyshaffer@google.com> Message-Id: <20190701202014.34480-12-emilyshaffer@google.com> Mime-Version: 1.0 References: <20190701201934.30321-1-emilyshaffer@google.com> <20190701202014.34480-1-emilyshaffer@google.com> X-Mailer: git-send-email 2.22.0.410.gd8fdbe21b5-goog Subject: [RFC PATCH v3 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 Change-Id: I6d22ba153c1afbc780c261c47f1fa03ea478b5ed --- builtin/walken.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/builtin/walken.c b/builtin/walken.c index b613102cfb..7b46377a2e 100644 --- a/builtin/walken.c +++ b/builtin/walken.c @@ -12,6 +12,7 @@ #include "pretty.h" #include "line-log.h" #include "list-objects.h" +#include "list-objects-filter-options.h" #include "grep.h" @@ -144,6 +145,8 @@ static void walken_show_object(struct object *obj, const char *str, void *buf) */ static void walken_object_walk(struct rev_info *rev) { + struct list_objects_filter_options filter_options = {}; + rev->tree_objects = 1; rev->blob_objects = 1; rev->tag_objects = 1; @@ -158,7 +161,24 @@ static void 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 (0) { + /* Unfiltered: */ + trace_printf(_("Unfiltered object walk.\n")); + traverse_commit_list(rev, walken_show_commit, + walken_show_object, NULL); + } else { + trace_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 during various operations (see + * `git help rev-list` and read the entry on `--filter`). + */ + parse_list_objects_filter(&filter_options, "tree:1"); + + traverse_commit_list_filtered(&filter_options, rev, + walken_show_commit, walken_show_object, NULL, NULL); + } /* * This print statement is designed to be script-parseable. Script From patchwork Mon Jul 1 20:20:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emily Shaffer X-Patchwork-Id: 11026679 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 04D9C14C0 for ; Mon, 1 Jul 2019 20:20:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ED0C827FA8 for ; Mon, 1 Jul 2019 20:20:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E144C28066; Mon, 1 Jul 2019 20:20:54 +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 9041E27FA8 for ; Mon, 1 Jul 2019 20:20:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727009AbfGAUUx (ORCPT ); Mon, 1 Jul 2019 16:20:53 -0400 Received: from mail-pf1-f201.google.com ([209.85.210.201]:55902 "EHLO mail-pf1-f201.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726762AbfGAUUx (ORCPT ); Mon, 1 Jul 2019 16:20:53 -0400 Received: by mail-pf1-f201.google.com with SMTP id i26so9414410pfo.22 for ; Mon, 01 Jul 2019 13:20:53 -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=P9pKwrlGaOOfj9iFXWKlglN3yvYMcUQW+AiUlhwNiJ0=; b=LzF0QmM5M/I6lBdKAhhlMmomK9n3Wx2T/lP1njlFJkDv2H3nKzeodP8+WaBvEoPD1u sk0RbBBg8lvh60kt8gMTUv7rPiLXpU74EngBZWu3LuBb1bc0olIIdBXyo1FUAcP7ipYu z7um6ErUMH0hdA7DrzlIFnIWzZMxkDffzViYaXyQui1nRbcGZYwEazluGLFmV9p/Zlod s1Ood/Hpw0t6nniQIUqYSL55e33Ik4elctICyZoipFVOPIkO7N7sMyC4MOU4tPED7KwO olV9xCiBWBAq52yHdg35eGwW8EkAl3Gp+To5j2J5h7M6miGeGmHgv2tkqVS9q/ObWPHw KMvw== 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=P9pKwrlGaOOfj9iFXWKlglN3yvYMcUQW+AiUlhwNiJ0=; b=efFgPFqW7vF6T94XZhN3mS+Z0T7/dDfjSL49XibI8fALN+UvfO/Gq8D2sBwtRJChh/ xYaZxaY+8NQ3gNDXQRv7TN3Rpaxysdx7JPdEcwG3xLJDQY11XrgDz9AVmuDZ5X7aOeON c7eNmc61gN7GZZ9tmy4gihsfwohPr0iP47fkApwoSa89fW/S1UkCLK0yreIxGWO6L2ef vOXpbArSZfsqmIKFwpXdX1P5b4WNnaBAZjsUXfsXo/bwovWDCVQGK+DOZZVPc8zRzEmN MgvdzLS2uuIE4cSmXCX5VGWrky01nB9qs4jchpqxR90Ha6uc0o0yDCr2BvgWiXMDkPtk hz2w== X-Gm-Message-State: APjAAAVi+dXWe4BGG3ckI9HQQu4NXMiMN3n8D6SZibF+3YyJ1uv18tTD YDAepDAg0K1HTeWggYtxMXlD98FFwq4Erp+DMmwM9g/KmouFJsJlVI0voUpo2Bu9RQkO1d9DjDR qrPP86hE+Xi01CnosuIDl9V1I6DPC4Y0BXMyw3CJJ4fuMldGDIKCK/0Nr2FZOOM6GY55niAT2iQ == X-Google-Smtp-Source: APXvYqwjSK+R3xtIB5KFGKSkE0OA6BGoUeVDZmKh9/W3/jBDkvo75lMCc0sHGpPHcnQjKrpJRQ62FsRiYV5Ur9hEG7A= X-Received: by 2002:a63:6cc3:: with SMTP id h186mr26182874pgc.292.1562012452457; Mon, 01 Jul 2019 13:20:52 -0700 (PDT) Date: Mon, 1 Jul 2019 13:20:13 -0700 In-Reply-To: <20190701202014.34480-1-emilyshaffer@google.com> Message-Id: <20190701202014.34480-13-emilyshaffer@google.com> Mime-Version: 1.0 References: <20190701201934.30321-1-emilyshaffer@google.com> <20190701202014.34480-1-emilyshaffer@google.com> X-Mailer: git-send-email 2.22.0.410.gd8fdbe21b5-goog Subject: [RFC PATCH v3 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 | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/builtin/walken.c b/builtin/walken.c index 7b46377a2e..1638f679f2 100644 --- a/builtin/walken.c +++ b/builtin/walken.c @@ -146,6 +146,11 @@ static void walken_show_object(struct object *obj, const char *str, void *buf) static void 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); rev->tree_objects = 1; rev->blob_objects = 1; @@ -180,13 +185,19 @@ static void walken_object_walk(struct rev_info *rev) walken_show_commit, walken_show_object, NULL, NULL); } + /* Count the omitted objects. */ + oidset_iter_init(&omitted, &oit); + + while ((oid = oidset_iter_next(&oit))) + omitted_count++; + /* * This print statement is designed to be script-parseable. Script * authors will rely on the output not to change, so we will not * localize this string. It will go to stdout directly. */ - printf("commits %d\n blobs %d\n tags %d\n trees %d\n", commit_count, - blob_count, tag_count, tree_count); + printf("commits %d\n blobs %d\n tags %d\n trees %d omitted %d\n", + commit_count, blob_count, tag_count, tree_count, omitted_count); } /* From patchwork Mon Jul 1 20:20:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emily Shaffer X-Patchwork-Id: 11026681 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 57FE914C0 for ; Mon, 1 Jul 2019 20:20:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4D2B427FA8 for ; Mon, 1 Jul 2019 20:20:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4183328066; Mon, 1 Jul 2019 20:20:57 +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 E6F5627FA8 for ; Mon, 1 Jul 2019 20:20:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727015AbfGAUU4 (ORCPT ); Mon, 1 Jul 2019 16:20:56 -0400 Received: from mail-pf1-f202.google.com ([209.85.210.202]:42411 "EHLO mail-pf1-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726762AbfGAUUz (ORCPT ); Mon, 1 Jul 2019 16:20:55 -0400 Received: by mail-pf1-f202.google.com with SMTP id y7so9442852pfy.9 for ; Mon, 01 Jul 2019 13:20:55 -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=Pp0OkZW/FgkuU6MiSbk6EZpEpgnCMkWIlsh0VlMIusk=; b=Tj3+tv+4giqrTHNSkH/DgANQm0r/3P9slff4GkYHfcInV5R3R0xsCcP5Qe+iHW/Xwv DWkWCtoyWh3W1ldgAdQIvAcCe6IY4TqXAGJ4ejYQneFDH9zXAjZ0nh3D32A7xFHG06gz IiINT6d1hZ8ZyF764jvaUw4nHMbzVTvYkR5bJobvARcCHPtbWTlRxEAcr3tvi9s5d4Bc jEdv2SQVkSn8RaMgVSfT7DJLiovgnzqMGhCRrqByq7CY2eYcmsNIbt9xqyak+tJuew7a G4qKurvutyayW/V4kk4p2oIa/c3yZZcYOoecCLBpkMg2mxXcR7MUB9p8KFEWWvPEzKOV U6yg== 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=Pp0OkZW/FgkuU6MiSbk6EZpEpgnCMkWIlsh0VlMIusk=; b=CIsKKgfMePg2eYB/nXNIwkEj1WPgxbrGBrXwiugRuS6xOFqUy684zqz5ZYMCKPKI7R RkYWMYHbx8uDj3VCrn1Xq7l7k2q7J9xBx+xzL4RGclAeB35+6e5DZU1WSWwjiF1xzqsR 8JnOkwgm0hgIi3h6hAf71tFxi78FiN2T7kACM+cG+3p20Z2VRqfsOBG7aVzhdJqqm0vS xfZdoJWv/Lbyt1+fppleFdH1lSQE3DEERAwKO5X6AUljLNab+ZKRPJJNgfJ8G6hYpxs0 dcSD9C4LZnZ3/ZJh9LQV8AubFTCgYWvoZTVMPgLhxXMu+aAT5IrzkpajkjHn2XDlg4BA R6HQ== X-Gm-Message-State: APjAAAU3KnOAAfvMrZrm3JBv6nOSIVxlL6Rl1Y3nOWhOyv3XSqCfjpBn 3+Q+I4bv6ypcC6EEqAJlDalxzns8oGGhccc7YEyKeulBTgKDrDLiPMA8SOkZ51a4FxgncJW+c5O nVU3YLxt8mf9V0uv8eKw7QSGZZmEagsMVgvTAR6LfZcY32Df5hfW7NVbeoWO8/fOFdVD1D8lH+w == X-Google-Smtp-Source: APXvYqxav2W9gm9cqfdaCDjIwfga0lAM2wsvqZaL0ECVPBuiwUOnDhSc17nkhKnU1OUOMtB0Pacf9drkMara7BZZuIs= X-Received: by 2002:a63:e317:: with SMTP id f23mr26143784pgh.39.1562012454769; Mon, 01 Jul 2019 13:20:54 -0700 (PDT) Date: Mon, 1 Jul 2019 13:20:14 -0700 In-Reply-To: <20190701202014.34480-1-emilyshaffer@google.com> Message-Id: <20190701202014.34480-14-emilyshaffer@google.com> Mime-Version: 1.0 References: <20190701201934.30321-1-emilyshaffer@google.com> <20190701202014.34480-1-emilyshaffer@google.com> X-Mailer: git-send-email 2.22.0.410.gd8fdbe21b5-goog Subject: [RFC PATCH v3 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 Change-Id: I91883b209a61ae4d87855878291e487fe36220c4 --- builtin/walken.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/builtin/walken.c b/builtin/walken.c index 1638f679f2..2eb12f92ed 100644 --- a/builtin/walken.c +++ b/builtin/walken.c @@ -104,11 +104,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++; @@ -157,6 +159,7 @@ static void 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"));