Commit Graph

57727 Commits

Author SHA1 Message Date
Johannes Schindelin
1e28e40966 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-03-18 01:11:20 +01:00
Johannes Schindelin
66540b4dcc 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-03-18 01:11:20 +01:00
Johannes Schindelin
e59903fb01 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-03-18 01:11:19 +01:00
Johannes Schindelin
e6faa23ee8 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-03-18 01:11:19 +01:00
Johannes Schindelin
32934de102 Merge 'unc-alternates' into HEAD 2016-03-18 01:11:18 +01:00
Johannes Schindelin
57b69ff45f Merge pull request #552 from duncansmart/fix-vcproj-gen
Fix Visual Studio .sln/.vcproj generation.
2016-03-18 01:11:18 +01:00
Johannes Schindelin
31c7fe07d9 Merge pull request #487 from dscho/default-username
Improve the default user name & email logic
2016-03-18 01:11:17 +01:00
Johannes Schindelin
07321ad0da Merge pull request #486 from dscho/mmap-no-error
Better mmap() emulation
2016-03-18 01:11:17 +01:00
Johannes Schindelin
0026db21ad 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-03-18 01:11:16 +01:00
Johannes Schindelin
8dd91a1208 Merge pull request #443 from kblees/kb/nanosecond-file-times-v2.5.3
nanosecond file times for v2.5.3
2016-03-18 01:11:16 +01:00
Johannes Schindelin
b9f7266b1a Merge pull request #305 from dscho/msysgit_issues_182
Allow `add -p` and `add -i` with a large number of files
2016-03-18 01:11:15 +01:00
Johannes Schindelin
f94f9a7d48 Merge pull request #246 from uecasm/patch-1
Verify memoized files can be reloaded before using them
2016-03-18 01:11:14 +01:00
Johannes Schindelin
7d58626a20 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-03-18 01:11:14 +01:00
Johannes Schindelin
357d595cf6 Merge pull request #159 from dscho/vagrant
Add Vagrant support (easy Linux VM setup)
2016-03-18 01:11:13 +01:00
Johannes Schindelin
bb22d77711 Merge pull request #156 from kblees/kb/symlinks
Symlink support
2016-03-18 01:11:13 +01:00
Johannes Schindelin
97ec4396ce 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-03-18 01:11:12 +01:00
Johannes Schindelin
cf308460c2 Merge 'readme' into HEAD
Add a README.md for GitHub goodness.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2016-03-18 01:11:12 +01:00
Johannes Schindelin
4c1bf497cd Merge 'fix-is-exe' into HEAD 2016-03-18 01:11:11 +01:00
Johannes Schindelin
672c146767 Merge 'fix-externals' into HEAD 2016-03-18 01:11:11 +01:00
Johannes Schindelin
2069d2fe40 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-03-18 01:11:10 +01:00
Johannes Schindelin
f401c9da2f Merge 'win-tests-fixes' into HEAD 2016-03-18 01:11:10 +01:00
Johannes Schindelin
fd85758ba8 Merge 'msys2' into HEAD
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2016-03-18 01:11:09 +01:00
Johannes Schindelin
29e4312fc5 Merge 'jberezanski/wincred-sso-r2' into HEAD 2016-03-18 01:11:09 +01:00
Johannes Schindelin
1e07495202 Merge 'gitk' into HEAD 2016-03-18 01:11:08 +01:00
Johannes Schindelin
ed92db270d Merge 'git-gui' into HEAD 2016-03-18 01:11:08 +01:00
Johannes Schindelin
93cf1f436e Merge 'hide-dotgit' into HEAD 2016-03-18 01:11:07 +01:00
Johannes Schindelin
fddeb35fe0 Merge 'unicode' into HEAD 2016-03-18 01:11:07 +01:00
Johannes Schindelin
83c5d448c0 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-03-18 01:10:49 +01:00
Johannes Schindelin
dde58d4068 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-03-18 01:10:48 +01:00
Johannes Schindelin
211ac797e7 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-03-18 01:10:47 +01:00
Johannes Schindelin
6a2769c2cb git wrapper: auto-grow buffer in expand_variables()
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2016-03-18 01:10:46 +01:00
Johannes Schindelin
0f24d74053 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-03-18 01:10:46 +01:00
Johannes Schindelin
4721574396 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-03-18 01:10:45 +01:00
Nico Rieck
e028d3eb3b 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-03-18 01:10:44 +01:00
Karsten Blees
e25a9fec7d 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-03-18 01:10:43 +01:00
Johannes Schindelin
5a2b6f0302 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-03-18 01:10:43 +01:00
Johannes Schindelin
13f188f426 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-03-18 01:10:42 +01:00
Johannes Schindelin
e7c1ba0c36 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-03-18 01:10:42 +01:00
Karsten Blees
a80664b562 git-wrapper: remove redundant TERM initialization
Remove redundant TERM initialization from git-wrapper in favor of TERM
initialization in git itself.

Signed-off-by: Karsten Blees <blees@dcon.de>
2016-03-18 01:10:41 +01:00
Karsten Blees
f54ed96b91 git-wrapper: fix HOME initialization
git-wrapper fails to initialize HOME correctly if $HOMEDRIVE$HOMEPATH
points to a disconnected network drive.

Check if the directory exists before using $HOMEDRIVE$HOMEPATH.

