From: Jeff King <peff@peff.net>
To: Junio C Hamano <gitster@pobox.com>
Cc: William Blevins <wblevins001@gmail.com>, git@vger.kernel.org
Subject: [PATCH v2 2/2] doc/ls-remote: clarify pattern format
Date: Fri, 10 Feb 2023 23:52:56 -0500 [thread overview]
Message-ID: <Y+cfKFz2rXLLVkjs@coredump.intra.peff.net> (raw)
In-Reply-To: <xmqq5yc8gbec.fsf@gitster.g>
On Fri, Feb 10, 2023 at 06:54:03PM -0800, Junio C Hamano wrote:
> > 'git ls-remote' [--heads] [--tags] [--refs] [--upload-pack=<exec>]
> > [-q | --quiet] [--exit-code] [--get-url] [--sort=<key>]
> > - [--symref] [<repository> [<refs>...]]
> > + [--symref] [<repository> [<patterns>...]]
>
> Micronit.
>
> builtin/ls-remote.c::ls_remote_usage[] needs a matching update.
Good catch. It is more than a micronit, as it causes t0450 to fail (I
did not even think to run the tests, since it was just a doc change).
> > -<refs>...::
> > +<patterns>...::
> > When unspecified, all references, after filtering done
> > - with --heads and --tags, are shown. When <refs>... are
> > - specified, only references matching the given patterns
> > - are displayed.
> > + with --heads and --tags, are shown. When <patterns>... are
> > + specified, only references matching one or more of the given
> > + patterns are displayed. Each pattern is interpreted as a glob
> > + (see `glob` in linkgit:gitglossary[7]) which is matched against
> > + the "tail" of a ref, starting from a slash separator (so `bar`
> > + matches `refs/heads/bar` but not `refs/heads/foobar`).
>
> Good. Is it too obvious that the pattern `refs/heads/bar` matches
> the ref `refs/heads/bar`, even though it becomes fuzzy what
> "starting from a slash separator" means in such a scenario?
Ah, thank you for bringing that up. I actually meant to call attention
to that case, as when I tried "git ls-remote . refs/heads/master", it
did not match anything, which seemed to me like a bug. But in fact it is
because I don't have a master branch in my repo (I only keep my feature
branches, plus an integration branch, and always refer to yours as
origin/master), and my experiment was buggy. :)
I do think it's worth mentioning (and thankfully there is no bug to
fix).
Here's a re-roll with both changes.
-- >8 --
Subject: [PATCH] doc/ls-remote: clarify pattern format
We document that you can specify "refs" to ls-remote, but we don't
explain any further than that they are "matched" as patterns. Since this
can be interpreted in a lot of ways, let's clarify that they are
tail-matched globs.
Likewise, let's use the word "patterns" to refer to them consistently,
rather than "refs" (both here and in the quick "-h" help), and mention
more explicitly that only one pattern needs to be matched (though there
is also an example already that shows this in action).
Signed-off-by: Jeff King <peff@peff.net>
---
Documentation/git-ls-remote.txt | 15 ++++++++++-----
builtin/ls-remote.c | 2 +-
2 files changed, 11 insertions(+), 6 deletions(-)
diff --git a/Documentation/git-ls-remote.txt b/Documentation/git-ls-remote.txt
index f17567945f..ff3da547dd 100644
--- a/Documentation/git-ls-remote.txt
+++ b/Documentation/git-ls-remote.txt
@@ -11,7 +11,7 @@ SYNOPSIS
[verse]
'git ls-remote' [--heads] [--tags] [--refs] [--upload-pack=<exec>]
[-q | --quiet] [--exit-code] [--get-url] [--sort=<key>]
- [--symref] [<repository> [<refs>...]]
+ [--symref] [<repository> [<patterns>...]]
DESCRIPTION
-----------
@@ -85,11 +85,16 @@ OPTIONS
either a URL or the name of a remote (see the GIT URLS and
REMOTES sections of linkgit:git-fetch[1]).
-<refs>...::
+<patterns>...::
When unspecified, all references, after filtering done
- with --heads and --tags, are shown. When <refs>... are
- specified, only references matching the given patterns
- are displayed.
+ with --heads and --tags, are shown. When <patterns>... are
+ specified, only references matching one or more of the given
+ patterns are displayed. Each pattern is interpreted as a glob
+ (see `glob` in linkgit:gitglossary[7]) which is matched against
+ the "tail" of a ref, starting either from the start of the ref
+ (so a full name like `refs/heads/foo` matches) or from a slash
+ separator (so `bar` matches `refs/heads/bar` but not
+ `refs/heads/foobar`).
EXAMPLES
--------
diff --git a/builtin/ls-remote.c b/builtin/ls-remote.c
index 5d5ac03871..6516177348 100644
--- a/builtin/ls-remote.c
+++ b/builtin/ls-remote.c
@@ -8,7 +8,7 @@
static const char * const ls_remote_usage[] = {
N_("git ls-remote [--heads] [--tags] [--refs] [--upload-pack=<exec>]\n"
" [-q | --quiet] [--exit-code] [--get-url] [--sort=<key>]\n"
- " [--symref] [<repository> [<refs>...]]"),
+ " [--symref] [<repository> [<patterns>...]]"),
NULL
};
--
2.39.1.795.g4b3688ded9
next prev parent reply other threads:[~2023-02-11 4:53 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-07 23:03 Unexpected (bug-like) behavior in `git ls-remote` matching William Blevins
2023-02-08 7:20 ` Junio C Hamano
2023-02-08 13:49 ` William Blevins
2023-02-08 14:51 ` Philip Oakley
2023-02-08 16:30 ` Jeff King
2023-02-08 16:33 ` Jeff King
2023-02-08 17:46 ` Junio C Hamano
2023-02-08 17:40 ` Junio C Hamano
2023-02-09 13:15 ` Jeff King
2023-02-09 19:43 ` Junio C Hamano
2023-02-11 2:41 ` Jeff King
2023-02-11 2:44 ` [PATCH 1/2] doc/ls-remote: cosmetic cleanups for examples Jeff King
2023-02-11 2:44 ` [PATCH 2/2] doc/ls-remote: clarify pattern format Jeff King
2023-02-11 2:54 ` Junio C Hamano
2023-02-11 4:52 ` Jeff King [this message]
2023-02-08 14:08 ` Unexpected (bug-like) behavior in `git ls-remote` matching Ævar Arnfjörð Bjarmason
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
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Y+cfKFz2rXLLVkjs@coredump.intra.peff.net \
--to=peff@peff.net \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=wblevins001@gmail.com \
/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.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).