Subject: Re: [PATCH 2/4] request-pull: stop depending on Perl

From: Patrick Steinhardt <[email-masked]>
Date: Wed, 16 Apr 2025 17:07:59 +0200

On Tue, Apr 15, 2025 at 09:16:05AM -0700, Junio C Hamano wrote:
> Patrick Steinhardt <[email-masked]> writes:
> > diff --git a/git-request-pull.sh b/git-request-pull.sh
> > index 775ba8ea11a..59276fe265b 100755
> > --- a/git-request-pull.sh
> > +++ b/git-request-pull.sh
> > @@ -78,41 +78,47 @@ fi
> >  merge_base=$(git merge-base $baserev $headrev) ||
> >  die "fatal: No commits in common between $base and $head"
> >  
> > -# $head is the refname from the command line.
> > -# Find a ref with the same name as $head that exists at the remote
> > +find_matching_ref () {
> > +	while read sha1 ref
> > +	do
> > +		case "$ref" in
> > +		*"^{}")
> > +			ref="${ref%"^{}"}"
> > +			deref=true
> 
> This got a bit tighter (the original allowed ls-remote output to be
> later extended to throw "^something-else" at the end of line), which
> I do not know is something we need to worry about.  I think retaining
> the original semantics is easy in this case, e.g.,
> 
> 		*"^"?*)
> 			ref="${ref%"^*"}"

This should probably read `ref="${ref%"^"*}"`, with the `*` outside of
the quotes.

> or something, if we wanted to.  As this is meant to be faithful
> rewrite to lose Perl, not a bugfix to correct overly loose pattern
> matching in the original, I think we want to in this case.

Fair enough. It should've been at least mentioned in the commit message,
but let's instead just retain the current behaviour as suggested.

Patrick