Commit Graph

81694 Commits

Author SHA1 Message Date
Johannes Schindelin
885ee99fde Merge 'aslr' into HEAD
Address Space Layout Randomization (ASLR) allows executables' memory
layout to change at random between runs, and therefore offers a quite
decent protection against many attacks.

We enable ASLR because MSYS2's C compiler offers support for ASLR, and
whatever performance impact it has is neglible, according to
https://insights.sei.cmu.edu/cert/2014/02/differences-between-aslr-on-windows-and-linux.html

This merges the part of https://github.com/git-for-windows/git/pull/612
that does not break Git ;-)

This fixes https://github.com/git-for-windows/git/issues/608

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2018-03-23 13:55:49 +01:00
Johannes Schindelin
75de7d4922 Merge pull request #552 from duncansmart/fix-vcproj-gen
Fix Visual Studio .sln/.vcproj generation.
2018-03-23 13:55:46 +01:00
Johannes Schindelin
6e0f18c9e2 Merge pull request #773 from jeffhostetler/vs2015
Build with VS2015
2018-03-23 13:55:44 +01:00
Johannes Schindelin
b9cc26560f Merge pull request #305 from dscho/msysgit_issues_182
Allow `add -p` and `add -i` with a large number of files
2018-03-23 13:55:42 +01:00
Johannes Schindelin
6aa9333d3a Merge branch 'program-data-config'
This branch introduces support for reading the "Windows-wide" Git
configuration from `%PROGRAMDATA%\Git\config`. As these settings are
intended to be shared between *all* Git-related software, that config
file takes an even lower precedence than `$(prefix)/etc/gitconfig`.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2018-03-23 13:55:39 +01:00
Johannes Schindelin
e6099362d6 Merge 'mingw-getcwd' into HEAD 2018-03-23 13:55:37 +01:00
Johannes Schindelin
87f46e422d Merge pull request #443 from kblees/kb/nanosecond-file-times-v2.5.3
nanosecond file times for v2.5.3
2018-03-23 13:55:34 +01:00
Johannes Schindelin
de53194188 Merge pull request #156 from kblees/kb/symlinks
Symlink support
2018-03-23 13:55:32 +01:00
Johannes Schindelin
3fdd7e178c Merge 'sideband-bug' into HEAD
This works around the push-over-git-protocol issues pointed out in
https://github.com/msysgit/git/issues/101.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2018-03-23 13:55:30 +01:00
Johannes Schindelin
249e9a8865 Merge 'fix-externals' into HEAD 2018-03-23 13:55:28 +01:00
Johannes Schindelin
8c5d7425cf 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>
2018-03-23 13:55:25 +01:00
Johannes Schindelin
27f0ca5b93 Merge 'win-tests-fixes' into HEAD 2018-03-23 13:55:23 +01:00
Johannes Schindelin
492384d1f6 Merge 'msys2' into HEAD
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2018-03-23 13:55:21 +01:00
Johannes Schindelin
0196a471ea Merge 'gitk' into HEAD 2018-03-23 13:55:18 +01:00
Johannes Schindelin
dcabcbdb22 Merge branch 'msys2-git-gui'
This topic branch addresses the bug where Git for Windows 2.x' Git GUI
failed to generate a working shortcut via Repository>Create Desktop
Shortcut.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2018-03-23 13:55:16 +01:00
Johannes Schindelin
5e0d89e34e Merge 'git-gui' into HEAD 2018-03-23 13:55:14 +01:00
Johannes Schindelin
a5cd4fb371 Merge 'readme' into HEAD
Add a README.md for GitHub goodness.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2018-03-23 13:55:12 +01:00
İsmail Dönmez
53b790dafa Enable DEP and ASLR
Enable DEP (Data Execution Prevention) and ASLR (Address Space Layout
Randomization) support. This applies to both 32bit and 64bit builds
and makes it substantially harder to exploit security holes in Git by
offering a much more unpredictable attack surface.

ASLR interferes with GDB's ability to set breakpoints. A similar issue
holds true when compiling with -O2 (in which case single-stepping is
messed up because GDB cannot map the code back to the original source
code properly). Therefore we simply enable ASLR only when an
optimization flag is present in the CFLAGS, using it as an indicator
that the developer does not want to debug in GDB anyway.

