Commit Graph

49004 Commits

Author SHA1 Message Date
Johannes Schindelin
857a6716ab Refactor git-wrapper into more functions
This prepares the wrapper for modifications to serve as a drop-in
replacement for the builtins.

This commit's diff is best viewed with the `-w` flag.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2015-03-18 08:50:33 +01:00
Johannes Schindelin
77b10cf882 fixup! Add Git for Windows' wrapper executable
This change simply makes the Git wrapper's source code conform to Git's
coding guide lines.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2015-03-17 15:41:30 +01:00
Johannes Schindelin
529a89998a fixup! Add Git for Windows' wrapper executable
Fix whitespace. This trick was performed by

	git rebase --whitespace=fix HEAD^

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2015-03-17 15:40:55 +01:00
Johannes Schindelin
055a65c56a mingw: Compile the Git wrapper
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2015-03-13 16:28:50 +01:00
Johannes Schindelin
9e7db4976e Add Git for Windows' wrapper executable
On Windows, Git is faced by the challenge that it has to set up certain
environment variables before running Git under special circumstances
such as when Git is called directly from cmd.exe (i.e. outside any
Bash environment).

This source code was taken from msysGit's commit 74a198d:

https://github.com/msysgit/msysgit/blob/74a198d/src/git-wrapper/git-wrapper.c

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2015-03-13 14:16:43 +01:00
dscho
8c01ab42cc Merge pull request #28 from dscho/tty-handles
Teach msys2-runtime to hand the tty through to Git
2015-03-11 20:07:06 +01:00
Johannes Schindelin
de0d35dbab mingw: Work around MSVCRT's isatty() not knowing about MSys2
MSys2 has a slightly different notion of what constitutes a tty than
the Microsoft C runtime. The former knows whether stdin/stdout/stderr
was redirected or not, while the latter looks for a Win32 Console.

In particular when we want to know whether to spawn a pager or not, we
would rather want to know what MSys2 thinks.

We are about to introduce a change to the msys2-runtime that sets an
environment variable MSYS_TTY_HANDLES to a list of Win32 handles that
correspond to stdin/stdout/stderr, respectively, *but skips* handles that
MSys2 does not think are terminals.

This commit handles that input to augment the isatty() function to return
1 also when MSYS_TTY_HANDLES contains the corresponding handle.

The only time when Git needs to know whether a Console is attached or not
is when winansi.c is asked to Do Its Thing, therefore we refrain from
overriding isatty there.

Note: this was an issue with MSys1-based Git for Windows, too, hidden by
the fact that Git for Windows used `cmd.exe` as a terminal -- which is
backed by a real Win32 Console. Had MSys1 used, say, rxvt as its default
terminal, the symptom would have been that "git log" does not spawn a
pager by default but instead outputs the entire history (without color
coding, too). In MSys2, the default terminal is mintty, therefore we
finally could not avoid to address the issue.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2015-03-10 14:59:06 +01:00
dscho
7354ebecf1 Merge pull request #36 from nalla/cvs-test-fixes
mingw: cvs-test-fixes
2015-03-10 14:57:19 +01:00
마누엘
c8f3dbe11a mingw: Fix CVS-related tests
The CVS tests expect `pwd` to return a POSIX-style directory. Let's skip
our MinGW-specific override to let `pwd` output a Windows-style directory
for that reason.

Helped-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: 마누엘 <nalla@hamal.uberspace.de>
2015-03-10 13:06:47 +01:00
Johannes Schindelin
3f560bc3d9 fixup! Port header fixes from MSys2
Whoops. The code does not even compile without this.
2015-03-09 17:53:01 +01:00
Sebastian Schuberth
f452084bb8 Merge pull request #35 from dscho/fix-warnings
squash! Port header fixes from MSys2
2015-03-09 11:04:35 +01:00
Johannes Schindelin
b2eeeed817 squash! Port header fixes from MSys2
Replace the commit message with this one:

Assorted header fixes to support MSys2-based MinGW build

The excellent MSys2 project brings a substantially updated MinGW
environment including newer GCC versions and new headers. To support
compiling Git, let's special-case the new MinGW (tell-tale: the
_MINGW64_VERSION_MAJOR constant is defined).

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2015-03-09 11:02:27 +01:00
Sebastian Schuberth
e9a2fe058c Merge pull request #33 from dscho/manifest
Embed a manifest into git.exe
2015-03-09 10:25:00 +01:00
Cesar Eduardo Barros
8b1d676017 mingw: Embed a manifest to trick UAC into Doing The Right Thing
On Windows >= Vista, not having an application manifest with a
requestedExecutionLevel can cause several kinds of confusing behavior.

