Commit Graph

45197 Commits

Author SHA1 Message Date
Karsten Blees
c4e60f1fb7 Win32 dirent: improve dirent implementation
Improve the dirent implementation by removing the relics that were once
necessary to plug into the now unused MinGW runtime, in preparation for
Unicode file name support.

Move FindFirstFile to opendir, and FindClose to closedir, with the
following implications:
- DIR.dd_name is no longer needed
- chdir(one); opendir(relative); chdir(two); readdir() works as expected
  (i.e. lists one/relative instead of two/relative)
- DIR.dd_handle is a valid handle for the entire lifetime of the DIR struct
- thus, all checks for dd_handle == INVALID_HANDLE_VALUE and dd_handle == 0
  have been removed
- the special case that the directory has been fully read (which was
  previously explicitly tracked with dd_handle == INVALID_HANDLE_VALUE &&
  dd_stat != 0) is now handled implicitly by the FindNextFile error
  handling code (if a client continues to call readdir after receiving
  NULL, FindNextFile will continue to fail with ERROR_NO_MORE_FILES, to
  the same effect)
- extracting dirent data from WIN32_FIND_DATA is needed in two places, so
  moved to its own method
- GetFileAttributes is no longer needed. The same information can be
  obtained from the FindFirstFile error code, which is ERROR_DIRECTORY if
  the name is NOT a directory (-> ENOTDIR), otherwise we can use
  err_win_to_posix (e.g. ERROR_PATH_NOT_FOUND -> ENOENT). The
  ERROR_DIRECTORY case could be fixed in err_win_to_posix, but this
  probably breaks other functionality.

Removes the ERROR_NO_MORE_FILES check after FindFirstFile (this was
fortunately a NOOP (searching for '*' always finds '.' and '..'),
otherwise the subsequent code would have copied data from an uninitialized
buffer).

Changes malloc to git support function xmalloc, so opendir will die() if
out of memory, rather than failing with ENOMEM and letting git work on
incomplete directory listings (error handling in dir.c is quite sparse).

Signed-off-by: Karsten Blees <blees@dcon.de>
Signed-off-by: Erik Faye-Lund <kusmabite@gmail.com>
2014-05-15 09:41:03 +02:00
Karsten Blees
c43dbc5b56 Win32 dirent: clarify #include directives
Git-compat-util.h is two dirs up, and already includes <dirent.h> (which
is the same as "dirent.h" due to -Icompat/win32 in the Makefile).

