git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Michael Haggerty <mhagger@alum.mit.edu>
To: Ian Jackson <ijackson@chiark.greenend.org.uk>, git@vger.kernel.org
Subject: Re: [PATCH 1/5] check-ref-format: Refactor out check_one_ref_format
Date: Mon, 19 Dec 2016 09:27:41 +0100	[thread overview]
Message-ID: <3e277bb8-bd1f-0d8c-47a7-9673ad711bce@alum.mit.edu> (raw)
In-Reply-To: <20161104191358.28812-2-ijackson@chiark.greenend.org.uk>

On 11/04/2016 08:13 PM, Ian Jackson wrote:
> We are going to want to reuse this.  No functional change right now.
> 
> It currently has a hidden memory leak if --normalize is used.
> 
> Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
> ---
>  builtin/check-ref-format.c | 26 ++++++++++++++------------
>  1 file changed, 14 insertions(+), 12 deletions(-)
> 
> diff --git a/builtin/check-ref-format.c b/builtin/check-ref-format.c
> index eac4994..4d56caa 100644
> --- a/builtin/check-ref-format.c
> +++ b/builtin/check-ref-format.c
> @@ -48,12 +48,22 @@ static int check_ref_format_branch(const char *arg)
>  	return 0;
>  }
>  
> +static int normalize = 0;
> +static int flags = 0;
> +
> +static int check_one_ref_format(const char *refname)
> +{
> +	if (normalize)
> +		refname = collapse_slashes(refname);
> +	if (check_refname_format(refname, flags))
> +		return 1;
> +	if (normalize)
> +		printf("%s\n", refname);

This function needs to `return 0` if it gets to the end.

> +}
> +
>  int cmd_check_ref_format(int argc, const char **argv, const char *prefix)
>  {
>  	int i;
> -	int normalize = 0;
> -	int flags = 0;
> -	const char *refname;
>  
>  	if (argc == 2 && !strcmp(argv[1], "-h"))
>  		usage(builtin_check_ref_format_usage);
> @@ -76,13 +86,5 @@ int cmd_check_ref_format(int argc, const char **argv, const char *prefix)
>  	if (! (i == argc - 1))
>  		usage(builtin_check_ref_format_usage);
>  
> -	refname = argv[i];
> -	if (normalize)
> -		refname = collapse_slashes(refname);
> -	if (check_refname_format(refname, flags))
> -		return 1;
> -	if (normalize)
> -		printf("%s\n", refname);
> -
> -	return 0;
> +	return check_one_ref_format(argv[i]);
>  }
> 

Michael


  reply	other threads:[~2016-12-19  8:36 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-04 19:13 [PATCH 0/5] git check-ref-format --stdin --report-errors Ian Jackson
2016-11-04 19:13 ` [PATCH 1/5] check-ref-format: Refactor out check_one_ref_format Ian Jackson
2016-12-19  8:27   ` Michael Haggerty [this message]
2016-12-19 13:19     ` Ian Jackson
2016-12-20  6:57       ` Michael Haggerty
2016-11-04 19:13 ` [PATCH 2/5] check-ref-format: Refactor to make --branch code more common Ian Jackson
2016-12-19 11:07   ` Michael Haggerty
2016-12-19 11:54     ` Ian Jackson
2016-11-04 19:13 ` [PATCH 3/5] check-ref-format: Abolish leak of collapsed refname Ian Jackson
2016-12-19 11:09   ` Michael Haggerty
2016-11-04 19:13 ` [PATCH 4/5] check-ref-format: New --report-errors option Ian Jackson
2016-11-04 19:13 ` [PATCH 5/5] check-ref-format: New --stdin option Ian Jackson
2016-12-19 11:22   ` Michael Haggerty
2016-12-19 13:43   ` Michael Haggerty
2016-12-19 11:29 ` [PATCH 0/5] git check-ref-format --stdin --report-errors Michael Haggerty
2016-12-19 16:22   ` Ian Jackson
2016-12-19 18:23   ` Junio C Hamano
2016-12-20  7:29     ` Michael Haggerty

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=3e277bb8-bd1f-0d8c-47a7-9673ad711bce@alum.mit.edu \
    --to=mhagger@alum.mit.edu \
    --cc=git@vger.kernel.org \
    --cc=ijackson@chiark.greenend.org.uk \
    /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 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 NNTP newsgroup(s).