aboutsummaryrefslogtreecommitdiff
path: root/git-compat-util.h
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2017-06-13 13:47:09 -0700
committerJunio C Hamano <gitster@pobox.com>2017-06-13 13:47:09 -0700
commitb9a7d55d938a81eb6268196b789d573437492100 (patch)
tree637c6e3452e5b81394faf99f0a4a24ce73c801e8 /git-compat-util.h
parent9743f18f3fef0b77b8715cba256a740a7238f761 (diff)
parente5b313442ab7c700d0851e9dbe7d2b029e3893e5 (diff)
downloadgit-b9a7d55d938a81eb6268196b789d573437492100.tar.gz
git-b9a7d55d938a81eb6268196b789d573437492100.tar.xz
Merge branch 'nd/fopen-errors'
We often try to open a file for reading whose existence is optional, and silently ignore errors from open/fopen; report such errors if they are not due to missing files. * nd/fopen-errors: mingw_fopen: report ENOENT for invalid file names mingw: verify that paths are not mistaken for remote nicknames log: fix memory leak in open_next_file() rerere.c: move error_errno() closer to the source system call print errno when reporting a system call error wrapper.c: make warn_on_inaccessible() static wrapper.c: add and use fopen_or_warn() wrapper.c: add and use warn_on_fopen_errors() config.mak.uname: set FREAD_READS_DIRECTORIES for Darwin, too config.mak.uname: set FREAD_READS_DIRECTORIES for Linux and FreeBSD clone: use xfopen() instead of fopen() use xfopen() in more places git_fopen: fix a sparse 'not declared' warning
Diffstat (limited to 'git-compat-util.h')
-rw-r--r--git-compat-util.h15
1 files changed, 9 insertions, 6 deletions
diff --git a/git-compat-util.h b/git-compat-util.h
index e83fd2eb0..51ba4e6b3 100644
--- a/git-compat-util.h
+++ b/git-compat-util.h
@@ -693,10 +693,12 @@ char *gitstrdup(const char *s);
#endif
#ifdef FREAD_READS_DIRECTORIES
-#ifdef fopen
-#undef fopen
-#endif
-#define fopen(a,b) git_fopen(a,b)
+# if !defined(SUPPRESS_FOPEN_REDEFINITION)
+# ifdef fopen
+# undef fopen
+# endif
+# define fopen(a,b) git_fopen(a,b)
+# endif
extern FILE *git_fopen(const char*, const char*);
#endif
@@ -804,6 +806,7 @@ extern int xmkstemp(char *template);
extern int xmkstemp_mode(char *template, int mode);
extern char *xgetcwd(void);
extern FILE *fopen_for_writing(const char *path);
+extern FILE *fopen_or_warn(const char *path, const char *mode);
#define ALLOC_ARRAY(x, alloc) (x) = xmalloc(st_mult(sizeof(*(x)), (alloc)))
#define REALLOC_ARRAY(x, alloc) (x) = xrealloc((x), st_mult(sizeof(*(x)), (alloc)))
@@ -1110,8 +1113,8 @@ int remove_or_warn(unsigned int mode, const char *path);
int access_or_warn(const char *path, int mode, unsigned flag);
int access_or_die(const char *path, int mode, unsigned flag);
-/* Warn on an inaccessible file that ought to be accessible */
-void warn_on_inaccessible(const char *path);
+/* Warn on an inaccessible file if errno indicates this is an error */
+int warn_on_fopen_errors(const char *path);
#ifdef GMTIME_UNRELIABLE_ERRORS
struct tm *git_gmtime(const time_t *);