Signed-off-by: İsmail Dönmez <ismail@i10z.com>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2018-03-23 13:53:24 +01:00
İsmail Dönmez
0b9f6558ce Don't let ld strip relocations
This is the first step for enabling ASLR (Address Space Layout
Randomization) support. We want to enable ASLR for better protection
against exploiting security holes in Git.

The problem fixed by this commit is that `ld.exe` seems to be stripping
relocations which in turn will break ASLR support. We just make sure
it's not stripping the main executable entry.

Signed-off-by: İsmail Dönmez <ismail@i10z.com>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2018-03-23 13:53:24 +01:00
Philip Oakley
daf53996a5 engine.pl: ignore invalidcontinue.obj which is known to MSVC
Commit 4b623d8 (MSVC: link in invalidcontinue.obj for better
POSIX compatibility, 2014-03-29) introduced invalidcontinue.obj
into the Makefile output, which was not parsed correctly by the
buildsystem. Ignore it, as it is known to Visual Studio and,
there is no matching source file.

Only substitute filenames ending with .o when generating the
source .c filename, otherwise a .cbj file may be expected.

Split the .o and .obj processing; 'make' does not produce .obj
files.

In the future there may be source files that produce .obj files
so keep the two issues (.obj files with & without source files)
separate.

Signed-off-by: Philip Oakley <philipoakley@iee.org>
Signed-off-by: Duncan Smart <duncan.smart@gmail.com>

(cherry picked from commit d01d71fe1aed67f4e3a5ab80eeadeaf525ad0846)
2018-03-23 13:53:21 +01:00
Johannes Schindelin
04bbd16932 compat/vcbuild: possibly reuse Git for Windows' SDK's NuGet
In Git for Windows' SDK, there is already a script to package Git for
Windows as a NuGet package, downloading nuget.exe if needed.

Let's just fall back to using that executable (if it is there) if
nuget.exe was not found in the PATH.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2018-03-23 13:53:17 +01:00
Jeff Hostetler
d16acfbd9b vs2015: remove todo list item from README_vs2015.txt
Remove todo list item for vs2015 build notes regarding
the third party DLLs.

Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
2018-03-23 13:53:16 +01:00
Jeff Hostetler
3357523cf2 vs2015: teach 'make clean' to delete PDBs
Teach main Makefile to also delete the generated PDB files
as well as the PDB files for the various EXE files during
"make MSVC=1 clean".

Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
2018-03-23 13:53:16 +01:00
Jeff Hostetler
8fcef213ca vs2015: turn on optimize-for-speed in release build
Set -O2 (maximize speed) rather than -Os (favor small code)
for non-debug builds.

Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
2018-03-23 13:53:16 +01:00
Johannes Schindelin
aa440592b6 t7800: fix quoting
When passing a command-line to call an external diff command to the
difftool, we must be prepared for paths containing special characters,
e.g. backslashes in the temporary directory's path on Windows.

This has been caught by running the test suite with an MSVC-built Git:
in contrast to the MINGW one, it does not rewrite `$TMP` to use forward
slashes instead of backslashes.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2018-03-23 13:53:15 +01:00
Johannes Schindelin
c7810f2b39 msvc: work around iconv() not setting errno
When compiling with MSVC, we rely on NuPkgs to provide the binaries of
dependencies such as libiconv. The libiconv 1.14.0.11 package available
from https://www.nuget.org/packages/libiconv seems to have a bug where
it does not set errno (when we would expect it to be E2BIG).

