Commit Graph

82935 Commits

Author SHA1 Message Date
Johannes Schindelin
aba71d8cd6 fixup! README.md: Add a Windows-specific preamble
Add a build badge, too.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2018-05-16 20:12:27 +02:00
Johannes Schindelin
33461f1d44 Merge pull request #1679 from telezhnaya/win
vcxproj: change build logic
2018-05-15 20:30:20 +02:00
Olga Telezhnaia
06d9a6af98 vcxproj: change build logic
Add new condition to invoke vcpkg_install.bat: it's not enough to check
the presence of folder vcpkg. We need to check the presence of some
header files because this is one of the main goals of this script.
Previous build attempt could be aborted, so the folder will exist but
the project will not be built properly.

Signed-off-by: Olga Telezhnaia <olyatelezhnaya@gmail.com>
2018-05-15 14:04:36 +03:00
Johannes Schindelin
06671f4dd8 fixup! add support for disabling SSL revocation checks in cURL
When comparing config keys, the key has been downcased already. So we
have to compare it to an all-lowercase string. The buggy code has been
identified by an unnamed colleague of Manuel Riezebosch.

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

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2018-05-15 12:06:03 +02:00
Johannes Schindelin
05ca542f78 Merge pull request #1651 from michaldudak/dir-symlinks-fix
fixup! Win32: symlink: add support for symlinks to directories
2018-05-03 12:46:36 +02:00
Michał Dudak
ec4523a1a7 fixup! Win32: symlink: add support for symlinks to directories
Change the way how directory symlinks are detected by trying to
open the link's target instead of the link itself.

It seems that Windows 10 1803 (April 2018 Update) does not allow to call
CreateFile on a link of a wrong type. If a file symlink points to a directory
an attempt to open it with CreateFile causes an ERROR_ACCESS_DENIED.
This behavior is different in previous version of Windows 10 (CreateFile
opens the incorrect link without complaining), that's why it worked fine
before.

This fixes #1646

Signed-off-by: Michał Dudak <michal.dudak@gmail.com>
2018-05-03 09:32:30 +02:00
Johannes Schindelin
df4ca5fb72 fixup! mingw: Windows Docker volumes are *not* symbolic links
Biiiiig brown paper bag, please. Please, quick. Really quick.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2018-04-25 14:21:12 +02:00
Junio C Hamano
8dd7bac908 Merge branch 'cb/bash-completion-ls-files-processing' into next
Shell completion (in contrib) that gives list of paths have been
optimized somewhat.

* cb/bash-completion-ls-files-processing:
  completion: improve ls-files filter performance

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

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2018-04-25 13:48:10 +02:00
Johannes Schindelin
fcbb1fa044 fixup! mingw: Windows Docker volumes are *not* symbolic links
Brown paper bag, please. Please, quick.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2018-04-25 11:39:23 +02:00
Johannes Schindelin
918fa5c06c fixup! mingw: Windows Docker volumes are *not* symbolic links
A quick fix: upon success, readlink() returns a non-negative value (not
0, as the code expected).

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2018-04-25 10:51:56 +02:00
Johannes Schindelin
e6ee2f786d Merge pull request #1645 from ZCube/master
Support windows container.
2018-04-24 21:19:40 +02:00
Johannes Schindelin
bb654bdb6f mingw: Windows Docker volumes are *not* symbolic links
... even if they may look like them.

As looking up the target of the "symbolic link" (just to see whether it
starts with `/ContainerMappedDirectories/`) is pretty expensive, we
do it when we can be *really* sure that there is a possibility that this
might be the case.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: JiSeop Moon <zcube@zcube.kr>
2018-04-24 15:10:33 +09:00
JiSeop Moon
e66b66b69b mingw: move the file_attr_to_st_mode() function definition
In preparation for making this function a bit more complicated (to allow
for special-casing the `ContainerMappedDirectories` in Windows
containers, which look like a symbolic link, but are not), let's move it
out of the header.