Signed-off-by: Karsten Blees <blees@dcon.de>
2016-03-18 01:10:41 +01:00
Vitaly Takmazov
d453338e76 git-wrapper: case-insensitive path comparison 2016-03-18 01:10:40 +01:00
Johannes Schindelin
3da87d9188 git-wrapper: interpret --cd=<directory> when configured via resources
This change accompanies the `--no-cd` option when configured via
resources. It is required to support `Git Bash Here`: when
right-clicking an icon in the Explorer to start a Bash, the working
directory is actually the directory that is displayed in the Explorer.
That means if the clicked icon actually refers to a directory, the
working directory would be its *parent* directory.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2016-03-18 01:10:39 +01:00
Johannes Schindelin
944192580b git-wrapper: serve as git-gui.exe, too
To avoid that ugly Console window when calling \cmd\git.exe gui...

To avoid confusion with builtins, we need to move the code block
handling gitk (and now git-gui, too) to intercept before git-gui is
mistaken for a builtin.

Unfortunately, git-gui is in libexec/git-core/ while gitk is in bin/,
therefore we need slightly more adjustments than just moving and
augmenting the gitk case.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2016-03-18 01:10:39 +01:00
nalla
e949d01764 git-wrapper: support git.exe and gitk.exe to be in a spaced dir
When *Git for Windows* is installed into a directory that has spaces in
it, e.g. `C:\Program Files\Git`, the `git-wrapper` appends this directory
unquoted when fixing up the command line. To resolve this, just quote the
provided `execpath`.

Signed-off-by: nalla <nalla@hamal.uberspace.de>
2016-03-18 01:10:38 +01:00
Johannes Schindelin
352d19e8d7 git-wrapper: Allow git-cmd.exe to add only /cmd/ to the PATH
The idea of having the Git wrapper in the /cmd/ directory is to allow
adding only a *tiny* set of executables to the search path, to allow
minimal interference with other software applications. It is quite
likely, for example, that other software applications require their own
version of zlib1.dll and would not be overly happy to find the version
Git for Windows ships.

The /cmd/ directory also gives us the opportunity to let the Git wrapper
handle the `gitk` script. It is a Tcl/Tk script that is not recognized
by Windows, therefore calling `gitk` in `cmd.exe` would not work, even
if we add all of Git for Windows' bin/ directories.

So let's use the /cmd/ directory instead of adding /mingw??/bin/ and
/usr/bin/ to the PATH when launching Git CMD.

The way we implemented Git CMD is to embed the appropriate command line
as string resource into a copy of the Git wrapper. Therefore we extended
that syntax to allow for configuring a minimal search path.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2016-03-18 01:10:38 +01:00
Johannes Schindelin
64c9607a65 git-wrapper: optionally skip cd $HOME when configured via resources
We recently added the ability to configure copies of the Git wrapper to
launch custom command-lines, configured via plain old Windows resources.
The main user is Git for Windows' `git-bash.exe`, of course. When the
user double-clicks the `git bash` icon, it makes sense to start the Bash
in the user's home directory.

Third-party software, such as TortoiseGit or GitHub for Windows, may
want to start the Git Bash in another directory, though.

Now, when third-party software wants to call Git, they already have to
construct a command-line, and can easily pass a command-line option
`--no-cd` (which this commit introduces), and since that option is not
available when the user double-clicks an icon on the Desktop or in the
Explorer, let's keep the default to switch to the home directory if the
`--no-cd` flag was not passed along.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2016-03-18 01:10:37 +01:00
Johannes Schindelin
176848f4de git-wrapper: make command-line argument skipping more robust
When we rewrite the command-line to call the *real* Git, we want to skip
the first command-line parameter. The previous code worked in most
circumstances, but was a bit fragile because it assumed that no fancy
quoting would take place.

In the next commit, we will want to have the option to skip more than
just one command-line parameter, so we have to be much more careful with
the command-line handling.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2016-03-18 01:10:36 +01:00
Johannes Schindelin
15e4eafb45 git-wrapper: remove 'gui' and 'citool' handling
In the meantime, Git for Windows learned to handle those subcommands
quite well itself; There is no longer a need to special-case them in the
wrapper.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2016-03-18 01:10:36 +01:00
Johannes Schindelin
6798e59798 Let the Git wrapper replace cmd\gitk.cmd, too
In a push to polish Git for Windows more, we are moving away from
scripts toward proper binaries.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2016-03-18 01:10:35 +01:00
Johannes Schindelin
098617e46d Git wrapper: allow overriding what executable is called
The Git wrapper does one thing, and does it well: setting up the
environment required to run Git and its scripts, and then hand off to
another program.

We already do this for the Git executable itself; in Git for Windows'
context, we have exactly the same need also when calling the Git Bash or
Git CMD. However, both are tied to what particular shell environment you
use, though: MSys or MSys2 (or whatever else cunning developers make
work for them). This means that the Git Bash and Git CMD need to be
compiled in the respective context (e.g. when compiling the
mingw-w64-git package in the MSys2 context).

Happily, Windows offers a way to configure compiled executables:
resources. So let's just look whether the current executable has a
string resource and use it as the command-line to execute after the
environment is set up. To support MSys2's Git Bash better (where
`mintty` should, but might not, be available), we verify whether the
specified executable exists, and keep looking for string resources if it
does not.

For even more flexibility, we expand environment variables specified as
`@@<VARIABLE-NAME>@@`, and for convenience `@@EXEPATH@@` expands into
the directory in which the executable resides.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2016-03-18 01:10:35 +01:00