Commit Graph

50862 Commits

Author SHA1 Message Date
Johannes Schindelin
d32afb6793 fixup! Windows: add support for a Windows-wide configuration
This fixes https://github.com/git-for-windows/git/issues/168.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2015-05-29 11:12:28 +02:00
Johannes Schindelin
18583f5f8c fixup! Win32: implement readlink()
Let's just fix up the commit that introduces the typedef. This will make
for an elegant clean during the next merging rebase.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2015-05-28 18:46:06 +02:00
Johannes Schindelin
f8952c23fd fixup! mingw: Fix the MSYS1 build
Let's really fix up the appropriate commit, to facilitate later upstream
submission.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2015-05-28 18:45:15 +02:00
dscho
f071ac83f7 Merge pull request #164 from git-for-windows/reparse-data-buffer-struct
mingw: Fix the MSYS1 build
2015-05-28 14:57:49 +00:00
Sebastian Schuberth
45c525f19e mingw: Fix the MSYS1 build
In contrast to MSYS2, MSYS1 not only defines REPARSE_DATA_BUFFER in
"ntifs.h" but also in "winnt.h". Luckily, we can distinguish between
MSYS1's and MSYS2's "winnt.h" by looking at the include-guards:
While MSYS1 defines "_WINNT_H", MSYS2 defines "_WINNT_".

Signed-off-by: Sebastian Schuberth <sschuberth@gmail.com>
2015-05-28 16:34:31 +02:00
Johannes Schindelin
57190aee31 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>
2015-05-27 18:52:50 +00:00
Johannes Schindelin
9967f9f669 squash! Merge pull request #104 from dscho/super-config
Back out the super-config branch in favor of the program-data-config
branch (which is a better version of the same feature).

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2015-05-27 18:51:22 +00:00
Johannes Schindelin
4b738e2352 Windows: add support for a Windows-wide configuration
Between the libgit2 and the Git for Windows project, there has been a
discussion how we could share Git configuration to avoid duplication (or
worse: skew).

Earlier, libgit2 was nice enough to just re-use Git for Windows'

	C:\Program Files (x86)\Git\etc\gitconfig

but with the upcoming Git for Windows 2.x, there would be more paths to
search, as we will have 64-bit and 32-bit versions, and the
corresponding config files will be in %PROGRAMFILES%\Git\mingw64\etc and
...\mingw32\etc, respectively.

Worse: there are portable Git for Windows versions out there which live
in totally unrelated directories, still.

Therefore we came to a consensus to use `%PROGRAMDATA%\Git\config` as the
location for shared Git settings that are of wider interest than just Git
for Windows.

On XP, there is no %PROGRAMDATA%, therefore we need to use
"%ALLUSERSPROFILE%\Application Data\Git\config" in those setups.

Of course, the configuration in `%PROGRAMDATA%\Git\config` has the
widest reach, therefore it must take the lowest precedence, i.e. Git for
Windows can still override settings in its `etc/gitconfig` file.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2015-05-27 18:47:41 +00:00
Karsten Blees
fd9fa26fb2 config.c: create missing parent directories when modifying config files
'git config' (--add / --unset etc.) automatically creates missing config
files. However, it fails with a misleading error message "could not lock
config file" if the parent directory doesn't exist.

Also create missing parent directories.

This is particularly important when calling

	git config -f /non/existing/directory/config ...

Signed-off-by: Karsten Blees <blees@dcon.de>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2015-05-27 18:07:24 +00:00
Karsten Blees
7612a76e7c config: factor out repeated code
Factor out near identical per-file logic.

Signed-off-by: Karsten Blees <blees@dcon.de>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2015-05-27 18:02:03 +00:00
Johannes Schindelin
59bd1a9382 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>
2015-05-27 17:36:26 +00:00
Johannes Schindelin
ac6b03cb41 git-wrapper: allow overriding the command to spawn via command-line args
By embedding string resources into the Git wrapper executable, it
can be configured to execute custom commands (after setting up the
environment in the way required for Git for Windows to work properly).
This feature is used e.g. for `git-bash.exe` which launches a Bash in
the configured terminal window.

