Re: [PATCH v2 3/6] wrapper: move is_empty_file() from builtin/am.c
- From
Pranit Bauva <pranit.bauva@gmail.com>
- Date
- Jun 15, 2016, 18:15 UTC
- Message-ID
- <CAFZEwPOH_mkESin+Ykx4yXqS6oo2yAy0WzqvUgTh_eZ3HwXZXQ@mail.gmail.com>
- In-Reply-To
- <xmqqh9cu724n.fsf@gitster.mtv.corp.google.com>
Hey Junio,
On Wed, Jun 15, 2016 at 11:42 PM, Junio C Hamano <gitster@pobox.com> wrote:
Show 35 quoted lines
> Pranit Bauva <pranit.bauva@gmail.com> writes:
>
>> diff --git a/builtin/am.c b/builtin/am.c
>> index 3dfe70b..84f21d0 100644
>> --- a/builtin/am.c
>> +++ b/builtin/am.c
>> @@ -30,22 +30,6 @@
>> #include "mailinfo.h"
>>
>> /**
>> - * Returns 1 if the file is empty or does not exist, 0 otherwise.
>> - */
>> -static int is_empty_file(const char *filename)
>> -{
>> - struct stat st;
>> -
>> - if (stat(filename, &st) < 0) {
>> - if (errno == ENOENT)
>> - return 1;
>> - die_errno(_("could not stat %s"), filename);
>> - }
>> -
>> - return !st.st_size;
>> -}
>> -
>
> This is perfectly fine in the context of "git am", but as a public
> function that is called is_empty_file(), callers can come from two
> camps. One is like the caller of this function in "am" where an
> empty and a missing file are treated equivalently. The other would
> want to act differently.
>
> Renaming it "is-empty-or-missing" is necessary in order to make it
> clear that this helper function is not targetted for the latter
> callers.Yes, its better to rename the function as is_empty_or_missing() . Thanks!
Regards, Pranit Bauva