Commit Graph

61314 Commits

Author SHA1 Message Date
Johannes Schindelin
8484b9bbfd Merge branch 'bash-redirector' 2016-08-09 16:51:39 +02:00
Johannes Schindelin
8a1df2b4a5 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-08-09 16:51:39 +02:00
Johannes Schindelin
1ecd520349 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-08-09 16:51:39 +02:00
Johannes Schindelin
86afed781c 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-08-09 16:51:38 +02:00
Johannes Schindelin
287a84a4d6 Merge 'gcc-6' into HEAD 2016-08-09 16:51:38 +02:00
Johannes Schindelin
e3a8a13084 Merge pull request #797 from glhez/master
`git bundle create <bundle>` leaks handle the revlist is empty.
2016-08-09 16:51:38 +02:00
Johannes Schindelin
3afe86d645 Merge 'release-gc-repack' into HEAD 2016-08-09 16:51:38 +02:00
Johannes Schindelin
e67e204bd4 Merge pull request #755 from bwijen/master
Prevent child processes from inheriting a handle to index.lock
2016-08-09 16:51:38 +02:00
Johannes Schindelin
ca1d47dceb Merge pull request #726 from orgads/git-gui-preserve-author-windows
git-gui: Do not reset author details on amend
2016-08-09 16:51:38 +02:00
Johannes Schindelin
2bf77e84bb Merge branch 'spawn-with-spaces'
This change lets us spawn .bat scripts whose paths contain spaces.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2016-08-09 16:51:37 +02:00
Johannes Schindelin
56f6eca651 Merge pull request #677 from yaras/fix-git-675
Fixed masking username with asterisks when reading credentials
2016-08-09 16:51:34 +02:00
Johannes Schindelin
71079099fa 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-09 16:51:34 +02:00
Johannes Schindelin
dd40762380 Merge pull request #665 from yaras/fix-git-664
Fix initial git gui message encoding
2016-08-09 16:51:34 +02:00
Johannes Schindelin
6a5419816a Merge 'git-gui-add-2nd-line' into HEAD 2016-08-09 16:51:34 +02:00
Johannes Schindelin
8eae44ba7e Merge pull request #620 from sidecut/sidecut-gitk-list-references-window-width
Make the "list references" default window width wider
2016-08-09 16:51:33 +02:00
Johannes Schindelin
2066226497 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-09 16:51:33 +02:00
Johannes Schindelin
9064da006a 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-09 16:51:33 +02:00
Johannes Schindelin
6516cc9ac6 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-09 16:51:33 +02:00
Johannes Schindelin
1f664b2400 Merge 'unc-alternates' into HEAD 2016-08-09 16:51:33 +02:00
Johannes Schindelin
89ddd3745a Merge pull request #552 from duncansmart/fix-vcproj-gen
Fix Visual Studio .sln/.vcproj generation.
2016-08-09 16:51:32 +02:00
Johannes Schindelin
00175cf8c3 Merge 'mingw/default-ident'
Improve the default user name & email logic

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2016-08-09 16:51:32 +02:00
Johannes Schindelin
7db7c48a90 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-09 16:51:32 +02:00
Johannes Schindelin
db43b8f015 Merge pull request #443 from kblees/kb/nanosecond-file-times-v2.5.3
nanosecond file times for v2.5.3
2016-08-09 16:51:32 +02:00
Johannes Schindelin
acab9c580d Merge pull request #305 from dscho/msysgit_issues_182
Allow `add -p` and `add -i` with a large number of files
2016-08-09 16:51:32 +02:00
Johannes Schindelin
9dfe9605b6 Merge pull request #246 from uecasm/patch-1
Verify memoized files can be reloaded before using them
2016-08-09 16:51:31 +02:00
Johannes Schindelin
bf083d8bea 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-09 16:51:31 +02:00
Johannes Schindelin
2d7df21c39 Merge pull request #159 from dscho/vagrant
Add Vagrant support (easy Linux VM setup)
2016-08-09 16:51:31 +02:00
Johannes Schindelin
a9c3d2e916 Merge 'mingw-getcwd' into HEAD 2016-08-09 16:51:31 +02:00
Johannes Schindelin
096549c20d Merge pull request #156 from kblees/kb/symlinks
Symlink support
2016-08-09 16:51:31 +02:00
Johannes Schindelin
e9d8b30bfe 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-09 16:51:31 +02:00
Johannes Schindelin
4c007b7245 Merge 'fix-is-exe' into HEAD 2016-08-09 16:51:30 +02:00
Johannes Schindelin
77707121ea Merge 'fix-externals' into HEAD 2016-08-09 16:51:30 +02:00
Johannes Schindelin
09ce218898 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-09 16:51:30 +02:00
Johannes Schindelin
6ddce6001f Merge 'win-tests-fixes' into HEAD 2016-08-09 16:51:30 +02:00
Johannes Schindelin
9b4e1c0a16 Merge 'msys2' into HEAD
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2016-08-09 16:51:30 +02:00
Johannes Schindelin
392681236b Merge 'jberezanski/wincred-sso-r2' into HEAD 2016-08-09 16:51:29 +02:00
Johannes Schindelin
3c8de1c786 Merge 'gitk' into HEAD 2016-08-09 16:51:29 +02:00
Johannes Schindelin
05ba37bd1c Merge 'git-gui' into HEAD 2016-08-09 16:51:29 +02:00
Johannes Schindelin
e6fa3adf59 Merge 'unicode' into HEAD 2016-08-09 16:51:29 +02:00
Johannes Schindelin
053404bf52 Merge 'jk/common-main'
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2016-08-09 16:51:29 +02:00
Johannes Schindelin
dbed33813a mingw: declare main()'s argv as const
In 84d32bf (sparse: Fix mingw_main() argument number/type errors,
2013-04-27), we addressed problems identified by the 'sparse' tool where
argv was declared inconsistently. The way we addressed it was by casting
from the non-const version to the const-version.