Signed-off-by: JiSeop Moon <zcube@zcube.kr>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2018-04-24 14:59:30 +09:00
JiSeop Moon
24b45a9511 mingw: when running in a Windows container, try to rename() harder
It is a known issue that a rename() can fail with an "Access denied"
error at times, when copying followed by deleting the original file
works. Let's just fall back to that behavior.

Signed-off-by: JiSeop Moon <zcube@zcube.kr>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2018-04-24 14:56:57 +09:00
JiSeop Moon
6b0d3d5462 mingw: introduce code to detect whether we're inside a Windows container
This will come in handy in the next commit.

Signed-off-by: JiSeop Moon <zcube@zcube.kr>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2018-04-23 23:22:50 +02:00
Junio C Hamano
82f1b61609 Merge branch 'ab/install-symlinks'
The build procedure learned to optionally use symbolic links
(instead of hardlinks and copies) to install "git-foo" for built-in
commands, whose binaries are all identical.

* ab/install-symlinks:
  Makefile: optionally symlink libexec/git-core binaries to bin/git
  Makefile: add a gitexecdir_relative variable
  Makefile: fix broken bindir_relative variable

[jes: merged into Git for Windows early, to facilitate work on skipping
the builtins entirely if desired, if I ever find the time to work on
this...]

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2018-04-23 13:39:07 +02:00
Johannes Schindelin
df8884cbc5 Merge branch 'ctrl-c'
This is part two of the Ctrl+C story, where part one is
https://github.com/git-for-windows/MSYS2-packages/commit/f4fda0f30aa.

Part one took care of extending the signal handling in the MSYS2 runtime
such that non-MSYS2 processes "receive" a SIGINT by injecting a remote
thread that runs kernel32!CtrlRoutine as if GenerateConsoleCtrlHandler()
had been called (but in contrast to the latter, only one process is
targeted at a time, not every process attached to the same Console) into
the process that needs to be interrupted as well as into all of the
spawned child processes.

Part two now takes care of removing the misguided "kill all spawned
children" atexit() handler, and it also installs a ConsoleCtrl handler
to run Git's SIGINT handlers, such as the one waiting for the pager to
exit.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2018-04-23 12:26:01 +02:00
Johannes Schindelin
20d8479690 Merge branch 'quote-braces'
This merges https://github.com/git-for-windows/git/pull/1637 with an
added regression test and a new commit message ready for the next
merging rebase (where the faulty commit will be amended).

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2018-04-23 12:23:02 +02:00
Johannes Schindelin
3a3f8cb043 squash! mingw: special-case arguments to sh
We need to take care to quote not only whitespace, but also curly
brackets. As aliases frequently going through the MSYS2 Bash, and
as aliases frequently get parameters such as HEAD@{yesterday}, let's
make sure that this does not regress by adding a test case for that.

Helped-by: Kim Gybels <kgybels@infogroep.be>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2018-04-23 12:21:30 +02:00
Johannes Schindelin
9dc9c421e1 fixup! mingw: quote argument to 'sh' if it contains brace
We revert that commit only to reapply it immediately with a fixup!
commit message, ready to be "auto-squashed" during the next merging
rebase.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2018-04-23 12:07:03 +02:00
Johannes Schindelin
1cbdbd7464 mingw: really handle SIGINT
Previously, we did not install any handler for Ctrl+C, but now we really
want to because the MSYS2 runtime learned the trick to call the
ConsoleCtrlHandler when Ctrl+C was pressed.

With this, hitting Ctrl+C while `git log` is running will only terminate
the Git process, but not the pager. This finally matches the behavior on
Linux and on macOS.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2018-04-23 00:24:29 +02:00
Johannes Schindelin
aa56ade320 Merge branch 'dj/runtime-prefix'
This topic branch first reverts a couple of conflicting patches and then
cherry-picks Dan Jacques' patches to support RUNTIME_PREFIX also on
other platforms than Windows. The original patches are already well
under way into the next Git version, and we just take them early to give
it a bit more testing.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2018-04-19 08:10:53 +02:00
Johannes Schindelin
016b860d14 git_setup_gettext: plug memory leak
The system_path() function returns a freshly-allocated string. We need
to release it.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2018-04-19 08:09:32 +02:00
Johannes Schindelin
75b76bf47b gettext: avoid initialization if the locale dir is not present
The runtime of a simple `git.exe version` call on Windows is currently
dominated by the gettext setup, adding a whopping ~150ms to the ~210ms
total.

