git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v3] refs: loosen restrictions on wildcard '*' refspecs

From
David Turner <dturner@twopensource.com>
Date
Jul 22, 2015, 18:21 UTC
Message-ID
<1437589261.4520.2.camel@twopensource.com>
In-Reply-To
<1437581180-26883-1-git-send-email-jacob.e.keller@intel.com>
On Wed, 2015-07-22 at 09:06 -0700, Jacob Keller wrote:
Show 58 quoted lines
> From: Jacob Keller <jacob.keller@gmail.com>
> 
> Update the check_refname_component logic in order to allow for a less
> strict refspec format in regards to REFNAME_REFSPEC_PATTERN. Previously
> the '*' could only replace a single full component, and could not
> replace arbitrary text. Now, refs such as `foo/bar*:foo/bar*` will be
> accepted. This allows for somewhat more flexibility in references and
> does not break any current users. The ref matching code already allows
> this but the check_refname_format did not. Note this does also allow
> refs such as `foo/bar*:foe/baz*`, that is, arbitrary renames. This was
> already possible with namespace sections before, but now is possible
> even as part of the pattern section. Since users have to explicitly type
> these into the configuration it does not seem an issue.
> 
> Also streamline the code by making this new check part of
> check_refname_component instead of checking after we error during
> check_refname_format, which fits better with how other issues in refname
> components are checked.
> 
> Signed-off-by: Jacob Keller <jacob.keller@gmail.com>
> Cc: Daniel Barkalow <barkalow@iabervon.iabervon.org>
> Cc: Junio C Hamano <gitster@pobox.com>
> ---
> 
> I updated the patch description a bit. This is also re-based onto the
> next/ branch in-case. This is mostly a resend so that anyone interested
> in review has another chance to see the patch.
> 
>  Documentation/git-check-ref-format.txt |  4 ++--
>  refs.c                                 | 39 +++++++++++++++++++---------------
>  refs.h                                 |  4 ++--
>  t/t1402-check-ref-format.sh            |  8 ++++---
>  4 files changed, 31 insertions(+), 24 deletions(-)
> 
> diff --git a/Documentation/git-check-ref-format.txt b/Documentation/git-check-ref-format.txt
> index fc02959ba4ab..9044dfaadae1 100644
> --- a/Documentation/git-check-ref-format.txt
> +++ b/Documentation/git-check-ref-format.txt
> @@ -94,8 +94,8 @@ OPTIONS
>  	Interpret <refname> as a reference name pattern for a refspec
>  	(as used with remote repositories).  If this option is
>  	enabled, <refname> is allowed to contain a single `*`
> -	in place of a one full pathname component (e.g.,
> -	`foo/*/bar` but not `foo/bar*`).
> +	in the refspec (e.g., `foo/bar*/baz` or `foo/bar*baz/`
> +	but not `foo/bar*/baz*`).
>  
>  --normalize::
>  	Normalize 'refname' by removing any leading slash (`/`)
> diff --git a/refs.c b/refs.c
> index ce8cd8d45001..3002015ff289 100644
> --- a/refs.c
> +++ b/refs.c
> @@ -20,11 +20,12 @@ struct ref_lock {
>   * 2: ., look for a preceding . to reject .. in refs
>   * 3: {, look for a preceding @ to reject @{ in refs
>   * 4: A bad character: ASCII control characters, "~", "^", ":" or SP
> + * 5: check for patterns to reject unless REFNAME_REFSPEC_PATTERN is set
How about this:
+ 5: *, reject unless REFNAME_REFSPEC_PATTERN is set

(I guess it's possible that we would later allow other pattern chars, but we could change the message then).

Previous: Jacob KellerNext: Jacob Keller
Message 2 of 3 in “refs: loosen restrictions on wildcard '*' refspecs”
  1. refs: loosen restrictions on wildcard '*' refspecsJacob Keller, Jul 22, 2015
  2. David TurnerJul 22, 2015
  3. Jacob KellerJul 22, 2015

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.