# [PATCH] fix revisions doc about quoting for ':/' notation

5 messages from 2017-08-16 to 2017-08-17. Participants: ryenus, Junio C Hamano, Andreas Heiduk.
Thread: https://gitlist.dev/t/46601

## ryenus, 2017-08-16 03:21

Subject: [PATCH] fix revisions doc about quoting for ':/' notation
Message-ID: <CAKkAvazj28RR1nHEWNNeZeyE6mpkb3opk6kvrxP6Lau6tcCbJQ@mail.gmail.com>
URL: https://gitlist.dev/e/CAKkAvazj28RR1nHEWNNeZeyE6mpkb3opk6kvrxP6Lau6tcCbJQ%40mail.gmail.com

```
To make sure the `<text>` in `:/<text>` is seen as one search string,
one should quote/escape `<text>` properly.

Especially, the example given in the manual `:/fix nasty bug` does not
work because of missing quotes. The examples are now corrected, and a
note about quoting/escaping is added as well.
---
 Documentation/revisions.txt | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/Documentation/revisions.txt b/Documentation/revisions.txt
index 61277469c..fdfdde0ad 100644
--- a/Documentation/revisions.txt
+++ b/Documentation/revisions.txt
@@ -169,14 +169,14 @@ existing tag object.
   and dereference the tag recursively until a non-tag object is
   found.

-'<rev>{caret}{/<text>}', e.g. 'HEAD^{/fix nasty bug}'::
+'<rev>{caret}{/<text>}', e.g. 'HEAD^{/"fix nasty bug"}'::
   A suffix '{caret}' to a revision parameter, followed by a brace
   pair that contains a text led by a slash,
   is the same as the ':/fix nasty bug' syntax below except that
   it returns the youngest matching commit which is reachable from
   the '<rev>' before '{caret}'.

-':/<text>', e.g. ':/fix nasty bug'::
+':/<text>', e.g. ':/"fix nasty bug"'::
   A colon, followed by a slash, followed by a text, names
   a commit whose commit message matches the specified regular expression.
   This name returns the youngest matching commit which is
@@ -185,7 +185,8 @@ existing tag object.
   e.g. ':/^foo'. The special sequence ':/!' is reserved for modifiers to what
   is matched. ':/!-foo' performs a negative match, while ':/!!foo' matches a
   literal '!' character, followed by 'foo'. Any other sequence beginning with
-  ':/!' is reserved for now.
+  ':/!' is reserved for now. And make sure to quote/escape for the text to be
+  seen as one search string.

 '<rev>:<path>', e.g. 'HEAD:README', ':README', 'master:./README'::
   A suffix ':' followed by a path names the blob or tree
--
2.14.1

```

## Junio C Hamano, 2017-08-16 18:49

Subject: Re: [PATCH] fix revisions doc about quoting for ':/' notation
Message-ID: <xmqq7ey3l551.fsf@gitster.mtv.corp.google.com>
URL: https://gitlist.dev/e/xmqq7ey3l551.fsf%40gitster.mtv.corp.google.com
In-Reply-To: <CAKkAvazj28RR1nHEWNNeZeyE6mpkb3opk6kvrxP6Lau6tcCbJQ@mail.gmail.com>

```
ryenus <ryenus@gmail.com> writes:

> To make sure the `<text>` in `:/<text>` is seen as one search string,
> one should quote/escape `<text>` properly.
>
> Especially, the example given in the manual `:/fix nasty bug` does not
> work because of missing quotes. The examples are now corrected, and a
> note about quoting/escaping is added as well.
> ---
>  Documentation/revisions.txt | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/Documentation/revisions.txt b/Documentation/revisions.txt
> index 61277469c..fdfdde0ad 100644
> --- a/Documentation/revisions.txt
> +++ b/Documentation/revisions.txt
> @@ -169,14 +169,14 @@ existing tag object.
>    and dereference the tag recursively until a non-tag object is
>    found.
>
> -'<rev>{caret}{/<text>}', e.g. 'HEAD^{/fix nasty bug}'::
> +'<rev>{caret}{/<text>}', e.g. 'HEAD^{/"fix nasty bug"}'::

This made me scratch my head, as I rarely read the formatted result
but look at the documentation in the source form.  The original
meant to quote the whole thing inside a single quote, but AsciiDoc
of course will strip that and instead makes the whole thing typeset
in monospace.

What you did is not wrong per-se, but I think quoting the whole
thing, instead of quoting just what is inside the braces, i.e.
'"HEAD^{/fix nasty bug}"' (or if you can manage it, using single
quote instead of double quote) would read better.

>    A suffix '{caret}' to a revision parameter, followed by a brace
>    pair that contains a text led by a slash,
>    is the same as the ':/fix nasty bug' syntax below except that
>    it returns the youngest matching commit which is reachable from
>    the '<rev>' before '{caret}'.
>
> -':/<text>', e.g. ':/fix nasty bug'::
> +':/<text>', e.g. ':/"fix nasty bug"'::

Likewise.

> @@ -185,7 +185,8 @@ existing tag object.
>    e.g. ':/^foo'. The special sequence ':/!' is reserved for modifiers to what
>    is matched. ':/!-foo' performs a negative match, while ':/!!foo' matches a
>    literal '!' character, followed by 'foo'. Any other sequence beginning with
> -  ':/!' is reserved for now.
> +  ':/!' is reserved for now. And make sure to quote/escape for the text to be
> +  seen as one search string.

Good.

Please sign-off your work (cf. Documentation/SubmittingPatches).

Thanks.

```

