[PATCH] git show-ref: add --remotes option.
From: Heikki Hokkanen <hidden>
Date: 2016-06-15 22:45:28
Subsystem:
documentation, the rest · Maintainers:
Jonathan Corbet, Linus Torvalds
This works as --tags and --heads, limiting the outputted ref types. Any combination of the three can be used. Signed-off-by: Heikki Hokkanen <redacted> --- 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