Commit Graph

49371 Commits

Author SHA1 Message Date
nalla
caaae01999 git-wrapper: support git.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>
2015-03-30 15:10:38 +01:00
Johannes Schindelin
e992745d61 Merge branch 'git-wrapper-revisited'
This undoes the contentious Git wrapper changes I made earlier, and
retains just the bare minimum to equip the Portable Application with a
Git Bash and a Git CMD.

The resource editing has been taken out, i.e. there is no longer a way
to reconfigure on the command-line which terminal emulator is used by
the Git Bash.

While at it, also fix the problems with the Git wrapper when serving as
replacement for the hardlinked builtins which were pointed out by Philip
Oakley in Git for Windows issue 52.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2015-03-28 22:58:31 +01:00
Johannes Schindelin
be311e2381 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>
2015-03-28 19:15:57 +01:00
Johannes Schindelin
4766c3db08 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>
2015-03-28 19:04:24 +01:00
Johannes Schindelin
b072d688cf 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>
2015-03-28 19:04:21 +01:00
Johannes Schindelin
83553058ba 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>
2015-03-28 19:04:19 +01:00
Johannes Schindelin
2ac10bd7c5 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>
2015-03-28 19:04:17 +01:00
Johannes Schindelin
41c1e1f32c 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>
2015-03-28 19:04:16 +01:00
Johannes Schindelin
1b1e072595 fixup! git-wrapper: add code to configure command-lines to be launched
The intention of this change was to make it easier for the Git for
Windows installer, or for power Git users, to change the command-line
launched when executing Git Bash. The idea was to allow reconfiguring
the Git Bash to run different terminals than MSys2's default, mintty.

However, the comments this commit got let no room for misunderstanding:
at least three developers who gained trust by being active in the Git
for Windows offered their vetoes.

RIP, resource editor.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2015-03-28 19:04:13 +01:00
Johannes Schindelin
c5cdad2f8d fixup! git-wrapper: allow the edit-res.exe copy to change icons, too
Instead of making it possible to change the .exe icon of git-bash.exe or
git-cmd.exe, this change was compared to adding the option to format USB
drives.

Let's get rid of this change, therefore, before real people are harmed.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2015-03-28 19:04:12 +01:00
Johannes Schindelin
580472680d git-wrapper: inherit stdin/stdout/stderr even without a console
Otherwise the output of Git commands cannot be caught by, say, Git GUI
(because it is running detached from any console, which would make
`git.exe` inherit the standard handles implicitly).

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2015-03-28 19:03:31 +01:00
dscho
521863b6ee Merge pull request #42 from dscho/msys2-wrapper
git-wrapper: support MSys2
2015-03-26 08:19:41 +00:00
Johannes Schindelin
35e219dff2 git-wrapper: allow the edit-res.exe copy to change icons, too
As we already allow changing text resources, it is a very small step to
allow changing the `.exe` icon, too.

So let's just do it.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2015-03-26 09:05:14 +01:00
Johannes Schindelin
304d297463 git-wrapper: add code to configure command-lines to be launched
To allow the Git wrapper to replace the `git-bash.bat` script (which
would always open the Win32 console, even if the user wants to use a
different terminal emulator), we need to offer a way to configure
*which* command-line to run.

We need to recompile the git-wrapper with the `-mwindows` flag to
declare that this is a GUI program (not a console program). Having to
recompile it anyway, let's put the new code in a conditionally compiled
section so that the builtins (for which we use the git-wrapper, too) do
not need to carry around that code.

To configure the command-line, we use a way that is very typical for
Windows: resources. Windows resources are data that are stored inside
.exe files, but can be changed *after* compilation. Therefore, this
facility is *exactly* what we want: we can easily copy the .exe to the
new name `git-bash.exe`, configure that executable to run the Bash, and
then copy it again to the new name `git-cmd.exe` and configure that
executable to run `cmd.exe` instead.

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.