Given that this cost is added to each and every git.exe invocation goes
through common-main's invocation of git_setup_gettext(), and given that
scripts have to call git.exe dozens, if not hundreds, of times, this is
a substantial performance penalty.

This is particularly pointless when considering that Git for Windows
ships without localization (to keep the installer's size to a bearable
~34MB): all that time setting up gettext is for naught.

So let's be smart about it and skip setting up gettext if the locale
directory is not even present.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2018-04-19 08:09:32 +02:00
Johannes Schindelin
6e007ce8ea mingw/msvc: use the new-style RUNTIME_PREFIX helper
This change also allows us to stop overriding argv[0] with the absolute
path of the executable, allowing us to preserve e.g. the case of the
executable's file name.

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

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2018-04-19 08:09:32 +02:00
Johannes Schindelin
0b6a950bb8 exec_cmd: provide a new-style RUNTIME_PREFIX helper for Windows
The RUNTIME_PREFIX feature comes from Git for Windows, but it was
enhanced to allow support for other platforms. While changing the
original idea, the concept was also improved by not forcing argv[0] to
be adjusted.

Let's allow the same for Windows by implementing a helper just as for
the other platforms.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2018-04-19 08:09:32 +02:00
Dan Jacques
df35f33859 exec_cmd: RUNTIME_PREFIX on some POSIX systems
Enable Git to resolve its own binary location using a variety of
OS-specific and generic methods, including:

- procfs via "/proc/self/exe" (Linux)
- _NSGetExecutablePath (Darwin)
- KERN_PROC_PATHNAME sysctl on BSDs.
- argv0, if absolute (all, including Windows).

This is used to enable RUNTIME_PREFIX support for non-Windows systems,
notably Linux and Darwin. When configured with RUNTIME_PREFIX, Git will
do a best-effort resolution of its executable path and automatically use
this as its "exec_path" for relative helper and data lookups, unless
explicitly overridden.

Small incidental formatting cleanup of "exec_cmd.c".

Signed-off-by: Dan Jacques <dnj@google.com>
Thanks-to: Robbie Iannucci <iannucci@google.com>
Thanks-to: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2018-04-19 08:09:32 +02:00
Dan Jacques
94ae12263b Makefile: add Perl runtime prefix support
Broaden the RUNTIME_PREFIX flag to configure Git's Perl scripts to
locate the Git installation's Perl support libraries by resolving
against the script's path, rather than hard-coding that path at
build-time. Hard-coding at build time worked on previous
RUNTIME_PREFIX configurations (i.e., Windows) because the Perl
scripts were run within a virtual filesystem whose paths were
consistent regardless of the location of the actual installation.
This will no longer be the case for non-Windows RUNTIME_PREFIX users.

When enabled, RUNTIME_PREFIX now requires Perl's system paths to be
expressed relative to a common installation directory in the Makefile,
and uses that relationship to locate support files based on the known
starting point of the script being executed, much like RUNTIME_PREFIX
does for the Git binary.

This change enables Git's Perl scripts to work when their Git installation
is relocated or moved to another system, even when they are not in a
virtual filesystem environment.

Signed-off-by: Dan Jacques <dnj@google.com>
Thanks-to: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Thanks-to: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2018-04-19 08:09:32 +02:00
Dan Jacques
3fd02ed2a2 Makefile: generate Perl header from template file
Currently, the generated Perl script headers are emitted by commands in
the Makefile. This mechanism restricts options to introduce alternative
header content, needed by Perl runtime prefix support, and obscures the
origin of the Perl script header.

Change the Makefile to generate a header by processing a template file and
move the header content into the "perl/" subdirectory. The generated
header content will now be stored in the "GIT-PERL-HEADER" file. This
allows the content of the Perl header to be controlled by changing the path
of the template in the Makefile.