Here, we introduce command-line options to override those string
resources. That way, a user can call `git-bash.exe` (which is a copy of
the Git wrapper with `usr\bin\bash.exe --login -i` embedded as string
resource) with command-line options that will override what command is
run.

ConEmu, for example, might want to call

	...\git-bash.exe --needs-console --no-hide --minimal-search-path ^
		--command=usr\\bin\\bash.exe --login -i

In particular, the following options are supported now:

--command=<command-line>::
	Executes `<command-line>` instead of the embedded string resource

--[no-]minimal-search-path::
	Ensures that only `/cmd/` is added to the `PATH` instead of
	`/mingw??/bin` and `/usr/bin/`, or not

--[no-]needs-console::
	Ensures that there is a Win32 console associated with the spawned
	process, or not

--[no-]hide::
	Hides the console window, or not

Helped-by: Eli Young <elyscape@gmail.com>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2015-05-27 17:35:08 +00:00
Johannes Schindelin
722bd15659 git wrapper: auto-grow buffer in expand_variables()
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2015-05-27 17:35:06 +00:00
Johannes Schindelin
57af847735 git wrapper: refactor @@VAR@@ expansion into its own function
We will enhance the function in the next commit to support @@VAR@@
expansion in the upcoming `--command=<command>` option.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2015-05-27 17:35:05 +00:00
Johannes Schindelin
2f10008c8e git wrapper: refactor extraction of 1st arg into its own function
This will be reused by the upcoming `--command=<command>` option.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2015-05-27 17:35:04 +00:00
마누엘
118e2acca3 Merge pull request #159 from dscho/vagrant
Add Vagrant support (easy Linux VM setup)
2015-05-27 09:40:20 +02:00
Mike Hommey
1f78e3852e clone: call transport_set_verbosity before anything else on the newly created transport
Commit 2879bc3 made the progress and verbosity options sent to remote helper
earlier than they previously were. But nothing else after that would send
updates if the value is changed later on with transport_set_verbosity.

While for fetch and push, transport_set_verbosity is the first thing that
is done after creating the transport, it was not the case for clone. So
commit 2879bc3 broke changing progress and verbosity for clone, for urls
requiring a remote helper only (so, not git:// urls, for instance).

Moving transport_set_verbosity to just after the transport is created
works around the issue.

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

Signed-off-by: Mike Hommey <mh@glandium.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2015-05-27 09:40:20 +02:00
Johannes Schindelin
84ee1cefbd Support Vagrant: quick & easy Linux virtual machine setup
When developing Git for Windows, we always have to ensure that we do not
break any non-Windows platforms, e.g. by introducing Windows-specific code
into the platform-independent source code.

At other times, it is necessary to test whether a bug is Windows-specific
or not, in order to send the bug report to the correct place. Having
access to a Linux-based Git comes in really handy in such a situation.

Vagrant offers a painless way to install and use a defined Linux
development environment on Windows (and other Operating Systems). We offer
a Vagrantfile to that end for two reasons:

1) To allow Windows users to gain the full power of Linux' Git

2) To offer users an easy path to verify that the issue they are about
   to report is really a Windows-specific issue; otherwise they would
   need to report it to git@vger.kernel.org instead.

Using it is easy: Download and install https://www.virtualbox.org/, then
download and install https://www.vagrantup.com/, then direct your
command-line window to the Git source directory containing the Vagrantfile
and run the commands:

	vagrant up
	vagrant ssh

See https://github.com/git-for-windows/git/wiki/Vagrant for details.

