Commit Graph

63619 Commits

Author SHA1 Message Date
Johannes Schindelin
7a57a2a8b2 Let the Git wrapper serve as a drop-in replacement for builtins
Git started out as a bunch of separate commands, in the true Unix spirit.
Over time, more and more functionality was shared between the different
Git commands, though, so it made sense to introduce the notion of
"builtins": programs that are actually integrated into the main Git
executable.

These builtins can be called in two ways: either by specifying a
subcommand as the first command-line argument, or -- for backwards
compatibility -- by calling the Git executable hardlinked to a filename
of the form "git-<subcommand>". Example: the "log" command can be called
via "git log <parameters>" or via "git-log <parameters>". The latter
form is actually deprecated and only supported for scripts; calling
"git-log" interactively will not even work by default because the
libexec/git-core/ directory is not in the PATH.

All of this is well and groovy as long as hard links are supported.

Sadly, this is not the case in general on Windows. So it actually hurts
quite a bit when you have to fall back to copying all of git.exe's
currently 7.5MB 109 times, just for backwards compatibility.

The simple solution would be to install really trivial shell script
wrappers in place of the builtins:

	for builtin in $BUILTINS
	do
		rm git-$builtin.exe
		printf '#!/bin/sh\nexec git %s "$@"\n' $builtin > git-builtin
		chmod a+x git-builtin
	done

This method would work -- even on Windows because Git for Windows ships a
full-fledged Bash. However, the Windows Bash comes at a price: it needs to
spin up a full-fledged POSIX emulation layer everytime it starts.
Therefore, the shell script solution would incur a significant performance
penalty.

The best solution the Git for Windows team could come up with is to extend
the Git wrapper -- that is needed to call Git from cmd.exe anyway, and
that weighs in with a scant 19KB -- to also serve as a drop-in replacement
for the builtins so that the following workaround is satisfactory:

	for builtin in $BUILTINS
	do
		cp git-wrapper.exe git-$builtin.exe
	done

This commit allows for this, by extending the module file parsing to
turn builtin command names like `git-log.exe ...` into calls to the main
Git executable: `git.exe log ...`.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2016-08-13 07:35:31 +02:00
Johannes Schindelin
baca8fc1cf 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>
2016-08-13 07:35:30 +02:00
Johannes Schindelin
af09784198 mingw: Compile the Git wrapper
We take care to embed the manifest, too, because we will modify the
wrapper in the next few commits to serve as a drop-in replacement for
the built-ins, i.e. we will want to call the wrapper under names such
as 'git-patch-id.exe', too.

To allow 32-bit and 64-bit builds in the same directory, we let
git-wrapper.o depend on GIT-PREFIX so that it gets recompiled when
compiling for a different architecture.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2016-08-13 07:35:30 +02:00
Johannes Schindelin
fa4297826a 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>
2016-08-13 07:35:29 +02:00
Gaël Lhez
58feffd447 git bundle create <bundle> leaks handle the revlist is empty.
issue #790: git bundle create does not close handle to *.lock file

This problem happens when an user tries to create an empty bundle, using the
following command:  `git bundle create <bundle> <revlist>` and when <revlist>
resolve to an empty list (for example, like `master..master`), `git bundle` fails
and warn the user about how it don't want to create empty bundle.

In that case, git tries to delete the `<bundle>.lock` file, and since there's still
an open file handle, fails to do so and ask the user if it should retry (which will
fail again).

The lock can still be deleted manually by the user (and it is required if the user
want to create a bundle after revising his rev-list).

Signed-off-by: Gaël Lhez <gael.lhez@gmail.com>
2016-08-13 07:35:27 +02:00
Johannes Schindelin
2ae39965c6 gc/repack: release packs when needed
On Windows, files cannot be removed nor renamed if there are still
handles held by a process. To remedy that, we introduced the
close_all_packs() function.

Earlier, we made sure that the packs are released just before `git gc`
is spawned, in case that gc wants to remove no-longer needed packs.

But this developer forgot that gc itself also needs to let go of packs,
e.g. when consolidating all packs via the --aggressive option.

Likewise, `git repack -d` wants to delete obsolete packs and therefore
needs to close all pack handles, too.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2016-08-13 07:35:25 +02:00
Ben Wijen
1d70d9423f Make sure temporary file handles are not inherited by child processes
When testing a merge driver which spawns a merge server (for future merges)
I got the following error:

    Rename from 'xxx/.git/index.lock' to 'xxx/.git/index' failed. Should I try again? (y/n)

Only after I stop the merge server the lock is released.
This is caused by windows handle inheritance.

Starting childs with bInheritHandles==FALSE does not work,
because no file handles would be inherited,
not even the hStdXxx handles in STARTUPINFO.

