Re: [PATCH v5 19/27] sequencer: stop releasing the strbuf in write_message()

2016-10-21 Thread Junio C Hamano
Johannes Schindelin  writes:

> Nothing in the name "write_message()" suggests that the function
> releases the strbuf passed to it. So let's release the strbuf in the
> caller instead.
>
> Signed-off-by: Johannes Schindelin 
> ---

I agree that it makes quite a lot of sense from the point of view of
"taste in the API design".

>  sequencer.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/sequencer.c b/sequencer.c
> index d74fdce..745c86f 100644
> --- a/sequencer.c
> +++ b/sequencer.c
> @@ -243,7 +243,6 @@ static int write_message(struct strbuf *msgbuf, const 
> char *filename)
>   return error_errno(_("Could not lock '%s'"), filename);
>   if (write_in_full(msg_fd, msgbuf->buf, msgbuf->len) < 0)
>   return error_errno(_("Could not write to %s"), filename);
> - strbuf_release(msgbuf);
>   if (commit_lock_file(_file) < 0)
>   return error(_("Error wrapping up %s."), filename);
>  
> @@ -759,6 +758,7 @@ static int do_pick_commit(enum todo_command command, 
> struct commit *commit,
>   free_commit_list(common);
>   free_commit_list(remotes);
>   }
> + strbuf_release();
>  
>   /*
>* If the merge was clean or if it failed due to conflict, we write


[PATCH v5 19/27] sequencer: stop releasing the strbuf in write_message()

2016-10-21 Thread Johannes Schindelin
Nothing in the name "write_message()" suggests that the function
releases the strbuf passed to it. So let's release the strbuf in the
caller instead.

Signed-off-by: Johannes Schindelin 
---
 sequencer.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sequencer.c b/sequencer.c
index d74fdce..745c86f 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -243,7 +243,6 @@ static int write_message(struct strbuf *msgbuf, const char 
*filename)
return error_errno(_("Could not lock '%s'"), filename);
if (write_in_full(msg_fd, msgbuf->buf, msgbuf->len) < 0)
return error_errno(_("Could not write to %s"), filename);
-   strbuf_release(msgbuf);
if (commit_lock_file(_file) < 0)
return error(_("Error wrapping up %s."), filename);
 
@@ -759,6 +758,7 @@ static int do_pick_commit(enum todo_command command, struct 
commit *commit,
free_commit_list(common);
free_commit_list(remotes);
}
+   strbuf_release();
 
/*
 * If the merge was clean or if it failed due to conflict, we write
-- 
2.10.1.583.g721a9e0