As part of switching Git for Windows' development environment from msysGit
to the MSys2-based Git SDK, this Vagrantfile was copy-edited from msysGit:

	https://github.com/msysgit/msysgit/blob/0be8f2208/Vagrantfile

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2015-05-27 09:40:19 +02:00
마누엘
cf64de99ec Merge pull request #156 from kblees/kb/symlinks
Symlink support
2015-05-27 09:40:18 +02:00
마누엘
67186087e9 Merge pull request #104 from dscho/super-config
Add support for %PROGRAMDATA%\Git\config

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2015-05-27 09:40:18 +02:00
마누엘
8b4ede6fc5 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>
2015-05-27 09:40:17 +02:00
마누엘
d30f8ace61 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-05-27 09:40:17 +02:00
마누엘
7613c0371f Merge 'non-win-fixes' into HEAD 2015-05-27 09:40:16 +02:00
마누엘
714421a2a4 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>
2015-05-27 09:40:16 +02:00
마누엘
432333a65e Merge 'readme' into HEAD
Add a README.md for GitHub goodness.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2015-05-27 09:40:15 +02:00
마누엘
6673a8d8f6 Merge 'fix-is-exe' into HEAD 2015-05-27 09:40:15 +02:00
마누엘
20a04729aa Merge 'fix-externals' into HEAD 2015-05-27 09:40:14 +02:00
마누엘
0657035df4 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-05-27 09:40:14 +02:00
마누엘
15fcfb1429 Merge 'win-tests-fixes' into HEAD 2015-05-27 09:40:13 +02:00
마누엘
37eaa7a396 Merge 'msys2' into HEAD
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2015-05-27 09:40:13 +02:00
마누엘
4d2648f61f Merge 'pull-rebase-interactive' into HEAD 2015-05-27 09:40:12 +02:00
마누엘
07d38777a4 Merge 'jberezanski/wincred-sso-r2' into HEAD 2015-05-27 09:40:12 +02:00
마누엘
3b1c2deaeb Merge 'gitk' into HEAD 2015-05-27 09:40:11 +02:00
마누엘
b390846f6c Merge 'git-gui' into HEAD 2015-05-27 09:40:11 +02:00
마누엘
d045d232e8 Merge 'criss-cross-merge' into HEAD 2015-05-27 09:40:10 +02:00
마누엘
8bba01e18b Merge 'hide-dotgit' into HEAD 2015-05-27 09:40:10 +02:00
마누엘
847fbcf90b Merge 'unicode' into HEAD 2015-05-27 09:40:09 +02:00
마누엘
843233919f Merge pull request #138 from tboegi/150504_blame-resurrect-convert-to-git
blame: CRLF in the working tree and LF in the repo
2015-05-27 09:40:09 +02:00
Karsten Blees
5fb365d5fb t7800: configure $(pwd) for posix-paths on MINGW
In test #49, $(pwd) must match $(readlink), which is an MSys utility.

Signed-off-by: Karsten Blees <blees@dcon.de>
2015-05-27 09:40:08 +02:00
Karsten Blees
5faa88faf7 t9100: don't use symlinks with SVN on MINGW
The SVN library doesn't seem to support symlinks, even if symlinks are
enabled in MSys and Git. Use 'cp' instead of 'ln -s'.

Signed-off-by: Karsten Blees <blees@dcon.de>
2015-05-27 09:40:07 +02:00
Karsten Blees
ba6a6b03ac Win32: symlink: add support for symlinks to directories
Symlinks on Windows have a flag that indicates whether the target is a file
or a directory. Symlinks of wrong type simply don't work. This even affects
core Win32 APIs (e.g. DeleteFile() refuses to delete directory symlinks).

However, CreateFile() with FILE_FLAG_BACKUP_SEMANTICS doesn't seem to care.
Check the target type by first creating a tentative file symlink, opening
it, and checking the type of the resulting handle. If it is a directory,
recreate the symlink with the directory flag set.

It is possible to create symlinks before the target exists (or in case of
symlinks to symlinks: before the target type is known). If this happens,
create a tentative file symlink and postpone the directory decision: keep
a list of phantom symlinks to be processed whenever a new directory is
created in mingw_mkdir().

Limitations: This algorithm may fail if a link target changes from file to
directory or vice versa, or if the target directory is created in another
process.

Signed-off-by: Karsten Blees <blees@dcon.de>
2015-05-27 09:40:07 +02:00
Karsten Blees
d957497a92 Win32: implement basic symlink() functionality (file symlinks only)
Implement symlink() that always creates file symlinks. Fails with ENOSYS
if symlinks are disabled or unsupported.