Let's simulate the error condition by taking less than 16 bytes
remaining in the out buffer as an indicator that we ran out of space.
While 16 might seem a bit excessive (when converting from, say, any
encoding to UTF-8, 8 bytes should be fine), it is designed to be a safe
margin.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2018-03-23 13:53:15 +01:00
Johannes Schindelin
2c282eb1c9 msvc: use libiconv
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2018-03-23 13:53:14 +01:00
Jeff Hostetler
df9cc518a6 msvc: use OpenSSL's SHA-1 routines
Just like 1e2ce1d (sha1: Use OpenSSL SHA1 routines on MINGW, 2016-10-12),
we now use OpenSSL's SHA-1 routines instead of Git's own because OpenSSL
is substantially faster as of version 1.0.2: it now uses hardware
acceleration on Intel processors much more effectively.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2018-03-23 13:53:14 +01:00
Johannes Schindelin
17881c63a4 msvc: respect the quiet-by-default output
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2018-03-23 13:53:13 +01:00
Jeff Hostetler
e3f6de6b1b msvc: release mode PDBs and library DLLs
Install required third-party DLLs next to EXEs.

Build and install release mode PDBs for git
executables allowing detailed stack traces
in the event of crash.

Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
2018-03-23 13:53:13 +01:00
Jeff Hostetler
f7992cd371 cache-tree.c: avoid reusing the DEBUG constant
In MSVC, the DEBUG constant is set automatically whenever compiling with
debug information.

This is clearly not what was intended in cache-tree.c, so let's use a less
ambiguous constant there.

Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
2018-03-23 13:53:12 +01:00
Johannes Schindelin
cd6dce47ee msvc: fix detect_msys_tty()
The ntstatus.h header is only available in MINGW.

Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
2018-03-23 13:53:12 +01:00
Jeff Hostetler
c00eafbc9a msvc: define ftello()
It is just called different in MSVC's headers.

Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
2018-03-23 13:53:12 +01:00
Jeff Hostetler
1448e2d9a1 msvc: do not re-declare the timespec struct
VS2015's headers already declare that struct.

Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
2018-03-23 13:53:11 +01:00
Johannes Schindelin
bf6b5413ba msvc: provide a main() wrapper similar to mingw_main()
The MINGW version of the main() wrapper gets away with declaring symbols
that were intentionally not exported. However, some of these symbols do
not actually exist in MSVC's UCRT.

So let's add an MSVC version of the main() wrapper that uses wmain() and
imports the UNICODE argv and environment. While at it, we pass our UTF-8
version of ARGV to the real main -- rather than overwriting __argv as is
done in the MINGW Version.

Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
2018-03-23 13:53:11 +01:00
Jeff Hostetler
a22de0e1a2 msvc: do not pretend to support all signals
This special-cases various signals that are not supported on Windows,
such as SIGPIPE. These cause the UCRT to throw asserts (at least in
debug mode).

Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
2018-03-23 13:53:10 +01:00
Jeff Hostetler
dcee2231b7 msvc: mark a variable as non-const
VS2015 complains when using a const pointer in memcpy()/free().

Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
2018-03-23 13:53:10 +01:00
Jeff Hostetler
66ac7d0272 msvc: convert environment from/to UTF-16 on the fly
This adds MSVC versions of getenv() and friends. These take UTF-8
arguments and return UTF-8 values, but use the UNICODE versions
of the CRT routines.  This avoids the need to write to __environ
(which is only visible if you statically link to the CRT).  This
also avoids the CP_ACP conversions performed inside the CRT.
It also avoids various memory leaks and problems.

Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
2018-03-23 13:53:10 +01:00
Philip Oakley
5986edf913 msvc: fix the declaration of the _REPARSE_DATA_BUFFER structure
GCC and MSVC disagree about using the GCC extension _ANONYMOUS_UNION.
Simply skip that offending keyword when compiling with MSVC.

Signed-off-by: Philip Oakley <philipoakley@iee.org>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2018-03-23 13:53:09 +01:00
Philip Oakley
e567476b3b msvc: define O_ACCMODE
This constant is not defined in MSVC's headers.

In UCRT's fcntl.h, _O_RDONLY, _O_WRONLY and _O_RDWR are defined as 0, 1
and 2, respectively. Yes, that means that UCRT breaks with the tradition
that O_RDWR == O_RDONLY | O_WRONLY.

It is a perfectly legal way to define those constants, though, therefore
we need to take care of defining O_ACCMODE accordingly.

This is particularly important in order to keep our "open() can set
errno to EISDIR" emulation working: it tests that (flags & O_ACCMODE) is
not identical to O_RDONLY before going on to test specifically whether
the file for which open() reported EACCES is, in fact, a directory.