Sadly, an executable cannot configure itself: the `.exe` file is locked
while the process is running. This means we have to have a separate
executable to edit the resources anyway, so let's just enhance the Git
wrapper *itself*: when copied to the new name `edit-res.exe`, it can
edit other copies of the Git wrapper like so:

	edit-res.exe git-cmd.exe command '@@COMSPEC@@ /K'

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2015-03-26 09:05:12 +01:00
Johannes Schindelin
d7ff2b2b16 git-wrapper: prepare for executing configurable command-lines
We are about to use the Git wrapper to call the Git Bash of Git for
Windows. All the wrapper needs to do for that is to set up the
environment variables, use the home directory as working directory and
then hand off to a user-specified command-line.

We prepare the existing code for this change by introducing flags to set
up the environment variables, to launch a non-Git program, and to use
the home directory as working directory.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2015-03-26 09:05:11 +01:00
Johannes Schindelin
9dbe2649f7 git-wrapper: support MSys2
The original purpose of the Git wrapper is to run from inside Git for
Windows' /cmd/ directory, to allow setting up some environment variables
before Git is allowed to take over.

Due to differences in the file system layout, MSys2 requires some
changes for that to work.

In addition, we must take care to set the `MSYSTEM` environment variable
to `MINGW32` or `MINGW64`, respectively, to allow MSys2 to be configured
correctly in case Git launches a shell or Perl script.

We also need to change the `TERM` variable to `cygwin` instead of
`msys`, otherwise the pager `less.exe` (spawned e.g. by `git log`) will
simply crash with a message similar to this one:

	1 [main] less 9832 cygwin_exception::open_stackdumpfile:
	Dumping stack trace to less.exe.stackdump

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2015-03-26 09:00:18 +01:00
Johannes Schindelin
4f5f8566a8 fixup! Let the Git wrapper serve as a drop-in replacement for builtins
Prepare to prefix the command-line with non-builtins. We are now using
the Git wrapper to call non-Git programs, too.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2015-03-25 20:22:22 +01:00
Johannes Schindelin
a938a03450 fixup! mingw: Fix git-svn tests 2015-03-24 16:03:41 +01:00
nalla
1a5e8bdaba Merge pull request #38 from dscho/mingw-environment
Fix access violations when cloning/fetching via HTTPS
2015-03-24 11:25:18 +01:00
nalla
3595b7c304 Merge pull request #40 from nalla/git-terminal-prompt
mingw: Proper `git_terminal_prompt` with `xterm`
2015-03-24 11:25:17 +01:00
nalla
73a6656b63 Merge 'poll_inftim' into HEAD
This was originally 'pull request #330 from ethomson/poll_inftim' in
msysgit/git.

