git show-ref: add --remotes option.
PATCH 1/1 git show-ref: add --remotes option.
This works as --tags and --heads, limiting the outputted ref types. Any combination of the three can be used.
Signed-off-by Heikki Hokkanen <[email protected]>
--- Documentation/git-show-ref.txt | 10 ++++++---- builtin-show-ref.c | 12 +++++++++--- 2 files changed, 15 insertions(+), 7 deletions(-)
Documentation/git-show-ref.txt +6 -4
@@ -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::
builtin-show-ref.c +9 -3
@@ -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, voconst 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=" ))
Signature · 1 line
1.6.0.2.526.g5c283.dirty