Signed-off-by: Philip Oakley <philipoakley@iee.org>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2018-03-23 13:53:09 +01:00
Philip Oakley
2ddddaada1 msvc: include sigset_t definition
On MSVC (VS2008) sigset_t is not defined.

Signed-off-by: Philip Oakley <philipoakley@iee.org>
2018-03-23 13:53:08 +01:00
Jeff Hostetler
e45ef203de msvc: update Makefile and compiler settings for VS2015
Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
2018-03-23 13:53:08 +01:00
Jeff Hostetler
9ee8df3abd msvc: update compile helper for VS2015
Support -Z flags ("specify PDB options"), only include -l args on link
commands, and force PDBs to be created.

Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
2018-03-23 13:53:07 +01:00
Jeff Hostetler
bfa5226332 msvc: add NuGet scripts for building with VS2015
This commit contains a GNU Makefile and NuGet configuration scripts to
download and install the various third-party libraries that we will need
to build/link with when using VS2015 to build Git.

The file "compat/vcbuild/README_VS2015.txt" contains instructions for
using this.

In this commit, "compat/vcbuild/Makefile" contains hard-coded version
numbers of the packages we require.  These are set to the current
versions as of the time of this commit.  We use "nuget restore" to
install them explicitly using a "package.config".  A future improvement
would try to use some of the automatic package management functions and
eliminate the need to specify exact versions.  I tried, but could not
get this to work.  NuGet was happy dowload "minimum requirements" rather
than "lastest" for dependencies -- and only look at one package at a
time.  For example, both curl and openssl depend upon zlib and have
different minimums.  It was unclear which version of zlib would be
installed and seemed to be dependent on the order of the top-level
packages.  So, I'm skipping that for now.

We need to be very precise when specifying NuGet package versions: while
nuget.exe auto-completes a version, say, 1.0.2 to 1.0.2.0, we will want
to parse packages.config ourselves, to generate the Visual Studio
solution, and there we need the exact version number to be able to
generate the exact path to the correct .targets file.

Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
2018-03-23 13:53:07 +01:00
Jeff Hostetler
406e1b17b7 msvc: ignore VS2015 trash files
Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
2018-03-23 13:53:07 +01:00
Johannes Schindelin
582c03aa49 msvc: fix dependencies of compat/msvc.c
The file compat/msvc.c includes compat/mingw.c, which means that we have
to recompile compat/msvc.o if compat/mingw.c changes.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2018-03-23 13:53:06 +01:00
Johannes Schindelin
a3134290af t3701: verify that we can add *lots* of files interactively
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2018-03-23 13:53:02 +01:00
Kelly Heller
1ed63c6f03 Allow add -p and add -i with a large number of files
This fixes https://github.com/msysgit/git/issues/182.

Inspired by Pull Request 218 using code from @PhilipDavis.

[jes: simplified code quite a bit]

Signed-off-by: Kelly Heller <kkheller@cedrus.com>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2018-03-23 13:53:02 +01:00
Andreas Heiduk
56e971fbed Improve documentation for C:\ProgramData\Git\config
Move the description for the additional Git for Windows configuration file
into the right place, so that the following descriptions of the read priority
also covers this file correctly.

Also make it clear, what file `git config --system` selects.

Signed-off-by: Andreas Heiduk <asheiduk@gmail.com>
2018-03-23 13:52:58 +01:00
Andreas Heiduk
945b5e5e02 Remove support for XP specific config location
Current Git for Windows supports an additional configuration location
for system setting. On contemporary versionws of Windows this is
$PROGRAMDATA/Git/config. But XP does not know about $PRORGRAMDATA so
$ALLUSERSPROFILE/Application Data/Git/config was used.

XP itself is EOL for quite some time and Git for Windows ceased to
support it officially with version 2.10.0 (release 3 Sep 2016).

https://github.com/git-for-windows/git/wiki/FAQ#which-versions-of-windows-are-supported
https://git-for-windows.github.io/requirements.html

Signed-off-by: Andreas Heiduk <asheiduk@gmail.com>
2018-03-23 13:52:57 +01:00