Commit Graph

59690 Commits

Author SHA1 Message Date
Johannes Schindelin
0795f9535c Merge branch 'clean-long-paths'
This addresses https://github.com/git-for-windows/git/issues/521

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2016-06-07 09:10:35 +02:00
Johannes Schindelin
698c090461 Merge branch 'git-wrapper-interpolate'
There was a bug in the wrapper where it would interpolate incorrectly if
the name of the environment variable to expand was longer than the value.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2016-06-07 09:10:34 +02:00
Johannes Schindelin
886aeb688f Merge branch 'home-bin' 2016-06-07 09:10:33 +02:00
Johannes Schindelin
f73f359ad9 Merge branch 'conhost-git-bash' 2016-06-07 09:10:32 +02:00
Johannes Schindelin
5296dfd3fd Merge branch 'bash-redirector' 2016-06-07 09:10:31 +02:00
Johannes Schindelin
bd953a4811 Merge branch 'pinnable'
Part 2/3 of fixing https://github.com/git-for-windows/git/issues/263

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2016-06-07 09:10:30 +02:00
Johannes Schindelin
ae0efb4f49 Merge branch 'git-wrapper--command'
This topic branch adds the --command=<command> option that allows
starting the Git Bash (or Git CMD) with different terminal emulators
than the one encoded via embedded string resources.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2016-06-07 09:10:29 +02:00
Johannes Schindelin
6ea0e6791e Merge 'git-wrapper' into HEAD
Use msysGit's `git-wrapper` instead of the builtins. This works around
two issues:

- when the file system does not allow hard links, we would waste over
  800 megabyte by having 109 copies of a multi-megabyte executable

- even when the file system allows hard links, the Windows Explorer
  counts the disk usage as if it did not. Many users complained about
  Git for Windows using too much space (when it actually did not). We
  can easily avoid those user complaints by merging this branch.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2016-06-07 09:10:28 +02:00
Johannes Schindelin
adfa6cfced 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>
2016-06-07 09:10:27 +02:00
Johannes Schindelin
6bbf225e5b Merge 'unc-alternates' into HEAD 2016-06-07 09:10:26 +02:00
Johannes Schindelin
87e3af26a0 Merge pull request #552 from duncansmart/fix-vcproj-gen
Fix Visual Studio .sln/.vcproj generation.
2016-06-07 09:10:25 +02:00
Johannes Schindelin
6019496016 Merge pull request #487 from dscho/default-username
Improve the default user name & email logic
2016-06-07 09:10:23 +02:00
Johannes Schindelin
e2a2f3fd03 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>
2016-06-07 09:10:22 +02:00
Johannes Schindelin
f2d82ab3bc Merge pull request #443 from kblees/kb/nanosecond-file-times-v2.5.3
nanosecond file times for v2.5.3
2016-06-07 09:10:21 +02:00
Johannes Schindelin
d95a16ab6b Merge pull request #305 from dscho/msysgit_issues_182
Allow `add -p` and `add -i` with a large number of files
2016-06-07 09:10:20 +02:00
Johannes Schindelin
e6f0881adb Merge pull request #246 from uecasm/patch-1
Verify memoized files can be reloaded before using them
2016-06-07 09:10:19 +02:00
Johannes Schindelin
e275410d58 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>
2016-06-07 09:10:18 +02:00
Johannes Schindelin
e63c8d640b Merge pull request #159 from dscho/vagrant
Add Vagrant support (easy Linux VM setup)
2016-06-07 09:10:17 +02:00
Johannes Schindelin
5a02421876 Merge pull request #156 from kblees/kb/symlinks
Symlink support
2016-06-07 09:10:16 +02:00
Johannes Schindelin
49ba2434f6 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>
2016-06-07 09:10:15 +02:00
Johannes Schindelin
01d0418903 Merge 'readme' into HEAD
Add a README.md for GitHub goodness.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2016-06-07 09:10:14 +02:00
Johannes Schindelin
ea7d139f3c Merge 'fix-is-exe' into HEAD 2016-06-07 09:10:13 +02:00
Johannes Schindelin
9397cc4faf Merge 'fix-externals' into HEAD 2016-06-07 09:10:12 +02:00
Johannes Schindelin
4319b94733 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>
2016-06-07 09:10:11 +02:00
Johannes Schindelin
b4682b8fcf Merge 'win-tests-fixes' into HEAD 2016-06-07 09:10:10 +02:00
Johannes Schindelin
4430e01781 Merge 'msys2' into HEAD
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2016-06-07 09:10:09 +02:00
Johannes Schindelin
4b8f0b22a8 Merge 'jberezanski/wincred-sso-r2' into HEAD 2016-06-07 09:10:08 +02:00
Johannes Schindelin
21d3413446 Merge 'gitk' into HEAD 2016-06-07 09:10:07 +02:00
Johannes Schindelin
d0e711f4d2 Merge 'git-gui' into HEAD 2016-06-07 09:10:06 +02:00
Johannes Schindelin
16f962f3df Merge 'unicode' into HEAD 2016-06-07 09:10:04 +02:00
Johannes Schindelin
0a3d686b7f t7300: git clean -dfx must show an error with long paths
In particular on Windows, where the default maximum path length is quite
small, but there are ways to circumvent that limit in many cases, it is
very important that users be given an indication why their command
failed because of too long paths when it did.

