Commit Graph

56882 Commits

Author SHA1 Message Date
Christophe Bucher
b85db5b1b9 git-wrapper: do not let the Ctrl-C event kill the wrapper
... while waiting for the child process to finish.

The Git wrapper serves, among other things, as git-cmd.exe. In that
role, its primary purpose is to provide an interactive cmd window that
knows where to find Git.

A secondary use of git-cmd.exe is to be able to launch other console
processes that know about Git, e.g. when ConsoleZ wants to call an
interactive Bash (it cannot call git-bash.exe because that would open a
new MinTTY window). To this end, git-cmd.exe supports the --command=...
command-line option. The interactive bash would be called like this:

	git-cmd --command=usr\bin\bash.exe -l -i

The command-line arguments after the --command=... options are simply
passed through to the command itself. If no --command=... option is
specified, git-cmd.exe defaults to cmd.exe.

Once git-cmd.exe is launched, it finds the top-level directory of the
Git for Windows installation and then launches the command as a child
process. And this is where things get a little bit tricky: When the user
presses CTRL-C, the cmd window receives WM_KEYDOWN/WM_KEYUP messages
which are then handled by the TranslateMessage function that generates a
CTRL-C event that is sent to the console processes running in the
console window (i.e. both git-cmd.exe and the child process).

If no Console Ctrl Handlers have been registered, the git-cmd.exe
process will simply be terminated, without having waited for the
interactive Bash to quit (it does not quit, of course, because it
handles Ctrl+C by terminating any process launched from within the
Bash). Now both cmd and the Bash compete for user input.

Luckily, the solution is very easy: the Win32 API sports a
SetConsoleCtrlHandler() function to register/unregister Console Ctrl
Handlers. When the NULL pointer is registered as "handler", it "causes
the calling process to ignore CTRL+C input":

https://msdn.microsoft.com/en-us/library/windows/desktop/ms686016.aspx

This is exactly what we need here: while waiting for the child processes
to finish, the git-cmd.exe process itself should not be interruptible by
the user. Immediately after the child process terminates, we unregister
the Console Ctrl Handler.

Note: we need to be careful with changes to the Git wrapper as it serves
many other purposes in addition to git-cmd.exe. For example, it serves
as the cmd\git.exe as well as all of the git-<builtin>.exe stand-ins.
So do we want the same Ctrl+C behavior even in those instances? Yes: If
the user interrupts using Ctrl+C, the child process should terminate
before the Git wrapper.

Also note: We cannot override the Console Ctrl Handler with a function
that simply always returns TRUE: this would prevent the console window
opened via git-cmd.exe from closing, since the Console Ctrl Handler
*also* handles "signals generated by the system when the user closes the
console, logs off, or shuts down the system."

[jes: changed the patch to conform with the surrounding coding style, to
pass NULL as Console Ctrl Handler and unregister it as soon as
appropriate, fixed commit message to be more accurate and informative,
added link to the SetConsoleCtrlHandler() documentation.]

This fixes https://github.com/git-for-windows/git/pull/205

Signed-off-by: Christophe Bucher Developer <christophe.bucher@laposte.net>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2016-02-18 17:03:50 +01:00
Johannes Schindelin
a5f58350aa 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-02-16 21:03:02 +01:00
Johannes Schindelin
900fff8cbe 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-02-16 16:48:58 +01:00
Johannes Schindelin
93f83ba903 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-02-16 16:48:57 +01:00
Johannes Schindelin
f77b9531a3 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-02-16 16:48:46 +01:00
Johannes Schindelin
fdf73750ea 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-02-16 16:48:45 +01:00
Johannes Schindelin
e9b424b858 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-02-16 16:45:31 +01:00
Johannes Schindelin
94e100b8d8 Merge branch 'programdata-doc'
This patch should be squashed into the commit that introduces the
ProgramData config, of course.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2016-02-16 15:32:17 +01:00
Johannes Schindelin
c56a3fe8dd Clarify the location of the Windows-specific ProgramData config
On Windows, there is no (single) `/etc/` directory. To address that, in
conjunction with the libgit2 project, Git for Windows introduced yet
another level of system-wide config files, located in C:\ProgramData
(and the equivalent on Windows XP).

Let's spell this out in the documentation.

This closes https://github.com/git-for-windows/git/pull/470 (because
there was no reaction in three months in that Pull Request).

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2016-02-16 15:31:38 +01:00
Junio C Hamano
4abc31070f Merge branch 'nd/do-not-move-worktree-manually'
"git worktree" had a broken code that attempted to auto-fix
possible inconsistency that results from end-users moving a
worktree to different places without telling Git (the original
repository needs to maintain backpointers to its worktrees, but
"mv" run by end-users who are not familiar with that fact will
obviously not adjust them), which actually made things worse
when triggered.

* nd/do-not-move-worktree-manually:
  worktree: stop supporting moving worktrees manually
  worktree.c: fix indentation

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2016-02-12 07:55:09 +01:00
Johannes Schindelin
78567b9f66 fixup! mingw: fix t5601-clone.sh 2016-02-06 14:44:11 +01:00
Johannes Schindelin
ffaa228823 Merge branch 'js/pull-rebase-i'
"git pull --rebase" has been extended to allow invoking
"rebase -i".

* js/pull-rebase-i:
  completion: add missing branch.*.rebase values
  remote: handle the config setting branch.*.rebase=interactive
  pull: allow interactive rebase with --rebase=interactive