poll: honor the timeout on Win32

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2015-03-24 11:25:16 +01:00
nalla
c862c02042 Merge pull request #34 from dscho/git-wrapper
Use msysGit's `git-wrapper` instead of the builtins
2015-03-24 11:25:15 +01:00
nalla
d8efbc0c0d Merge 'non-win-fixes' into HEAD 2015-03-24 11:25:14 +01:00
nalla
caf2670ac8 Merge pull request #239 from sschuberth/taskkill
git-gui/gitk: Do not use a Cygwin-specific kill flag on Windows
2015-03-24 11:25:13 +01:00
nalla
bb4d5734e1 Merge pull request #122 from kblees/kb/long-paths-v2
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2015-03-24 11:25:13 +01:00
nalla
db8cbf020b Merge remote-tracking branch 'kblees/kb/fscache-v4-tentative-1.8.5' into thicket-1.8.5.2 2015-03-24 11:25:12 +01:00
nalla
c18adde009 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-24 11:25:11 +01:00
nalla
a6920995b9 Merge pull request #24 from gitter-badger/gitter-badge
Add a Gitter chat badge to README.md
2015-03-24 11:25:10 +01:00
nalla
7c08957c9f Merge pull request #14 from dscho/readme
Add a README.md for GitHub goodness.
2015-03-24 11:25:09 +01:00
nalla
d4519e9ba3 Merge 'fix-is-exe' into HEAD 2015-03-24 11:25:08 +01:00
nalla
d4c0906811 Merge 'fix-externals' into HEAD 2015-03-24 11:25:08 +01:00
nalla
e170e22a1c 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-24 11:25:07 +01:00
nalla
6a88513756 Merge 'win-tests-fixes' into HEAD 2015-03-24 11:25:06 +01:00
nalla
e469731d24 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-24 11:25:05 +01:00
nalla
1dd7778fbb Merge pull request #28 from dscho/tty-handles
Teach msys2-runtime to hand the tty through to Git
2015-03-24 11:25:04 +01:00
nalla
e60734d01e Merge pull request #33 from dscho/manifest
Embed a manifest into git.exe
2015-03-24 11:25:03 +01:00
nalla
42b1fc6095 Merge pull request #26 from dscho/msys2
Fixes required to build Git for Windows with MSys2
2015-03-24 11:25:02 +01:00
nalla
f96acd3889 Merge 'pull-rebase-interactive' into HEAD 2015-03-24 11:25:01 +01:00
nalla
f9fc855959 Merge 'jberezanski/wincred-sso-r2' into HEAD 2015-03-24 11:25:00 +01:00
nalla
88f75d5db2 Merge 'gitweb-syntax' into HEAD 2015-03-24 11:25:00 +01:00
nalla
31961d60dd Merge 'gitk' into HEAD 2015-03-24 11:24:59 +01:00
nalla
781f39f395 Merge 'git-gui' into HEAD 2015-03-24 11:24:58 +01:00
nalla
434790165f Merge 'criss-cross-merge' into HEAD 2015-03-24 11:24:58 +01:00
nalla
bcffd8382a Merge 'am-submodules' into HEAD 2015-03-24 11:24:57 +01:00
nalla
c2535cebe7 Merge 'hide-dotgit' into HEAD 2015-03-24 11:24:56 +01:00
nalla
f271353394 Merge 'unicode' into HEAD 2015-03-24 11:24:56 +01:00
nalla
213873eafd Merge 'refs/rewritten/junio/notyet' into HEAD 2015-03-24 11:24:55 +01:00
Johannes Schindelin
94140406bd mingw: be *very* wary about outside environment changes
The environment is modified in most surprising circumstances, and not
all of them are under Git's control. For example, calling
curl_global_init() on Windows will ensure that the CHARSET variable is
set, adding one if necessary.

While the previous commit worked around crashes triggered by such
outside changes of the environment by relaxing the requirement that the
environment be terminated by a NULL pointer, the other assumption made
by `mingw_getenv()` and `mingw_putenv()` is that the environment is
sorted, for efficient lookup via binary search.

Let's make real sure that our environment is intact before querying or
modifying it, and reinitialize our idea of the environment if necessary.

With this commit, before working on the environment we look briefly for
indicators that the environment was modified outside of our control, and
to ensure that it is terminated with a NULL pointer and sorted again in
that case.

Note: the indicators are maybe not sufficient. For example, when a
variable is removed, it will not be noticed. It might also be a problem
if outside changes to the environment result in a modified `environ`
pointer: it is unclear whether such a modification could result in a
problem when `mingw_putenv()` needs to `realloc()` the environment
buffer.

For the moment, however, the current fix works well enough, so let's
only face the potential problems when (and if!) they occur.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2015-03-24 11:24:54 +01:00
Johannes Schindelin
9741b0772a mingw: be more defensive when making the environment block
Outside of our Windows-specific code, the end of the environment can be
marked also by a pointer to a NUL character, not only by a NULL pointer
as our code assumed so far.

That led to a buffer overrun in `make_environment_block()` when running
`git-remote-https` in `mintty` (because `curl_global_init()` added the
`CHARSET` environment variable *outside* of `mingw_putenv()`, ending the
environment in a pointer to an empty string).

Side note for future debugging on Windows: when running programs in
`mintty`, the standard input/output/error is not connected to a Win32
Console, but instead is pipe()d. That means that even stderr may not be
written completely before a crash, but has to be fflush()ed explicitly.
For example, when debugging crashes, the developer should insert an
`fflush(stderr);` at the end of the `error()` function defined in
usage.c.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2015-03-24 11:24:53 +01:00
Johannes Schindelin
c301336487 UTF-8 environment: be a little bit more defensive
It is unlikely that we have an empty environment, ever, but *if* we do,
when `environ_size - 1` is passed to `bsearchenv()` it is misinterpreted
as a real large integer.

To make the code truly defensive, refuse to do anything at all if the
size is negative (which should not happen, of course).

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2015-03-24 11:24:53 +01:00