File tree Expand file tree Collapse file tree 4 files changed +36
-3
lines changed Expand file tree Collapse file tree 4 files changed +36
-3
lines changed Original file line number Diff line number Diff line change
1
+ #define CYGWIN_C
1
2
#define WIN32_LEAN_AND_MEAN
2
3
#ifdef CYGWIN_V15_WIN32API
3
4
#include "../git-compat-util.h"
10
11
#endif
11
12
#include "../cache.h" /* to read configuration */
12
13
14
+ /*
15
+ * Return POSIX permission bits, regardless of core.ignorecygwinfstricks
16
+ */
17
+ int cygwin_get_st_mode_bits (const char * path , int * mode )
18
+ {
19
+ struct stat st ;
20
+ if (lstat (path , & st ) < 0 )
21
+ return -1 ;
22
+ * mode = st .st_mode ;
23
+ return 0 ;
24
+ }
25
+
13
26
static inline void filetime_to_timespec (const FILETIME * ft , struct timespec * ts )
14
27
{
15
28
long long winTime = ((long long )ft -> dwHighDateTime << 32 ) +
Original file line number Diff line number Diff line change 4
4
typedef int (* stat_fn_t )(const char * , struct stat * );
5
5
extern stat_fn_t cygwin_stat_fn ;
6
6
extern stat_fn_t cygwin_lstat_fn ;
7
+ int cygwin_get_st_mode_bits (const char * path , int * mode );
7
8
9
+ #define get_st_mode_bits (p ,m ) cygwin_get_st_mode_bits((p),(m))
10
+ #ifndef CYGWIN_C
11
+ /* cygwin.c needs the original lstat() */
8
12
#define stat (path , buf ) (*cygwin_stat_fn)(path, buf)
9
13
#define lstat (path , buf ) (*cygwin_lstat_fn)(path, buf)
14
+ #endif
Original file line number Diff line number Diff line change 163
163
typedef long intptr_t ;
164
164
typedef unsigned long uintptr_t ;
165
165
#endif
166
+ int get_st_mode_bits (const char * path , int * mode );
166
167
#if defined(__CYGWIN__ )
167
168
#undef _XOPEN_SOURCE
168
169
#include <grp.h>
Original file line number Diff line number Diff line change 14
14
#include "strbuf.h"
15
15
#include "string-list.h"
16
16
17
+ #ifndef get_st_mode_bits
18
+ /*
19
+ * The replacement lstat(2) we use on Cygwin is incomplete and
20
+ * may return wrong permission bits. Most of the time we do not care,
21
+ * but the callsites of this wrapper do care.
22
+ */
23
+ int get_st_mode_bits (const char * path , int * mode )
24
+ {
25
+ struct stat st ;
26
+ if (lstat (path , & st ) < 0 )
27
+ return -1 ;
28
+ * mode = st .st_mode ;
29
+ return 0 ;
30
+ }
31
+ #endif
32
+
17
33
static char bad_path [] = "/bad-path/" ;
18
34
19
35
static char * get_pathname (void )
@@ -391,7 +407,6 @@ const char *enter_repo(const char *path, int strict)
391
407
392
408
int set_shared_perm (const char * path , int mode )
393
409
{
394
- struct stat st ;
395
410
int tweak , shared , orig_mode ;
396
411
397
412
if (!shared_repository ) {
@@ -400,9 +415,8 @@ int set_shared_perm(const char *path, int mode)
400
415
return 0 ;
401
416
}
402
417
if (!mode ) {
403
- if (lstat (path , & st ) < 0 )
418
+ if (get_st_mode_bits (path , & mode ) < 0 )
404
419
return -1 ;
405
- mode = st .st_mode ;
406
420
orig_mode = mode ;
407
421
} else
408
422
orig_mode = 0 ;
You can’t perform that action at this time.
0 commit comments