Signed-off-by: Karsten Blees <blees@dcon.de>
Signed-off-by: Erik Faye-Lund <kusmabite@gmail.com>
2014-05-15 09:41:02 +02:00
Karsten Blees
7ac2f5d802 Win32 dirent: change FILENAME_MAX to MAX_PATH
FILENAME_MAX and MAX_PATH are both 260 on Windows, however, MAX_PATH is
used throughout the other Win32 code in Git, and also defines the length
of file name buffers in the Win32 API (e.g. WIN32_FIND_DATA.cFileName,
from which we're copying the dirent data).

Signed-off-by: Karsten Blees <blees@dcon.de>
Signed-off-by: Erik Faye-Lund <kusmabite@gmail.com>
2014-05-15 09:41:01 +02:00
Karsten Blees
7f14196f62 Win32 dirent: remove unused dirent.d_reclen member
Remove the union around dirent.d_type and the unused dirent.d_reclen member
(which was necessary for compatibility with the MinGW dirent runtime, which
is no longer used).

Signed-off-by: Karsten Blees <blees@dcon.de>
Signed-off-by: Erik Faye-Lund <kusmabite@gmail.com>
2014-05-15 09:41:00 +02:00
Karsten Blees
414263d42c Win32 dirent: remove unused dirent.d_ino member
There are no proper inodes on Windows, so remove dirent.d_ino and #define
NO_D_INO_IN_DIRENT in the Makefile (this skips e.g. an ineffective qsort in
fsck.c).

Signed-off-by: Karsten Blees <blees@dcon.de>
Signed-off-by: Erik Faye-Lund <kusmabite@gmail.com>
2014-05-15 09:40:59 +02:00
Karsten Blees
06c1292434 Warn if the Windows console font doesn't support Unicode
Unicode console output won't display correctly with default settings
because the default console font ("Terminal") only supports the system's
OEM charset. Unfortunately, this is a user specific setting, so it cannot
be easily fixed by e.g. some registry tricks in the setup program.

This change prints a warning on exit if console output contained non-ascii
characters and the console font is supposedly not a TrueType font (which
usually have decent Unicode support).

Signed-off-by: Karsten Blees <blees@dcon.de>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2014-05-15 09:40:58 +02:00
Karsten Blees
38b9bfd2fb Detect console streams more reliably on Windows
GetStdHandle(STD_OUTPUT_HANDLE) doesn't work for stderr if stdout is
redirected. Use _get_osfhandle of the FILE* instead.

_isatty() is true for all character devices (including parallel and serial
ports). Check return value of GetConsoleScreenBufferInfo instead to
reliably detect console handles (also don't initialize internal state from
an uninitialized CONSOLE_SCREEN_BUFFER_INFO structure if the function
fails).

Signed-off-by: Karsten Blees <blees@dcon.de>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2014-05-15 09:40:57 +02:00
Karsten Blees
c7759fadde Support Unicode console output on Windows
WriteConsoleW seems to be the only way to reliably print unicode to the
console (without weird code page conversions).

Also redirects vfprintf to the winansi.c version.

Signed-off-by: Karsten Blees <blees@dcon.de>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2014-05-15 09:40:56 +02:00
Stepan Kasal
94696668a7 Start the merging-rebase to v1.9.3
This commit starts the rebase of 4e4b3c7 to 3d9867a
2014-05-15 09:30:47 +02:00
Sebastian Schuberth
70d7fea57e Merge pull request #181 from kasal/tests-no-posix
Revert "test: fix t7001 cp to use POSIX options"
2014-05-14 12:42:53 +02:00
Stepan Kasal
d928d330aa Revert "test: fix t7001 cp to use POSIX options"
This reverts commit 00764ca1, as our ancient version of "cp" has
problems about the "new" POSIX option "-P" (yields exit code 1).
2014-05-14 11:18:12 +02:00
Jeff King
12949d047d config.c: mark die_bad_number as NORETURN
This can help avoid -Wuninitialized false positives in
git_config_int and git_config_ulong, as the compiler now
knows that we do not return "ret" if we hit the error
codepath.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2014-05-10 17:13:53 -05:00
Johannes Schindelin
9860bbb4ed Merge remote-tracking branch 't-b/sideband-bug'
This will allow us to work around the push issues pointed out in
https://github.com/msysgit/git/issues/101.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2014-05-10 17:13:50 -05:00
Thomas Braun
b6e7fcf533 Config option to disable side-band-64k for transport
Since commit 0c499ea60f the send-pack builtin uses the side-band-64k
capability if advertised by the server.

Unfortunately this breaks pushing over the dump git protocol if used
over a network connection.

The detailed reasons for this breakage are (by courtesy of Jeff Preshing,
quoted from ttps://groups.google.com/d/msg/msysgit/at8D7J-h7mw/eaLujILGUWoJ):
----------------------------------------------------------------------------
MinGW wraps Windows sockets in CRT file descriptors in order to mimic the
functionality of POSIX sockets. This causes msvcrt.dll to treat sockets as
Installable File System (IFS) handles, calling ReadFile, WriteFile,
DuplicateHandle and CloseHandle on them. This approach works well in simple
cases on recent versions of Windows, but does not support all usage patterns.
In particular, using this approach, any attempt to read & write concurrently
on the same socket (from one or more processes) will deadlock in a scenario
where the read waits for a response from the server which is only invoked after
the write. This is what send_pack currently attempts to do in the use_sideband
codepath.
----------------------------------------------------------------------------

The new config option "sendpack.sideband" allows to override the side-band-64k
capability of the server, and thus makes the dump git protocol work.

Other transportation methods like ssh and http/https still benefit from
the sideband channel, therefore the default value of "sendpack.sideband"
is still true.

Signed-off-by: Thomas Braun <thomas.braun@byte-physics.de>
2014-05-10 17:13:50 -05:00
Erik Faye-Lund
db40d884d0 Makefile: do not depend on curl-config
MinGW builds of cURL does not ship with curl-config unless built
with the autoconf based build system, which is not the practice
recommended by the documentation. MsysGit has had issues with
binaries of that sort, so it has switched away from autoconf-based
cURL-builds.

Unfortunately, broke pushing over WebDAV on Windows, because
http-push.c depends on cURL's multi-threaded API, which we could
not determine the presence of any more.

Since troublesome curl-versions are ancient, and not even present
in RedHat 5, let's just assume cURL is capable instead of doing a
non-robust check.

Instead, add a check for curl_multi_init to our configure-script,
for those on ancient system. They probably already need to do the
configure-dance anyway.

Signed-off-by: Erik Faye-Lund <kusmabite@gmail.com>
2014-05-10 17:13:49 -05:00
Johannes Schindelin
af30131ce0 Merge pull request #122 from kblees/kb/long-paths-v2
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2014-05-10 17:13:49 -05:00
Johannes Schindelin
231f53802f Merge remote-tracking branch 'kblees/kb/fscache-v4-tentative-1.8.5' into thicket-1.8.5.2 2014-05-10 17:13:49 -05:00
Johannes Schindelin
2588ee01ea Merge branch 'kb/hashmap-v5-minimal' into kb/fscache-v4-t1.8.5 2014-05-10 17:13:49 -05:00
Johannes Schindelin
0853bed367 Merge branch 'tag-contains'
This topic branch addresses out-of-memory errors in particular on
Windows, where the default stack space is not very large.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2014-05-10 16:57:03 -05:00
Johannes Schindelin
58af5a8889 Merge pull request #126 from RomanBelinsky/master
fix date parsing error:  Update SVN.pm
2014-05-10 16:57:02 -05:00
Johannes Schindelin
8947aba21a Merge pull request #115 from msysgit/tip4commit
Mention tip4commit
2014-05-10 16:57:02 -05:00
Johannes Schindelin
d774bfc142 Merge 'poll-busy-wait' into HEAD 2014-05-10 16:57:02 -05:00
Johannes Schindelin
43e098b1b2 Merge 'normalize-win-paths' into HEAD 2014-05-10 16:57:02 -05:00
Johannes Schindelin
8f9a5f39f3 Merge 'msvc-link-crt' into HEAD 2014-05-10 16:57:02 -05:00
Johannes Schindelin
a02dd25e70 Merge 'install-wincred' into HEAD 2014-05-10 16:57:02 -05:00
Johannes Schindelin
618f8140c9 Merge 'fix-is-exe' into HEAD 2014-05-10 16:57:01 -05:00
Johannes Schindelin
4af426c1e5 Merge 'fix-externals' into HEAD 2014-05-10 16:57:01 -05:00
Johannes Schindelin
e598900a99 Merge 'stash-reflog' into HEAD 2014-05-10 16:57:01 -05:00
Johannes Schindelin
7abda7a425 Merge 'http-msys-paths' into HEAD 2014-05-10 16:57:01 -05:00
Johannes Schindelin
b7593f867f Merge 'remote-hg-prerequisites' into HEAD
These fixes were necessary for Sverre Rabbelier's remote-hg to work,
but for some magic reason they are not necessary for the current
remote-hg. Makes you wonder how that one gets away with it.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2014-05-10 16:57:01 -05:00
Johannes Schindelin
acdd2fc2d3 Merge 'win-tests-fixes' into HEAD 2014-05-10 16:57:01 -05:00
Johannes Schindelin
cbdee028b8 Merge branch 'some-CR-fixes'
This branch contains some hacks so that Git produces less CR, and then
some tests.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2014-05-10 16:57:00 -05:00
Johannes Schindelin
5a9b30853b Merge 'grep-fixes' into HEAD 2014-05-10 16:57:00 -05:00
Johannes Schindelin
5322eac747 Merge 'pull-rebase-interactive' into HEAD 2014-05-10 16:57:00 -05:00
Johannes Schindelin
ab62c69232 Merge 'send-email' into HEAD 2014-05-10 16:57:00 -05:00
Johannes Schindelin
2398365930 Merge 'jberezanski/wincred-sso-r2' into HEAD 2014-05-10 16:57:00 -05:00
Johannes Schindelin
66353333a0 Merge 'gitweb-syntax' into HEAD 2014-05-10 16:56:59 -05:00
Johannes Schindelin
48e63552e6 Merge 'gitk' into HEAD 2014-05-10 16:56:59 -05:00
Johannes Schindelin
790f423a13 Merge 'git-gui' into HEAD 2014-05-10 16:56:59 -05:00
Johannes Schindelin
9a1e8b50f4 Merge 'deny-current-branch' into HEAD 2014-05-10 16:56:59 -05:00
Johannes Schindelin
7536fcf23d Merge 'criss-cross-merge' into HEAD 2014-05-10 16:56:59 -05:00
Johannes Schindelin
be6b605193 Merge 'am-submodules' into HEAD 2014-05-10 16:56:59 -05:00
Johannes Schindelin
9485bf31d5 Merge 'unc' into HEAD 2014-05-10 16:56:58 -05:00
Johannes Schindelin
a565692e8c Merge 'home' into HEAD 2014-05-10 16:56:58 -05:00
Johannes Schindelin
16180e48a2 Merge 'hide-dotgit' into HEAD 2014-05-10 16:56:58 -05:00
Johannes Schindelin
547db2e8c8 Merge 'unicode' into HEAD 2014-05-10 16:56:58 -05:00
Karsten Blees
104d4e8941 Win32: support long paths
Windows paths are typically limited to MAX_PATH = 260 characters, even
though the underlying NTFS file system supports paths up to 32,767 chars.
This limitation is also evident in Windows Explorer, cmd.exe and many
other applications (including IDEs).

Particularly annoying is that most Windows APIs return bogus error codes
if a relative path only barely exceeds MAX_PATH in conjunction with the
current directory, e.g. ERROR_PATH_NOT_FOUND / ENOENT instead of the
infinitely more helpful ERROR_FILENAME_EXCED_RANGE / ENAMETOOLONG.

Many Windows wide char APIs support longer than MAX_PATH paths through the
file namespace prefix ('\\?\' or '\\?\UNC\') followed by an absolute path.
Notable exceptions include functions dealing with executables and the
current directory (CreateProcess, LoadLibrary, Get/SetCurrentDirectory) as
well as the entire shell API (ShellExecute, SHGetSpecialFolderPath...).

Introduce a handle_long_path function to check the length of a specified
path properly (and fail with ENAMETOOLONG), and to optionally expand long
paths using the '\\?\' file namespace prefix. Short paths will not be
modified, so we don't need to worry about device names (NUL, CON, AUX).

Contrary to MSDN docs, the GetFullPathNameW function doesn't seem to be
limited to MAX_PATH (at least not on Win7), so we can use it to do the
heavy lifting of the conversion (translate '/' to '\', eliminate '.' and
'..', and make an absolute path).

Add long path error checking to xutftowcs_path for APIs with hard MAX_PATH
limit.

Add a new MAX_LONG_PATH constant and xutftowcs_long_path function for APIs
that support long paths.

While improved error checking is always active, long paths support must be
explicitly enabled via 'core.longpaths' option. This is to prevent end
users to shoot themselves in the foot by checking out files that Windows
Explorer, cmd/bash or their favorite IDE cannot handle.

Thanks-to: Martin W. Kirst <maki@bitkings.de>
Thanks-to: Doug Kelly <dougk.ff7@gmail.com>
Signed-off-by: Karsten Blees <blees@dcon.de>
2014-05-10 16:56:57 -05:00
Karsten Blees
738ce022b2 Win32: add a cache below mingw's lstat and dirent implementations
Checking the work tree status is quite slow on Windows, due to slow lstat
emulation (git calls lstat once for each file in the index). Windows
operating system APIs seem to be much better at scanning the status
of entire directories than checking single files.

Add an lstat implementation that uses a cache for lstat data. Cache misses
read the entire parent directory and add it to the cache. Subsequent lstat
calls for the same directory are served directly from the cache.

Also implement opendir / readdir / closedir so that they create and use
directory listings in the cache.

The cache doesn't track file system changes and doesn't plug into any
modifying file APIs, so it has to be explicitly enabled for git functions
that don't modify the working copy.

Note: in an earlier version of this patch, the cache was always active and
tracked file system changes via ReadDirectoryChangesW. However, this was
much more complex and had negative impact on the performance of modifying
git commands such as 'git checkout'.

Signed-off-by: Karsten Blees <blees@dcon.de>
2014-05-10 16:56:57 -05:00
Doug Kelly
aad2ca9251 Add a test demonstrating a problem with long submodule paths
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2014-05-10 16:56:57 -05:00
Karsten Blees
658d848289 add infrastructure for read-only file system level caches
Add a macro to mark code sections that only read from the file system,
along with a config option and documentation.

This facilitates implementation of relatively simple file system level
caches without the need to synchronize with the file system.

Enable read-only sections for 'git status' and preload_index.

Signed-off-by: Karsten Blees <blees@dcon.de>
2014-05-10 16:56:57 -05:00