git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Johannes Sixt <j.sixt@viscovery.net>
To: Ilari Liusvaara <ilari.liusvaara@elisanet.fi>
Cc: git@vger.kernel.org
Subject: Re: [PATCH v2] rev-parse --namespace
Date: Wed, 20 Jan 2010 08:29:03 +0100	[thread overview]
Message-ID: <4B56B0BF.6020102@viscovery.net> (raw)
In-Reply-To: <1263798952-27624-1-git-send-email-ilari.liusvaara@elisanet.fi>

I've implemented --remotes=foo on top of your patch because I needed it,
and --namespace=remotes/foo was too much to type. Are you interested in
integrating this in your series in some way?

I only needed the --remotes=foo part; the --branches=foo is only
"because we can". Note that 'foo' is always a complete path component,
because it is the name of a remote (the trailing slash is implied), e.g.,
'--remotes=origin'.

--- 8< ---
From: Johannes Sixt <j6t@kdbg.org>
Subject: [PATCH] revision options --remotes=prefix and --branches=prefix

Signed-off-by: Johannes Sixt <j6t@kdbg.org>
---
 builtin-rev-parse.c |    2 ++
 revision.c          |   23 +++++++++++++++++++++++
 2 files changed, 25 insertions(+), 0 deletions(-)

diff --git a/builtin-rev-parse.c b/builtin-rev-parse.c
index 34af347..08b0555 100644
--- a/builtin-rev-parse.c
+++ b/builtin-rev-parse.c
@@ -42,6 +42,7 @@ static int is_rev_argument(const char *arg)
 		"--bisect",
 		"--dense",
 		"--branches",
+		"--branches=",
 		"--header",
 		"--max-age=",
 		"--max-count=",
@@ -52,6 +53,7 @@ static int is_rev_argument(const char *arg)
 		"--parents",
 		"--pretty",
 		"--remotes",
+		"--remotes=",
 		"--namespace=",
 		"--sparse",
 		"--tags",
diff --git a/revision.c b/revision.c
index ec63fa0..68e251b 100644
--- a/revision.c
+++ b/revision.c
@@ -714,6 +714,21 @@ static void handle_refs(struct rev_info *revs, unsigned flags,
 	for_each(handle_one_ref, &cb);
 }

+static void handle_ref_subset(struct rev_info *revs, unsigned flags,
+			      const char *prefix, const char *postfix)
+{
+	struct strbuf name = STRBUF_INIT;
+	struct all_refs_cb cb;
+
+	strbuf_addstr(&name, prefix);
+	strbuf_addstr(&name, postfix);
+	if (name.buf[name.len - 1] != '/')
+		strbuf_addch(&name, '/');
+	init_all_refs_cb(&cb, revs, flags);
+	for_each_ref_in(name.buf, handle_one_ref, &cb);
+	strbuf_release(&name);
+}
+
 static void handle_one_reflog_commit(unsigned char *sha1, void *cb_data)
 {
 	struct all_refs_cb *cb = cb_data;
@@ -1344,6 +1359,10 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch
 				handle_refs(revs, flags, for_each_branch_ref);
 				continue;
 			}
+			if (!prefixcmp(arg, "--branches=")) {
+				handle_ref_subset(revs, flags, "refs/heads/", arg + 11);
+				continue;
+			}
 			if (!strcmp(arg, "--bisect")) {
 				handle_refs(revs, flags, for_each_bad_bisect_ref);
 				handle_refs(revs, flags ^ UNINTERESTING, for_each_good_bisect_ref);
@@ -1358,6 +1377,10 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch
 				handle_refs(revs, flags, for_each_remote_ref);
 				continue;
 			}
+			if (!prefixcmp(arg, "--remotes=")) {
+				handle_ref_subset(revs, flags, "refs/remotes/", arg + 10);
+				continue;
+			}
 			if (!prefixcmp(arg, "--namespace=")) {
 				struct all_refs_cb cb;

-- 
1.6.6.1301.g354d

      parent reply	other threads:[~2010-01-20  7:44 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-01-18  7:15 [PATCH v2] rev-parse --namespace Ilari Liusvaara
2010-01-18  7:56 ` Junio C Hamano
2010-01-18  9:51   ` [PATCH v3] " Ilari Liusvaara
2010-01-19  6:56     ` Jeff King
2010-01-19  9:35       ` [PATCH] Fix errors in t6018 Ilari Liusvaara
2010-01-19 20:25         ` Junio C Hamano
2010-01-19 17:39 ` [PATCH v2] rev-parse --namespace Thomas Rast
2010-01-19 18:37   ` Ilari Liusvaara
2010-01-19 20:06     ` Junio C Hamano
2010-01-19 21:44       ` Ilari Liusvaara
2010-01-19 21:46         ` Thomas Rast
2010-01-19 22:12           ` Ilari Liusvaara
2010-01-19 22:36             ` Junio C Hamano
2010-01-20  7:29 ` Johannes Sixt [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4B56B0BF.6020102@viscovery.net \
    --to=j.sixt@viscovery.net \
    --cc=git@vger.kernel.org \
    --cc=ilari.liusvaara@elisanet.fi \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).