Signed-off-by: Dan Jacques <dnj@google.com>
Thanks-to: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Thanks-to: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2018-04-19 08:09:32 +02:00
Johannes Schindelin
51339858c9 fixup! gettext: handle GIT_TEXTDOMAINDIR relative to $(prefix)
In preparation for the more general RUNTIME_PREFIX support, this reverts
commit 5ff388f6f2.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2018-04-19 08:09:59 +02:00
Johannes Schindelin
c00e8aa923 fixup! gettext: avoid initialization if the locale dir is not present
In preparation for the more general RUNTIME_PREFIX support, this reverts
commit 50254073ea.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2018-04-19 08:09:53 +02:00
Johannes Schindelin
f91c5f2839 fixup! gettext: use a GIT_LOCALE_PATH relative to $(prefix)
In preparation for the more general RUNTIME_PREFIX support, this reverts
commit 8eed480e3f.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2018-04-19 08:09:32 +02:00
Johannes Schindelin
6ff703e48c fixup! mingw: kill unterminated child processes on signals
This reverts the change where we tried to make sure that child processes
are killed upon exit of the git.exe process.

This change was misguided: it wanted to pretend that each process was
responsible to signal its child processes upon receiving a signal. But
it is the responsibility of the syscall `signal()` (or in the case of
Windows, either MSYS2's signal() or whoever wanted to terminate the
git.exe process) to take care of the child processes.