## Andreas Heiduk, 2017-08-16 21:15

Subject: Re: [PATCH] fix revisions doc about quoting for ':/' notation
Message-ID: <956ccc83-c291-4217-795c-fcef33fac35b@gmail.com>
URL: https://gitlist.dev/e/956ccc83-c291-4217-795c-fcef33fac35b%40gmail.com
In-Reply-To: <CAKkAvazj28RR1nHEWNNeZeyE6mpkb3opk6kvrxP6Lau6tcCbJQ@mail.gmail.com>

```
Am 16.08.2017 um 05:21 schrieb ryenus:
> To make sure the `<text>` in `:/<text>` is seen as one search string,
> one should quote/escape `<text>` properly.
> 
> Especially, the example given in the manual `:/fix nasty bug` does not
> work because of missing quotes. The examples are now corrected, and a
> note about quoting/escaping is added as well.

Right now the documentation describes the syntax as git sees the
parameters. This is agnostic of the shell or other UI with their
different quoting rules.  For example users of fish must quote
`rev@{2}`. A GUI might require no quoting at all. In that case `:/"fix
nasty bugs"` would be given to git verbatim and hence not find the revision.

Also: Other examples like `HEAD@{5 minutes ago}` need the same quoting.

So my suggestion is to not use quoting in the examples and provide only
a hint in the text. Example:

 <rev>{caret}{/<text>}', e.g. 'HEAD^{/fix nasty bug}'::
    A suffix '{caret}' to a revision parameter, followed by a brace
    pair that contains a text led by a slash,
    is the same as the ':/fix nasty bug' syntax below except that
    it returns the youngest matching commit which is reachable from
    the '<rev>' before '{caret}'.
+   Depending on the given text the shell's word splitting rules
+   might require additional quoting.

```

## Junio C Hamano, 2017-08-16 21:57

Subject: Re: [PATCH] fix revisions doc about quoting for ':/' notation
Message-ID: <xmqqo9rfi3b2.fsf@gitster.mtv.corp.google.com>
URL: https://gitlist.dev/e/xmqqo9rfi3b2.fsf%40gitster.mtv.corp.google.com
In-Reply-To: <956ccc83-c291-4217-795c-fcef33fac35b@gmail.com>

```
Andreas Heiduk <asheiduk@gmail.com> writes:

> Am 16.08.2017 um 05:21 schrieb ryenus:
>> To make sure the `<text>` in `:/<text>` is seen as one search string,
>> one should quote/escape `<text>` properly.
>> 
>> Especially, the example given in the manual `:/fix nasty bug` does not
>> work because of missing quotes. The examples are now corrected, and a
>> note about quoting/escaping is added as well.
>
> Right now the documentation describes the syntax as git sees the
> parameters. This is agnostic of the shell or other UI with their
> different quoting rules.  For example users of fish must quote
> `rev@{2}`. A GUI might require no quoting at all. In that case `:/"fix
> nasty bugs"` would be given to git verbatim and hence not find the revision.

These are all good points that I didn't consider when responding.

> Also: Other examples like `HEAD@{5 minutes ago}` need the same quoting.
>
> So my suggestion is to not use quoting in the examples and provide only
> a hint in the text. Example:
>
>  <rev>{caret}{/<text>}', e.g. 'HEAD^{/fix nasty bug}'::
>     A suffix '{caret}' to a revision parameter, followed by a brace
>     pair that contains a text led by a slash,
>     is the same as the ':/fix nasty bug' syntax below except that
>     it returns the youngest matching commit which is reachable from
>     the '<rev>' before '{caret}'.
> +   Depending on the given text the shell's word splitting rules
> +   might require additional quoting.

That sounds like a very safe change to adopt, regardless of what we
decide to do to the other part of the proposed change.

Thanks.

```

## ryenus, 2017-08-17 07:01

Subject: Re: [PATCH] fix revisions doc about quoting for ':/' notation
Message-ID: <CAKkAvay1gJTLJrGLb3aFMJmnyQjPhSD9cx0DRAAN3Mh5NAhfiQ@mail.gmail.com>
URL: https://gitlist.dev/e/CAKkAvay1gJTLJrGLb3aFMJmnyQjPhSD9cx0DRAAN3Mh5NAhfiQ%40mail.gmail.com
In-Reply-To: <xmqqo9rfi3b2.fsf@gitster.mtv.corp.google.com>

```
On 17 August 2017 at 05:57, Junio C Hamano <gitster@pobox.com> wrote:
> Andreas Heiduk <asheiduk@gmail.com> writes:
>
>> Am 16.08.2017 um 05:21 schrieb ryenus:
>>> To make sure the `<text>` in `:/<text>` is seen as one search string,
>>> one should quote/escape `<text>` properly.
>>>
>>> Especially, the example given in the manual `:/fix nasty bug` does not
>>> work because of missing quotes. The examples are now corrected, and a
>>> note about quoting/escaping is added as well.
>>
>> Right now the documentation describes the syntax as git sees the
>> parameters. This is agnostic of the shell or other UI with their
>> different quoting rules.  For example users of fish must quote
>> `rev@{2}`. A GUI might require no quoting at all. In that case `:/"fix
>> nasty bugs"` would be given to git verbatim and hence not find the revision.
>
> These are all good points that I didn't consider when responding.
>

Makes sense for me, too. I've just sent a v2 patch, which leaves the original
example as-is, meanwhile added a example inside the explanation.

Thanks!

```