This test case makes sure that a warning is issued that would have
helped the user who reported Git for Windows' issue 521:

	https://github.com/git-for-windows/git/issues/521

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2016-06-07 09:09:54 +02:00
Johannes Schindelin
99ffba8849 remove_dirs: do not swallow error when stat() failed
Without an error message when stat() failed, e.g. `git clean` would
abort without an error message, leaving the user quite puzzled.

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

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2016-06-07 09:09:53 +02:00
Johannes Schindelin
2ff7918292 git-wrapper: fix interpolation with short values
To be precise: when the value of the environment variable is shorter than
its name, we have to move the remaining bytes *after* expanding the
environment variable: we would look for the wrong name otherwise.

When the value is longer than the name, we still need to move the bytes
out of the way first, to avoid overwriting them with the interpolated
text.

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

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2016-06-07 09:09:52 +02:00
Johannes Schindelin
fc32feeb80 git-wrapper: make the interpolation code easier to understand
When moving bytes (because the name and the value of the environment
variable to interpolate differ in length), we introduce a variable to
unclutter the code and make it more obvious what is happening.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2016-06-07 09:09:51 +02:00
Johannes Schindelin
3cfef40c2b git-wrapper: simplify interpolation code
After we found the `@@` marker after the key to interpolate, we pretty
much only need the offset *after* the marker. So let's just advance it
instead of adding 2 in many places.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2016-06-07 09:09:51 +02:00
Johannes Schindelin
d75667c02f git-wrapper: append $HOME/bin to the PATH
`$HOME/bin/` is quite convenient a place to put user-specific Git
helpers, such as credential or remote helpers.