We just changed the MSYS2 runtime accordingly, in the hope that this
addresses the Ctrl+C problems (stale .git/index.lock files, runaway
git-remote-https when interrupting a clone, killed pager when hitting
Ctrl+C in `git log`, interrupting node.js processes that listen to
SIGINT, C# programs installing a ConsoleCtrlHandler, etc) once and for
all.

This commit is part of the fix, as pressing Ctrl+C while `git log` is
running would kill the pager otherwise (it is a child process of git.exe
after all).

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2018-04-18 09:51:57 +02:00
Kim Gybels
50b82c744c mingw: quote argument to 'sh' if it contains brace
Fixes https://github.com/git-for-windows/git/issues/1220

Signed-off-by: Kim Gybels <kgybels@infogroep.be>
2018-04-18 01:00:43 +02:00
Clemens Buchacher
78a2d21231 completion: improve ls-files filter performance
From the output of ls-files, we remove all but the leftmost path
component and then we eliminate duplicates. We do this in a while loop,
which is a performance bottleneck when the number of iterations is large
(e.g. for 60000 files in linux.git).

$ COMP_WORDS=(git status -- ar) COMP_CWORD=3; time _git

real    0m11.876s
user    0m4.685s
sys     0m6.808s

Replacing the loop with the cut command improves performance
significantly:

$ COMP_WORDS=(git status -- ar) COMP_CWORD=3; time _git

real    0m1.372s
user    0m0.263s
sys     0m0.167s

The measurements were done with Msys2 bash, which is used by Git for
Windows.

When filtering the ls-files output we take care not to touch absolute
paths. This is redundant, because ls-files will never output absolute
paths. Remove the unnecessary operations.

The issue was reported here:
https://github.com/git-for-windows/git/issues/1533

Signed-off-by: Clemens Buchacher <drizzd@gmx.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2018-04-10 16:00:53 +09:00
Johannes Schindelin
7e4058d72e Merge branch 'fix-vcxproj-after-2.17.0'
Fix a couple of issues with the Visual Studio project generation which
were partially caused by the rebase to Git v2.17.0 (and partially only
detected because of the breakage).

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2018-04-04 12:23:29 +02:00
Johannes Schindelin
f93adde67c fixup! vcxproj: let vcs-svn depend on libgit
We really need to let vcs-svn depend on libgit... And the target name is
currently `vcs-svn/lib`. Let's be a little bit more lenient and search
for the substring `vcs-svn`, just in case that the exact target will
change in the future.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2018-04-04 12:20:58 +02:00
Johannes Schindelin
8b3ed721bd fixup! msvc: add a Makefile target to pre-generate the VS solution
The Perl project is now built without using MakeMaker, and therefore the
way we need to build vcxproj changed, too.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2018-04-04 12:20:56 +02:00
Johannes Schindelin
b9deee1225 fixup! vcxproj: automatically initialize the vcpkg system
The three static libraries (libgit, xdiff and vcs-svn) do not rely on
any vcpkg-generated libraries, and therefore the <VCPKGLibs> entry is
empty. Visual Studio likes to insert a line break into such empty
entries, so we should, too.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2018-04-04 12:20:55 +02:00
Johannes Schindelin
e7621d891d Merge pull request #1567 from derrickstolee/whitespace
CONTRIBUTING.md: check for whitespace before submitting
2018-04-02 22:48:51 +02:00
Derrick Stolee
191617783c CONTRIBUTING.md: check for whitespace before submitting
Whitespace errors are easy to create but hard to check manually. Add
two git commands that detect these whitespace errors to the commit
cleanup section of CONTRIBUTING.md.

Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
2018-04-02 22:48:48 +02:00
Johannes Schindelin
39c34f4fcc Merge pull request #1564 from git-for-windows/larsxschneider-patch-1
CONTRIBUTING.md: Fix typo
2018-04-02 22:48:45 +02:00
Lars Schneider
d89605f455 CONTRIBUTING.md: Fix typo
Signed-off-by: Lars Schneider <larsxschneider@gmail.com>
2018-04-02 22:48:42 +02:00
Johannes Schindelin
53d2a9b53c Merge pull request #1548 from alejandro5042/master
Document how $HOME is set on Windows
2018-04-02 22:48:40 +02:00
Alejandro Barreto
001faf3170 Document how $HOME is set on Windows
Git documentation refers to $HOME and $XDG_CONFIG_HOME often, but does not specify how or where these values come from on Windows where neither is set by default. The new documentation reflects the behavior of setup_windows_environment() in compat/mingw.c.

Signed-off-by: Alejandro Barreto <alejandro.barreto@ni.com>
2018-04-02 22:48:36 +02:00
Johannes Schindelin
d8ae2969ec Merge branch 'fix-unc-buffer-overflow'
This fixes `git status` in a Git worktree at the top of a file share.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2018-04-02 22:48:33 +02:00
Johannes Schindelin
10ad06b567 Merge pull request #1529 from derrickstolee/contributing
Rewrite CONTRIBUTING.md to be a guide for new developers on Windows
2018-04-02 22:48:31 +02:00
Johannes Schindelin
bb6e3da7af setup_git_directory(): handle UNC root paths correctly
When working in the root directory of a file share (this is only
possible in Git Bash and Powershell, but not in CMD), the current
directory is reported without a trailing slash.

This is different from Unix and standard Windows directories: both / and
C:\ are reported with a trailing slash as current directories.

If a Git worktree is located there, Git is not quite prepared for that:
while it does manage to find the .git directory/file, it returns as
length of the top-level directory's path *one more* than the length of
the current directory, and setup_git_directory_gently() would then
return an undefined string as prefix.

In practice, this undefined string usually points to NUL bytes, and does
not cause much harm. Under rare circumstances that are really involved
to reproduce (and not reliably so), the reported prefix could be a
suffix string of Git's exec path, though.

A careful analysis determined that this bug is unlikely to be
exploitable, therefore we mark this as a regular bug fix.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2018-04-02 22:48:27 +02:00
Derrick Stolee
e423ae8cd0 CONTRIBUTING.md: add guide for first-time contributors
Getting started contributing to Git can be difficult on a Windows machine.
CONTRIBUTING.md contains a guide to getting started, including detailed
steps for setting up build tools, running tests, and submitting patches
to upstream.

Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
2018-04-02 22:48:25 +02:00
Derrick Stolee
254a6e90a2 CODE_OF_CONDUCT: Rename CONTRIBUTING.md to CODE_OF_CONDUCT.md
The current CONTRIBUTING.md file is actually a code of conduct. This is
a valuable document, but is misnamed. A following patch will replace
CONTRIBUTING.md with a guide to contributing to Git using a Windows machine.

Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
2018-04-02 22:48:24 +02:00