Opening every file with O_NOINHERIT does not work,
Since it is used by git-upload-pack for example,
which expects inherited handles.

This leaves us with only creating temp files with the O_NOINHERIT flag.
Which (currently) only used by lock_file which is exactly what we want.


Signed-off-by: Ben Wijen <ben@wijen.net>
2016-08-13 07:35:23 +02:00
Ben Wijen
17af49a90a Add index.lock test to t/t6026-merge-attr.sh
This test was added to verify the behaviour of merge
when a merge server is spawned.

Because file handles are inherited by child processes,
the index.lock is also inherited and - on win32 - can't
be released until the child has stopped.

Signed-off-by: Ben Wijen <ben@wijen.net>
2016-08-13 07:35:22 +02:00
Orgad Shaneh
2f82475baf git-gui: Do not reset author details on amend
git commit --amend preserves the author details unless --reset-author is
given.

git-gui discards the author details on amend.

Fix by reading the author details along with the commit message, and
setting the appropriate environment variables required for preserving
them.

Reported long ago in the mailing list[1].

[1] http://article.gmane.org/gmane.comp.version-control.git/243921

Signed-off-by: Orgad Shaneh <orgad.shaneh@audiocodes.com>
2016-08-13 07:35:20 +02:00
Johannes Schindelin
35eb599816 mingw: support spawning programs containing spaces in their names
The CreateProcessW() function does not really support spaces in its
first argument, lpApplicationName. But it supports passing NULL as
lpApplicationName, which makes it figure out the application from the
(possibly quoted) first argument of lpCommandLine.

Let's use that trick (if we are certain that the first argument matches
the executable's path) to support launching programs whose path contains
spaces.

This fixes https://github.com/git-for-windows/git/issue/692

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2016-08-13 07:35:17 +02:00
Johannes Schindelin
206769e855 Merge pull request #677 from yaras/fix-git-675
Fixed masking username with asterisks when reading credentials
2016-08-13 07:35:16 +02:00
Johannes Schindelin
fd044c3c6c Merge pull request #665 from yaras/fix-git-664
Fix initial git gui message encoding
2016-08-13 07:35:15 +02:00
Johannes Schindelin
a223a4f3d2 Merge 'git-gui-add-2nd-line' into HEAD 2016-08-13 07:35:14 +02:00
Johannes Schindelin
e5d32ab6b3 Merge pull request #620 from sidecut/sidecut-gitk-list-references-window-width
Make the "list references" default window width wider
2016-08-13 07:35:14 +02:00
Johannes Schindelin
f4efd3c8cd Merge branch 'gitk-cursor-keys'
This patch needs to be contributed to gitk proper, of course.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2016-08-13 07:35:13 +02:00
Johannes Schindelin
0476fd79fa 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-08-13 07:35:12 +02:00
Johannes Schindelin
4eee80620f 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-08-13 07:35:11 +02:00
Johannes Schindelin
3cf2464b16 Merge 'unc-alternates' into HEAD 2016-08-13 07:35:10 +02:00
Johannes Schindelin
2b7e4aaf37 Merge pull request #552 from duncansmart/fix-vcproj-gen
Fix Visual Studio .sln/.vcproj generation.
2016-08-13 07:35:09 +02:00
Johannes Schindelin
c550db7316 Merge 'mingw/default-ident'
Improve the default user name & email logic

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2016-08-13 07:35:08 +02:00
Johannes Schindelin
0b3ce76f6d 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-08-13 07:35:08 +02:00
Johannes Schindelin
e11359c840 Merge pull request #443 from kblees/kb/nanosecond-file-times-v2.5.3
nanosecond file times for v2.5.3
2016-08-13 07:35:07 +02:00
Johannes Schindelin
31506bd4b8 Merge pull request #305 from dscho/msysgit_issues_182
Allow `add -p` and `add -i` with a large number of files
2016-08-13 07:35:06 +02:00
Johannes Schindelin
f9546a076d Merge pull request #246 from uecasm/patch-1
Verify memoized files can be reloaded before using them
2016-08-13 07:35:05 +02:00
Johannes Schindelin
38325419a2 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-08-13 07:35:04 +02:00
Johannes Schindelin
96e6ab586f Merge pull request #159 from dscho/vagrant
Add Vagrant support (easy Linux VM setup)
2016-08-13 07:35:04 +02:00
Johannes Schindelin
59f27208bf Merge 'mingw-getcwd' into HEAD 2016-08-13 07:35:03 +02:00
Johannes Schindelin
79bda3d38e Merge pull request #156 from kblees/kb/symlinks
Symlink support
2016-08-13 07:35:02 +02:00
Johannes Schindelin
ac3c63f035 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-08-13 07:35:01 +02:00
Johannes Schindelin
6d0e0d17b1 Merge 'fix-is-exe' into HEAD 2016-08-13 07:35:00 +02:00
Johannes Schindelin
87f0b1fc13 Merge 'fix-externals' into HEAD 2016-08-13 07:34:59 +02:00
Johannes Schindelin
11af6544af 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-08-13 07:34:59 +02:00
Johannes Schindelin
88634d6d3d Merge 'win-tests-fixes' into HEAD 2016-08-13 07:34:58 +02:00
Johannes Schindelin
4df8320eda Merge 'msys2' into HEAD
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2016-08-13 07:34:57 +02:00
Johannes Schindelin
2a8e28b4d2 Merge 'jberezanski/wincred-sso-r2' into HEAD 2016-08-13 07:34:56 +02:00
Johannes Schindelin
12289a2181 Merge 'gitk' into HEAD 2016-08-13 07:34:55 +02:00
Johannes Schindelin
a011e48a5b Merge 'git-gui' into HEAD 2016-08-13 07:34:55 +02:00
Johannes Schindelin
76ce871e4b Merge 'unicode' into HEAD 2016-08-13 07:34:54 +02:00
Johannes Schindelin
e9ffb9ffd6 Merge 'jk/common-main'
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2016-08-13 07:34:53 +02:00
Johannes Schindelin
432c5a605f Merge 'readme' into HEAD
Add a README.md for GitHub goodness.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2016-08-13 07:34:52 +02:00
yaras
68fde6de64 Do not mask the username when reading credentials
When user is asked for credentials there is no need to mask username,
so PROMPT_ASKPASS flag on calling credential_ask_one for login is
unnecessary.