Note: CreateSymbolicLinkW() was introduced with symlink support in Windows
Vista. For compatibility with Windows XP, we need to load it dynamically
and fail gracefully if it isnt's available.

Signed-off-by: Karsten Blees <blees@dcon.de>
2015-05-27 09:40:07 +02:00
Karsten Blees
4f2f66eb01 Win32: implement readlink()
Implement readlink() by reading NTFS reparse points. Works for symlinks
and directory junctions. If symlinks are disabled, fail with ENOSYS.

Signed-off-by: Karsten Blees <blees@dcon.de>
2015-05-27 09:40:06 +02:00
Karsten Blees
299852c4ea Win32: mingw_chdir: change to symlink-resolved directory
If symlinks are enabled, resolve all symlinks when changing directories,
as required by POSIX.

Note: Git's real_path() function bases its link resolution algorithm on
this property of chdir(). Unfortunately, the current directory on Windows
is limited to only MAX_PATH (260) characters. Therefore using symlinks and
long paths in combination may be problematic.

Note: GetFinalPathNameByHandleW() was introduced with symlink support in
Windows Vista. Thus, for compatibility with Windows XP, we need to load it
dynamically and behave gracefully if it isnt's available.

Signed-off-by: Karsten Blees <blees@dcon.de>
2015-05-27 09:40:06 +02:00
Karsten Blees
9397a6c54e Win32: mingw_rename: support renaming symlinks
MSVCRT's _wrename() cannot rename symlinks over existing files: it returns
success without doing anything. Newer MSVCR*.dll versions probably do not
have this problem: according to CRT sources, they just call MoveFileEx()
with the MOVEFILE_COPY_ALLOWED flag.

Get rid of _wrename() and call MoveFileEx() with proper error handling.

Signed-off-by: Karsten Blees <blees@dcon.de>
2015-05-27 09:40:05 +02:00
Karsten Blees
3b7b577734 Win32: mingw_unlink: support symlinks to directories
_wunlink() / DeleteFileW() refuses to delete symlinks to directories. If
_wunlink() fails with ERROR_ACCESS_DENIED, try _wrmdir() as well.

Signed-off-by: Karsten Blees <blees@dcon.de>
2015-05-27 09:40:05 +02:00
Karsten Blees
0ae6cfd3f4 Win32: add symlink-specific error codes
Signed-off-by: Karsten Blees <blees@dcon.de>
2015-05-27 09:40:05 +02:00
Karsten Blees
ca9ec38d92 Win32: change default of 'core.symlinks' to false
Symlinks on Windows don't work the same way as on Unix systems. E.g. there
are different types of symlinks for directories and files, creating
symlinks requires administrative privileges etc.

By default, disable symlink support on Windows. I.e. users explicitly have
to enable it with 'git config [--system|--global] core.symlinks true'.

The test suite ignores system / global config files. Allow testing *with*
symlink support by checking if native symlinks are enabled in MSys2 (via
'MSYS=winsymlinks:nativestrict').

Reminder: This would need to be changed if / when we find a way to run the
test suite in a non-MSys-based shell (e.g. dash).

Signed-off-by: Karsten Blees <blees@dcon.de>
2015-05-27 09:40:04 +02:00
Karsten Blees
1e026b0aeb Win32: factor out retry logic
The retry pattern is duplicated in three places. It also seems to be too
hard to use: mingw_unlink() and mingw_rmdir() duplicate the code to retry,
and both of them do so incompletely. They also do not restore errno if the
user answers 'no'.

Introduce a retry_ask_yes_no() helper function that handles retry with
small delay, asking the user, and restoring errno.

mingw_unlink: include _wchmod in the retry loop (which may fail if the
file is locked exclusively).

mingw_rmdir: include special error handling in the retry loop.

Signed-off-by: Karsten Blees <blees@dcon.de>
2015-05-27 09:40:04 +02:00
Karsten Blees
d9cbc31156 Win32: simplify loading of DLL functions
Dynamic loading of DLL functions is duplicated in several places.

Add a set of macros to simplify the process.

Signed-off-by: Karsten Blees <blees@dcon.de>
2015-05-27 09:40:03 +02:00