Skip to content

Commit

Permalink
cygwin: Remove the Win32 l/stat() implementation
Browse files Browse the repository at this point in the history
Commit adbc0b6 ("cygwin: Use native Win32 API for stat", 30-09-2008)
added a Win32 specific implementation of the stat functions. In order
to handle absolute paths, cygwin mount points and symbolic links, this
implementation may fall back on the standard cygwin l/stat() functions.
Also, the choice of cygwin or Win32 functions is made lazily (by the
first call(s) to l/stat) based on the state of some config variables.

Unfortunately, this "schizophrenic stat" implementation has been the
source of many problems ever since. For example, see commits 7faee6b,
7974843, 452993c, 085479e, b8a9733, 924aaf3, 05bab3e and 0117c2f.

In order to avoid further problems, such as the issue raised by the new
reference handling API, remove the Win32 l/stat() implementation.

Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Ramsay Jones authored and Junio C Hamano committed Jul 18, 2013
1 parent 001b097 commit f66450a
Show file tree
Hide file tree
Showing 9 changed files with 2 additions and 200 deletions.
11 changes: 0 additions & 11 deletions Documentation/config.txt
Original file line number Diff line number Diff line change
Expand Up @@ -213,17 +213,6 @@ The default is true, except linkgit:git-clone[1] or linkgit:git-init[1]
will probe and set core.fileMode false if appropriate when the
repository is created.

core.ignoreCygwinFSTricks::
This option is only used by Cygwin implementation of Git. If false,
the Cygwin stat() and lstat() functions are used. This may be useful
if your repository consists of a few separate directories joined in
one hierarchy using Cygwin mount. If true, Git uses native Win32 API
whenever it is possible and falls back to Cygwin functions only to
handle symbol links. The native mode is more than twice faster than
normal Cygwin l/stat() functions. True by default, unless core.filemode
is true, in which case ignoreCygwinFSTricks is ignored as Cygwin's
POSIX emulation is required to support core.filemode.

core.ignorecase::
If true, this option enables various workarounds to enable
Git to work better on filesystems that are not case sensitive,
Expand Down
1 change: 0 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -654,7 +654,6 @@ LIB_H += color.h
LIB_H += column.h
LIB_H += commit.h
LIB_H += compat/bswap.h
LIB_H += compat/cygwin.h
LIB_H += compat/mingw.h
LIB_H += compat/obstack.h
LIB_H += compat/poll/poll.h
Expand Down
157 changes: 0 additions & 157 deletions compat/cygwin.c

This file was deleted.

14 changes: 0 additions & 14 deletions compat/cygwin.h

This file was deleted.

1 change: 0 additions & 1 deletion config.mak.uname
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,6 @@ ifeq ($(uname_O),Cygwin)
# Try commenting this out if you suspect MMAP is more efficient
NO_MMAP = YesPlease
X = .exe
COMPAT_OBJS += compat/cygwin.o
UNRELIABLE_FSTAT = UnfortunatelyYes
SPARSE_FLAGS = -isystem /usr/include/w32api -Wno-one-bit-signed-bitfield
endif
Expand Down
1 change: 0 additions & 1 deletion contrib/completion/git-completion.bash
Original file line number Diff line number Diff line change
Expand Up @@ -1957,7 +1957,6 @@ _git_config ()
core.fileMode
core.fsyncobjectfiles
core.gitProxy
core.ignoreCygwinFSTricks
core.ignoreStat
core.ignorecase
core.logAllRefUpdates
Expand Down
3 changes: 0 additions & 3 deletions git-compat-util.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,6 @@
#include <poll.h>
#endif

extern int get_st_mode_bits(const char *path, int *mode);

#if defined(__MINGW32__)
/* pull in Windows compatibility stuff */
#include "compat/mingw.h"
Expand Down Expand Up @@ -171,7 +169,6 @@ typedef unsigned long uintptr_t;
#undef _XOPEN_SOURCE
#include <grp.h>
#define _XOPEN_SOURCE 600
#include "compat/cygwin.h"
#else
#undef _ALL_SOURCE /* AIX 5.3L defines a struct list with _ALL_SOURCE. */
#include <grp.h>
Expand Down
5 changes: 1 addition & 4 deletions help.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,7 @@ static int is_executable(const char *name)
!S_ISREG(st.st_mode))
return 0;

#if defined(GIT_WINDOWS_NATIVE) || defined(__CYGWIN__)
#if defined(__CYGWIN__)
if ((st.st_mode & S_IXUSR) == 0)
#endif
#if defined(GIT_WINDOWS_NATIVE)
{ /* cannot trust the executable bit, peek into the file instead */
char buf[3] = { 0 };
int n;
Expand Down
9 changes: 1 addition & 8 deletions path.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,14 @@
#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)
static 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/";

Expand Down

0 comments on commit f66450a

Please sign in to comment.