This patch is long overdue, fixing compat/mingw.h's declaration to
make the "argv" parameter const.  This also allows us to lose the
"const" trickery introduced earlier to common-main.c:main().

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-08-09 16:51:18 +02:00
Jeff King
25cccfd634 common-main: call git_setup_gettext()
This should be part of every program, as otherwise users do
not get translated error messages. However, some external
commands forgot to do so (e.g., git-credential-store). This
fixes them, and eliminates the repeated code in programs
that did remember to use it.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-08-09 16:51:18 +02:00
Jeff King
d22da10a1c common-main: call restore_sigpipe_to_default()
This is another safety/sanity setup that should be in force
everywhere, but which we only applied in git.c. This did
catch most cases, since even external commands are typically
run via "git ..." (and the restoration applies to
sub-processes, too). But there were cases we missed, such as
somebody calling git-upload-pack directly via ssh, or
scripts which use dashed external commands directly.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-08-09 16:51:18 +02:00
Jeff King
819db56a44 common-main: call sanitize_stdfds()
This is setup that should be done in every program for
safety, but we never got around to adding it everywhere (so
builtins benefited from the call in git.c, but any external
commands did not). Putting it in the common main() gives us
this safety everywhere.

Note that the case in daemon.c is a little funny. We wait
until we know whether we want to daemonize, and then either:

 - call daemonize(), which will close stdio and reopen it to
   /dev/null under the hood

 - sanitize_stdfds(), to fix up any odd cases

But that is way too late; the point of sanitizing is to give
us reliable descriptors on 0/1/2, and we will already have
executed code, possibly called die(), etc. The sanitizing
should be the very first thing that happens.

With this patch, git-daemon will sanitize first, and can
remove the call in the non-daemonize case. It does mean that
daemonize() may just end up closing the descriptors we
opened, but that's not a big deal (it's not wrong to do so,
nor is it really less optimal than the case where our parent
process redirected us from /dev/null ahead of time).

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-08-09 16:51:18 +02:00
Jeff King
9b96dddbbb common-main: call git_extract_argv0_path()
Every program which links against libgit.a must call this
function, or risk hitting an assert() in system_path() that
checks whether we have configured argv0_path (though only
when RUNTIME_PREFIX is defined, so essentially only on
Windows).

Looking at the diff, you can see that putting it into the
common main() saves us having to do it individually in each
of the external commands. But what you can't see are the
cases where we _should_ have been doing so, but weren't
(e.g., git-credential-store, and all of the t/helper test
programs).

This has been an accident-waiting-to-happen for a long time,
but wasn't triggered until recently because it involves one
of those programs actually calling system_path(). That
happened with git-credential-store in v2.8.0 with ae5f677
(lazily load core.sharedrepository, 2016-03-11). The
program:

  - takes a lock file, which...

  - opens a tempfile, which...

  - calls adjust_shared_perm to fix permissions, which...

  - lazy-loads the config (as of ae5f677), which...

  - calls system_path() to find the location of
    /etc/gitconfig

