Re: [PATCH] opening files in remote.c should ensure it is opening a file
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Feb 8, 2008, 20:09 UTC
- Message-ID
- <7vhcgjjjlh.fsf@gitster.siamese.dyndns.org>
- In-Reply-To
- <20080208174654.2e9e679c@pc09.procura.nl>
"H.Merijn Brand" <h.m.brand@xs4all.nl> writes:
> HP-UX allows directories to be opened with fopen (path, "r"), which > will cause some translations that expect to read files, read dirs > instead. This patch makes sure the two fopen () calls in remote.c > only open the file if it is a file.
Show 7 quoted lines
> +static FILE *open_file(char *full_path)
> +{
> + struct stat st_buf;
> + if (stat(full_path, &st_buf) || !S_ISREG(st_buf.st_mode))
> + return NULL;
> + return (fopen(full_path, "r"));
> +}Can we make this a platform specific "compat" hack?
It is not fair to force stat() overhead to ports on platforms that fails fopen() on directories, as I doubt we would ever want from directory using fopen() anyway.