git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] git show-ref: add --remotes option.

From
HHHeikki Hokkanen <hoxu@users.sf.net>
Date
Oct 13, 2008, 19:23 UTC
Message-ID
<48F3A043.5070406@users.sf.net>

This works as --tags and --heads, limiting the outputted ref types. Any combination of the three can be used.

Signed-off-by: Heikki Hokkanen <hoxu@users.sf.net>
---
 Documentation/git-show-ref.txt |   10 ++++++----
 builtin-show-ref.c             |   12 +++++++++---
 2 files changed, 15 insertions(+), 7 deletions(-)
diff --git a/Documentation/git-show-ref.txt b/Documentation/git-show-ref.txt
index 2f173ff..5aea2de 100644
--- a/Documentation/git-show-ref.txt
+++ b/Documentation/git-show-ref.txt
@@ -9,7 +9,8 @@ SYNOPSIS
 --------
 [verse]
 'git show-ref' [-q|--quiet] [--verify] [-h|--head] [-d|--dereference]
-	     [-s|--hash] [--abbrev] [--tags] [--heads] [--] <pattern>...
+	     [-s|--hash] [--abbrev] [--tags] [--heads] [--remotes]
+	     [--] <pattern>...
 'git show-ref' --exclude-existing[=pattern]
 
 DESCRIPTION
@@ -36,10 +37,11 @@ OPTIONS
 
 --tags::
 --heads::
+--remotes::
 
-	Limit to only "refs/heads" and "refs/tags", respectively.  These
-	options are not mutually exclusive; when given both, references stored
-	in "refs/heads" and "refs/tags" are displayed.
+	Limit to only "refs/heads", "refs/tags" and "refs/remotes" respectively.
+	These options are not mutually exclusive; when given all, references
+	stored in "refs/heads", "refs/tags" and "refs/remotes" are displayed.
 
 -d::
 --dereference::
diff --git a/builtin-show-ref.c b/builtin-show-ref.c
index 572b114..d2362c2 100644
--- a/builtin-show-ref.c
+++ b/builtin-show-ref.c
@@ -5,10 +5,11 @@
 #include "tag.h"
 #include "string-list.h"
 
-static const char show_ref_usage[] = "git show-ref [-q|--quiet] [--verify] [-h|--head] [-d|--dereference] [-s|--hash[=<length>]] [--abbrev[=<length>]] [--tags] [--heads] [--] [pattern*] < ref-list";
+static const char show_ref_usage[] = "git show-ref [-q|--quiet] [--verify] [-h|--head] [-d|--dereference] [-s|--hash[=<length>]] [--abbrev[=<length>]] [--tags] [--heads] [--remotes] [--] [pattern*] < ref-list";
 
 static int deref_tags = 0, show_head = 0, tags_only = 0, heads_only = 0,
-	found_match = 0, verify = 0, quiet = 0, hash_only = 0, abbrev = 0;
+	remotes_only = 0, found_match = 0, verify = 0, quiet = 0, hash_only = 0,
+	abbrev = 0;
 static const char **pattern;
 
 static void show_one(const char *refname, const unsigned char *sha1)
@@ -26,11 +27,12 @@ static int show_ref(const char *refname, const unsigned char *sha1, int flag, vo
 	const char *hex;
 	unsigned char peeled[20];
 
-	if (tags_only || heads_only) {
+	if (tags_only || heads_only || remotes_only) {
 		int match;
 
 		match = heads_only && !prefixcmp(refname, "refs/heads/");
 		match |= tags_only && !prefixcmp(refname, "refs/tags/");
+		match |= remotes_only && !prefixcmp(refname, "refs/remotes/");
 		if (!match)
 			return 0;
 	}
@@ -217,6 +219,10 @@ int cmd_show_ref(int argc, const char **argv, const char *prefix)
 			heads_only = 1;
 			continue;
 		}
+		if (!strcmp(arg, "--remotes")) {
+			remotes_only = 1;
+			continue;
+		}
 		if (!strcmp(arg, "--exclude-existing"))
 			return exclude_existing(NULL);
 		if (!prefixcmp(arg, "--exclude-existing="))
-- 
1.6.0.2.526.g5c283.dirty
Message 1 of 1 in “git show-ref: add --remotes option.”
  1. git show-ref: add --remotes option.Heikki Hokkanen, Oct 13, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.