Subject: Re: [PATCH v7 5/8] refs: new public ref function: safe_create_reflog

From: Michael Haggerty <[email-masked]>
Date: Wed, 08 Jul 2015 13:49:57 +0200

On 07/08/2015 02:56 AM, David Turner wrote:
> The safe_create_reflog function creates a reflog, if it does not
> already exist.
> 
> The log_ref_setup function becomes private and gains a force_create
> parameter to force the creation of a reflog even if log_all_ref_updates
> is false or the refname is not one of the special refnames.
> 
> The new parameter also reduces the need to store, modify, and restore
> the log_all_ref_updates global before reflog creation.
> 
> In a moment, we will use this to add reflog creation commands to
> git-reflog.
> 
> Signed-off-by: David Turner <[email-masked]>
> ---
>  builtin/checkout.c | 16 +++++-----------
>  refs.c             | 25 +++++++++++++++++++++----
>  refs.h             |  2 +-
>  3 files changed, 27 insertions(+), 16 deletions(-)
> 
> [...]
> diff --git a/refs.c b/refs.c
> index e694359..01b0af5 100644
> --- a/refs.c
> +++ b/refs.c
> @@ -3128,8 +3128,14 @@ static int should_autocreate_reflog(const char *refname)
>  		!strcmp(refname, "HEAD");
>  }
>  
> -/* This function will fill in *err and return -1 on failure */
> -int log_ref_setup(const char *refname, struct strbuf *sb_logfile, struct strbuf *err)
> +/*
> + * Create a reflog for a ref.  If force_create = 0, the reflog will
> + * only be created for certain refs (those for which
> + * should_autocreate_reflog returns non-zero.  Otherwise, it will be
> + * created regardless of the ref name.  This function will fill in
> + * *err and return -1 on failure
> + */
> +static int log_ref_setup(const char *refname, struct strbuf *sb_logfile, struct strbuf *err, int force_create)
>  {
>  	int logfd, oflags = O_APPEND | O_WRONLY;
>  	char *logfile;

Sorry for being unclear in the last round. I meant that the whole
docstring should be in the imperative voice, like

/*
 * Create a reflog for a ref. If force_create = 0, only create the
 * reflog for certain refs (those for which should_autocreate_reflog
 * returns non-zero). Otherwise, create it regardless of the reference
 * name. Fill in *err and return -1 on failure.
 */

Otherwise, this patch looks good.

Michael

-- 
Michael Haggerty
[email-masked]