From: Matthias Lederhofer <matled@gmx.net>
To: git@vger.kernel.org
Subject: [PATCH] show-ref: allow glob-style ref matching
Date: Fri, 26 Jan 2007 10:50:26 +0100 [thread overview]
Message-ID: <20070126095026.GA31802@moooo.ath.cx> (raw)
show-ref without --verify will try to match pattern with
fnmatch against the full refname and every suffix starting
at a / in refname
---
I've been using ls .git/refs/tags/v1.4.* and other glob patterns to
take a look at refs. This allows to use such patterns with show-ref.
If this patch is accepted I'll add the missing documentation.
---
builtin-show-ref.c | 21 ++++++++++-----------
1 files changed, 10 insertions(+), 11 deletions(-)
diff --git a/builtin-show-ref.c b/builtin-show-ref.c
index 853f13f..64a1246 100644
--- a/builtin-show-ref.c
+++ b/builtin-show-ref.c
@@ -34,21 +34,20 @@ static int show_ref(const char *refname, const unsigned char *sha1, int flag, vo
return 0;
}
if (pattern) {
- int reflen = strlen(refname);
const char **p = pattern, *m;
while ((m = *p++) != NULL) {
- int len = strlen(m);
- if (len > reflen)
- continue;
- if (memcmp(m, refname + reflen - len, len))
- continue;
- if (len == reflen)
- goto match;
+ const char *r = refname;
/* "--verify" requires an exact match */
- if (verify)
+ if (verify) {
+ if (strcmp(m, refname))
+ goto match;
continue;
- if (refname[reflen - len - 1] == '/')
- goto match;
+ }
+ do {
+ if (!fnmatch(m, r, 0))
+ goto match;
+ r = index(r, '/');
+ } while (r++);
}
return 0;
}
--
1.5.0.rc2.g18af
reply other threads:[~2007-01-26 9:50 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20070126095026.GA31802@moooo.ath.cx \
--to=matled@gmx.net \
--cc=git@vger.kernel.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.