Re: [PATCH v2 3/6] wrapper: move is_empty_file() from builtin/am.c
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Jun 15, 2016, 18:12 UTC
- Message-ID
- <xmqqh9cu724n.fsf@gitster.mtv.corp.google.com>
- In-Reply-To
- <20160615140026.10519-4-pranit.bauva@gmail.com>
Pranit Bauva <pranit.bauva@gmail.com> writes:
Show 23 quoted lines
> 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.