credential_ask_one internally uses git_prompt which in case of given
flag PROMPT_ASKPASS uses masked input method instead of
git_terminal_prompt, which does not mask user input.

This fixes #675

Signed-off-by: yaras <yaras6@gmail.com>
2016-08-13 07:34:50 +02:00
yaras
672ccb7b74 Fix initial git gui message encoding
This fix refers https://github.com/git-for-windows/git/issues/664

After `git merge --squash` git creates .git/SQUASH_MSG (UTF-8 encoded)
which contains squashed commits. When run `git gui` it copies SQUASH_MSG
to PREPARE_COMMIT_MSG, but without honoring UTF-8. This leads to encoding
problems on `git gui` commit prompt.

The same applies on git cherry-pick conflict, where MERGE_MSG is created
and then is copied to PREPARE_COMMIT_MSG.

In both cases PREPARE_COMMIT_MSG must be configured to store data in UTF-8.

Signed-off-by: yaras <yaras6@gmail.com>
2016-08-13 07:34:48 +02:00
Johannes Schindelin
8bd143c7a2 git gui: fix staging a second line to a 1-line file
When a 1-line file is augmented by a second line, and the user tries to
stage that single line via the "Stage Line" context menu item, we do not
want to see "apply: corrupt patch at line 5".

The reason for this error was that the hunk header looks like this:

	@@ -1 +1,2 @@

but the existing code expects the original range always to contain a
comma. This problem is easily fixed by cutting the string "1 +1,2"
(that Git GUI formerly mistook for the starting line) at the space.

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

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2016-08-13 07:34:45 +02:00
James J. Raden
a92ea3023c gitk: make the "list references" default window width wider
When using remotes (with git-flow especially), the remote reference names
are almost always wordwrapped in the "list references" window because it's
somewhat narrow by default. It's possible to resize it with a mouse,
but it's annoying to have to do this every time, especially on Windows 10,
where the window border seems to be only one (1) pixel wide, thus making
the grabbing of the window border tricky.

Signed-off-by: James J. Raden <james.raden@gmail.com>
2016-08-13 07:34:43 +02:00
Johannes Schindelin
ebc95197f2 gitk: fix arrow keys in input fields with Tcl/Tk >= 8.6
Tcl/Tk 8.6 introduced new events for the cursor left/right keys and
apparently changed the behavior of the previous event.

Let's work around that by using the new events when we are running with
Tcl/Tk 8.6 or later.

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

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2016-08-13 07:34:41 +02:00
Johannes Schindelin
4e9ce0b917 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-08-13 07:34:39 +02:00
Johannes Schindelin
9ac813ad75 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-08-13 07:34:38 +02:00
İsmail Dönmez
9346389531 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>
2016-08-13 07:34:36 +02:00
İsmail Dönmez
39a716d94f 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>
2016-08-13 07:34:35 +02:00
Johannes Schindelin
a8af77c56d mingw: support UNC alternates
Just like we support having alternates pointing to different drives, we
want to support alternates pointing to network shares, i.e. UNC paths.

Technically, what we do in this patch is not to support UNC alternates,
but to support UNC paths when normalizing paths. But the latter implies
the former, and the former really was the motivation for this patch.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2016-08-13 07:34:33 +02:00