summaryrefslogtreecommitdiff
path: root/path.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2013-04-02 15:09:54 -0700
committerJunio C Hamano <gitster@pobox.com>2013-04-02 15:09:54 -0700
commit76d1ab30a3ad1c3bf406efb60c55b00a566f9050 (patch)
tree9b304604709131edb97f316277c9f80dba4faa58 /path.c
parent37ba4c61d04d0782bd34971be5cc4eec10f59d36 (diff)
parent0117c2f043183fb99e9b046b0df7d64c1b296624 (diff)
downloadgit-76d1ab30a3ad1c3bf406efb60c55b00a566f9050.tar.gz
Merge branch 'tb/cygwin-shared-repository'
Cygwin port has a faster-but-lying lstat(2) emulation whose incorrectness does not matter in practice except for a few codepaths, and setting permission bits to directories is a codepath that needs to use a more correct one. * tb/cygwin-shared-repository: Make core.sharedRepository work under cygwin 1.7
Diffstat (limited to 'path.c')
-rw-r--r--path.c20
1 files changed, 17 insertions, 3 deletions
diff --git a/path.c b/path.c
index d3d3f8b8ad..2fdccc2f18 100644
--- a/path.c
+++ b/path.c
@@ -14,6 +14,22 @@
#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)
@@ -391,7 +407,6 @@ const char *enter_repo(const char *path, int strict)
int set_shared_perm(const char *path, int mode)
{
- struct stat st;
int tweak, shared, orig_mode;
if (!shared_repository) {
@@ -400,9 +415,8 @@ int set_shared_perm(const char *path, int mode)
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;