#include "strbuf.h"
#include "string-list.h"
+#ifndef get_st_mode_bits
+/*
+ * The replacement lstat(2) we use on Cygwin is incomplete and
+ * may return wrong permission bits. Most of the time we do not care,
+ * but the callsites of this wrapper do care.
+ */
+int get_st_mode_bits(const char *path, int *mode)
+{
+ struct stat st;
+ if (lstat(path, &st) < 0)
+ return -1;
+ *mode = st.st_mode;
+ return 0;
+}
+#endif
+
static char bad_path[] = "/bad-path/";
static char *get_pathname(void)
int set_shared_perm(const char *path, int mode)
{
- struct stat st;
int tweak, shared, orig_mode;
if (!shared_repository) {
return 0;
}
if (!mode) {
- if (lstat(path, &st) < 0)
+ if (get_st_mode_bits(path, &mode) < 0)
return -1;
- mode = st.st_mode;
orig_mode = mode;
} else
orig_mode = 0;