From patchwork Wed May 8 11:12:31 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Duy Nguyen X-Patchwork-Id: 10934957 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 4BDB513AD for ; Wed, 8 May 2019 11:13:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3A065201B0 for ; Wed, 8 May 2019 11:13:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 259662870C; Wed, 8 May 2019 11:13: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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI 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 9CCAC201B0 for ; Wed, 8 May 2019 11:13:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727424AbfEHLN2 (ORCPT ); Wed, 8 May 2019 07:13:28 -0400 Received: from mail-pg1-f193.google.com ([209.85.215.193]:33075 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726254AbfEHLN2 (ORCPT ); Wed, 8 May 2019 07:13:28 -0400 Received: by mail-pg1-f193.google.com with SMTP id h17so3969867pgv.0 for ; Wed, 08 May 2019 04:13:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=A4ZMZuk5PUzRDWgtCFj7V63t6/TPRpeBoDMTUV6s05Y=; b=tyCAA8bNeKSQmoPxkl3WCcUjhJgIpEjBZaq8pNsZrb0EGBDgFjSM3YIQr818sab4WZ LDedWWfu4F7hHPd6U44anhDtFzo8HnltBILnQb7XykUwMhSPTIikv4tZRGWzFRgllhQ0 bqAtwswy1D4dbcMOi7zD0M6WAypHsevoaKveJJFOafMXiGq/6ofnodVHHPMHdfFFW0Sn cN+a/Gd72i0s6Qkb/Ov1rRU8HIr7DF2XRYLAvHG3+Ns/BgWjnr1nWJpWF4guc5Ej+NBC iBDtq0LPIn32LpiXqU1XA1npkNXUbPwoC3LWWEnary1ai8wsAlqvU7No6qIcx0eQ2a5E WUIw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=A4ZMZuk5PUzRDWgtCFj7V63t6/TPRpeBoDMTUV6s05Y=; b=X/IoPqv991/lufPjiaJRHUuIYOCfwRZlZZiv/8gwZufBXeiUUgeOwb0exLJZx+Js7r Nx+zkSxwN168Emv7u5Q22d1Ib+IFEXrUKai1aZV+t+GFIzqqXQD4RAdcZOO8NMH1NYYO 2A1NmN659AQlV3761rBanyzWEClKPez6odulm3O/kxzrNIAaziiKMRlZWBM/FjnyGlke KzM3iv/TZHfdDjZqRS2hWAQex/2tKXVUi6m0dkzYTjj5CdMB57ou4Wyg1rQga/A0q5RB T9jc0tRkZcPy/hWQ3/G5G2x6SWcIYeRUtAvPppB9oWsZ9wLo2UpEG2plTt0tv1JUw+yG G8Sg== X-Gm-Message-State: APjAAAXPZTVrLBVoNtAMGSfuTxbs5Pn5MiMyee/QfpvlC2VUF0YBvE0E Se7tcIjSAT6ZdfWkBhqrLy1Ah88l X-Google-Smtp-Source: APXvYqx/UPJ4oxB5nwLJ4IM8dh78683CWNxiur5JjwZbo1E6d4R7AKFD92sfjsrFJod25VAMHd/jrA== X-Received: by 2002:a62:6b44:: with SMTP id g65mr47973926pfc.27.1557314007540; Wed, 08 May 2019 04:13:27 -0700 (PDT) Received: from ash ([115.72.28.243]) by smtp.gmail.com with ESMTPSA id h27sm21381876pfd.53.2019.05.08.04.13.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 08 May 2019 04:13:26 -0700 (PDT) Received: by ash (sSMTP sendmail emulation); Wed, 08 May 2019 18:13:23 +0700 From: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= To: git@vger.kernel.org Cc: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= Subject: [PATCH 01/19] revision.h: avoid bit fields in struct rev_info Date: Wed, 8 May 2019 18:12:31 +0700 Message-Id: <20190508111249.15262-2-pclouds@gmail.com> X-Mailer: git-send-email 2.21.0.1141.gd54ac2cb17 In-Reply-To: <20190508111249.15262-1-pclouds@gmail.com> References: <20190508111249.15262-1-pclouds@gmail.com> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Bitfield addresses cannot be passed around in a pointer. This makes it hard to use parse-options to set/unset them. Turn this struct to normal integers. This of course increases the size of this struct multiple times, but since we only have a handful of rev_info variables around, memory consumption is not at all a concern. Signed-off-by: Nguyễn Thái Ngọc Duy --- revision.h | 164 ++++++++++++++++++++++++++--------------------------- 1 file changed, 82 insertions(+), 82 deletions(-) diff --git a/revision.h b/revision.h index 4134dc6029..01e4c42274 100644 --- a/revision.h +++ b/revision.h @@ -107,95 +107,95 @@ struct rev_info { unsigned int early_output; - unsigned int ignore_missing:1, - ignore_missing_links:1; + unsigned int ignore_missing; + unsigned int ignore_missing_links; /* Traversal flags */ - unsigned int dense:1, - prune:1, - no_walk:2, - remove_empty_trees:1, - simplify_history:1, - topo_order:1, - simplify_merges:1, - simplify_by_decoration:1, - single_worktree:1, - tag_objects:1, - tree_objects:1, - blob_objects:1, - verify_objects:1, - edge_hint:1, - edge_hint_aggressive:1, - limited:1, - unpacked:1, - boundary:2, - count:1, - left_right:1, - left_only:1, - right_only:1, - rewrite_parents:1, - print_parents:1, - show_decorations:1, - reverse:1, - reverse_output_stage:1, - cherry_pick:1, - cherry_mark:1, - bisect:1, - ancestry_path:1, - first_parent_only:1, - line_level_traverse:1, - tree_blobs_in_commit_order:1, - - /* - * Blobs are shown without regard for their existence. - * But not so for trees: unless exclude_promisor_objects - * is set and the tree in question is a promisor object; - * OR ignore_missing_links is set, the revision walker - * dies with a "bad tree object HASH" message when - * encountering a missing tree. For callers that can - * handle missing trees and want them to be filterable - * and showable, set this to true. The revision walker - * will filter and show such a missing tree as usual, - * but will not attempt to recurse into this tree - * object. - */ - do_not_die_on_missing_tree:1, - - /* for internal use only */ - exclude_promisor_objects:1; + unsigned int dense; + unsigned int prune; + unsigned int no_walk; + unsigned int remove_empty_trees; + unsigned int simplify_history; + unsigned int topo_order; + unsigned int simplify_merges; + unsigned int simplify_by_decoration; + unsigned int single_worktree; + unsigned int tag_objects; + unsigned int tree_objects; + unsigned int blob_objects; + unsigned int verify_objects; + unsigned int edge_hint; + unsigned int edge_hint_aggressive; + unsigned int limited; + unsigned int unpacked; + unsigned int boundary; + unsigned int count; + unsigned int left_right; + unsigned int left_only; + unsigned int right_only; + unsigned int rewrite_parents; + unsigned int print_parents; + unsigned int show_decorations; + unsigned int reverse; + unsigned int reverse_output_stage; + unsigned int cherry_pick; + unsigned int cherry_mark; + unsigned int bisect; + unsigned int ancestry_path; + unsigned int first_parent_only; + unsigned int line_level_traverse; + unsigned int tree_blobs_in_commit_order; + + /* + * Blobs are shown without regard for their existence. + * But not so for trees: unless exclude_promisor_objects + * is set and the tree in question is a promisor object; + * OR ignore_missing_links is set, the revision walker + * dies with a "bad tree object HASH" message when + * encountering a missing tree. For callers that can + * handle missing trees and want them to be filterable + * and showable, set this to true. The revision walker + * will filter and show such a missing tree as usual, + * but will not attempt to recurse into this tree + * object. + */ + unsigned int do_not_die_on_missing_tree; + + /* for internal use only */ + unsigned int exclude_promisor_objects; /* Diff flags */ - unsigned int diff:1, - full_diff:1, - show_root_diff:1, - no_commit_id:1, - verbose_header:1, - ignore_merges:1, - combine_merges:1, - combined_all_paths:1, - dense_combined_merges:1, - always_show_header:1; + unsigned int diff; + unsigned int full_diff; + unsigned int show_root_diff; + unsigned int no_commit_id; + unsigned int verbose_header; + unsigned int ignore_merges; + unsigned int combine_merges; + unsigned int combined_all_paths; + unsigned int dense_combined_merges; + unsigned int always_show_header; /* Format info */ - unsigned int shown_one:1, - shown_dashes:1, - show_merge:1, - show_notes:1, - show_notes_given:1, - show_signature:1, - pretty_given:1, - abbrev_commit:1, - abbrev_commit_given:1, - zero_commit:1, - use_terminator:1, - missing_newline:1, - date_mode_explicit:1, - preserve_subject:1; - unsigned int disable_stdin:1; + unsigned int shown_one; + unsigned int shown_dashes; + unsigned int show_merge; + unsigned int show_notes; + unsigned int show_notes_given; + unsigned int show_signature; + unsigned int pretty_given; + unsigned int abbrev_commit; + unsigned int abbrev_commit_given; + unsigned int zero_commit; + unsigned int use_terminator; + unsigned int missing_newline; + unsigned int date_mode_explicit; + unsigned int preserve_subject; + unsigned int disable_stdin; /* --show-linear-break */ - unsigned int track_linear:1, - track_first_time:1, - linear:1; + unsigned int track_linear; + unsigned int track_first_time; + unsigned int linear; struct date_mode date_mode; int expand_tabs_in_log; /* unset if negative */ From patchwork Wed May 8 11:12:32 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Duy Nguyen X-Patchwork-Id: 10934959 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 1ABD513AD for ; Wed, 8 May 2019 11:13:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 09544201B0 for ; Wed, 8 May 2019 11:13:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F128B2870C; Wed, 8 May 2019 11:13:33 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI 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 9F79B201B0 for ; Wed, 8 May 2019 11:13:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727427AbfEHLNc (ORCPT ); Wed, 8 May 2019 07:13:32 -0400 Received: from mail-pf1-f194.google.com ([209.85.210.194]:38613 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726254AbfEHLNc (ORCPT ); Wed, 8 May 2019 07:13:32 -0400 Received: by mail-pf1-f194.google.com with SMTP id 10so10335074pfo.5 for ; Wed, 08 May 2019 04:13:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=GMP/cRtemm2PZO8EJbuclLTX3igG7dY30nAnBhSu8xY=; b=Du8lkG2PE1f6YXu9zDMOlgz4+RqaAWcLPc+WLI2hvGljUPUaMuESJR6LwJcnn4PkPj RU95cX+LPWmRazd0Wzkl0yvJA/HNfufFK22A5odJS4+8mOtfEiAAJ4NA6uzZpFTxqJWP SAXwrg41DaUrAr+VGG7/tJwDXDfsLGqP6fJgcsMjCEhhoGmIL6Va1poD7OXtuGqMfrmH hXbF33xmJYSdq20JC8HD4tGZUEORx2haFvJgsnOf8vZdFKGh5vOeaG4rI6zO6xIeNx7g Bu4+68Kw+AuPbxOtvSKFMSwoCwEcg4NkVFkk0GeCbeTJ0If37B1Iae5+k4C5I5gfJQaw 5LDQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=GMP/cRtemm2PZO8EJbuclLTX3igG7dY30nAnBhSu8xY=; b=uPSp3S99a4uTMUV5Q5daWQmc8Mbd9CPjH/zpMhibMpDn/GIiGa6d0wDctl/jcJDwAG +3JvUmm/YylgOgdrks5jSL/KtpBqKVqOIfPEJlP4wDeGzNPheAVndzkFM0HXxSG4RfAh +ZJJ+SmUY2Jpd6KTLqiRehQoYttECtt1b63npZsbNG3ArSI9Pop3KROQa9Zhv1hasfYR 11S/mQtRXAND38b+J+/CLK5Sn1i3eKIQVH/B2LqrPPOdXYckr4N16ciHpRpDXlIeuAws iF8mGE/uraQg5ueOpTPgdedGRHLki4djB+T5SH5Huixk3K3AK560lUO/LdoPr3hSAS2k gvBA== X-Gm-Message-State: APjAAAXLhwn0y3vm9r+Vrnog+02NiXFRtuHnTAvgM3TAFogZLRnCWiBs kXpj0Yw/Yiowr3GKNsVF/FDLLORN X-Google-Smtp-Source: APXvYqxVdNP5BTnnDYYu5EU5AY0SIEvfBsZGUCZ1macTCQL/s0JkSHn0cbI5bwVCSK1M6L1YW9kJ/g== X-Received: by 2002:a63:1b56:: with SMTP id b22mr22861062pgm.87.1557314011707; Wed, 08 May 2019 04:13:31 -0700 (PDT) Received: from ash ([115.72.28.243]) by smtp.gmail.com with ESMTPSA id u75sm4809691pfa.138.2019.05.08.04.13.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 08 May 2019 04:13:31 -0700 (PDT) Received: by ash (sSMTP sendmail emulation); Wed, 08 May 2019 18:13:27 +0700 From: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= To: git@vger.kernel.org Cc: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= Subject: [PATCH 02/19] revision.h: move repo field down Date: Wed, 8 May 2019 18:12:32 +0700 Message-Id: <20190508111249.15262-3-pclouds@gmail.com> X-Mailer: git-send-email 2.21.0.1141.gd54ac2cb17 In-Reply-To: <20190508111249.15262-1-pclouds@gmail.com> References: <20190508111249.15262-1-pclouds@gmail.com> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This block at the top of rev_info is "Starting list" and repo is obviously not one. Move it to the bottom since it's not that important to stay on top. Signed-off-by: Nguyễn Thái Ngọc Duy --- revision.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/revision.h b/revision.h index 01e4c42274..71e724c59c 100644 --- a/revision.h +++ b/revision.h @@ -74,7 +74,6 @@ struct rev_info { /* Starting list */ struct commit_list *commits; struct object_array pending; - struct repository *repo; /* Parents of shown commits */ struct object_array boundary_commits; @@ -278,6 +277,8 @@ struct rev_info { struct revision_sources *sources; struct topo_walk_info *topo_walk_info; + + struct repository *repo; }; int ref_excluded(struct string_list *, const char *path); From patchwork Wed May 8 11:12:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Duy Nguyen X-Patchwork-Id: 10934961 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 68C1B92A for ; Wed, 8 May 2019 11:13:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 57E3A201B0 for ; Wed, 8 May 2019 11:13:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4C4702870C; Wed, 8 May 2019 11:13:38 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI 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 D22D9201B0 for ; Wed, 8 May 2019 11:13:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727429AbfEHLNh (ORCPT ); Wed, 8 May 2019 07:13:37 -0400 Received: from mail-pf1-f196.google.com ([209.85.210.196]:39969 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726254AbfEHLNg (ORCPT ); Wed, 8 May 2019 07:13:36 -0400 Received: by mail-pf1-f196.google.com with SMTP id u17so10331426pfn.7 for ; Wed, 08 May 2019 04:13:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=s/u+NfQtbX6ekNTSEF21UGawUBtM5yEWW6NhUAob68Q=; b=VfDO2wqftDTCHpANZLS9SFuuwY/CC+FnWdOncSmd057cHHovP3uFLib22JPI4kc4yP vxXbEobFNQSQZxNBvUP7+yG7pD8+n/Pf+9OYrfjsl21UdG1/pKed3avJIARBkcLOryWV BOai0MaE06BaDjRrA4lzDKYjUC0emoyAiERGQRjHxGL2dgASRK5lr6oIAlOg1WC9/kbB QxFfTz377SP7HSlzt6Ig7HZ4jfQCNkGxmvdRf5We1bjE3jOkoLPuNbkm+YlQjB02gIDj x69A+8Fwv2HHwdAOJFGKAsh5qmr9V5DTyPApKtsUCK5PxhKOsPHtc68AdL+Ws7yyVq1N gddQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=s/u+NfQtbX6ekNTSEF21UGawUBtM5yEWW6NhUAob68Q=; b=hT1MuWM64S2kWooZ+ZKWFUVVmd+UMRG1uVqC6r46zprX+mXvNPuywmwY/OutXyUIv9 LhPEjROmDojf0EZLvX/mIs4nQlBySXR6qgKioazhZlbw+PIAYPZZtfgEuMk6QrMEyaEw qVy9Y+GOqGJ/q6DuhD7fQHtcObaiuMMA0MomayEvoeUGiJU4SiodVkR+UbhQ+sMQGY9W KzDSl36U2ZrHc0JTVOjDV8utsj1gY7thsKpw4LWH5mBtacddyGYqyGKLCD1fyEH/gZnw qx+WJh5ASGcB+1/X9XFed1MYXG3zaJTacW41orNyUCGNwtMZIi85SjyxQVKVJziohwIP C8jQ== X-Gm-Message-State: APjAAAUf0ARja8Lu69Hld3dOPbH9uuWoy8ZC2ppMpbiC4WEDpxwI/7Ze wkBVOou1TEaSZwcFNY0bAyxbKpLJ X-Google-Smtp-Source: APXvYqywrPawI0oy6FvHpUvvr/wafjGhDcCiPbHGldiY5E66SeZzZ7fWjLmRyhIwGxZcPkIQzC+YXw== X-Received: by 2002:a65:5647:: with SMTP id m7mr36128407pgs.348.1557314016006; Wed, 08 May 2019 04:13:36 -0700 (PDT) Received: from ash ([115.72.28.243]) by smtp.gmail.com with ESMTPSA id q17sm41554915pfi.185.2019.05.08.04.13.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 08 May 2019 04:13:35 -0700 (PDT) Received: by ash (sSMTP sendmail emulation); Wed, 08 May 2019 18:13:31 +0700 From: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= To: git@vger.kernel.org Cc: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= Subject: [PATCH 03/19] revision.c: prepare to convert handle_revision_pseudo_opt() Date: Wed, 8 May 2019 18:12:33 +0700 Message-Id: <20190508111249.15262-4-pclouds@gmail.com> X-Mailer: git-send-email 2.21.0.1141.gd54ac2cb17 In-Reply-To: <20190508111249.15262-1-pclouds@gmail.com> References: <20190508111249.15262-1-pclouds@gmail.com> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch is essentially no-op. It allows to parse_options() to handle some options. But the new option list remains empty. The option will be moved one by one from the old manual parsing code to this list. Signed-off-by: Nguyễn Thái Ngọc Duy --- revision.c | 44 ++++++++++++++++++++++++++++++++++---------- revision.h | 2 ++ 2 files changed, 36 insertions(+), 10 deletions(-) diff --git a/revision.c b/revision.c index d4aaf0ef25..65d40c9255 100644 --- a/revision.c +++ b/revision.c @@ -26,6 +26,7 @@ #include "argv-array.h" #include "commit-reach.h" #include "commit-graph.h" +#include "parse-options.h" #include "prio-queue.h" #include "hashmap.h" @@ -1598,6 +1599,8 @@ static int add_parents_only(struct rev_info *revs, const char *arg_, int flags, return 1; } +static void make_pseudo_options(struct rev_info *revs); + void repo_init_revisions(struct repository *r, struct rev_info *revs, const char *prefix) @@ -1638,6 +1641,7 @@ void repo_init_revisions(struct repository *r, } revs->notes_opt.use_default_notes = -1; + make_pseudo_options(revs); } static void add_pending_commit_list(struct rev_info *revs, @@ -2355,6 +2359,25 @@ static int for_each_good_bisect_ref(struct ref_store *refs, each_ref_fn fn, void return for_each_bisect_ref(refs, fn, cb_data, term_good); } +static void make_pseudo_options(struct rev_info *revs) +{ + /* + * NOTE! + * + * Commands like "git shortlog" will not accept the options below + * unless parse_revision_opt queues them (as opposed to erroring + * out). + * + * When implementing your new pseudo-option, remember to + * register it in the list at the top of handle_revision_opt. + */ + struct option options[] = { + OPT_END() + }; + ALLOC_ARRAY(revs->pseudo_options, ARRAY_SIZE(options)); + memcpy(revs->pseudo_options, options, sizeof(options)); +} + static int handle_revision_pseudo_opt(const char *submodule, struct rev_info *revs, int argc, const char **argv, int *flags) @@ -2377,16 +2400,16 @@ static int handle_revision_pseudo_opt(const char *submodule, } else refs = get_main_ref_store(revs->repo); - /* - * NOTE! - * - * Commands like "git shortlog" will not accept the options below - * unless parse_revision_opt queues them (as opposed to erroring - * out). - * - * When implementing your new pseudo-option, remember to - * register it in the list at the top of handle_revision_opt. - */ + argc = parse_options(argc, argv, revs->prefix, + revs->pseudo_options, NULL, + PARSE_OPT_KEEP_DASHDASH | + PARSE_OPT_KEEP_UNKNOWN | + PARSE_OPT_NO_INTERNAL_HELP | + PARSE_OPT_ONE_SHOT | + PARSE_OPT_STOP_AT_NON_OPTION); + if (argc) + return argc; + if (!strcmp(arg, "--all")) { handle_refs(refs, revs, *flags, refs_for_each_ref); handle_refs(refs, revs, *flags, refs_head_ref); @@ -2685,6 +2708,7 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, struct s if (revs->expand_tabs_in_log < 0) revs->expand_tabs_in_log = revs->expand_tabs_in_log_default; + FREE_AND_NULL(revs->pseudo_options); return left; } diff --git a/revision.h b/revision.h index 71e724c59c..0769c97dee 100644 --- a/revision.h +++ b/revision.h @@ -39,6 +39,7 @@ #define DECORATE_FULL_REFS 2 struct log_info; +struct option; struct repository; struct rev_info; struct string_list; @@ -279,6 +280,7 @@ struct rev_info { struct topo_walk_info *topo_walk_info; struct repository *repo; + struct option *pseudo_options; }; int ref_excluded(struct string_list *, const char *path); From patchwork Wed May 8 11:12:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Duy Nguyen X-Patchwork-Id: 10934963 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 D5FCE13AD for ; Wed, 8 May 2019 11:13:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C44CB201B0 for ; Wed, 8 May 2019 11:13:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B8A452870C; Wed, 8 May 2019 11:13:42 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI 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 5A3F4201B0 for ; Wed, 8 May 2019 11:13:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727431AbfEHLNl (ORCPT ); Wed, 8 May 2019 07:13:41 -0400 Received: from mail-pg1-f196.google.com ([209.85.215.196]:33096 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726254AbfEHLNl (ORCPT ); Wed, 8 May 2019 07:13:41 -0400 Received: by mail-pg1-f196.google.com with SMTP id h17so3970109pgv.0 for ; Wed, 08 May 2019 04:13:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=tWMYnawcyghwN3MkBi00ecMRIE023rx9MrKjlvLSlPQ=; b=BJOV9u8s2aXH4/22BNNZLvEBR7IPJznc+1rJzO9GdRI8YpP1t/xvo9IEJMY+KwMk5a W9r9sDoH990PHe2wPAuB9o9nPeP8a6GmZ/9yGbJuKTZ7Sb1yp6YkNRdmOUfiPq8oBXAI wbUJ4U9WAieWOYk0HpNkFEAteR5WGKo5QkcwexHSLJHBaFvrwTl56/CbM4E0Mw/ZBdDm bJiUPXYeNbfk8sbwv6BkBrrYt8UcQ/sLn+/9oUuZEpJFVEN7Sd4JBfVkrrfbxa3aPdgn cT9vSCHl3A4IUPbIzALKDWFxszxjTjVavBkHyWaB6+FjIN+Smgp79cZMArtsdIS4UITT L8/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=tWMYnawcyghwN3MkBi00ecMRIE023rx9MrKjlvLSlPQ=; b=R5uM35vsIOvX7E9TrpRSqAGOpeHoD6wx91cmB/ZyjSbxw49ZNrVWeN4tLir7X0NYC6 drTT/jEdWSGDJvTUrATtHVLaTHtA0HVYfpnYnErpdAhtEBIgKswZKPs8hBvqGkQwOzs/ 1u171xosblUi9JT+3l4NMmAHCsH8J+hIggTnWOUu5/ORVpYRqJyYM0pKzxo/l9GBa36Y YK2ISSUtpWpxEj1GflcbMU60AI2mDRIZYvAYyPgBjdz8Ye9TUVhOOH+bCMsJs5LmZDP3 KJgVQkRyoN+A6UlrUCl0cPyUd2v4xTsS7G8LxvpbzWRqJN7fNauzFcoF0WYcT6716AII g7bg== X-Gm-Message-State: APjAAAU8Pz4J7raATheWNjJ/0dJXPrd+CSG3Vgv5njbyiiT1gjoETqyI mXea6dLo6jsXWYQmX0OoCNEog3kK X-Google-Smtp-Source: APXvYqyqUDq67za0rf6YYNf7MxcqRKjraZJo2A9euj8THuBf/nWpldMAARE0vmm/hIiQzfti73XqQQ== X-Received: by 2002:aa7:8e0d:: with SMTP id c13mr48858766pfr.193.1557314020386; Wed, 08 May 2019 04:13:40 -0700 (PDT) Received: from ash ([115.72.28.243]) by smtp.gmail.com with ESMTPSA id l129sm8084431pfc.61.2019.05.08.04.13.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 08 May 2019 04:13:39 -0700 (PDT) Received: by ash (sSMTP sendmail emulation); Wed, 08 May 2019 18:13:36 +0700 From: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= To: git@vger.kernel.org Cc: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= Subject: [PATCH 04/19] rev-parseopt: convert --all Date: Wed, 8 May 2019 18:12:34 +0700 Message-Id: <20190508111249.15262-5-pclouds@gmail.com> X-Mailer: git-send-email 2.21.0.1141.gd54ac2cb17 In-Reply-To: <20190508111249.15262-1-pclouds@gmail.com> References: <20190508111249.15262-1-pclouds@gmail.com> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Nguyễn Thái Ngọc Duy --- revision.c | 41 ++++++++++++++++++++++++++++++----------- revision.h | 2 ++ 2 files changed, 32 insertions(+), 11 deletions(-) diff --git a/revision.c b/revision.c index 65d40c9255..9a346577f6 100644 --- a/revision.c +++ b/revision.c @@ -30,6 +30,10 @@ #include "prio-queue.h" #include "hashmap.h" +#define OPT_REV_NOARG(s, l, h, cb) \ + OPT_CALLBACK_F(s, l, revs, NULL, h, \ + PARSE_OPT_NONEG | PARSE_OPT_NOARG, cb) + volatile show_early_output_fn_t show_early_output; static const char *term_bad; @@ -2359,6 +2363,26 @@ static int for_each_good_bisect_ref(struct ref_store *refs, each_ref_fn fn, void return for_each_bisect_ref(refs, fn, cb_data, term_good); } +static int rev_opt_all(const struct option *opt, const char *arg, int unset) +{ + struct rev_info *revs = opt->value; + int flags = *revs->pseudo_flags; + struct ref_store *refs = revs->pseudo_refs; + + BUG_ON_OPT_NEG(unset); + BUG_ON_OPT_ARG(arg); + handle_refs(refs, revs, flags, refs_for_each_ref); + handle_refs(refs, revs, flags, refs_head_ref); + if (!revs->single_worktree) { + struct all_refs_cb cb; + + init_all_refs_cb(&cb, revs, flags); + other_head_refs(handle_one_ref, &cb); + } + clear_ref_exclusion(&revs->ref_excludes); + return 0; +} + static void make_pseudo_options(struct rev_info *revs) { /* @@ -2372,6 +2396,9 @@ static void make_pseudo_options(struct rev_info *revs) * register it in the list at the top of handle_revision_opt. */ struct option options[] = { + OPT_REV_NOARG(0, "all", + N_("include all refs in refs/ and HEAD"), + rev_opt_all), OPT_END() }; ALLOC_ARRAY(revs->pseudo_options, ARRAY_SIZE(options)); @@ -2400,6 +2427,8 @@ static int handle_revision_pseudo_opt(const char *submodule, } else refs = get_main_ref_store(revs->repo); + revs->pseudo_flags = flags; + revs->pseudo_refs = refs; argc = parse_options(argc, argv, revs->prefix, revs->pseudo_options, NULL, PARSE_OPT_KEEP_DASHDASH | @@ -2410,17 +2439,7 @@ static int handle_revision_pseudo_opt(const char *submodule, if (argc) return argc; - if (!strcmp(arg, "--all")) { - handle_refs(refs, revs, *flags, refs_for_each_ref); - handle_refs(refs, revs, *flags, refs_head_ref); - if (!revs->single_worktree) { - struct all_refs_cb cb; - - init_all_refs_cb(&cb, revs, *flags); - other_head_refs(handle_one_ref, &cb); - } - clear_ref_exclusion(&revs->ref_excludes); - } else if (!strcmp(arg, "--branches")) { + if (!strcmp(arg, "--branches")) { handle_refs(refs, revs, *flags, refs_for_each_branch_ref); clear_ref_exclusion(&revs->ref_excludes); } else if (!strcmp(arg, "--bisect")) { diff --git a/revision.h b/revision.h index 0769c97dee..cec5215c04 100644 --- a/revision.h +++ b/revision.h @@ -281,6 +281,8 @@ struct rev_info { struct repository *repo; struct option *pseudo_options; + int *pseudo_flags; + struct ref_store *pseudo_refs; }; int ref_excluded(struct string_list *, const char *path); From patchwork Wed May 8 11:12:35 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Duy Nguyen X-Patchwork-Id: 10934965 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 8438F13AD for ; Wed, 8 May 2019 11:13:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 73EAA201B0 for ; Wed, 8 May 2019 11:13:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 657942870C; Wed, 8 May 2019 11:13:47 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI 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 04735201B0 for ; Wed, 8 May 2019 11:13:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727432AbfEHLNq (ORCPT ); Wed, 8 May 2019 07:13:46 -0400 Received: from mail-pf1-f194.google.com ([209.85.210.194]:38635 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726254AbfEHLNp (ORCPT ); Wed, 8 May 2019 07:13:45 -0400 Received: by mail-pf1-f194.google.com with SMTP id 10so10335349pfo.5 for ; Wed, 08 May 2019 04:13:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=bRKhZKJX3ffNxWFbuSrIAW/UVEPmGGIpkgTg75W4sRM=; b=QG5KOSxBmCRE3VLZ72HVdgu6k/mHv2mSOvYLrEnKffO0Aa4PHVujF8rlsoocfI1SYs Oj8ShHbhoCVcDXDv4A4qQnFrYfi5MsKCHgc03gaKk0hBEldwVam7UOOoRUcKo0tKbzxT OwYCZaQ6FhUvJdil/PkKHa1bAp7FbjV7c+j0J1WHuowPRmNHjEuUiZim5eVPzetr4RW0 waKvxhPesf2Ayip0iDvmkUT7xtRZxh/UmgxBUdSrYFivpxjf8Gczpbs1TcKXVVDGTQze T+9WHTh/bCsWZoS2rpOXwizJWp2YnhyYfrG4U+zv6RPIaaQcHs57aVeVMnjlYBEigs9M p64g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=bRKhZKJX3ffNxWFbuSrIAW/UVEPmGGIpkgTg75W4sRM=; b=HQnASG3qPy/c83m7DL+9QNWwp6aio7FCVRLWEq7SJB9eUl7wowzkQrZCjkktaexOJL Eykk68cu6GriP34ZK07KgP3fF9BXbLiyJ00tUbMthB/Q93/OsBX7aAXvuJgFXkgA4ow0 R8wmb+BprzYZihLG3BTXjxGs/ASuYAnsSWWSjZT29C7FQWC31iEGpXkvF6o3Bsh4H/71 VtH9w0v+aiJJKy/iGBNqcT1iEbGz9laBhtyTyv5CI+OMJYOtOL4vsQDBfxCZ6EojkRgb MrT+ttSXkjfp7iY4s9tGtszucdpXXWPB/zaS+cDpkM3+dJ7jXRdVWp28TGICrPbfBF+4 kSvw== X-Gm-Message-State: APjAAAX4XhSvyPSmmPqpXdVxXLAYFNkAqG2dh1J/pT+khZtwao2Sj+/v 5xEI1R0tZrm5CWh/sf7GVQ7+VRrS X-Google-Smtp-Source: APXvYqzVxgvfwJRcYanx0chkEPuhwUOTVwMdImCbbSr88UgwBe0YHclT1KIKXPECkNUmFKzXEsTRFg== X-Received: by 2002:a63:170a:: with SMTP id x10mr44718146pgl.355.1557314025040; Wed, 08 May 2019 04:13:45 -0700 (PDT) Received: from ash ([115.72.28.243]) by smtp.gmail.com with ESMTPSA id f15sm19216928pgf.18.2019.05.08.04.13.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 08 May 2019 04:13:44 -0700 (PDT) Received: by ash (sSMTP sendmail emulation); Wed, 08 May 2019 18:13:40 +0700 From: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= To: git@vger.kernel.org Cc: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= Subject: [PATCH 05/19] rev-parseopt: convert --branches Date: Wed, 8 May 2019 18:12:35 +0700 Message-Id: <20190508111249.15262-6-pclouds@gmail.com> X-Mailer: git-send-email 2.21.0.1141.gd54ac2cb17 In-Reply-To: <20190508111249.15262-1-pclouds@gmail.com> References: <20190508111249.15262-1-pclouds@gmail.com> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Nguyễn Thái Ngọc Duy --- revision.c | 38 +++++++++++++++++++++++++++++--------- 1 file changed, 29 insertions(+), 9 deletions(-) diff --git a/revision.c b/revision.c index 9a346577f6..7db1109b57 100644 --- a/revision.c +++ b/revision.c @@ -34,6 +34,10 @@ OPT_CALLBACK_F(s, l, revs, NULL, h, \ PARSE_OPT_NONEG | PARSE_OPT_NOARG, cb) +#define OPT_REV_OPTARG(s, l, a, h, cb) \ + OPT_CALLBACK_F(s, l, revs, a, h, \ + PARSE_OPT_NONEG | PARSE_OPT_OPTARG, cb) + volatile show_early_output_fn_t show_early_output; static const char *term_bad; @@ -2383,6 +2387,27 @@ static int rev_opt_all(const struct option *opt, const char *arg, int unset) return 0; } +static int rev_opt_branches(const struct option *opt, + const char *arg, int unset) +{ + struct rev_info *revs = opt->value; + int flags = *revs->pseudo_flags; + struct ref_store *refs = revs->pseudo_refs; + + BUG_ON_OPT_NEG(unset); + if (arg) { + struct all_refs_cb cb; + + init_all_refs_cb(&cb, revs, flags); + for_each_glob_ref_in(handle_one_ref, arg, "refs/heads/", &cb); + clear_ref_exclusion(&revs->ref_excludes); + } else { + handle_refs(refs, revs, flags, refs_for_each_branch_ref); + clear_ref_exclusion(&revs->ref_excludes); + } + return 0; +} + static void make_pseudo_options(struct rev_info *revs) { /* @@ -2399,6 +2424,9 @@ static void make_pseudo_options(struct rev_info *revs) OPT_REV_NOARG(0, "all", N_("include all refs in refs/ and HEAD"), rev_opt_all), + OPT_REV_OPTARG(0, "branches", N_(""), + N_("include all refs in refs/heads (optionally matches pattern)"), + rev_opt_branches), OPT_END() }; ALLOC_ARRAY(revs->pseudo_options, ARRAY_SIZE(options)); @@ -2439,10 +2467,7 @@ static int handle_revision_pseudo_opt(const char *submodule, if (argc) return argc; - if (!strcmp(arg, "--branches")) { - handle_refs(refs, revs, *flags, refs_for_each_branch_ref); - clear_ref_exclusion(&revs->ref_excludes); - } else if (!strcmp(arg, "--bisect")) { + if (!strcmp(arg, "--bisect")) { read_bisect_terms(&term_bad, &term_good); handle_refs(refs, revs, *flags, for_each_bad_bisect_ref); handle_refs(refs, revs, *flags ^ (UNINTERESTING | BOTTOM), @@ -2463,11 +2488,6 @@ static int handle_revision_pseudo_opt(const char *submodule, } else if ((argcount = parse_long_opt("exclude", argv, &optarg))) { add_ref_exclusion(&revs->ref_excludes, optarg); return argcount; - } else if (skip_prefix(arg, "--branches=", &optarg)) { - struct all_refs_cb cb; - init_all_refs_cb(&cb, revs, *flags); - for_each_glob_ref_in(handle_one_ref, optarg, "refs/heads/", &cb); - clear_ref_exclusion(&revs->ref_excludes); } else if (skip_prefix(arg, "--tags=", &optarg)) { struct all_refs_cb cb; init_all_refs_cb(&cb, revs, *flags); From patchwork Wed May 8 11:12:36 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Duy Nguyen X-Patchwork-Id: 10934967 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 B4C2B13AD for ; Wed, 8 May 2019 11:13:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A3D3D201B0 for ; Wed, 8 May 2019 11:13:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 982482870C; Wed, 8 May 2019 11:13: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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI 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 44735201B0 for ; Wed, 8 May 2019 11:13:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727435AbfEHLNu (ORCPT ); Wed, 8 May 2019 07:13:50 -0400 Received: from mail-pg1-f195.google.com ([209.85.215.195]:39309 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726254AbfEHLNu (ORCPT ); Wed, 8 May 2019 07:13:50 -0400 Received: by mail-pg1-f195.google.com with SMTP id w22so8635361pgi.6 for ; Wed, 08 May 2019 04:13:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Xu8Lrzqw4E2szh815J5hVKeDDiGe2DhwUBv3wllVcVU=; b=Ei1fW5JSHtUitXD+zesLHhU83ZGxc0OzKEoM+J0U9oDaNQKbDEqCsKFFhVVer6iI7G eT9fzk16U3pIxptwkmfUEsptkmevF8WRoXeMTsq8zj3Ll1CKi7e2kwrtQqaRePOBol5C 6RPXVHgrJxVSlRxboRxTNEPII3Eypt1bT6DMChSy3SqwzuvK6D6Dg+NXxF0y+RriWC75 TgIKYgs7agN70ZyRVOJ6LWW570e/Yb28FjDACgScWWBLcJ37pdx1LBSjIVCUy6xw+TA1 9rj3qfrMjm6jA4ASiPALEE5NNR2UB5BZE/9FbIZRTND53NeE37rgOsk2G1tddjn2ht9G BiTA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Xu8Lrzqw4E2szh815J5hVKeDDiGe2DhwUBv3wllVcVU=; b=snVQJ9xTcxC1B5I/0geWjAPhrwOBk8WaLJfWCU9Aa+eyScilnRt9BIs2mFehLJ1uxa bgXtUowc06jJaVjRTqRkd19rD6XXOASUgMlXZJ/YADr0mkOLZUxrZwUgCnfdmYQK0cey m/H6tjF6HwEgS+V2F+tY9PIbwM+rlthiwVPxxnqd4auanLEDeLOVDmKJCM9QQzTkDAiS VcVWXQDM+vDy7J37KmPmsk856GoW7kpWIs9V/iN7hnczZ0c06rh4BZSimXUND0riD4gj ly2nQ1NgvLE5VwdYd25UpdTOmj5hRMyrNIPCZFO0/1soP7r9RmotAt8Lqt9WRExdbs/V XgeQ== X-Gm-Message-State: APjAAAVzbgkKJl5KamwkX6RenJh/SpPLiMk/vdSfoI6sRX7GC3tBtpZD R1HDKbwT74prcklaUMWCBrW1FTX+ X-Google-Smtp-Source: APXvYqxhgkesaWpGfd3ZnPuSRrFJmTcxCsfO6Gued/oZfChtdiY8S8r6gbZBwZwfj+Hbcawkg1snNg== X-Received: by 2002:a62:56c3:: with SMTP id h64mr11901137pfj.163.1557314029271; Wed, 08 May 2019 04:13:49 -0700 (PDT) Received: from ash ([115.72.28.243]) by smtp.gmail.com with ESMTPSA id f6sm17561468pgq.11.2019.05.08.04.13.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 08 May 2019 04:13:48 -0700 (PDT) Received: by ash (sSMTP sendmail emulation); Wed, 08 May 2019 18:13:45 +0700 From: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= To: git@vger.kernel.org Cc: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= Subject: [PATCH 06/19] rev-parseopt: convert --bisect Date: Wed, 8 May 2019 18:12:36 +0700 Message-Id: <20190508111249.15262-7-pclouds@gmail.com> X-Mailer: git-send-email 2.21.0.1141.gd54ac2cb17 In-Reply-To: <20190508111249.15262-1-pclouds@gmail.com> References: <20190508111249.15262-1-pclouds@gmail.com> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Nguyễn Thái Ngọc Duy --- revision.c | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/revision.c b/revision.c index 7db1109b57..0d34f81716 100644 --- a/revision.c +++ b/revision.c @@ -2387,6 +2387,23 @@ static int rev_opt_all(const struct option *opt, const char *arg, int unset) return 0; } +static int rev_opt_bisect(const struct option *opt, + const char *arg, int unset) +{ + struct rev_info *revs = opt->value; + int flags = *revs->pseudo_flags; + struct ref_store *refs = revs->pseudo_refs; + + BUG_ON_OPT_NEG(unset); + BUG_ON_OPT_ARG(arg); + read_bisect_terms(&term_bad, &term_good); + handle_refs(refs, revs, flags, for_each_bad_bisect_ref); + handle_refs(refs, revs, flags ^ (UNINTERESTING | BOTTOM), + for_each_good_bisect_ref); + revs->bisect = 1; + return 0; +} + static int rev_opt_branches(const struct option *opt, const char *arg, int unset) { @@ -2427,6 +2444,9 @@ static void make_pseudo_options(struct rev_info *revs) OPT_REV_OPTARG(0, "branches", N_(""), N_("include all refs in refs/heads (optionally matches pattern)"), rev_opt_branches), + OPT_REV_NOARG(0, "bisect", + N_("synonym to refs/bisect/good-* --not refs/bisect/bad"), + rev_opt_bisect), OPT_END() }; ALLOC_ARRAY(revs->pseudo_options, ARRAY_SIZE(options)); @@ -2467,13 +2487,7 @@ static int handle_revision_pseudo_opt(const char *submodule, if (argc) return argc; - if (!strcmp(arg, "--bisect")) { - read_bisect_terms(&term_bad, &term_good); - handle_refs(refs, revs, *flags, for_each_bad_bisect_ref); - handle_refs(refs, revs, *flags ^ (UNINTERESTING | BOTTOM), - for_each_good_bisect_ref); - revs->bisect = 1; - } else if (!strcmp(arg, "--tags")) { + if (!strcmp(arg, "--tags")) { handle_refs(refs, revs, *flags, refs_for_each_tag_ref); clear_ref_exclusion(&revs->ref_excludes); } else if (!strcmp(arg, "--remotes")) { From patchwork Wed May 8 11:12:37 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Duy Nguyen X-Patchwork-Id: 10934969 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 0036813AD for ; Wed, 8 May 2019 11:13:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E3D042870C for ; Wed, 8 May 2019 11:13:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D852E2875C; Wed, 8 May 2019 11:13:55 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI 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 7EC692870C for ; Wed, 8 May 2019 11:13:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727438AbfEHLNy (ORCPT ); Wed, 8 May 2019 07:13:54 -0400 Received: from mail-pf1-f196.google.com ([209.85.210.196]:34009 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726254AbfEHLNy (ORCPT ); Wed, 8 May 2019 07:13:54 -0400 Received: by mail-pf1-f196.google.com with SMTP id n19so1783638pfa.1 for ; Wed, 08 May 2019 04:13:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=NPvS6o29MVYpA3fJJQHNXptvb8jUx8VKCa5sWZSLBfM=; b=h4AOEgstDKMdFjhxRdEaabjfXYxPBFL6nDEcIY28gU3GDsvVMNuSAYrpgMeg/SncGb PFO9Psue4Qk1Wcqg0HelFyVvOEiSMHCeEu9gPi0udikKWfM3AzruOl/RkOzwykpK7SBC g5RsgrNAJjtVc6A1kpbqHv/dRbJ4qb/ffMO31xEzk/dLy+7/4KUskOu4VzojZhqG+a+q e9YvMLIXeMRNtOEvzmAPHQ2JcM/9aHpO9nB91hqTWyb5oRifQbqTM1VRGVlKlOV1U0gb D0NBi4ctaoIQLeyyFUbUUuJ7keG1Gta5YUpHhmqMz8FE5bJGNbhIWmqK7nvpUVcLBKbV gLjw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=NPvS6o29MVYpA3fJJQHNXptvb8jUx8VKCa5sWZSLBfM=; b=I5QOPKCSctGVkaTH19vnLJUx8MHiNtBAz/PrZf3XWrzydqsjTPUIAlm5gbbIuGgNn1 5QNlIru4GfZA4NLSMsnDY7JQJRvLzJ9xTTgPe7Mw/NwJVkEuSUAqpi/2E9Nh5zzNSJY5 PAGX+t+g8N3IGs8/aIGX3bsbx/60K8jnPAQtJ4PhgH9/3mMf+eUfa+f5sC9LF51V+kWt Q8Bh/bELY+xcwljRqxo7SpLMaLtYNnrSy842xpDy7EdiaTDPB9WgGXLMWbklrulw2eqL VkN2R+Cp7xD2XD6NMiyHoI7czR1gzPWCGJ9SfS6AE3Uqucl7IG5ywNZJGh1dvuFZHxzN Ihhg== X-Gm-Message-State: APjAAAWpkLfCeAGyVecPWW/3AffOyPDYKVCcc9mlHVaftuHl9mBFsFG7 oKO4P1Bwaz/WF5z21vFyoucadjQr X-Google-Smtp-Source: APXvYqxlTvGZLS+3FEZ0HwyIwwGuOL43DXkws9gqaAkP7rVM2hnSuw2rheQ0VxjI45LkdqVP6wTcOg== X-Received: by 2002:a63:af45:: with SMTP id s5mr45611627pgo.420.1557314033569; Wed, 08 May 2019 04:13:53 -0700 (PDT) Received: from ash ([115.72.28.243]) by smtp.gmail.com with ESMTPSA id 19sm40494600pfs.104.2019.05.08.04.13.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 08 May 2019 04:13:52 -0700 (PDT) Received: by ash (sSMTP sendmail emulation); Wed, 08 May 2019 18:13:49 +0700 From: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= To: git@vger.kernel.org Cc: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= Subject: [PATCH 07/19] rev-parseopt: convert --tags Date: Wed, 8 May 2019 18:12:37 +0700 Message-Id: <20190508111249.15262-8-pclouds@gmail.com> X-Mailer: git-send-email 2.21.0.1141.gd54ac2cb17 In-Reply-To: <20190508111249.15262-1-pclouds@gmail.com> References: <20190508111249.15262-1-pclouds@gmail.com> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Nguyễn Thái Ngọc Duy --- revision.c | 34 +++++++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/revision.c b/revision.c index 0d34f81716..5183cdf66d 100644 --- a/revision.c +++ b/revision.c @@ -2425,6 +2425,27 @@ static int rev_opt_branches(const struct option *opt, return 0; } +static int rev_opt_tags(const struct option *opt, + const char *arg, int unset) +{ + struct rev_info *revs = opt->value; + int flags = *revs->pseudo_flags; + struct ref_store *refs = revs->pseudo_refs; + + BUG_ON_OPT_NEG(unset); + if (arg) { + struct all_refs_cb cb; + + init_all_refs_cb(&cb, revs, flags); + for_each_glob_ref_in(handle_one_ref, arg, "refs/tags/", &cb); + clear_ref_exclusion(&revs->ref_excludes); + } else { + handle_refs(refs, revs, flags, refs_for_each_tag_ref); + clear_ref_exclusion(&revs->ref_excludes); + } + return 0; +} + static void make_pseudo_options(struct rev_info *revs) { /* @@ -2447,6 +2468,9 @@ static void make_pseudo_options(struct rev_info *revs) OPT_REV_NOARG(0, "bisect", N_("synonym to refs/bisect/good-* --not refs/bisect/bad"), rev_opt_bisect), + OPT_REV_OPTARG(0, "tags", N_(""), + N_("include all refs in refs/tags (optionally matches pattern)"), + rev_opt_tags), OPT_END() }; ALLOC_ARRAY(revs->pseudo_options, ARRAY_SIZE(options)); @@ -2487,10 +2511,7 @@ static int handle_revision_pseudo_opt(const char *submodule, if (argc) return argc; - if (!strcmp(arg, "--tags")) { - handle_refs(refs, revs, *flags, refs_for_each_tag_ref); - clear_ref_exclusion(&revs->ref_excludes); - } else if (!strcmp(arg, "--remotes")) { + if (!strcmp(arg, "--remotes")) { handle_refs(refs, revs, *flags, refs_for_each_remote_ref); clear_ref_exclusion(&revs->ref_excludes); } else if ((argcount = parse_long_opt("glob", argv, &optarg))) { @@ -2502,11 +2523,6 @@ static int handle_revision_pseudo_opt(const char *submodule, } else if ((argcount = parse_long_opt("exclude", argv, &optarg))) { add_ref_exclusion(&revs->ref_excludes, optarg); return argcount; - } else if (skip_prefix(arg, "--tags=", &optarg)) { - struct all_refs_cb cb; - init_all_refs_cb(&cb, revs, *flags); - for_each_glob_ref_in(handle_one_ref, optarg, "refs/tags/", &cb); - clear_ref_exclusion(&revs->ref_excludes); } else if (skip_prefix(arg, "--remotes=", &optarg)) { struct all_refs_cb cb; init_all_refs_cb(&cb, revs, *flags); From patchwork Wed May 8 11:12:38 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Duy Nguyen X-Patchwork-Id: 10934971 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 6BE4792A for ; Wed, 8 May 2019 11:14:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5B955201B0 for ; Wed, 8 May 2019 11:14:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4F9F62870C; Wed, 8 May 2019 11:14:00 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI 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 EC96A201B0 for ; Wed, 8 May 2019 11:13:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727442AbfEHLN7 (ORCPT ); Wed, 8 May 2019 07:13:59 -0400 Received: from mail-pg1-f194.google.com ([209.85.215.194]:45394 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726254AbfEHLN6 (ORCPT ); Wed, 8 May 2019 07:13:58 -0400 Received: by mail-pg1-f194.google.com with SMTP id i21so9932856pgi.12 for ; Wed, 08 May 2019 04:13:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ZUM7gI5InJUf0+qZmV9xNjRDOOAmpEtrxBYL5F+fm6Q=; b=bMWHAcKwF6qR30PgS/3Xf1Vd6IyqRGn7DDUCpDKKeuLNxDDBfhBwheEydZpjozNMp+ 3rTgrQUZPnOehZX5hAhSR9fRYKVkYWvAQVHgdoA+O4IpHWmqkbRavC1kFzN6QSGPl9TW ZUt/0vhE0UHlTBnVgJRQYEU+0UR7xMhkpD5/5DhdrQ5JwWkyM6mPxtLtBj73MFe17wvI tKsezZZFoR3WFyV8+Ij5n8WzQyPSHlFGwfQOPIBsUgToPwMbw2bols4zYc7C5YEcHAq7 9mGEPNPYYjU8xKn1If+faxA2aaTjJzvB4JCsUqOznsqHw2Xe4JuSTpRY2WqadGPx6M5X R21Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ZUM7gI5InJUf0+qZmV9xNjRDOOAmpEtrxBYL5F+fm6Q=; b=rjXi0381ysdWneg8QzUQIR+7Cz3evMomWSWzY1fqo1gzXSzp64ThrUkZAUIAQNZN7+ 8GjWKUeaPkWNUsGhlJIxPRPYdu0/LTJvMwowE4oEFp97Yq+NMrtWu8pSvNJkPnQyd0C9 lqdt5tZ4BmKDBYJYrSmK+WnLSsdTTQh1fzCoqetPccgiktes8mCDRMnvJYHo6lcQtR5C 3MCv4mPa12DRM0CFWCsPP8YJHGSXMYLOwA8o0COwNdJoK69lG8LKFy7Pael+bI5dYUvF jfjZPjNoRmLad6yLEdiTGtCYRhJ/1RW/zdZa7qlfqMw45eAYp8Dxd4iw1gPu46HwbM9M /k2A== X-Gm-Message-State: APjAAAX5Li2idbFDloIDnmAolNvS+7hornRYhI5hHJDG7U3nItNfj2o7 47fh6iYNvEVjKSe3RoLmFXEnoyyb X-Google-Smtp-Source: APXvYqz9QwFBE2n0Zklu+W3lD+Bz0rGOdDlkuWYGpeiQ4AKgw53zxMmqxxCrd1XPELGNd5KxsS5LIg== X-Received: by 2002:a65:5181:: with SMTP id h1mr46539443pgq.167.1557314038026; Wed, 08 May 2019 04:13:58 -0700 (PDT) Received: from ash ([115.72.28.243]) by smtp.gmail.com with ESMTPSA id n184sm18581875pfn.21.2019.05.08.04.13.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 08 May 2019 04:13:57 -0700 (PDT) Received: by ash (sSMTP sendmail emulation); Wed, 08 May 2019 18:13:53 +0700 From: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= To: git@vger.kernel.org Cc: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= Subject: [PATCH 08/19] rev-parseopt: convert --remotes Date: Wed, 8 May 2019 18:12:38 +0700 Message-Id: <20190508111249.15262-9-pclouds@gmail.com> X-Mailer: git-send-email 2.21.0.1141.gd54ac2cb17 In-Reply-To: <20190508111249.15262-1-pclouds@gmail.com> References: <20190508111249.15262-1-pclouds@gmail.com> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Nguyễn Thái Ngọc Duy --- revision.c | 34 +++++++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/revision.c b/revision.c index 5183cdf66d..bcfca8856f 100644 --- a/revision.c +++ b/revision.c @@ -2425,6 +2425,27 @@ static int rev_opt_branches(const struct option *opt, return 0; } +static int rev_opt_remotes(const struct option *opt, + const char *arg, int unset) +{ + struct rev_info *revs = opt->value; + int flags = *revs->pseudo_flags; + struct ref_store *refs = revs->pseudo_refs; + + BUG_ON_OPT_NEG(unset); + if (arg) { + struct all_refs_cb cb; + + init_all_refs_cb(&cb, revs, flags); + for_each_glob_ref_in(handle_one_ref, arg, "refs/remotes/", &cb); + clear_ref_exclusion(&revs->ref_excludes); + } else { + handle_refs(refs, revs, flags, refs_for_each_remote_ref); + clear_ref_exclusion(&revs->ref_excludes); + } + return 0; +} + static int rev_opt_tags(const struct option *opt, const char *arg, int unset) { @@ -2471,6 +2492,9 @@ static void make_pseudo_options(struct rev_info *revs) OPT_REV_OPTARG(0, "tags", N_(""), N_("include all refs in refs/tags (optionally matches pattern)"), rev_opt_tags), + OPT_REV_OPTARG(0, "remotes", N_(""), + N_("include all refs in refs/remotes (optionally matches pattern)"), + rev_opt_remotes), OPT_END() }; ALLOC_ARRAY(revs->pseudo_options, ARRAY_SIZE(options)); @@ -2511,10 +2535,7 @@ static int handle_revision_pseudo_opt(const char *submodule, if (argc) return argc; - if (!strcmp(arg, "--remotes")) { - handle_refs(refs, revs, *flags, refs_for_each_remote_ref); - clear_ref_exclusion(&revs->ref_excludes); - } else if ((argcount = parse_long_opt("glob", argv, &optarg))) { + if ((argcount = parse_long_opt("glob", argv, &optarg))) { struct all_refs_cb cb; init_all_refs_cb(&cb, revs, *flags); for_each_glob_ref(handle_one_ref, optarg, &cb); @@ -2523,11 +2544,6 @@ static int handle_revision_pseudo_opt(const char *submodule, } else if ((argcount = parse_long_opt("exclude", argv, &optarg))) { add_ref_exclusion(&revs->ref_excludes, optarg); return argcount; - } else if (skip_prefix(arg, "--remotes=", &optarg)) { - struct all_refs_cb cb; - init_all_refs_cb(&cb, revs, *flags); - for_each_glob_ref_in(handle_one_ref, optarg, "refs/remotes/", &cb); - clear_ref_exclusion(&revs->ref_excludes); } else if (!strcmp(arg, "--reflog")) { add_reflogs_to_pending(revs, *flags); } else if (!strcmp(arg, "--indexed-objects")) { From patchwork Wed May 8 11:12:39 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Duy Nguyen X-Patchwork-Id: 10934973 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 C308B92A for ; Wed, 8 May 2019 11:14:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B1BF3201B0 for ; Wed, 8 May 2019 11:14:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A61122870C; Wed, 8 May 2019 11:14: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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI 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 50B34201B0 for ; Wed, 8 May 2019 11:14:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727444AbfEHLOD (ORCPT ); Wed, 8 May 2019 07:14:03 -0400 Received: from mail-pg1-f193.google.com ([209.85.215.193]:34585 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726254AbfEHLOD (ORCPT ); Wed, 8 May 2019 07:14:03 -0400 Received: by mail-pg1-f193.google.com with SMTP id c13so9961636pgt.1 for ; Wed, 08 May 2019 04:14:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=eGWRSgE5cBrb3UWIyEsygESHpzpNpNpwWZfwDvI8Tuk=; b=f1hWHAzIdzfjHDt4GmlZKROkD7PkJGd+ak2K+o9SHbcs/fdjF0Zh7Dk++U/9BXWoHk F46ed4bEdOj935HQsi8GZDTuPLNIgZOPirMebM6qexVHa33+OU7tMOKp2saxa92nWtZh wkLU5tSRMx3osSlMejaHVi/HlyENznvN81LL/Gf2xV/GckDRMpyrpvdp8EP4RHb2lO8O MOI4zYfh7R0IsXCA88t9Uyq6Pdco/kDrQIYjlRAvssFZaRylotfyiquvvAn36ElPzZ3y LAJP0ktrGwpGl3pDykIfeHUnOvUh10kKy1dsxX/9Jyn2T5noIfj/Gf5yYoXPQ6a8OjFV 5+jQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=eGWRSgE5cBrb3UWIyEsygESHpzpNpNpwWZfwDvI8Tuk=; b=I41Pz0S9gl6v+GEhKnfXIUaIHPwssiBtWxqXy6Mb6rw8CW7Of6wDWMIXRKVezGDXqN HypBc99UiqyfwwGFSwvqnP0wqZ74i9uRhUL/PJzl6hPo4lSFmDnGb+fd3H9GySHQRgbT qI/bwUoIidFheixCNqaK+CnPfEFEcAx1vHWDLV+FqgNuemGhXcDo41dln5o18pTE5YuS oaC5XrnGMycnKYePFefrECCJkQUKqgBhAimO0K3dFIrHhy/0cXwnsLZHsSy9yHXvoUve WxSVovvjtC5XPEKD0H6jkOzZ1uFwrYuCWG1vJJ4dGXLkOTyKGSbcxgYq8AXv0yhAlRQ0 ZNRw== X-Gm-Message-State: APjAAAXudXrokYt4RbuVxoMxDevnIWLRp8aADCYGaSQfPwEQmzHJ6AQQ 0VCXTjr1/x+rLxv77QBfLHB5vb1w X-Google-Smtp-Source: APXvYqy/cFqe2P6ICZ6a6TfuS5pUrFmUKgrezBibX4NkUqf16BRwcBe0gLB3LjtOmahFuelZhm+rbg== X-Received: by 2002:a63:88c7:: with SMTP id l190mr8736635pgd.244.1557314042528; Wed, 08 May 2019 04:14:02 -0700 (PDT) Received: from ash ([115.72.28.243]) by smtp.gmail.com with ESMTPSA id s9sm21318220pfe.183.2019.05.08.04.14.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 08 May 2019 04:14:01 -0700 (PDT) Received: by ash (sSMTP sendmail emulation); Wed, 08 May 2019 18:13:58 +0700 From: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= To: git@vger.kernel.org Cc: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= Subject: [PATCH 09/19] rev-parseopt: convert --glob Date: Wed, 8 May 2019 18:12:39 +0700 Message-Id: <20190508111249.15262-10-pclouds@gmail.com> X-Mailer: git-send-email 2.21.0.1141.gd54ac2cb17 In-Reply-To: <20190508111249.15262-1-pclouds@gmail.com> References: <20190508111249.15262-1-pclouds@gmail.com> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Nguyễn Thái Ngọc Duy --- revision.c | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/revision.c b/revision.c index bcfca8856f..013b8ec19f 100644 --- a/revision.c +++ b/revision.c @@ -30,6 +30,9 @@ #include "prio-queue.h" #include "hashmap.h" +#define OPT_REV(s, l, a, h, cb) \ + OPT_CALLBACK_F(s, l, revs, a, h, PARSE_OPT_NONEG, cb) + #define OPT_REV_NOARG(s, l, h, cb) \ OPT_CALLBACK_F(s, l, revs, NULL, h, \ PARSE_OPT_NONEG | PARSE_OPT_NOARG, cb) @@ -2425,6 +2428,20 @@ static int rev_opt_branches(const struct option *opt, return 0; } +static int rev_opt_glob(const struct option *opt, + const char *arg, int unset) +{ + struct rev_info *revs = opt->value; + int flags = *revs->pseudo_flags; + struct all_refs_cb cb; + + BUG_ON_OPT_NEG(unset); + init_all_refs_cb(&cb, revs, flags); + for_each_glob_ref(handle_one_ref, arg, &cb); + clear_ref_exclusion(&revs->ref_excludes); + return 0; +} + static int rev_opt_remotes(const struct option *opt, const char *arg, int unset) { @@ -2495,6 +2512,9 @@ static void make_pseudo_options(struct rev_info *revs) OPT_REV_OPTARG(0, "remotes", N_(""), N_("include all refs in refs/remotes (optionally matches pattern)"), rev_opt_remotes), + OPT_REV(0, "glob", N_(""), + N_("include all refs matching shell glob"), + rev_opt_glob), OPT_END() }; ALLOC_ARRAY(revs->pseudo_options, ARRAY_SIZE(options)); @@ -2535,13 +2555,7 @@ static int handle_revision_pseudo_opt(const char *submodule, if (argc) return argc; - if ((argcount = parse_long_opt("glob", argv, &optarg))) { - struct all_refs_cb cb; - init_all_refs_cb(&cb, revs, *flags); - for_each_glob_ref(handle_one_ref, optarg, &cb); - clear_ref_exclusion(&revs->ref_excludes); - return argcount; - } else if ((argcount = parse_long_opt("exclude", argv, &optarg))) { + if ((argcount = parse_long_opt("exclude", argv, &optarg))) { add_ref_exclusion(&revs->ref_excludes, optarg); return argcount; } else if (!strcmp(arg, "--reflog")) { From patchwork Wed May 8 11:12:40 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Duy Nguyen X-Patchwork-Id: 10934975 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 B063313AD for ; Wed, 8 May 2019 11:14:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9EF842870C for ; Wed, 8 May 2019 11:14:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 921482875C; Wed, 8 May 2019 11:14: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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI 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 3F57F2870C for ; Wed, 8 May 2019 11:14:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727446AbfEHLOI (ORCPT ); Wed, 8 May 2019 07:14:08 -0400 Received: from mail-pl1-f195.google.com ([209.85.214.195]:33624 "EHLO mail-pl1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726254AbfEHLOI (ORCPT ); Wed, 8 May 2019 07:14:08 -0400 Received: by mail-pl1-f195.google.com with SMTP id y3so9788224plp.0 for ; Wed, 08 May 2019 04:14:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=i8eF5hnjyNDQU3QvMJCzC3RXps+fCYO0g4ozWxbIOfg=; b=tcB6LS3oZij/LDyXhm2uEu+9bjuRavgCYwRkcUJcHBCDxqhRFevH2ChJ0hzjt+nE5O 20RWvw1W2N5R51mS8VVGYTHGbwuf1GuAjffI2779mscfE/BzIB+glU0FJbew/5T8ueRZ hL7QQ3jUrpkbJigy1TjS7pJ5rP454EIxIFjIl0kLRSn6+utEeoSKU2ucPW0IK30wwfxt bzucg1QI7QwYENt5KuuM5P6qItfRjz4JUA3ZU3TnL4EDXaL9ZVapU5rZCVP741XWiLxA 20PvKzC/04Exe5JIff+r4iQECrwltvmioJFr5Di5IcI2tlKojumymPGhHAuAdluzs7FL 6VwA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=i8eF5hnjyNDQU3QvMJCzC3RXps+fCYO0g4ozWxbIOfg=; b=CdiL7v6bTBlToJLg2glMnAALCrTb4komdyZX7hycyGZT0eKMPD+bvlwMyhgjeUAD8y SkCnadCciBp5XL0iDldwuF1ro+ecZuQLd/nAsKDY8CFJq+JS0VT1t1bslYPJXslUYGNc sSQKxyFr3Q9EnOWGg0LwgMwzeEfcixjz6Xz2jhourahdwdLc1aH3b94/vzBkA+KAo4CT ZjZhUnRN88sigyyrnU2PjxbVS+Qr3Nm+KFbS4XgI6V4fvWpVB0JqtG1WfOKzFAWqDTBW D8amIijXy2ub+diXKtCPMN+K/sHkxNaRC8d0gZLJrndlJ76bNUyYI0/q6yGSWePMh5rf mYWA== X-Gm-Message-State: APjAAAUN/gfOIZwW3zNKSTqcf9SFu52v2u/Hi2CauabQW57tyN8hV1P2 I7O3QXqfRTBwb/IxZA35FifUT9rJ X-Google-Smtp-Source: APXvYqxsk1mR/C2j8AGBf332dO8XlNziMD0zTHXzLF1evtMjuYO8rN65MlXEQOGcu7wSHt+Qarx2VA== X-Received: by 2002:a17:902:8f82:: with SMTP id z2mr47519038plo.51.1557314047204; Wed, 08 May 2019 04:14:07 -0700 (PDT) Received: from ash ([115.72.28.243]) by smtp.gmail.com with ESMTPSA id w12sm10944680pfj.41.2019.05.08.04.14.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 08 May 2019 04:14:06 -0700 (PDT) Received: by ash (sSMTP sendmail emulation); Wed, 08 May 2019 18:14:02 +0700 From: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= To: git@vger.kernel.org Cc: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= Subject: [PATCH 10/19] rev-parseopt: convert --exclude Date: Wed, 8 May 2019 18:12:40 +0700 Message-Id: <20190508111249.15262-11-pclouds@gmail.com> X-Mailer: git-send-email 2.21.0.1141.gd54ac2cb17 In-Reply-To: <20190508111249.15262-1-pclouds@gmail.com> References: <20190508111249.15262-1-pclouds@gmail.com> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Nguyễn Thái Ngọc Duy --- revision.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/revision.c b/revision.c index 013b8ec19f..d34e17984d 100644 --- a/revision.c +++ b/revision.c @@ -2428,6 +2428,16 @@ static int rev_opt_branches(const struct option *opt, return 0; } +static int rev_opt_exclude(const struct option *opt, + const char *arg, int unset) +{ + struct rev_info *revs = opt->value; + + BUG_ON_OPT_NEG(unset); + add_ref_exclusion(&revs->ref_excludes, arg); + return 0; +} + static int rev_opt_glob(const struct option *opt, const char *arg, int unset) { @@ -2515,6 +2525,9 @@ static void make_pseudo_options(struct rev_info *revs) OPT_REV(0, "glob", N_(""), N_("include all refs matching shell glob"), rev_opt_glob), + OPT_REV(0, "exclude", N_(""), + N_("exclude refs matching glob pattern"), + rev_opt_exclude), OPT_END() }; ALLOC_ARRAY(revs->pseudo_options, ARRAY_SIZE(options)); @@ -2528,7 +2541,6 @@ static int handle_revision_pseudo_opt(const char *submodule, const char *arg = argv[0]; const char *optarg; struct ref_store *refs; - int argcount; if (submodule) { /* @@ -2555,10 +2567,7 @@ static int handle_revision_pseudo_opt(const char *submodule, if (argc) return argc; - if ((argcount = parse_long_opt("exclude", argv, &optarg))) { - add_ref_exclusion(&revs->ref_excludes, optarg); - return argcount; - } else if (!strcmp(arg, "--reflog")) { + if (!strcmp(arg, "--reflog")) { add_reflogs_to_pending(revs, *flags); } else if (!strcmp(arg, "--indexed-objects")) { add_index_objects_to_pending(revs, *flags); From patchwork Wed May 8 11:12:41 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Duy Nguyen X-Patchwork-Id: 10934977 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 20CF413AD for ; Wed, 8 May 2019 11:14:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0F23E28758 for ; Wed, 8 May 2019 11:14:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0171B287AB; Wed, 8 May 2019 11:14:13 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI 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 92F84286D4 for ; Wed, 8 May 2019 11:14:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727066AbfEHLOM (ORCPT ); Wed, 8 May 2019 07:14:12 -0400 Received: from mail-pg1-f195.google.com ([209.85.215.195]:46499 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726254AbfEHLOM (ORCPT ); Wed, 8 May 2019 07:14:12 -0400 Received: by mail-pg1-f195.google.com with SMTP id t187so5824009pgb.13 for ; Wed, 08 May 2019 04:14:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=RsAlZiDVZWlmNbwDJY8sDxCYHVLxjKQI2Qtck0cocTU=; b=s6COS5whirxashaCKYRvMDArWwzTlZyL4lBIBQ0LNRHZNNbb5Hvplj4Bus5CoTAtGC qvFc5i3JKA9JN83Y+ARr3DEqPUq7Pe1iwSMZn45jfZ71erVhalqgXMAgwGC3NowmGMG+ 2KyMPtJlgUkBvKxTicWo1TXabN/42cUY94y6+J40OkYmRIx6Nz+Bei4v7qpe1JdSN2s2 jMfy4wHFOvMFKhHMi2jQn6yReBDKJcS8iYGovqNGhRDAiIy14g8hN3OR9ohGbDDsj86A TPBBTYN2FQs0s9TAubVScnyhr5+XhNNxFd0vkxMqzgmKolGgkOamLsnQ0pP34xRki6kp WUEg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=RsAlZiDVZWlmNbwDJY8sDxCYHVLxjKQI2Qtck0cocTU=; b=bYyHhiY3GCSW+Af7ilDYd9lcTu09q4iJbf+6EgvGsl0Pj5YRIjZNAsz3zKnmj91eV8 7ZQ8X0trMwAvMHXRCWMLjXNSraHnSbXZFGGsgzkkL+HjVIGtCc/YSjvKmlmphxF8NGUu 9krMFpKsVTbhIO8sjQFnoB8s0fgROBX4OAikHOs+jK9A4J2umsv2ug63jP+6lzer4i2s aw6ZK+zonaHYv7Xdl8g9qPdWC+ZIaMGYfY1QxsBhzI+UHn+1sWdbo/gi2dzby5Vup38H mqZI996yNxRn7b5SoVmN7SLR1HF5pEJ/+kjQVMu2livBKPbZ7Mo1GXH+TlNHb6i8/DOZ Xkkg== X-Gm-Message-State: APjAAAUI82IYKop1TnL+v9c7vD3kMfhYDELIaqc1vgmuQkSh3qhtbr8c IbOsx8CnAph6DRUYfrw/uQYxv6xK X-Google-Smtp-Source: APXvYqwtNhCrxJI4UPJx94N+l/OTGjvMkDZmeB7jrmtlrVOCDIa5g83cWeQLR2JJ+cnVKx7J55658w== X-Received: by 2002:aa7:820c:: with SMTP id k12mr47798820pfi.177.1557314051569; Wed, 08 May 2019 04:14:11 -0700 (PDT) Received: from ash ([115.72.28.243]) by smtp.gmail.com with ESMTPSA id i1sm6824659pgj.70.2019.05.08.04.14.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 08 May 2019 04:14:10 -0700 (PDT) Received: by ash (sSMTP sendmail emulation); Wed, 08 May 2019 18:14:07 +0700 From: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= To: git@vger.kernel.org Cc: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= Subject: [PATCH 11/19] rev-parseopt: convert --reflog Date: Wed, 8 May 2019 18:12:41 +0700 Message-Id: <20190508111249.15262-12-pclouds@gmail.com> X-Mailer: git-send-email 2.21.0.1141.gd54ac2cb17 In-Reply-To: <20190508111249.15262-1-pclouds@gmail.com> References: <20190508111249.15262-1-pclouds@gmail.com> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Nguyễn Thái Ngọc Duy --- revision.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/revision.c b/revision.c index d34e17984d..6efa9bee1e 100644 --- a/revision.c +++ b/revision.c @@ -2452,6 +2452,18 @@ static int rev_opt_glob(const struct option *opt, return 0; } +static int rev_opt_reflog(const struct option *opt, + const char *arg, int unset) +{ + struct rev_info *revs = opt->value; + int flags = *revs->pseudo_flags; + + BUG_ON_OPT_NEG(unset); + BUG_ON_OPT_ARG(arg); + add_reflogs_to_pending(revs, flags); + return 0; +} + static int rev_opt_remotes(const struct option *opt, const char *arg, int unset) { @@ -2528,6 +2540,9 @@ static void make_pseudo_options(struct rev_info *revs) OPT_REV(0, "exclude", N_(""), N_("exclude refs matching glob pattern"), rev_opt_exclude), + OPT_REV_NOARG(0, "reflog", + N_("include all refs from reflog"), + rev_opt_reflog), OPT_END() }; ALLOC_ARRAY(revs->pseudo_options, ARRAY_SIZE(options)); @@ -2567,9 +2582,7 @@ static int handle_revision_pseudo_opt(const char *submodule, if (argc) return argc; - if (!strcmp(arg, "--reflog")) { - add_reflogs_to_pending(revs, *flags); - } else if (!strcmp(arg, "--indexed-objects")) { + if (!strcmp(arg, "--indexed-objects")) { add_index_objects_to_pending(revs, *flags); } else if (!strcmp(arg, "--not")) { *flags ^= UNINTERESTING | BOTTOM; From patchwork Wed May 8 11:12:42 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Duy Nguyen X-Patchwork-Id: 10934979 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 4FA0192A for ; Wed, 8 May 2019 11:14:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3B9CA286D4 for ; Wed, 8 May 2019 11:14:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2FFB328758; Wed, 8 May 2019 11:14: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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI 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 D3A37286D4 for ; Wed, 8 May 2019 11:14:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727343AbfEHLOQ (ORCPT ); Wed, 8 May 2019 07:14:16 -0400 Received: from mail-pf1-f196.google.com ([209.85.210.196]:42510 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726254AbfEHLOQ (ORCPT ); Wed, 8 May 2019 07:14:16 -0400 Received: by mail-pf1-f196.google.com with SMTP id 13so10023702pfw.9 for ; Wed, 08 May 2019 04:14:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=L7TDkfQTomjtt4utKYLNiSNALkxZKbaqSD3L//NWjMI=; b=oZTVcUuZR0Fqj4BDrEgbbF0jmdjI+5eHSCXCXoT+pJctnY/8QuRisbEp9MtvGTRK69 sPcVX2JZrCLDxhaEyC+zOWy5xO38EdPGgki/RCJ8njRUI9FGxx6lWDIi9YbRsLKOwpNM dgt+T05JEWWdANU8smE/Pi2CyXr5ErsXEyj+ckebKdwu1offf9Ee0Pz1K3gP14dexerr F/gJ2wWYmaitrqXrL9dSAZ04uiLQVbzegeBIFaIxMZZ4hQ89G/NIACXzRt21m0e0EWZI MxrBxXdCtlWBdtbOt9aygcM6ms7tgv843BHxV+8hfYHrOIJEXipM5+xZIvcr+3M7tiNs r8IQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=L7TDkfQTomjtt4utKYLNiSNALkxZKbaqSD3L//NWjMI=; b=Rmq8HAjS0ibmuoblwuymLsulKEXDuLa8gH7saKdZf38PGKJn1ULwJB7QEBllaHdm6t XJByX/RUPU4YKOXwqL4zVU+ecB1MtPFlo+h5ZBFiUwSIEHwdhKNZ+pdZVdKWA8pf0lUY f4Qlfqvc9X09j4se37x1FTASEAkLfKPVXp5w3Hrp210xtmQ0fQLuLe/GRkETCrHQUKap 5kvZU84vEKTHszizdwilJXaVHAJ+u43Jec6SBr7ob+CvN+eHX5A1e0Qb9AjeOI4OBl+g 19CRUdKYv14arO+RdfOiufk8tYB0YIAJCxQGl7KoLIS1xAPUtYFuJ2RbR0tKHPuC3QmN y/Rg== X-Gm-Message-State: APjAAAXGNneARz2lugdL6n4Xn5ZlMi/8bXpqd4/d5MmAMoJpKQiLAf6/ FH8cSeqPEYMBYyQy/4vcrVxmaRuf X-Google-Smtp-Source: APXvYqxeeJ6Zppp5PaDPmQ4BmAXLLRJeOtXWtJcEi03v+jv//eXsuc5zwncCVdtcnlzL+FcvjTPG5A== X-Received: by 2002:a62:200f:: with SMTP id g15mr40136643pfg.7.1557314055900; Wed, 08 May 2019 04:14:15 -0700 (PDT) Received: from ash ([115.72.28.243]) by smtp.gmail.com with ESMTPSA id m16sm27174593pfi.29.2019.05.08.04.14.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 08 May 2019 04:14:15 -0700 (PDT) Received: by ash (sSMTP sendmail emulation); Wed, 08 May 2019 18:14:11 +0700 From: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= To: git@vger.kernel.org Cc: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= Subject: [PATCH 12/19] rev-parseopt: convert --indexed-objects Date: Wed, 8 May 2019 18:12:42 +0700 Message-Id: <20190508111249.15262-13-pclouds@gmail.com> X-Mailer: git-send-email 2.21.0.1141.gd54ac2cb17 In-Reply-To: <20190508111249.15262-1-pclouds@gmail.com> References: <20190508111249.15262-1-pclouds@gmail.com> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Nguyễn Thái Ngọc Duy --- revision.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/revision.c b/revision.c index 6efa9bee1e..9cfa4dc151 100644 --- a/revision.c +++ b/revision.c @@ -2438,6 +2438,18 @@ static int rev_opt_exclude(const struct option *opt, return 0; } +static int rev_opt_indexed_objects(const struct option *opt, + const char *arg, int unset) +{ + struct rev_info *revs = opt->value; + int flags = *revs->pseudo_flags; + + BUG_ON_OPT_NEG(unset); + BUG_ON_OPT_ARG(arg); + add_index_objects_to_pending(revs, flags); + return 0; +} + static int rev_opt_glob(const struct option *opt, const char *arg, int unset) { @@ -2543,6 +2555,9 @@ static void make_pseudo_options(struct rev_info *revs) OPT_REV_NOARG(0, "reflog", N_("include all refs from reflog"), rev_opt_reflog), + OPT_REV_NOARG(0, "indexed-objects", + N_("include all trees and blobs used by the index"), + rev_opt_indexed_objects), OPT_END() }; ALLOC_ARRAY(revs->pseudo_options, ARRAY_SIZE(options)); @@ -2582,9 +2597,7 @@ static int handle_revision_pseudo_opt(const char *submodule, if (argc) return argc; - if (!strcmp(arg, "--indexed-objects")) { - add_index_objects_to_pending(revs, *flags); - } else if (!strcmp(arg, "--not")) { + if (!strcmp(arg, "--not")) { *flags ^= UNINTERESTING | BOTTOM; } else if (!strcmp(arg, "--no-walk")) { revs->no_walk = REVISION_WALK_NO_WALK_SORTED; From patchwork Wed May 8 11:12:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Duy Nguyen X-Patchwork-Id: 10934981 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 980FB13AD for ; Wed, 8 May 2019 11:14:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 88811287AB for ; Wed, 8 May 2019 11:14:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7CD1E287B6; Wed, 8 May 2019 11:14:22 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI 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 1B9DA2875C for ; Wed, 8 May 2019 11:14:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727448AbfEHLOV (ORCPT ); Wed, 8 May 2019 07:14:21 -0400 Received: from mail-pf1-f196.google.com ([209.85.210.196]:37526 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726254AbfEHLOU (ORCPT ); Wed, 8 May 2019 07:14:20 -0400 Received: by mail-pf1-f196.google.com with SMTP id g3so10330684pfi.4 for ; Wed, 08 May 2019 04:14:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=KwztP47TRck8jhdK40kygXdUG58ZoOPs6LrTA+ELyao=; b=ah8CyPulXMUqo+T2UgzlYa0UiN4s6IZWARWOisiHklCOR7biN9Vp+EcOy3K0uQajeC UokR4MPrYdTQtKl39zTwtdb3ouW5hKr1Y9O9Uq2AJ3aSNR9h5/u8146sD2taaFf+4VOQ xjP2P+ovc6Fm+Wj1MbuQ7G6CTNjV0sBQymal1UeG9HBs0Vf4ew/OQ407X0HgsuTaT9G+ Dhqgc48txt0iygXjQvZ3X2TzpO/VvKNBzNYCNEq6ocTbwrSSRo3wywsHRGh5yx7kzx4q VAt0cgx4hrnlEibUO2r91vOA03UJAsvWj3Cxab7XgnV65vrsHjzjJ8EwUXQhec9/5Hg2 /afg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=KwztP47TRck8jhdK40kygXdUG58ZoOPs6LrTA+ELyao=; b=iusV5+gcnnxIUTHKo7M08uM6Qm2nDQoFYJbl1HneO5wxC4D1hPwbPaiwBEvnFOcd0S xYJ8EPtmxaYhXz3TJzpFQKWrdpLyDs7X9CFSwNJkRHOaKpOAvuTRnV7o+xObtPHOtQzp pHE/AnpXDefjtiN45c/3DJjPbQcUGupK9dDAiipyV4E3uHr5coXrzi5f24hl+u35q6LJ i9ALXQ3hG2MbPPHW0YZokm7TwGlaUI5KrXQcZ6u+P6tY9thZ2V+iM9+/gEmx2GspcEF8 q9wrbAHIJESk2miTtnDSj415MarK2kHV8xVqK8Dvm65J0yj48xta/ZnGZEI4+a+ZD5ZL dg8Q== X-Gm-Message-State: APjAAAXC98vSfYDtOvo3D/yCnyOZPdfkdW7XIZiGvkGrvT0asOo474Vc osOOydsGCs9Th8NwF+EYRwh5wE6v X-Google-Smtp-Source: APXvYqymB9Keiy8r5p5jnyXc327Eu3zUH5B7QWE2fFwDqpwsK+hzIgdyS6PJ1KHWNloYmjhV1YkH6g== X-Received: by 2002:a65:5302:: with SMTP id m2mr26529432pgq.369.1557314060080; Wed, 08 May 2019 04:14:20 -0700 (PDT) Received: from ash ([115.72.28.243]) by smtp.gmail.com with ESMTPSA id p7sm20262066pgn.64.2019.05.08.04.14.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 08 May 2019 04:14:19 -0700 (PDT) Received: by ash (sSMTP sendmail emulation); Wed, 08 May 2019 18:14:16 +0700 From: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= To: git@vger.kernel.org Cc: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= Subject: [PATCH 13/19] rev-parseopt: convert --not Date: Wed, 8 May 2019 18:12:43 +0700 Message-Id: <20190508111249.15262-14-pclouds@gmail.com> X-Mailer: git-send-email 2.21.0.1141.gd54ac2cb17 In-Reply-To: <20190508111249.15262-1-pclouds@gmail.com> References: <20190508111249.15262-1-pclouds@gmail.com> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Nguyễn Thái Ngọc Duy --- revision.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/revision.c b/revision.c index 9cfa4dc151..b02cb4660b 100644 --- a/revision.c +++ b/revision.c @@ -2464,6 +2464,17 @@ static int rev_opt_glob(const struct option *opt, return 0; } +static int rev_opt_not(const struct option *opt, + const char *arg, int unset) +{ + struct rev_info *revs = opt->value; + + BUG_ON_OPT_NEG(unset); + BUG_ON_OPT_ARG(arg); + *revs->pseudo_flags ^= UNINTERESTING | BOTTOM; + return 0; +} + static int rev_opt_reflog(const struct option *opt, const char *arg, int unset) { @@ -2558,6 +2569,9 @@ static void make_pseudo_options(struct rev_info *revs) OPT_REV_NOARG(0, "indexed-objects", N_("include all trees and blobs used by the index"), rev_opt_indexed_objects), + OPT_REV_NOARG(0, "not", + N_("reverse the meaning of '^' for all following revisions"), + rev_opt_not), OPT_END() }; ALLOC_ARRAY(revs->pseudo_options, ARRAY_SIZE(options)); @@ -2597,9 +2611,7 @@ static int handle_revision_pseudo_opt(const char *submodule, if (argc) return argc; - if (!strcmp(arg, "--not")) { - *flags ^= UNINTERESTING | BOTTOM; - } else if (!strcmp(arg, "--no-walk")) { + if (!strcmp(arg, "--no-walk")) { revs->no_walk = REVISION_WALK_NO_WALK_SORTED; } else if (skip_prefix(arg, "--no-walk=", &optarg)) { /* From patchwork Wed May 8 11:12:44 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Duy Nguyen X-Patchwork-Id: 10934983 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 996DA13AD for ; Wed, 8 May 2019 11:14:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 89366286D4 for ; Wed, 8 May 2019 11:14:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7D93528758; Wed, 8 May 2019 11:14: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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI 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 1CD77286D4 for ; Wed, 8 May 2019 11:14:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727452AbfEHLOZ (ORCPT ); Wed, 8 May 2019 07:14:25 -0400 Received: from mail-pl1-f195.google.com ([209.85.214.195]:37007 "EHLO mail-pl1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726254AbfEHLOZ (ORCPT ); Wed, 8 May 2019 07:14:25 -0400 Received: by mail-pl1-f195.google.com with SMTP id p15so2584542pll.4 for ; Wed, 08 May 2019 04:14:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=15zT0c/TSUSpr+b5xfPQNS4RPhjdXk5JhY0jhLmkIxo=; b=VtTMDSIekS8kn1NOJa2CMGsOmg2Zuf84wkwI9LRilWYw7CnqcTRqbR7sh+Zck4vC6a jWcs5nQkw+cQPdoVejCTix6rp4J30dnjOyCp8PiaezEdFstzLO+/ylX9V8VAYEdYcf5J DImWAdXVDY4a0h/wIHvRpCnAldyBbKCor4cGtFPzbzj9ChNCM05eJlgYtgqy8YZXlwzX yZLax85eTRQ6I680Za0Pjx5FAi7+Q+42MYqiLtGOZoJbbFQt0KzRpnF9EXbPxevQoZqX YJBe0zgbEtZ9+4oJvLbjXCCPiyy/BWcBVvpzmPgvbgJtNgJvRDB9tHCLa9zWXvTlecDP 6hrg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=15zT0c/TSUSpr+b5xfPQNS4RPhjdXk5JhY0jhLmkIxo=; b=lXdiRq/myoOj8tAPv0h5ENKdrE0y8K7V39eY8ty4M6pIUyV/QYuQZ9PH/aWFbF3KZ1 Af22BAf/1YFZn+W9+PHraScu+lu8grecTnccnPmsHewEmiclYF88VluSwmrILB6j4pT8 SxCll660klhKLzHQvvqw+yBGCc0CZxiLQSD/4B+Y5WhhnwPMtcxWeriPgCnQU1ipeK+y GZYLCXj4H3FDuDpviZ1E8jsjl9huRAY2p8vuPPjFcD28hk5zqUZo11GXbs54X2hLTS5V f6lM1tx2YmBhzUsu2mSXwAHhm2X8Xsh0C2/RhWzC8Yehy8ZOg6jxQg12SQv6eU4Ue0lU OpWw== X-Gm-Message-State: APjAAAVQ0GUISU2vMmDwKQe68ma/tAo5WDY2eCrpwRsG/C3Z3QGSVc5a rh7L69u6gSImyQAxZFglPKMBk+/A X-Google-Smtp-Source: APXvYqymN/3jVOsDmbxhUbXMJ3C9e6LIrt5hE/rs7fxDky/bDN8yXqa3J4/XDA/hOqSCJpKLlgSETQ== X-Received: by 2002:a17:902:1d4a:: with SMTP id u10mr41151428plu.272.1557314064371; Wed, 08 May 2019 04:14:24 -0700 (PDT) Received: from ash ([115.72.28.243]) by smtp.gmail.com with ESMTPSA id 2sm11320763pgc.49.2019.05.08.04.14.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 08 May 2019 04:14:23 -0700 (PDT) Received: by ash (sSMTP sendmail emulation); Wed, 08 May 2019 18:14:20 +0700 From: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= To: git@vger.kernel.org Cc: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= Subject: [PATCH 14/19] rev-parseopt: convert --no-walk and --do-walk Date: Wed, 8 May 2019 18:12:44 +0700 Message-Id: <20190508111249.15262-15-pclouds@gmail.com> X-Mailer: git-send-email 2.21.0.1141.gd54ac2cb17 In-Reply-To: <20190508111249.15262-1-pclouds@gmail.com> References: <20190508111249.15262-1-pclouds@gmail.com> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Nguyễn Thái Ngọc Duy --- revision.c | 47 ++++++++++++++++++++++++++++++----------------- 1 file changed, 30 insertions(+), 17 deletions(-) diff --git a/revision.c b/revision.c index b02cb4660b..f04eb7f140 100644 --- a/revision.c +++ b/revision.c @@ -2464,6 +2464,29 @@ static int rev_opt_glob(const struct option *opt, return 0; } +static int rev_opt_no_walk(const struct option *opt, + const char *arg, int unset) +{ + struct rev_info *revs = opt->value; + + BUG_ON_OPT_NEG(unset); + if (!arg) { + revs->no_walk = REVISION_WALK_NO_WALK_SORTED; + } else { + /* + * Detached form ("--no-walk X" as opposed to "--no-walk=X") + * not allowed, since the argument is optional. + */ + if (!strcmp(arg, "sorted")) + revs->no_walk = REVISION_WALK_NO_WALK_SORTED; + else if (!strcmp(arg, "unsorted")) + revs->no_walk = REVISION_WALK_NO_WALK_UNSORTED; + else + return error(_("invalid argument to --no-walk")); + } + return 0; +} + static int rev_opt_not(const struct option *opt, const char *arg, int unset) { @@ -2572,6 +2595,12 @@ static void make_pseudo_options(struct rev_info *revs) OPT_REV_NOARG(0, "not", N_("reverse the meaning of '^' for all following revisions"), rev_opt_not), + OPT_REV_OPTARG(0, "no-walk", N_("(sorted|unsorted)"), + N_("only show given commits but do not traverse their ancestors"), + rev_opt_no_walk), + OPT_SET_INT_F(0, "do-walk", &revs->no_walk, + N_("override a previous --no-walk"), + 0, PARSE_OPT_NONEG), OPT_END() }; ALLOC_ARRAY(revs->pseudo_options, ARRAY_SIZE(options)); @@ -2583,7 +2612,6 @@ static int handle_revision_pseudo_opt(const char *submodule, int argc, const char **argv, int *flags) { const char *arg = argv[0]; - const char *optarg; struct ref_store *refs; if (submodule) { @@ -2611,22 +2639,7 @@ static int handle_revision_pseudo_opt(const char *submodule, if (argc) return argc; - if (!strcmp(arg, "--no-walk")) { - revs->no_walk = REVISION_WALK_NO_WALK_SORTED; - } else if (skip_prefix(arg, "--no-walk=", &optarg)) { - /* - * Detached form ("--no-walk X" as opposed to "--no-walk=X") - * not allowed, since the argument is optional. - */ - if (!strcmp(optarg, "sorted")) - revs->no_walk = REVISION_WALK_NO_WALK_SORTED; - else if (!strcmp(optarg, "unsorted")) - revs->no_walk = REVISION_WALK_NO_WALK_UNSORTED; - else - return error("invalid argument to --no-walk"); - } else if (!strcmp(arg, "--do-walk")) { - revs->no_walk = 0; - } else if (!strcmp(arg, "--single-worktree")) { + if (!strcmp(arg, "--single-worktree")) { revs->single_worktree = 1; } else { return 0; From patchwork Wed May 8 11:12:45 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Duy Nguyen X-Patchwork-Id: 10934985 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 F422692A for ; Wed, 8 May 2019 11:14:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E3C50286D4 for ; Wed, 8 May 2019 11:14:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D808928758; Wed, 8 May 2019 11:14: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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI 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 5D1F8286D4 for ; Wed, 8 May 2019 11:14:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727457AbfEHLOa (ORCPT ); Wed, 8 May 2019 07:14:30 -0400 Received: from mail-pf1-f193.google.com ([209.85.210.193]:34951 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726254AbfEHLO3 (ORCPT ); Wed, 8 May 2019 07:14:29 -0400 Received: by mail-pf1-f193.google.com with SMTP id t87so9758525pfa.2 for ; Wed, 08 May 2019 04:14:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=MhX8QRf4IZ221NRb8RVo0hUIZHfVfrOOAaKEd5BTWCo=; b=KHaROa2VFeXkUqQpvyX2t8Pkm2v+7esFQifmJeLehsToPMSG1xS2AJr48vhs6vDPDb orP0pEmcOrxvn3E4oSWKkv2AHgJRewN+ri1fMP055ZfIMEMgagAjU3/3pctbRlzwsQ8+ eD51B3xeQCds/iQkRF+SdHuOQNQaxJ2+6fNZybXCMdjU7vyoFxWIyiuNQUWqUpsOJkpy EcbyZM3cWzH04aEFl/cIGOmaFyY1zKRU4OE7V9JhTEd6VVPeUlLGXmd7w0INpkkloKK6 DJ96yHqu+XEpF1hOTFrrotyUR6AueAYVG5KtdEMVbIRKFDTx2pQDcXp8tIZ3xcH01Bh7 3Vuw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=MhX8QRf4IZ221NRb8RVo0hUIZHfVfrOOAaKEd5BTWCo=; b=qhSAHcyfv1+YYWqTlSm381enJ2/Ms1d6j3sTsw68FESfU7/f6chwIXrqX2PZUV8KTl zPpoHvVp/7s7gCnTWjwDqA8+1Fp9qJijqZbuTgy0LdnLZEV3TEU1DPBbM2HeW7fK+Alb qhx7XrmOp8TreVDL4Aw9lEaDCQOqLeSVRyff1wt0QPYNjaL/mtXS5X+vmK4liEIcdj2E 17TWxWp9cLWG7Ucq+cLEPIxr57+8af6dbHMt68fHu+85WU+WIDziVTD++ZmvQY5bo5tn HNau/Sae1XMAon/J79gG7FeumGiRRrwOXw2HPaQzOXzqWJupZM7SDdS1+g6Dc2xBmGON zGUQ== X-Gm-Message-State: APjAAAUc7hPmmSlgZCc1urilNEsVUonXEnfOImXhkFkDqhbFcU0ljOW3 LTWxnYfgYyZh3rTqZjQ0mwQDDsEm X-Google-Smtp-Source: APXvYqyKu/23MFEmbyj6E77v4Q9bv3dGcsODEvAcplhV6ZbvEWiCc3MAyCxnvW8suzBVgwmhhDLyyw== X-Received: by 2002:a65:56c3:: with SMTP id w3mr27763519pgs.232.1557314068775; Wed, 08 May 2019 04:14:28 -0700 (PDT) Received: from ash ([115.72.28.243]) by smtp.gmail.com with ESMTPSA id q5sm25873443pfb.51.2019.05.08.04.14.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 08 May 2019 04:14:28 -0700 (PDT) Received: by ash (sSMTP sendmail emulation); Wed, 08 May 2019 18:14:24 +0700 From: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= To: git@vger.kernel.org Cc: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= Subject: [PATCH 15/19] rev-parseopt: convert --single-worktree Date: Wed, 8 May 2019 18:12:45 +0700 Message-Id: <20190508111249.15262-16-pclouds@gmail.com> X-Mailer: git-send-email 2.21.0.1141.gd54ac2cb17 In-Reply-To: <20190508111249.15262-1-pclouds@gmail.com> References: <20190508111249.15262-1-pclouds@gmail.com> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Nguyễn Thái Ngọc Duy --- revision.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/revision.c b/revision.c index f04eb7f140..dd22ac5c39 100644 --- a/revision.c +++ b/revision.c @@ -2601,6 +2601,9 @@ static void make_pseudo_options(struct rev_info *revs) OPT_SET_INT_F(0, "do-walk", &revs->no_walk, N_("override a previous --no-walk"), 0, PARSE_OPT_NONEG), + OPT_BOOL_F(0, "single-worktree", &revs->single_worktree, + N_("only consider refs from the current worktree"), + PARSE_OPT_NONEG), OPT_END() }; ALLOC_ARRAY(revs->pseudo_options, ARRAY_SIZE(options)); @@ -2611,7 +2614,6 @@ static int handle_revision_pseudo_opt(const char *submodule, struct rev_info *revs, int argc, const char **argv, int *flags) { - const char *arg = argv[0]; struct ref_store *refs; if (submodule) { @@ -2636,16 +2638,7 @@ static int handle_revision_pseudo_opt(const char *submodule, PARSE_OPT_NO_INTERNAL_HELP | PARSE_OPT_ONE_SHOT | PARSE_OPT_STOP_AT_NON_OPTION); - if (argc) - return argc; - - if (!strcmp(arg, "--single-worktree")) { - revs->single_worktree = 1; - } else { - return 0; - } - - return 1; + return argc; } static void NORETURN diagnose_missing_default(const char *def) From patchwork Wed May 8 11:12:46 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Duy Nguyen X-Patchwork-Id: 10934987 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 98D5713AD for ; Wed, 8 May 2019 11:14:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 850BB286D4 for ; Wed, 8 May 2019 11:14:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 74EFF28758; Wed, 8 May 2019 11:14:38 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI 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 6F27D286D4 for ; Wed, 8 May 2019 11:14:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727455AbfEHLOf (ORCPT ); Wed, 8 May 2019 07:14:35 -0400 Received: from mail-pl1-f194.google.com ([209.85.214.194]:36008 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726254AbfEHLOe (ORCPT ); Wed, 8 May 2019 07:14:34 -0400 Received: by mail-pl1-f194.google.com with SMTP id d21so2287292plr.3 for ; Wed, 08 May 2019 04:14:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=AsmIzKsEHIVz6P7ye1wAFFd42stgcYhE9fALBWycPlU=; b=JK/OLACsoA8QXHJmrkh5Gwr491a0zAGqe45NoAlDVK9sUjUYv6+dlO85V6sh7SKSOh WBP+WjDOfnmV+YJ1yPTLntfSuY9NY3yrKs4iD9ZWGxMrSim4fNBCFt3P9N+0qmVYJZmd qD5pyge16IPBlSwATI13a6AqoQFb67lNvGJmL0QvYj5sPsQbCEVzsKi5Rz0fKOtliFbQ eNJgS+aLSjsYnTQ+MUMKa4U5GO2h9YVgYJ6ytyF9maq6Kc8EsmbjMifhx5wk/+JDMs/7 1obCQIE3yB/q8f1L+AdzF9vvu+ik7Lc0D215Zv6JD6UokDPOlW1DVuD02zfMGPfBx9k7 ez+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=AsmIzKsEHIVz6P7ye1wAFFd42stgcYhE9fALBWycPlU=; b=iBaM7w/We0nG5YiL0HIkjs87N+0VcZ0EDAUsDUEH1ySMN1dSu79KzkZyz6ifNhMVgg OFxWu7LvMRAKzKE/dd0Ji0Y8lpxjmi/djMn+j1HbVKGstELLlB10+Hr2hHqkJPvU6Crd leXgWp/xscbWhCNbElMcUDL9oL1B0uSf7UtHhn66so5nGYFpNOPc4XW130EE2YrBuuGA 6vqsX1qn8Z8j8GEtLaWheOFETDbHSo/kQibHYh3BBB4UeBb1W5cxMVEyPSDO7ZngzG7T 55PDOYKFII4VsU0dzD586PI47Nln3yb8Lj4d5JD4Y69baDjZO6KZAaWSAxr2nbocKZ9r TJWA== X-Gm-Message-State: APjAAAVZLQD94umy3La5TsPOPzQ4IubXb+7kcJYywRa1rWtpOscseydj Rqr3m7iAkhoPdQ2/AFMlKx/SIU2C X-Google-Smtp-Source: APXvYqwIFZKIjM1QfxNc1/1Hc9JgL5vt6OrRDAeZ0aLN3oCKbCUNjFlvqwrrD/quvNSHYc49tRuNYg== X-Received: by 2002:a17:902:9a03:: with SMTP id v3mr47978876plp.27.1557314073144; Wed, 08 May 2019 04:14:33 -0700 (PDT) Received: from ash ([115.72.28.243]) by smtp.gmail.com with ESMTPSA id s9sm21320641pfe.183.2019.05.08.04.14.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 08 May 2019 04:14:32 -0700 (PDT) Received: by ash (sSMTP sendmail emulation); Wed, 08 May 2019 18:14:29 +0700 From: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= To: git@vger.kernel.org Cc: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= Subject: [PATCH 16/19] rev-parseopt: prepare to convert handle_revision_opt() Date: Wed, 8 May 2019 18:12:46 +0700 Message-Id: <20190508111249.15262-17-pclouds@gmail.com> X-Mailer: git-send-email 2.21.0.1141.gd54ac2cb17 In-Reply-To: <20190508111249.15262-1-pclouds@gmail.com> References: <20190508111249.15262-1-pclouds@gmail.com> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Besides preparing an empty option table to be added in. The table is also concatenated with diff option table so we don't need diff_opt_parse() anymore. Merging with pseudo-opt table though will not happen until we kill parse_revision_opt(). --abbrev has to be converted right away to override the same one from the diff option parser (which runs first now, if not overriden) Signed-off-by: Nguyễn Thái Ngọc Duy --- Documentation/technical/api-diff.txt | 6 +-- diff.c | 16 ------- diff.h | 1 - revision.c | 64 +++++++++++++++++++++------- revision.h | 1 + 5 files changed, 53 insertions(+), 35 deletions(-) diff --git a/Documentation/technical/api-diff.txt b/Documentation/technical/api-diff.txt index 30fc0e9c93..1e4e6968f4 100644 --- a/Documentation/technical/api-diff.txt +++ b/Documentation/technical/api-diff.txt @@ -22,9 +22,9 @@ Calling sequence sets up the vanilla default. * Fill in the options structure to specify desired output format, rename - detection, etc. `diff_opt_parse()` can be used to parse options given - from the command line in a way consistent with existing git-diff - family of programs. + detection, etc. `parseopts[]` can be used with parse_options() to + parse options from the command line in a way consistent with + existing git-diff family of programs. * Call `diff_setup_done()`; this inspects the options set up so far for internal consistency and make necessary tweaking to it (e.g. if diff --git a/diff.c b/diff.c index 4d3cf83a27..ef0eb2a160 100644 --- a/diff.c +++ b/diff.c @@ -5522,22 +5522,6 @@ static void prep_parse_options(struct diff_options *options) memcpy(options->parseopts, parseopts, sizeof(parseopts)); } -int diff_opt_parse(struct diff_options *options, - const char **av, int ac, const char *prefix) -{ - if (!prefix) - prefix = ""; - - ac = parse_options(ac, av, prefix, options->parseopts, NULL, - PARSE_OPT_KEEP_DASHDASH | - PARSE_OPT_KEEP_UNKNOWN | - PARSE_OPT_NO_INTERNAL_HELP | - PARSE_OPT_ONE_SHOT | - PARSE_OPT_STOP_AT_NON_OPTION); - - return ac; -} - int parse_rename_score(const char **cp_p) { unsigned long num, scale; diff --git a/diff.h b/diff.h index b20cbcc091..c75480a998 100644 --- a/diff.h +++ b/diff.h @@ -351,7 +351,6 @@ int git_diff_ui_config(const char *var, const char *value, void *cb); #define diff_setup(diffopts) repo_diff_setup(the_repository, diffopts) #endif void repo_diff_setup(struct repository *, struct diff_options *); -int diff_opt_parse(struct diff_options *, const char **, int, const char *); void diff_setup_done(struct diff_options *); int git_config_rename(const char *var, const char *value); diff --git a/revision.c b/revision.c index dd22ac5c39..f15aa3e62d 100644 --- a/revision.c +++ b/revision.c @@ -1611,6 +1611,7 @@ static int add_parents_only(struct rev_info *revs, const char *arg_, int flags, } static void make_pseudo_options(struct rev_info *revs); +static void make_rev_options(struct rev_info *revs); void repo_init_revisions(struct repository *r, struct rev_info *revs, @@ -1653,6 +1654,7 @@ void repo_init_revisions(struct repository *r, revs->notes_opt.use_default_notes = -1; make_pseudo_options(revs); + make_rev_options(revs); } static void add_pending_commit_list(struct rev_info *revs, @@ -1953,6 +1955,38 @@ static void add_message_grep(struct rev_info *revs, const char *pattern) add_grep(revs, pattern, GREP_PATTERN_BODY); } +static int rev_opt_abbrev(const struct option *opt, + const char *optarg, int unset) +{ + struct rev_info *revs = opt->value; + + if (unset) { + revs->abbrev = 0; + } else if (!optarg) { + revs->abbrev = DEFAULT_ABBREV; + } else { + const unsigned hexsz = the_hash_algo->hexsz; + + revs->abbrev = strtoul(optarg, NULL, 10); + if (revs->abbrev < MINIMUM_ABBREV) + revs->abbrev = MINIMUM_ABBREV; + else if (revs->abbrev > hexsz) + revs->abbrev = hexsz; + } + return 0; +} + +static void make_rev_options(struct rev_info *revs) +{ + struct option options[] = { + OPT_CALLBACK_F(0, "abbrev", revs, N_("n"), + N_("show the given source prefix instead of \"a/\""), + PARSE_OPT_OPTARG, rev_opt_abbrev), + OPT_END(), + }; + revs->options = parse_options_concat(options, revs->diffopt.parseopts); +} + static int handle_revision_opt(struct rev_info *revs, int argc, const char **argv, int *unkc, const char **unkv, const struct setup_revision_opt* opt) @@ -1960,7 +1994,6 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg const char *arg = argv[0]; const char *optarg; int argcount; - const unsigned hexsz = the_hash_algo->hexsz; /* pseudo revision arguments */ if (!strcmp(arg, "--all") || !strcmp(arg, "--branches") || @@ -1977,6 +2010,18 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg return 1; } + revs->pseudo_flags = NULL; + revs->pseudo_refs = NULL; + argc = parse_options(argc, argv, revs->prefix, + revs->options, NULL, + PARSE_OPT_KEEP_DASHDASH | + PARSE_OPT_KEEP_UNKNOWN | + PARSE_OPT_NO_INTERNAL_HELP | + PARSE_OPT_ONE_SHOT | + PARSE_OPT_STOP_AT_NON_OPTION); + if (argc) + return argc; + if ((argcount = parse_long_opt("max-count", argv, &optarg))) { revs->max_count = atoi(optarg); revs->no_walk = 0; @@ -2243,16 +2288,6 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg revs->no_commit_id = 1; } else if (!strcmp(arg, "--always")) { revs->always_show_header = 1; - } else if (!strcmp(arg, "--no-abbrev")) { - revs->abbrev = 0; - } else if (!strcmp(arg, "--abbrev")) { - revs->abbrev = DEFAULT_ABBREV; - } else if (skip_prefix(arg, "--abbrev=", &optarg)) { - revs->abbrev = strtoul(optarg, NULL, 10); - if (revs->abbrev < MINIMUM_ABBREV) - revs->abbrev = MINIMUM_ABBREV; - else if (revs->abbrev > hexsz) - revs->abbrev = hexsz; } else if (!strcmp(arg, "--abbrev-commit")) { revs->abbrev_commit = 1; revs->abbrev_commit_given = 1; @@ -2324,10 +2359,8 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg BUG("exclude_promisor_objects can only be used when fetch_if_missing is 0"); revs->exclude_promisor_objects = 1; } else { - int opts = diff_opt_parse(&revs->diffopt, argv, argc, revs->prefix); - if (!opts) - unkv[(*unkc)++] = arg; - return opts; + unkv[(*unkc)++] = arg; + return 0; } if (revs->graph && revs->track_linear) die("--show-linear-break and --graph are incompatible"); @@ -2861,6 +2894,7 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, struct s revs->expand_tabs_in_log = revs->expand_tabs_in_log_default; FREE_AND_NULL(revs->pseudo_options); + FREE_AND_NULL(revs->options); return left; } diff --git a/revision.h b/revision.h index cec5215c04..4e840c8eb1 100644 --- a/revision.h +++ b/revision.h @@ -283,6 +283,7 @@ struct rev_info { struct option *pseudo_options; int *pseudo_flags; struct ref_store *pseudo_refs; + struct option *options; }; int ref_excluded(struct string_list *, const char *path); From patchwork Wed May 8 11:12:47 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Duy Nguyen X-Patchwork-Id: 10934989 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 2D14592A for ; Wed, 8 May 2019 11:14:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1D141286D4 for ; Wed, 8 May 2019 11:14:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 116FB28758; Wed, 8 May 2019 11:14: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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI 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 AC0AF286D4 for ; Wed, 8 May 2019 11:14:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727265AbfEHLOi (ORCPT ); Wed, 8 May 2019 07:14:38 -0400 Received: from mail-pg1-f196.google.com ([209.85.215.196]:34649 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726687AbfEHLOi (ORCPT ); Wed, 8 May 2019 07:14:38 -0400 Received: by mail-pg1-f196.google.com with SMTP id c13so9962466pgt.1 for ; Wed, 08 May 2019 04:14:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=I6dBq6shRUFhCwxorTRNrM7Qvz4MnpA8ohnOuII6ZU0=; b=B468ucT3CZtfXw1HwPdPU3JpAQdhMfpyPKciTC9/cIee8n4VHmC+9ry2yOhy+YqD/E LD/Rx0B74XHWRyFf1FEDpfDtfsqEY4zb3xJbvLnKezLwL0Z9LP+tvnqzYySW8p2uvONN jDxtjruFSS5GAaKepIoZ69ztL9Nab64o8LKlY173OCMw7J2B4pHdXDaAqUUN2YAnFJzc O9mSMZc4PUcGZnjRBrbbwErpkDmI/isBSbUBRXoE4JeEJJc8YH2ISZkEmwgcc0sGFJci XfoGf5Tz9Q6qUACjQowJlU/1cLmUicngPcyzCP53JkBT2ieeL0AvIL9UGeUSS0SXmUOW ZoIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=I6dBq6shRUFhCwxorTRNrM7Qvz4MnpA8ohnOuII6ZU0=; b=D9cyqJoMC7NYDtBOCXFqR+UPXM3FHWQ9Ph6+12l4ePtKU8gQzIEBJG52HbAapRzO6F yULnG7IuVDPWOzJUZdh7ffmHIY60RoyDNYWGQyGXCIsZZP2/Pi9CVUih3m1cBIia+jmp TL7D9KaTLbnaZ/mnelGUGBMaXxyqrmh58S2fP5/gHHudeiz6kJCBEcH0x+yOnMwxYYIO r7b/GU0dSIs7FepH8cJIuTD6QE0Sj8Rqf0HKXoYIJKEKgKorUj4PtEDvxxhHWXv9UnKv 7wRvvOhC1uEBFqLp5a637pJNUe/YzuaxFoj8SenI5fSwXd+6xwpONW6cFqX0yw5FwPVZ 82Ag== X-Gm-Message-State: APjAAAWtsUP+Grl3/gFB8Q3IrVRaEQpG5vthi+Gbjri8PY5xYyooNe9C RSkwyxlyg7z7mv1Fx6ax1RnaeYlM X-Google-Smtp-Source: APXvYqxmpir4HEoM8Kz8JyhR2haq3/Uf4Z3uCqvqFNR9g8oPJUznv2x1Uuo0BQo8xeYXnuJOyIHGqw== X-Received: by 2002:a63:1b65:: with SMTP id b37mr23703404pgm.408.1557314077443; Wed, 08 May 2019 04:14:37 -0700 (PDT) Received: from ash ([115.72.28.243]) by smtp.gmail.com with ESMTPSA id n64sm23477948pfb.38.2019.05.08.04.14.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 08 May 2019 04:14:36 -0700 (PDT) Received: by ash (sSMTP sendmail emulation); Wed, 08 May 2019 18:14:33 +0700 From: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= To: git@vger.kernel.org Cc: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= Subject: [PATCH 17/19] rev-parseopt: convert --max-count Date: Wed, 8 May 2019 18:12:47 +0700 Message-Id: <20190508111249.15262-18-pclouds@gmail.com> X-Mailer: git-send-email 2.21.0.1141.gd54ac2cb17 In-Reply-To: <20190508111249.15262-1-pclouds@gmail.com> References: <20190508111249.15262-1-pclouds@gmail.com> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Nguyễn Thái Ngọc Duy --- revision.c | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/revision.c b/revision.c index f15aa3e62d..c53347d362 100644 --- a/revision.c +++ b/revision.c @@ -1976,12 +1976,26 @@ static int rev_opt_abbrev(const struct option *opt, return 0; } +static int rev_opt_max_count(const struct option *opt, + const char *arg, int unset) +{ + struct rev_info *revs = opt->value; + + BUG_ON_OPT_NEG(unset); + revs->max_count = atoi(arg); + revs->no_walk = 0; + return 0; +} + static void make_rev_options(struct rev_info *revs) { struct option options[] = { OPT_CALLBACK_F(0, "abbrev", revs, N_("n"), N_("show the given source prefix instead of \"a/\""), PARSE_OPT_OPTARG, rev_opt_abbrev), + OPT_REV('n', "max-count", N_(""), + N_("limit the number of commis to stdout"), + rev_opt_max_count), OPT_END(), }; revs->options = parse_options_concat(options, revs->diffopt.parseopts); @@ -2022,11 +2036,7 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg if (argc) return argc; - if ((argcount = parse_long_opt("max-count", argv, &optarg))) { - revs->max_count = atoi(optarg); - revs->no_walk = 0; - return argcount; - } else if ((argcount = parse_long_opt("skip", argv, &optarg))) { + if ((argcount = parse_long_opt("skip", argv, &optarg))) { revs->skip_count = atoi(optarg); return argcount; } else if ((*arg == '-') && isdigit(arg[1])) { @@ -2035,15 +2045,6 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg revs->max_count < 0) die("'%s': not a non-negative integer", arg + 1); revs->no_walk = 0; - } else if (!strcmp(arg, "-n")) { - if (argc <= 1) - return error("-n requires an argument"); - revs->max_count = atoi(argv[1]); - revs->no_walk = 0; - return 2; - } else if (skip_prefix(arg, "-n", &optarg)) { - revs->max_count = atoi(optarg); - revs->no_walk = 0; } else if ((argcount = parse_long_opt("max-age", argv, &optarg))) { revs->max_age = atoi(optarg); return argcount; From patchwork Wed May 8 11:12:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Duy Nguyen X-Patchwork-Id: 10934991 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 0B4B192A for ; Wed, 8 May 2019 11:14:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EDF8D2870C for ; Wed, 8 May 2019 11:14:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DC56028758; Wed, 8 May 2019 11:14: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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI 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 B584B2875C for ; Wed, 8 May 2019 11:14:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727459AbfEHLOm (ORCPT ); Wed, 8 May 2019 07:14:42 -0400 Received: from mail-pl1-f193.google.com ([209.85.214.193]:46837 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727367AbfEHLOm (ORCPT ); Wed, 8 May 2019 07:14:42 -0400 Received: by mail-pl1-f193.google.com with SMTP id bi2so9769229plb.13 for ; Wed, 08 May 2019 04:14:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=wcZSW69vX7CUbudGRc7pW3Y3ePNi9rALz48CQlhitKI=; b=PLQAIUSGLTrStcXRUiEc8hgB+q9+wL9ayCh6oLKEHrowxn0uWEVGf+82kbxDxZmgzX gm+kpisYLo8JT2JgO4tQODP9rZBycV4MbKKs4ZkUrV6qklJR15KjRTULvd6MUK/XbTxh 2CNVG4DnU81MveMxNH/CF8ziEwvZLENCan3WhPSo9EOlbfkNrROgNL2oTIw+5mNULrTS nSGyKuEOwIu3SB5uEmQomu65XOAw0Qfg68TzEeRDCJQgjQGflOo4prYsG5qS683VS1i6 ebCO45djJDEUbm2ysSXz4hooxPfHWpEoWz54Xtk3dbF/Zdc/vu0Q03jf5Z1UyaEJY8Kc 0GAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=wcZSW69vX7CUbudGRc7pW3Y3ePNi9rALz48CQlhitKI=; b=IXQS1NVgXAdfNDzWQY+oNY1NT8KMUolV8rrsgFMV661ngXTV1MT0mgSt9+bvS/LO6e GbncYl4RXyxdV4uhZGF/WKqKrA5AeVl6aG6iNvWS74V98jdS9chdvvsprDmE5/aTimif 39iwYwuQ+RpcfIrVON3ZPD9kShQ32nfYbGwn9czIjQn7sp3/x2dvvvf4fjhv9+Cbsyha sWN2D/Z26GvftKv4sNSvz3gF16Xi8lCh8cmVNChSz0noDQX74W2jFu7yNIHXItBDz8bb cfvLmjcEco5zTITpfRt+ZjDjMWdR6rRecQKvI+4Lg2LDKdLaDC4fo/gQ3bphKYeQHgwL oddg== X-Gm-Message-State: APjAAAXsCFm+M05ElvxVLwAu2kHYsldz4XZPbErR9MA2UgSIQdEpd1z8 TrLRwDMrOjL9eMYK9Q79s1a7wmpy X-Google-Smtp-Source: APXvYqzT2sYHTdzyKuHmS/S33goIhOQ1Bl/nwfvGO0iVFCm9Si1yhyKNvYntOQsPWmDaKx809Au1Yg== X-Received: by 2002:a17:902:2927:: with SMTP id g36mr44838830plb.6.1557314081643; Wed, 08 May 2019 04:14:41 -0700 (PDT) Received: from ash ([115.72.28.243]) by smtp.gmail.com with ESMTPSA id j12sm20506393pff.148.2019.05.08.04.14.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 08 May 2019 04:14:41 -0700 (PDT) Received: by ash (sSMTP sendmail emulation); Wed, 08 May 2019 18:14:37 +0700 From: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= To: git@vger.kernel.org Cc: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= Subject: [PATCH 18/19] rev-parseopt: convert --skip Date: Wed, 8 May 2019 18:12:48 +0700 Message-Id: <20190508111249.15262-19-pclouds@gmail.com> X-Mailer: git-send-email 2.21.0.1141.gd54ac2cb17 In-Reply-To: <20190508111249.15262-1-pclouds@gmail.com> References: <20190508111249.15262-1-pclouds@gmail.com> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Nguyễn Thái Ngọc Duy --- revision.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/revision.c b/revision.c index c53347d362..42d466cd08 100644 --- a/revision.c +++ b/revision.c @@ -1996,6 +1996,9 @@ static void make_rev_options(struct rev_info *revs) OPT_REV('n', "max-count", N_(""), N_("limit the number of commis to stdout"), rev_opt_max_count), + OPT_INTEGER_F(0, "skip", &revs->skip_count, + N_("skip a number of commits before starting to show"), + PARSE_OPT_NONEG), OPT_END(), }; revs->options = parse_options_concat(options, revs->diffopt.parseopts); @@ -2036,10 +2039,7 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg if (argc) return argc; - if ((argcount = parse_long_opt("skip", argv, &optarg))) { - revs->skip_count = atoi(optarg); - return argcount; - } else if ((*arg == '-') && isdigit(arg[1])) { + if ((*arg == '-') && isdigit(arg[1])) { /* accept -, like traditional "head" */ if (strtol_i(arg + 1, 10, &revs->max_count) < 0 || revs->max_count < 0) From patchwork Wed May 8 11:12:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Duy Nguyen X-Patchwork-Id: 10934993 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 E03C092A for ; Wed, 8 May 2019 11:14:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CDD06286D4 for ; Wed, 8 May 2019 11:14:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C0962287AB; Wed, 8 May 2019 11:14: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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI 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 177AE2875C for ; Wed, 8 May 2019 11:14:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727462AbfEHLOr (ORCPT ); Wed, 8 May 2019 07:14:47 -0400 Received: from mail-pl1-f195.google.com ([209.85.214.195]:44721 "EHLO mail-pl1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727367AbfEHLOq (ORCPT ); Wed, 8 May 2019 07:14:46 -0400 Received: by mail-pl1-f195.google.com with SMTP id d3so5754919plj.11 for ; Wed, 08 May 2019 04:14:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=pYFvXswZZAhhwYgFDZ33FbFbJT3r9AF6X/nOYYgaju0=; b=FbMyAjJx3gvlH8fKE0nCiZycIZ/oDADeF5+ZIgNhHZ1bdgczRUO3dHkvw1tEKjyZZu iYlFY0Rt0mDaG0LjVuMM7JdtXuKDTjC5pvLajIU5byJP4yiXA1Om5W+xywjaQaPNRH2k KB1aJsJ5Tt+JPVAy7PM6CqJTmzAe+EwwAtCvvTQ6sJ5ANXaO+zZcFSWSNUnSgyvt20bx iMb+d2f9X8RdYr5iNndkoyNx3jwKlZJW+bSYe691NduL6XoVnIFilPjwCzKlukGPt1Sn u5G69PSNEuQXGPGeCIdty7hIVjuOyRjPPPZOTJmhiLxYd+arxL3L56my52lXTaVb7a/5 qSdw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=pYFvXswZZAhhwYgFDZ33FbFbJT3r9AF6X/nOYYgaju0=; b=dPSGPv1vk35vwDJv+rDAn/Pl03CstlGAwW1MleaAQy207Td17o+B/yVdmChJPqGwuZ 3DwK8xnQtsXLmajG/5qkb9z7jz0KlJklJiW4sZ+DwKEcmYwTp91I+Dg2DG0q8hWXXisT qukhpbMzPbJEXLHZigMi4RzNLgXMIlR2iKzuJhe61j3VEWh319Tr6sierqlEqXLiY3it VeifJlVMuaO4jneoM+bum3feVW1ze+qqGluC7eh+SCWPE4mQXCInnr8xpb46nlF4csb2 4SPz7SMjSrXx/mE6SMNT6Acx7TgoXITgCG8QvpIsPV5lqmGDYzOqOqIZvwKiNziDWhNZ RO4A== X-Gm-Message-State: APjAAAUkml0qeOYcjyGzHpQiGHNFwRUqTiJwfLD0CVQN3lYknJhfnWlu dIw5QOEiQtooKtlOt0iV4+ut6lqO X-Google-Smtp-Source: APXvYqx++45S3rNGowKpXAdSLMtEDD3EYmQr/dJF/+v/LnQ7XcBZMHRk7Du8WDlNg4lzDJB+j7yOdA== X-Received: by 2002:a17:902:2962:: with SMTP id g89mr46456472plb.190.1557314085913; Wed, 08 May 2019 04:14:45 -0700 (PDT) Received: from ash ([115.72.28.243]) by smtp.gmail.com with ESMTPSA id x4sm20432667pfm.19.2019.05.08.04.14.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 08 May 2019 04:14:45 -0700 (PDT) Received: by ash (sSMTP sendmail emulation); Wed, 08 May 2019 18:14:41 +0700 From: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= To: git@vger.kernel.org Cc: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= Subject: [PATCH 19/19] rev-parseopt: convert --min-age and --max-age Date: Wed, 8 May 2019 18:12:49 +0700 Message-Id: <20190508111249.15262-20-pclouds@gmail.com> X-Mailer: git-send-email 2.21.0.1141.gd54ac2cb17 In-Reply-To: <20190508111249.15262-1-pclouds@gmail.com> References: <20190508111249.15262-1-pclouds@gmail.com> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Nguyễn Thái Ngọc Duy --- parse-options-cb.c | 8 ++++++++ parse-options.h | 4 ++++ revision.c | 10 ++++------ 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/parse-options-cb.c b/parse-options-cb.c index 6e2e8d6273..7cdbbf5f6d 100644 --- a/parse-options-cb.c +++ b/parse-options-cb.c @@ -39,6 +39,14 @@ int parse_opt_expiry_date_cb(const struct option *opt, const char *arg, return 0; } +int parse_opt_timestamp_cb(const struct option *opt, + const char *arg, int unset) +{ + BUG_ON_OPT_NEG(unset); + *(timestamp_t *)opt->value = atoi(arg); + return 0; +} + int parse_opt_color_flag_cb(const struct option *opt, const char *arg, int unset) { diff --git a/parse-options.h b/parse-options.h index cc9230adac..7637864c41 100644 --- a/parse-options.h +++ b/parse-options.h @@ -168,6 +168,9 @@ struct option { #define OPT_EXPIRY_DATE(s, l, v, h) \ { OPTION_CALLBACK, (s), (l), (v), N_("expiry-date"),(h), 0, \ parse_opt_expiry_date_cb } +#define OPT_TIMESTAMP(s, l, v, h) \ + { OPTION_CALLBACK, (s), (l), (v), N_("timestamp"),(h), \ + PARSE_OPT_NONEG, parse_opt_timestamp_cb } #define OPT_CALLBACK(s, l, v, a, h, f) OPT_CALLBACK_F(s, l, v, a, h, 0, f) #define OPT_NUMBER_CALLBACK(v, h, f) \ { OPTION_NUMBER, 0, NULL, (v), NULL, (h), \ @@ -275,6 +278,7 @@ struct option *parse_options_concat(struct option *a, struct option *b); /*----- some often used options -----*/ int parse_opt_abbrev_cb(const struct option *, const char *, int); int parse_opt_expiry_date_cb(const struct option *, const char *, int); +int parse_opt_timestamp_cb(const struct option *, const char *, int); int parse_opt_color_flag_cb(const struct option *, const char *, int); int parse_opt_verbosity_cb(const struct option *, const char *, int); int parse_opt_object_name(const struct option *, const char *, int); diff --git a/revision.c b/revision.c index 42d466cd08..0c28b67978 100644 --- a/revision.c +++ b/revision.c @@ -1999,6 +1999,10 @@ static void make_rev_options(struct rev_info *revs) OPT_INTEGER_F(0, "skip", &revs->skip_count, N_("skip a number of commits before starting to show"), PARSE_OPT_NONEG), + OPT_TIMESTAMP(0, "min-age", &revs->min_age, + N_("limit the commits output to a specified time range")), + OPT_TIMESTAMP(0, "max-age", &revs->max_age, + N_("limit the commits output to a specified time range")), OPT_END(), }; revs->options = parse_options_concat(options, revs->diffopt.parseopts); @@ -2045,18 +2049,12 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg revs->max_count < 0) die("'%s': not a non-negative integer", arg + 1); revs->no_walk = 0; - } else if ((argcount = parse_long_opt("max-age", argv, &optarg))) { - revs->max_age = atoi(optarg); - return argcount; } else if ((argcount = parse_long_opt("since", argv, &optarg))) { revs->max_age = approxidate(optarg); return argcount; } else if ((argcount = parse_long_opt("after", argv, &optarg))) { revs->max_age = approxidate(optarg); return argcount; - } else if ((argcount = parse_long_opt("min-age", argv, &optarg))) { - revs->min_age = atoi(optarg); - return argcount; } else if ((argcount = parse_long_opt("before", argv, &optarg))) { revs->min_age = approxidate(optarg); return argcount;