Re: [PATCH v2 10/26] wrapper.c: allow to create an empty file with write_file()
- From
Duy Nguyen <pclouds@gmail.com>
- Date
- Feb 18, 2016, 00:49 UTC
- Message-ID
- <CACsJy8AQKfJoq6qcOoiay79zGKn1F3s=fnsdbBxbHyJRir-LfQ@mail.gmail.com>
- In-Reply-To
- <xmqqpovvgeca.fsf@gitster.mtv.corp.google.com>
On Thu, Feb 18, 2016 at 5:29 AM, Junio C Hamano <gitster@pobox.com> wrote:
Show 24 quoted lines
> Nguyễn Thái Ngọc Duy <pclouds@gmail.com> writes:
>
>> This is used later on to create empty .git/worktrees/xxx/locked when
>> "git worktree lock" is called with no reason given.
>>
>> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
>> ---
>> wrapper.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/wrapper.c b/wrapper.c
>> index 29a45d2..1dc1eff 100644
>> --- a/wrapper.c
>> +++ b/wrapper.c
>> @@ -666,7 +666,7 @@ static int write_file_v(const char *path, int fatal,
>> }
>> strbuf_vaddf(&sb, fmt, params);
>> strbuf_complete_line(&sb);
>> - if (write_in_full(fd, sb.buf, sb.len) != sb.len) {
>> + if (sb.len && write_in_full(fd, sb.buf, sb.len) != sb.len) {
>
> I do not quite see how this change relates to what the log message
> claims this commit does. write_in_full() returns 0 when called with
> count==0 just fine, no?You're right. Somehow I got the impression that xwrite() was called, but it's not in this case.
-- Duy