File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ #define CYGWIN_C
12#define WIN32_LEAN_AND_MEAN
23#ifdef CYGWIN_V15_WIN32API
34#include "../git-compat-util.h"
1011#endif
1112#include "../cache.h" /* to read configuration */
1213
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+
1326static inline void filetime_to_timespec (const FILETIME * ft , struct timespec * ts )
1427{
1528 long long winTime = ((long long )ft -> dwHighDateTime << 32 ) +
Original file line number Diff line number Diff line change 44typedef int (* stat_fn_t )(const char * , struct stat * );
55extern stat_fn_t cygwin_stat_fn ;
66extern stat_fn_t cygwin_lstat_fn ;
7+ int cygwin_get_st_mode_bits (const char * path , int * mode );
78
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() */
812#define stat (path , buf ) (*cygwin_stat_fn)(path, buf)
913#define lstat (path , buf ) (*cygwin_lstat_fn)(path, buf)
14+ #endif
Original file line number Diff line number Diff line change 163163typedef long intptr_t ;
164164typedef unsigned long uintptr_t ;
165165#endif
166+ int get_st_mode_bits (const char * path , int * mode );
166167#if defined(__CYGWIN__ )
167168#undef _XOPEN_SOURCE
168169#include <grp.h>
Original file line number Diff line number Diff line change 1414#include "strbuf.h"
1515#include "string-list.h"
1616
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+
1733static char bad_path [] = "/bad-path/" ;
1834
1935static char * get_pathname (void )
@@ -391,7 +407,6 @@ const char *enter_repo(const char *path, int strict)
391407
392408int set_shared_perm (const char * path , int mode )
393409{
394- struct stat st ;
395410 int tweak , shared , orig_mode ;
396411
397412 if (!shared_repository ) {
@@ -400,9 +415,8 @@ int set_shared_perm(const char *path, int mode)
400415 return 0 ;
401416 }
402417 if (!mode ) {
403- if (lstat (path , & st ) < 0 )
418+ if (get_st_mode_bits (path , & mode ) < 0 )
404419 return -1 ;
405- mode = st .st_mode ;
406420 orig_mode = mode ;
407421 } else
408422 orig_mode = 0 ;
You can’t perform that action at this time.
0 commit comments