When run in Git Bash, it is therefore already appended to the PATH;
Let's do the equivalent when run in Git CMD: when `git.exe` is
called, Git is told to look also for scripts and programs in
`$HOME/bin` (this does not modify Git CMD's `PATH`, of course).

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

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2016-06-07 09:09:50 +02:00
Johannes Schindelin
f6d1be3cba git-wrapper: support COMSPEC better
The quoting rules of `cmd.exe` are really, really quirky. In particular,
if there are more than two quotes, the entire set of rules changes. That
is the reason why

	CMD /C "C:\Program Files\Git\usr\bin\bash.exe" -l -i

works, but

	CMD /C "C:\Program Files\Git\usr\bin\bash.exe" -l -i "test.sh"

fails with this error message:

	'C:\Program' is not recognized as an internal or external command,
	operable program or batch file.

The recommended fix is to pass the /S option to `cmd.exe` and surround
the entire command-line by an extra set of quotes. And here lies the
rub: for that to work, we have to append an extra quote. At the end of
the command-line. *After* the last argument was appended, if any.

This commit supports that use case by introducing the option
"APPEND_QUOTE". The intended usage is to use the following string
resource:

	SHOW_CONSOLE=1 APPEND_QUOTE=1
	@@COMSPEC@@ /S /C \"\"@@EXEPATH@@\\usr\\bin\\bash.exe\" --login -i

(Note that there are only three quotes on that command-line, the fourth
to be appended due to the `APPEND_QUOTE` setting.)

This is (1/3) to fix https://github.com/git-for-windows/git/issues/396

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2016-06-07 09:09:49 +02:00
Johannes Schindelin
136446ae7b mingw: let the Git wrapper determine the top-level directory
The Git wrapper is also used as a redirector for Git for Windows'
bin\bash.exe dropin: for backwards-compatibility, bin\bash.exe exists
and simply sets up the environment variables before executing the
*real* bash.

However, due to our logic to use the directory in which the `.exe`
lives as top-level directory (or one directory below for certain, known
basenames such as `git.exe` and `gitk.exe`), the `PATH` environment
variable was prefixed with the `/bin/bin` and `/bin/mingw/bin`
directories -- which makes no sense.

Instead, let's just auto-detect the top-level directory in the common
case.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2016-06-07 09:09:47 +02:00
Johannes Schindelin
0aad30a263 mingw: clean up the Git wrapper a bit
We should not conflate the 'exepath' with the 'top-level
directory'. The former should be the directory in which the executable
lives while the latter should be the top-level directory ("POSIX root
directory") as far as Git is concerned.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2016-06-07 09:09:47 +02:00
Johannes Schindelin
97be855990 git-wrapper: also allow setting the application ID
Windows 7 allows users to pin running applications to the task bar. By
setting the application ID, multiple processes can share a single task
bar entry, and this is exactly what we need for `git-bash.exe` which
wants to share the task bar entry with the `mintty.exe` instance it
launches.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2016-06-07 09:09:46 +02:00
Johannes Schindelin
431c6635f7 git-wrapper: leave the working directory alone by default
The idea of `git-bash.exe` automatically running the Git Bash in the
home directory was to support the start menu item `Git Bash` (which
should not start in C:\Program Files\Git, but in $HOME), and to make
that behavior consistent with double-clicking in `git-bash.exe`
portable Git.

However, it turns out that one of the main use cases of portable Git is
to run the Git Bash in GitHub for Windows, and it should start in the
top-level directory of a given project. Therefore, the concern to keep
double-clicking `git-bash.exe` consistent with the start menu item was
actually unfounded.

As to the start menu item: it can easily be changed to launch
`git-bash.exe` with a command-line option. So let's introduce the
--cd-to-home option for that purpose.

As a bonus, the Git wrapper can now also serve as a drop-in redirector
/bin/bash.exe to provide backwards-compatibility of Git for Windows 2.x
with 1.x: some 3rd-party software expects to find that executable there,
and it also expects it to leave the working directory unchanged.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2016-06-07 09:09:45 +02:00
Johannes Schindelin
c205287d42 git-wrapper: allow overriding the command to spawn via command-line args
By embedding string resources into the Git wrapper executable, it
can be configured to execute custom commands (after setting up the
environment in the way required for Git for Windows to work properly).
This feature is used e.g. for `git-bash.exe` which launches a Bash in
the configured terminal window.

Here, we introduce command-line options to override those string
resources. That way, a user can call `git-bash.exe` (which is a copy of
the Git wrapper with `usr\bin\bash.exe --login -i` embedded as string
resource) with command-line options that will override what command is
run.

ConEmu, for example, might want to call

	...\git-bash.exe --needs-console --no-hide --minimal-search-path ^
		--command=usr\\bin\\bash.exe --login -i

In particular, the following options are supported now:

--command=<command-line>::
	Executes `<command-line>` instead of the embedded string resource

--[no-]minimal-search-path::
	Ensures that only `/cmd/` is added to the `PATH` instead of
	`/mingw??/bin` and `/usr/bin/`, or not

--[no-]needs-console::
	Ensures that there is a Win32 console associated with the spawned
	process, or not

--[no-]hide::
	Hides the console window, or not

Helped-by: Eli Young <elyscape@gmail.com>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2016-06-07 09:09:44 +02:00
Johannes Schindelin
e33d433cc4 git wrapper: auto-grow buffer in expand_variables()
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2016-06-07 09:09:44 +02:00
Johannes Schindelin
714799ae60 git wrapper: refactor @@VAR@@ expansion into its own function
We will enhance the function in the next commit to support @@VAR@@
expansion in the upcoming `--command=<command>` option.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2016-06-07 09:09:43 +02:00
Johannes Schindelin
f44e8264aa git wrapper: refactor extraction of 1st arg into its own function
This will be reused by the upcoming `--command=<command>` option.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2016-06-07 09:09:43 +02:00
Nico Rieck
5e404f5440 git-wrapper: let git gui run in the background
This fixes https://github.com/git-for-windows/git/issues/172.

Signed-off-by: Nico Rieck <nico.rieck@gmail.com>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2016-06-07 09:09:42 +02:00
Karsten Blees
6f42d91b3d git-wrapper: don't set the console input code page
Using different code pages for console input (SetConsoleCP()) and console
output (SetConsoleOutputCP()) doesn't make much sense and may be hazardous
for native Windows programs.

Git uses UTF-8 internally, so it actually needs 'SetConsoleCP(CP_UTF8)'
rather than 'SetConsoleCP(GetACP())'. However, ReadFile() / ReadConsoleA()
are broken with CP_UTF8 (and thus any higher level APIs such as fgetc(),
getchar() etc.). Unicode-aware console input would have to be implemented
via mingw_* wrappers using ReadConsoleW(). As Git typically launches an
editor for anything more complex than ASCII-only, yes/no-style questions,
this is currently not a problem.

Drop 'SetConsoleCP()' from the git-wrapper, so that input and output code
pages stay in sync.

Signed-off-by: Karsten Blees <blees@dcon.de>
2016-06-07 09:09:42 +02:00
Johannes Schindelin
e57e97cc45 git-wrapper: support the non-mintty fall-back for Git Bash
When we fall back to starting the Git Bash in the regular Windows
console, we need to show said console's window... So let's introduce yet
another configuration knob for use via string resources.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2016-06-07 09:09:41 +02:00
Johannes Schindelin
4b39e93498 git wrapper: allow _Git Bash_ to run with a newly allocated console
With a recent change in Cygwin (which is the basis of the msys2-runtime),
a GUI process desiring to launch an MSys2 executable needs to allocate a
console for the new process (otherwise the process will just hang on
Windows XP). _Git Bash_ is such a GUI process.

While at it, use correct handles when inheriting the stdin/stdout/stderr
handles: `GetStdHandle()` returns NULL for invalid handles, but the
STARTUPINFO must specify `INVALID_HANDLE_VALUE` instead.

Originally, the hope was that only this `NULL` => `INVALID_HANDLE_VALUE`
conversion would be required to fix the Windows XP issue mentioned above
(extensive debugging revealed that starting _Git Bash_ on Windows XP would
yield invalid handles for `stdin` and `stderr`, but *not* for `stdout`).

However, while _Git Bash_ eventually showed a `mintty` when not allocating
a new console, it took around one second to show it, and several seconds
to close it. So let's just include both fixes.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2016-06-07 09:09:41 +02:00
Johannes Schindelin
6bf3b09f2f git-wrapper: prepare to allow more options than MINIMAL_PATH
With the resource-driven command-line configuration, we introduced the
option to ensure that only the PATH environment variable is edited only
minimally, i.e. only /cmd/ is added (as appropriate for _Git CMD_).

We are about to add another option, so let's refactor the equivalent of
Git's `strip_prefix()` function; It is not *quite* the same because we
have to `memmove()` the remainder to the beginning of the buffer.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2016-06-07 09:09:40 +02:00