The first and more obvious behavior is "Installer Detection", where
Windows sometimes decides (by looking at things like the file name and
even sequences of bytes within the executable) that an executable is an
installer and should run elevated (causing the well-known popup dialog
to appear). In Git's context, subcommands such as "git patch-id" or "git
update-index" fall prey to this behavior.

The second and more confusing behavior is "File Virtualization". It
means that when files are written without having write permission, it
does not fail (as expected), but they are instead redirected to
somewhere else. When the files are read, the original contents are
returned, though, not the ones that were just written somewhere else.
Even more confusing, not all write accesses are redirected; Trying to
write to write-protected .exe files, for example, will fail instead of
redirecting.

In addition to being unwanted behavior, File Virtualization causes
dramatic slowdowns in Git (see for instance
http://code.google.com/p/msysgit/issues/detail?id=320).

There are two ways to prevent those two behaviors: Either you embed an
application manifest within all your executables, or you add an external
manifest (a file with the same name followed by .manifest) to all your
executables. Since Git's builtins are hardlinked (or copied), it is
simpler and more robust to embed a manifest.

A recent enough MSVC compiler should already embed a working internal
manifest, but for MinGW you have to do so by hand.

Very lightly tested on Wine, where like on Windows XP it should not make
any difference.

References:
  - New UAC Technologies for Windows Vista
    http://msdn.microsoft.com/en-us/library/bb756960.aspx
  - Create and Embed an Application Manifest (UAC)
    http://msdn.microsoft.com/en-us/library/bb756929.aspx

[js: simplified the embedding dramatically by reusing Git for Windows'
existing Windows resource file, removed the optional (and dubious)
processorArchitecture attribute of the manifest's assemblyIdentity
section.]

Signed-off-by: Cesar Eduardo Barros <cesarb@cesarb.net>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2015-03-09 10:19:53 +01:00
Johannes Schindelin
3cd528c49d Merge 'non-win-fixes' into HEAD 2015-03-06 18:13:40 +01:00
Johannes Schindelin
bad4e6ecd6 Merge pull request #239 from sschuberth/taskkill
git-gui/gitk: Do not use a Cygwin-specific kill flag on Windows
2015-03-06 18:13:39 +01:00
Johannes Schindelin
11d4909c07 Merge pull request #122 from kblees/kb/long-paths-v2
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2015-03-06 18:13:39 +01:00
Johannes Schindelin
518bc40412 Merge remote-tracking branch 'kblees/kb/fscache-v4-tentative-1.8.5' into thicket-1.8.5.2 2015-03-06 18:13:39 +01:00
Johannes Schindelin
49fb2af240 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>
2015-03-06 18:13:39 +01:00
Johannes Schindelin
7f4531f7f6 Merge pull request #24 from gitter-badger/gitter-badge
Add a Gitter chat badge to README.md
2015-03-06 18:13:39 +01:00
Johannes Schindelin
fde7d7b95b Merge pull request #14 from dscho/readme
Add a README.md for GitHub goodness.
2015-03-06 18:13:39 +01:00
Johannes Schindelin
d2540b8582 Merge 'fix-is-exe' into HEAD 2015-03-06 18:13:39 +01:00
Johannes Schindelin
6c8009273d Merge 'fix-externals' into HEAD 2015-03-06 18:13:39 +01:00
Johannes Schindelin
3ac4881b7e 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>
2015-03-06 18:13:39 +01:00
Johannes Schindelin
0a0ef263ec Merge 'win-tests-fixes' into HEAD 2015-03-06 18:13:38 +01:00
Johannes Schindelin
4c03b241d7 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>
2015-03-06 18:13:38 +01:00
Johannes Schindelin
a852a69043 Merge pull request #26 from dscho/msys2
Fixes required to build Git for Windows with MSys2
2015-03-06 18:13:38 +01:00
Johannes Schindelin
124dadd18e Merge 'pull-rebase-interactive' into HEAD 2015-03-06 18:13:38 +01:00
Johannes Schindelin
ce9184833b Merge 'jberezanski/wincred-sso-r2' into HEAD 2015-03-06 18:13:38 +01:00
Johannes Schindelin
4b7d5dc622 Merge 'gitweb-syntax' into HEAD 2015-03-06 18:13:38 +01:00
Johannes Schindelin
c3510adae0 Merge 'gitk' into HEAD 2015-03-06 18:13:38 +01:00
Johannes Schindelin
2df74a500a Merge 'git-gui' into HEAD 2015-03-06 18:13:38 +01:00
Johannes Schindelin
659668e1cf Facilitate debugging Git executables in tests with gdb
When prefixing a Git call in the test suite with 'TEST_GDB_GIT=1 ', it
will now be run with GDB, allowing the developer to debug test failures
more conveniently.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2015-03-06 18:13:37 +01:00
Johannes Schindelin
c2565b9b8a Merge 'criss-cross-merge' into HEAD 2015-03-06 18:13:37 +01:00
Johannes Schindelin
d69ba5f3be Merge 'am-submodules' into HEAD 2015-03-06 18:13:37 +01:00
Johannes Schindelin
5eeb39d0d2 Merge 'hide-dotgit' into HEAD 2015-03-06 18:13:37 +01:00
Johannes Schindelin
b8f8af0ad0 Merge 'unicode' into HEAD 2015-03-06 18:13:37 +01:00
Johannes Schindelin
a0d8291fe6 Merge 'refs/rewritten/junio/notyet' into HEAD 2015-03-06 18:13:37 +01:00
Pat Thoyts
e1e50b04a1 remote-http(s): Support SOCKS proxies
With this patch we properly support SOCKS proxies, configured e.g. like
this:

	git config http.proxy socks5://192.168.67.1:32767

Without this patch, Git mistakenly tries to use SOCKS proxies as if they
were HTTP proxies, resulting in a error message like:

	fatal: unable to access 'http://.../': Proxy CONNECT aborted

This patch was required to work behind a faulty AP and scraped from
http://stackoverflow.com/questions/15227130/#15228479 and guarded with
an appropriate cURL version check by Johannes Schindelin.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2015-03-06 18:12:50 +01:00
Sebastian Schuberth
9d00d109f2 git-gui/gitk: Do not use a Cygwin-specific kill flag on Windows
Windows does not necessarily mean Cygwin, it could also be MSYS. The
latter ships with a version of "kill" that does not understand "-f". In
msysgit this was addressed shipping Cygwin's version of kill.

Properly fix this by using the stock Windows "taskkill" command instead,
which is available since Windows XP Professional.

Signed-off-by: Sebastian Schuberth <sschuberth@gmail.com>
2015-03-06 18:11:29 +01:00
Johannes Schindelin
b9ca6c674f Only use CURLOPT_LOGIN_OPTIONS if it is actually available
This fixes the compilation on an older Linux that was used to debug
test failures when upgrading Git for Windows to Git v2.3.0.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2015-03-06 18:11:29 +01:00
Karsten Blees
a26061e650 Win32: fix 'lstat("dir/")' with long paths
Use a suffciently large buffer to strip the trailing slash.

Signed-off-by: Karsten Blees <blees@dcon.de>
2015-03-06 18:11:28 +01:00
Karsten Blees
52b829129f fscache: load directories only once
If multiple threads access a directory that is not yet in the cache, the
directory will be loaded by each thread. Only one of the results is added
to the cache, all others are leaked. This wastes performance and memory.

On cache miss, add a future object to the cache to indicate that the
directory is currently being loaded. Subsequent threads register themselves
with the future object and wait. When the first thread has loaded the
directory, it replaces the future object with the result and notifies
waiting threads.

Signed-off-by: Karsten Blees <blees@dcon.de>
2015-03-06 18:11:28 +01:00
Thomas Braun
101ae534bd t2025: Tell tail explicitly to read from stdin
Our current version of bash 3.1.17(5) can not parse the following snippet
correctly
p=abcd
abspath=/$p
subdir="x$(echo "$p" | tail -c $((253 - ${#abspath})))"
as it returns
tail: cannot open `253' for reading: No such file or directory

This is fixed in bash 3.1.20(4), I did not check earlier versions.

Signed-off-by: Thomas Braun <thomas.braun@byte-physics.de>
2015-03-06 18:11:28 +01:00
Karsten Blees
e698f39a39 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>
2015-03-06 18:11:28 +01:00
Karsten Blees
befd56f110 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.

Test suite:
Test the case is when the full pathname length of a dir is close
to 260 (MAX_PATH).
Bug report and an original reproducer by Andrey Rogozhnikov:
https://github.com/msysgit/git/pull/122#issuecomment-43604199

Thanks-to: Martin W. Kirst <maki@bitkings.de>
Thanks-to: Doug Kelly <dougk.ff7@gmail.com>
Signed-off-by: Karsten Blees <blees@dcon.de>
Original-test-by: Andrey Rogozhnikov <rogozhnikov.andrey@gmail.com>
Signed-off-by: Stepan Kasal <kasal@ucw.cz>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2015-03-06 18:11:28 +01:00
Karsten Blees
0032f712c3 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>
2015-03-06 18:11:28 +01:00
Doug Kelly
4fe9f27c02 Add a test demonstrating a problem with long submodule paths
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2015-03-06 18:11:28 +01:00
Thomas Braun
11c75dbe87 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>
2015-03-06 18:11:27 +01:00
The Gitter Badger
ee7e1619d9 Added Gitter badge 2015-03-06 18:11:27 +01:00