From mboxrd@z Thu Jan 1 00:00:00 1970 From: Karthik Nayak Subject: [PATCH v2 07/11] for-each-ref: add '--merged' and '--no-merged' options Date: Sun, 14 Jun 2015 01:48:22 +0530 Message-ID: <1434226706-3764-7-git-send-email-karthik.188@gmail.com> References: <1434226706-3764-1-git-send-email-karthik.188@gmail.com> Cc: christian.couder@gmail.com, Matthieu.Moy@grenoble-inp.fr, Karthik Nayak To: git@vger.kernel.org X-From: git-owner@vger.kernel.org Sat Jun 13 22:19:06 2015 Return-path: Envelope-to: gcvg-git-2@plane.gmane.org Received: from vger.kernel.org ([209.132.180.67]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Z3rtR-0003SQ-HU for gcvg-git-2@plane.gmane.org; Sat, 13 Jun 2015 22:19:06 +0200 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752495AbbFMUTA (ORCPT ); Sat, 13 Jun 2015 16:19:00 -0400 Received: from mail-pd0-f173.google.com ([209.85.192.173]:35418 "EHLO mail-pd0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752435AbbFMUSz (ORCPT ); Sat, 13 Jun 2015 16:18:55 -0400 Received: by pdbnf5 with SMTP id nf5so45061864pdb.2 for ; Sat, 13 Jun 2015 13:18:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=nzJ4aaST38xqT7dtzJkiPsfbllSObIz/dc3sNq9SEcg=; b=mXABsOj6wlzOXrNNMKPgqPqooliKQLaiJAS4as0hnUzbo/w77VEXWBd9Fw1oV+hph8 cxaNRZOHaW9/wqO5RJTwo5jFRKpgizSOVs+fJ7icpwb19rvkjKV5wB10I7hupBkVxzVN YJz/fqSlUKh1hLQghL07Wj6grLQutGfUnLqew+XjI/zoF/IaoRw/QWv3r8xLtFlNenf5 QQi/tQa48GTyDGWqE6mS01RgFAI92F7dDpFET85uG0YqOiaXAmX2+WR4MCMofeU+fy30 +Rp+pogNwGBhIGElqu7PmbfLDyTKUZhuElf/RsonhxDiNScjfFVNlLJg3d1ssLQWV9Bl VnTw== X-Received: by 10.70.95.106 with SMTP id dj10mr34386957pdb.103.1434226734980; Sat, 13 Jun 2015 13:18:54 -0700 (PDT) Received: from ashley.localdomain ([106.51.130.23]) by mx.google.com with ESMTPSA id nw8sm7471590pdb.30.2015.06.13.13.18.53 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 13 Jun 2015 13:18:54 -0700 (PDT) X-Mailer: git-send-email 2.4.3.435.g2403634.dirty In-Reply-To: <1434226706-3764-1-git-send-email-karthik.188@gmail.com> Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Archived-At: Add the '--merged' and '--no-merged' options provided by 'ref-filter'. The '--merged' option lets the user to only list refs merged into the named commit. The '--no-merged' option lets the user to only list refs not merged into the named commit. Add documentation and tests for the same. Based-on-patch-by: Jeff King Mentored-by: Christian Couder Mentored-by: Matthieu Moy Signed-off-by: Karthik Nayak --- Documentation/git-for-each-ref.txt | 10 +++++++++- builtin/for-each-ref.c | 3 +++ t/t6301-for-each-ref-filter.sh | 21 +++++++++++++++++++++ 3 files changed, 33 insertions(+), 1 deletion(-) diff --git a/Documentation/git-for-each-ref.txt b/Documentation/git-for-each-ref.txt index 0524ac4..d61a756 100644 --- a/Documentation/git-for-each-ref.txt +++ b/Documentation/git-for-each-ref.txt @@ -10,7 +10,7 @@ SYNOPSIS [verse] 'git for-each-ref' [--count=] [--shell|--perl|--python|--tcl] [(--sort=)...] [--format=] [...] - [--points-at ] + [--points-at ] [(--merged | --no-merged) ] DESCRIPTION ----------- @@ -66,6 +66,14 @@ OPTIONS --points-at :: Only list refs of the given object. +--merged []:: + Only list refs whose tips are reachable from the + specified commit (HEAD if not specified). + +--no-merged []:: + Only list refs whose tips are not reachable from the + specified commit (HEAD if not specified). + FIELD NAMES ----------- diff --git a/builtin/for-each-ref.c b/builtin/for-each-ref.c index 2dee149..00913f4 100644 --- a/builtin/for-each-ref.c +++ b/builtin/for-each-ref.c @@ -8,6 +8,7 @@ static char const * const for_each_ref_usage[] = { N_("git for-each-ref [] []"), N_("git for-each-ref [--points-at ]"), + N_("git for-each-ref [(--merged | --no-merged) ]"), NULL }; @@ -38,6 +39,8 @@ int cmd_for_each_ref(int argc, const char **argv, const char *prefix) OPT_CALLBACK(0, "points-at", &filter.points_at, N_("object"), N_("print only refs of the object"), parse_opt_object_name), + OPT_MERGED(&filter, N_("print only refs that are merged")), + OPT_NO_MERGED(&filter, N_("print only refs that are not merged")), OPT_END(), }; diff --git a/t/t6301-for-each-ref-filter.sh b/t/t6301-for-each-ref-filter.sh index 3a1c3f6..3ed97bd 100644 --- a/t/t6301-for-each-ref-filter.sh +++ b/t/t6301-for-each-ref-filter.sh @@ -42,4 +42,25 @@ test_expect_success 'filtering with --points-at' ' test_cmp expect actual ' +test_expect_success 'filtering with --merged' ' + cat >expect <<-\EOF && + refs/heads/master + refs/odd/spot + refs/tags/one + refs/tags/three + refs/tags/two + EOF + git for-each-ref --format="%(refname)" --merged=master >actual && + test_cmp expect actual +' + +test_expect_success 'filtering with --no-merged' ' + cat >expect <<-\EOF && + refs/heads/side + refs/tags/four + EOF + git for-each-ref --format="%(refname)" --no-merged=master >actual && + test_cmp expect actual +' + test_done -- 2.4.3.435.g2403634.dirty