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")) {