# [BUG] 'git show-ref <pattern>' doesn't work (shows nothing)

3 messages from 2010-10-18 to 2010-10-18. Participants: Jakub Narebski, Michael J Gruber.
Thread: https://gitlist.dev/t/25467

## Jakub Narebski, 2010-10-18 10:03

Subject: [BUG] 'git show-ref <pattern>' doesn't work (shows nothing)
Message-ID: <201010181203.38554.jnareb@gmail.com>
URL: https://gitlist.dev/e/201010181203.38554.jnareb%40gmail.com

```
In the git-show-ref documentation we read:

  git-show-ref - List references in a local repository

  SYNOPSIS
  --------
  [verse]
  'git show-ref' [-q|--quiet] [--verify] [--head] [-d|--dereference]
               [-s|--hash[=<n>]] [--abbrev[=<n>]] [--tags]
               [--heads] [--] [<pattern>...]
  'git show-ref' --exclude-existing[=<pattern>] < ref-list

  DESCRIPTION
  -----------

  Displays references available in a local repository along with the
  associated commit IDs. Results can be filtered using a pattern and
  tags can be dereferenced into object IDs. Additionally, it can be
  used to test whether a particular ref exists.

Let's overlook the fact that the using '--verify' is a separate way of 
operation, and should be given seperate line in synopsis.

What is more important is that filtering using pattern doesn't work.  
All of commands listed below produce empty output:

  $ git show-ref refs/heads
  $ git show-ref refs/heads/
  $ git show-ref 'refs/heads/*'
  $ git show-ref -- refs/heads
  $ git show-ref -- 'refs/heads/*'

Note that using '--heads' gives output:

  $ git show-ref --heads
  01cc740941a6b81fd7be03484c83f688dc79a5f2 refs/heads/Git.pm
  23b2a0387f0acd7e3cd906a0dc3c2c23dd32c03d refs/heads/autoconf
  [...]

but I am more interested in patterns like 'refs/heads/gitweb/', or 
'refs/remotes/origin/', or 'refs/tags/v*'.

For the time of being I'd have to use git-for-each-ref instead:

  $ git for-each-ref refs/heads/
  01cc740941a6b81fd7be03484c83f688dc79a5f2 commit refs/heads/Git.pm
  23b2a0387f0acd7e3cd906a0dc3c2c23dd32c03d commit refs/heads/autoconf

(though to get same output I'd have to use appropriate <format>).
-- 
Jakub Narebski
Poland

```

## Michael J Gruber, 2010-10-18 11:33

Subject: [PATCH] git-show-ref.txt: clarify the pattern matching
Message-ID: <21215c6fd41bd344c4226f410b69680f3901549b.1287401559.git.git@drmicha.warpmail.net>
URL: https://gitlist.dev/e/21215c6fd41bd344c4226f410b69680f3901549b.1287401559.git.git%40drmicha.warpmail.net
In-Reply-To: <201010181203.38554.jnareb@gmail.com>

```
git-show-ref really does not do what one would expect under the name
pattern matching, so describe it.

Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>
---
 Documentation/git-show-ref.txt |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/Documentation/git-show-ref.txt b/Documentation/git-show-ref.txt
index 4696af7..be0ec18 100644
--- a/Documentation/git-show-ref.txt
+++ b/Documentation/git-show-ref.txt
@@ -84,7 +84,11 @@ OPTIONS
 
 <pattern>...::
 
-	Show references matching one or more patterns.
+	Show references matching one or more patterns. Patterns are matched from
+	the end of the full name, and only complete parts are matched, e.g.
+	'master' matches 'refs/heads/master', 'refs/remotes/origin/master',
+	'refs/tags/jedi/master' but not 'refs/heads/mymaster' nor
+	'refs/remotes/master/jedi'.
 
 OUTPUT
 ------
-- 
1.7.3.1.208.g53ea2

```

## Jakub Narebski, 2010-10-18 12:07

Subject: Re: [PATCH] git-show-ref.txt: clarify the pattern matching
Message-ID: <201010181407.30770.jnareb@gmail.com>
URL: https://gitlist.dev/e/201010181407.30770.jnareb%40gmail.com
In-Reply-To: <21215c6fd41bd344c4226f410b69680f3901549b.1287401559.git.git@drmicha.warpmail.net>

```
Michael J Gruber wrote:

> git-show-ref really does not do what one would expect under the name
> pattern matching, so describe it.
> 
> Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>

Thanks a lot!  That clarifies it.

-- 
Jakub Narebski
Poland

```