On systems with RUNTIME_PREFIX, this means credential-store
reliably hits that assert() and cannot be used.

We never noticed in the test suite, because we set
GIT_CONFIG_NOSYSTEM there, which skips the system_path()
lookup entirely.  But if we were to tweak git_config() to
find /etc/gitconfig even when we aren't going to open it,
then the test suite shows multiple failures (for
credential-store, and for some other test helpers). I didn't
include that tweak here because it's way too specific to
this particular call to be worth carrying around what is
essentially dead code.

The implementation is fairly straightforward, with one
exception: there is exactly one caller (git.c) that actually
cares about the result of the function, and not the
side-effect of setting up argv0_path. We can accommodate
that by simply replacing the value of argv[0] in the array
we hand down to cmd_main().

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-08-09 16:51:18 +02:00
Jeff King
89a6298f98 add an extra level of indirection to main()
There are certain startup tasks that we expect every git
process to do. In some cases this is just to improve the
quality of the program (e.g., setting up gettext()). In
others it is a requirement for using certain functions in
libgit.a (e.g., system_path() expects that you have called
git_extract_argv0_path()).

Most commands are builtins and are covered by the git.c
version of main(). However, there are still a few external
commands that use their own main(). Each of these has to
remember to include the correct startup sequence, and we are
not always consistent.

Rather than just fix the inconsistencies, let's make this
harder to get wrong by providing a common main() that can
run this standard startup.

We basically have two options to do this:

 - the compat/mingw.h file already does something like this by
   adding a #define that replaces the definition of main with a
   wrapper that calls mingw_startup().

   The upside is that the code in each program doesn't need
   to be changed at all; it's rewritten on the fly by the
   preprocessor.

   The downside is that it may make debugging of the startup
   sequence a bit more confusing, as the preprocessor is
   quietly inserting new code.

 - the builtin functions are all of the form cmd_foo(),
   and git.c's main() calls them.

   This is much more explicit, which may make things more
   obvious to somebody reading the code. It's also more
   flexible (because of course we have to figure out _which_
   cmd_foo() to call).

   The downside is that each of the builtins must define
   cmd_foo(), instead of just main().

This patch chooses the latter option, preferring the more
explicit approach, even though it is more invasive. We
introduce a new file common-main.c, with the "real" main. It
expects to call cmd_main() from whatever other objects it is
linked against.

We link common-main.o against anything that links against
libgit.a, since we know that such programs will need to do
this setup. Note that common-main.o can't actually go inside
libgit.a, as the linker would not pick up its main()
function automatically (it has no callers).

The rest of the patch is just adjusting all of the various
external programs (mostly in t/helper) to use cmd_main().
I've provided a global declaration for cmd_main(), which
means that all of the programs also need to match its
signature. In particular, many functions need to switch to
"const char **" instead of "char **" for argv. This effect
ripples out to a few other variables and functions, as well.

This makes the patch even more invasive, but the end result
is much better. We should be treating argv strings as const
anyway, and now all programs conform to the same signature
(which also matches the way builtins are defined).

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-08-09 16:51:09 +02:00
Johannes Schindelin
8c2a81f1cf mingw: use domain information for default email
When a user is registered in a Windows domain, it is really easy to
obtain the email address. So let's do that.

Suggested by Lutz Roeder.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2016-08-09 16:45:48 +02:00
Karsten Blees
36c4f1fb1c Win32: implement nanosecond-precision file times
We no longer use any of MSVCRT's stat-functions, so there's no need to
stick to a CRT-compatible 'struct stat' either.

Define and use our own POSIX-2013-compatible 'struct stat' with nanosecond-
precision file times.

Note: Due to performance issues when using git variants with different file
time resolutions, this patch does *not* yet enable nanosecond precision in
the Makefile (use 'make USE_NSEC=1').

Signed-off-by: Karsten Blees <blees@dcon.de>
2016-08-09 16:45:48 +02:00
Johannes Schindelin
86e47cb755 getpwuid(mingw): provide a better default for the user name
We do have the excellent GetUserInfoEx() function to obtain more
detailed information of the current user (if the user is part of a
Windows domain); Let's use it.

Suggested by Lutz Roeder.

To avoid the cost of loading Secur32.dll (even lazily, loading DLLs
takes a non-neglibile amount of time), we use the established technique
to load DLLs only when, and if, needed.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2016-08-09 16:45:48 +02:00
Johannes Schindelin
230dc5febe getpwuid(mingw): initialize the structure only once
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2016-08-09 16:45:48 +02:00