Forward-port from upstream Git.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2016-02-06 14:39:58 +01:00
Johannes Schindelin
f609530226 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-02-06 14:39:57 +01:00
Johannes Schindelin
8aeea97f0f Merge branch 'home-bin' 2016-02-06 14:39:57 +01:00
Johannes Schindelin
29882056d7 Merge branch 'conhost-git-bash' 2016-02-06 14:39:56 +01:00
Johannes Schindelin
0882edb781 Merge branch 'bash-redirector' 2016-02-06 14:39:56 +01:00
Johannes Schindelin
7f00bc0155 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-02-06 14:39:55 +01:00
Johannes Schindelin
a76f7f2c9e 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-02-06 14:39:54 +01:00
Johannes Schindelin
9192447e8e 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-02-06 14:39:54 +01:00
Johannes Schindelin
586893a170 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-02-06 14:39:53 +01:00
Johannes Schindelin
d44c5c4319 Merge 'unc-alternates' into HEAD 2016-02-06 14:39:53 +01:00
Johannes Schindelin
fdd9493014 Merge pull request #552 from duncansmart/fix-vcproj-gen
Fix Visual Studio .sln/.vcproj generation.
2016-02-06 14:39:52 +01:00
Johannes Schindelin
ae830c411d Merge pull request #487 from dscho/default-username
Improve the default user name & email logic
2016-02-06 14:39:51 +01:00
Johannes Schindelin
f177f92980 Merge pull request #486 from dscho/mmap-no-error
Better mmap() emulation
2016-02-06 14:39:51 +01:00
Johannes Schindelin
d0c4c0ef67 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-02-06 14:39:50 +01:00
Johannes Schindelin
7843a0b5cf Merge pull request #443 from kblees/kb/nanosecond-file-times-v2.5.3
nanosecond file times for v2.5.3
2016-02-06 14:39:49 +01:00
Johannes Schindelin
5a3bec530f Merge pull request #305 from dscho/msysgit_issues_182
Allow `add -p` and `add -i` with a large number of files
2016-02-06 14:39:47 +01:00
Johannes Schindelin
7f56f2446c Merge pull request #246 from uecasm/patch-1
Verify memoized files can be reloaded before using them
2016-02-06 14:39:47 +01:00
Johannes Schindelin
bbb67e2752 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-02-06 14:39:46 +01:00
Johannes Schindelin
2f137b74ed Merge pull request #159 from dscho/vagrant
Add Vagrant support (easy Linux VM setup)
2016-02-06 14:39:45 +01:00
Johannes Schindelin
0457432b7b Merge pull request #156 from kblees/kb/symlinks
Symlink support
2016-02-06 14:39:45 +01:00
Johannes Schindelin
c67def34a5 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-02-06 14:39:44 +01:00
Johannes Schindelin
74ed4b93db Merge 'readme' into HEAD
Add a README.md for GitHub goodness.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2016-02-06 14:39:43 +01:00
Johannes Schindelin
5b09dd23a2 Merge 'fix-is-exe' into HEAD 2016-02-06 14:39:43 +01:00
Johannes Schindelin
4a87acf131 Merge 'fix-externals' into HEAD 2016-02-06 14:39:42 +01:00
Johannes Schindelin
47e6fba15c 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-02-06 14:39:41 +01:00
Johannes Schindelin
0c67e9c856 Merge 'win-tests-fixes' into HEAD 2016-02-06 14:39:39 +01:00
Johannes Schindelin
9f5cbee70c Merge 'msys2' into HEAD
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2016-02-06 14:39:31 +01:00
Johannes Schindelin
99f0ae03a6 Merge 'jberezanski/wincred-sso-r2' into HEAD 2016-02-06 14:39:26 +01:00
Johannes Schindelin
d16f87aa5b Merge 'gitk' into HEAD 2016-02-06 14:39:24 +01:00
Johannes Schindelin
33305b0937 Merge 'git-gui' into HEAD 2016-02-06 14:39:20 +01:00
Johannes Schindelin
fefb1a3118 Merge 'hide-dotgit' into HEAD 2016-02-06 14:39:17 +01:00
Johannes Schindelin
657311fcc7 Merge 'unicode' into HEAD 2016-02-06 14:39:15 +01:00
Johannes Schindelin
bdfa542222 completion: add missing branch.*.rebase values
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-02-06 14:38:57 +01:00
Johannes Schindelin
d333323684 remote: handle the config setting branch.*.rebase=interactive
The config variable branch.<branchname>.rebase is not only used by `git
pull`, but also by `git remote` when showing details about a remote.
Therefore, it needs to be taught to accept the newly-introduced
`interactive` value of said variable.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-02-06 14:38:56 +01:00
Johannes Schindelin
08e9391c6a pull: allow interactive rebase with --rebase=interactive
A couple of years ago, I found the need to collaborate on topic
branches that were rebased all the time, and I really needed to see
what I was rebasing when pulling, so I introduced an
interactively-rebasing pull.

The way builtin pull works, this change also supports the value
'interactive' for the 'branch.<name>.rebase' config variable, which
is a neat thing because users can now configure given branches for
interactively-rebasing pulls without having to type out the complete
`--rebase=interactive` option every time they pull.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-02-06 14:38:56 +01:00
Johannes Schindelin
ffff1217b9 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-02-06 14:38:55 +01:00
Johannes Schindelin
1779241e17 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-02-06 14:38:54 +01:00
Johannes Schindelin
e034c5ec3c 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-02-06 14:38:54 +01:00
Johannes Schindelin
61adb85aec 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-02-06 14:38:52 +01:00