On Tue, Sep 04, 2018 at 02:27:20PM -0700, Pratik Karki via GitGitGadget wrote:
> From: Pratik Karki <predatoram...@gmail.com>
> 
> When running a rebase on a detached HEAD, we currently store the string
> "detached HEAD" in options.head_name. That is a faithful translation of
> the shell script version, and we still kind of need it for the purposes of
> the scripted backends.
> 
> It is poor style for C, though, where we would really only want a valid,
> fully-qualified ref name as value, and NULL for detached HEADs, using
> "detached HEAD" for display only. Make it so.
> 
> Signed-off-by: Pratik Karki <predatoram...@gmail.com>
> Signed-off-by: Johannes Schindelin <johannes.schinde...@gmx.de>
> ---
>  builtin/rebase.c | 11 ++++++++---
>  1 file changed, 8 insertions(+), 3 deletions(-)
> 
> diff --git a/builtin/rebase.c b/builtin/rebase.c
> index d45f8f9008..afc75fe731 100644
> --- a/builtin/rebase.c
> +++ b/builtin/rebase.c

> @@ -575,7 +579,8 @@ int cmd_rebase(int argc, const char **argv, const char 
> *prefix)
>                               branch_name = options.head_name;
>  
>               } else {
> -                     options.head_name = xstrdup("detached HEAD");
> +                     free(options.head_name);
> +                     options.head_name = NULL;

Please use FREE_AND_NULL(options.head_name) here.

>                       branch_name = "HEAD";
>               }
>               if (get_oid("HEAD", &options.orig_head))
> -- 
> gitgitgadget
> 

Reply via email to