Commit Graph

56251 Commits

Author SHA1 Message Date
Johannes Schindelin
bfeff87581 Merge pull request #286 from dscho/unc-alternates
Make alternates work on UNC paths
2016-01-05 14:48:39 +01:00
Johannes Schindelin
fce0f95ac2 Merge pull request #275 from cs96and/cygwin_fixes
winansi.c: Fix colourization on Cygwin pseudo terminals.
2016-01-05 14:48:37 +01:00
Johannes Schindelin
a4f947e6ef 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-01-05 14:48:36 +01:00
Johannes Schindelin
97d2c570bc Merge pull request #276 from dscho/issue-0xff
mingw: Suppress warning that <commit>:.gitattributes does not exist
2016-01-05 14:48:35 +01:00
Johannes Schindelin
10183d9079 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-01-05 14:48:29 +01:00
Alan Davies
e3632f96d6 winansi.c: Fix colourization on Cygwin pseudo terminals.
Git only colours the output and uses pagination if isatty() returns 1.
MSys and Cygwin emulate pseudo terminals via named pipes, meaning that
isatty() returns 0.

Commit 3adef8de55 fixed this for MSys
terminals, but not Cygwin.

The named pipes that Cygwin and Msys use are very similar.  MSys PTY pipes
are called 'msys-*-pty*' and Cygwin uses 'cygwin-*-pty*'.  This commit
modifies the existing check to allow both MSys and Cygwin PTY pipes to be
identified as TTYs.

Note that Pagination is still broken on Cygwin.  less.exe is spawned (as
seen in Process Explorer and using GIT_TRACE=1), but the output is not
being piped into it.

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

Signed-off-by: Alan Davies <alan.n.davies@gmail.com>
2016-01-05 14:46:18 +01:00
Johannes Schindelin
67dbf32ba5 git-wrapper: also allow setting the application ID
Windows 7 allows users to pin running applications to the task bar. By
setting the application ID, multiple processes can share a single task
bar entry, and this is exactly what we need for `git-bash.exe` which
wants to share the task bar entry with the `mintty.exe` instance it
launches.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2016-01-05 14:46:16 +01:00
Johannes Schindelin
c4d856223d mingw: Suppress warning that <commit>:.gitattributes does not exist
On Windows, a file name containing a colon is illegal. We should
therefore expect the corresponding errno when `fopen()` is called for a
path of the form <commit>:.gitattributes.

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

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2016-01-05 14:46:14 +01:00
Johannes Schindelin
d222d29588 Merge pull request #200 from dscho/code-of-conduct
Add a brief "code of conduct" section to the Governance Model
2016-01-05 14:46:12 +01:00
Johannes Schindelin
ad980b23b7 Work around MinGW-w64 erroneously claiming to have flockfile()
The _POSIX_THREAD_SAFE_FUNCTIONS constant is supposed to be defined only
if flockfile() and friends are available. MinGW-w64 defines that
constant, but the functions are not available. Work around that.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2016-01-05 14:46:12 +01:00
Johannes Schindelin
1ed5b6e5d7 Merge pull request #246 from uecasm/patch-1
Verify memoized files can be reloaded before using them
2016-01-05 14:46:11 +01:00
Johannes Schindelin
6cb702a7f7 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-01-05 14:46:09 +01:00
Johannes Schindelin
f3ee28447a 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-01-05 14:46:08 +01:00
Johannes Schindelin
4439117b76 Merge pull request #159 from dscho/vagrant
Add Vagrant support (easy Linux VM setup)
2016-01-05 14:46:07 +01:00
Johannes Schindelin
5db5bc456c Merge pull request #156 from kblees/kb/symlinks
Symlink support
2016-01-05 14:46:06 +01:00
Johannes Schindelin
ebfdd2c847 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-01-05 14:46:05 +01:00
Johannes Schindelin
8720831d6d 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-01-05 14:46:03 +01:00
Johannes Schindelin
99629d75f5 Merge 'readme' into HEAD
Add a README.md for GitHub goodness.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2016-01-05 14:46:02 +01:00
Johannes Schindelin
878cc877be Merge 'fix-is-exe' into HEAD 2016-01-05 14:46:02 +01:00
Johannes Schindelin
2ea7b3178b Merge 'fix-externals' into HEAD 2016-01-05 14:46:01 +01:00
Johannes Schindelin
d7c712bbad 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-01-05 14:46:00 +01:00
Johannes Schindelin
1d3c98c222 Merge 'win-tests-fixes' into HEAD 2016-01-05 14:45:59 +01:00
Johannes Schindelin
65af238691 Merge 'msys2' into HEAD
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2016-01-05 14:45:58 +01:00
Johannes Schindelin
d97cfc2cd5 Merge 'pull-rebase-interactive' into HEAD 2016-01-05 14:45:57 +01:00
Johannes Schindelin
f0922a0cd3 Merge 'jberezanski/wincred-sso-r2' into HEAD 2016-01-05 14:45:56 +01:00
Johannes Schindelin
0dc9fe9dd2 Merge 'gitk' into HEAD 2016-01-05 14:45:55 +01:00
Johannes Schindelin
3ac69df47e Merge 'git-gui' into HEAD 2016-01-05 14:45:54 +01:00
Johannes Schindelin
9dfbf9d1df Merge 'criss-cross-merge' into HEAD 2016-01-05 14:45:53 +01:00
Johannes Schindelin
a969009781 Merge 'hide-dotgit' into HEAD 2016-01-05 14:45:52 +01:00
Johannes Schindelin
592db0bd2b Merge 'unicode' into HEAD 2016-01-05 14:45:51 +01:00
Johannes Schindelin
82cf05cc02 Add a Code of Conduct
It is better to state clearly expectations and intentions than to assume
quietly that everybody agrees.

This Code of Conduct is the Open Code of Conduct as per
http://todogroup.org/opencodeofconduct/ (the only modifications are the
adjustments to reflect that there is no "response team" in addition to the
Git for Windows maintainer, and the addition of the link to the Open Code
of Conduct itself).

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2016-01-05 14:45:49 +01:00
Gavin Lambert
4833532806 git-svn: do not reuse caches memoized for a different architecture
Reusing cached data speeds up git-svn by quite a fair bit. However, if
the YAML module is unavailable, the caches are written to disk in an
architecture-dependent manner. That leads to problems when upgrading,
say, from 32-bit to 64-bit Git for Windows.

Let's just try to read those caches back if we detect the absence of the
YAML module and the presence of the file, and delete the file if it
could not be read back correctly.

Note that the only way to catch the error when the memoized cache could
not be read back is to put the call inside an `eval { ... }` block
because it would die otherwise; the `eval` block should also return `1`
in case of success explicitly since the function reading back the cached
data does not return an appropriate value to test for success.

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

[jes: fixed the commit message, made the sign-off explicit]

Signed-off-by: Gavin Lambert <github@mirality.co.nz>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2016-01-05 14:45:46 +01:00
Johannes Schindelin
dfce1fb4a1 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>
2016-01-05 14:45:43 +01:00
Karsten Blees
c2302016cf 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>
2016-01-05 14:45:43 +01:00
Karsten Blees
2f67cd26ea 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>
2016-01-05 14:45:42 +01:00
Johannes Schindelin
2ed655b1da git-wrapper: leave the working directory alone by default
The idea of `git-bash.exe` automatically running the Git Bash in the
home directory was to support the start menu item `Git Bash` (which
should not start in C:\Program Files\Git, but in $HOME), and to make
that behavior consistent with double-clicking in `git-bash.exe`
portable Git.

However, it turns out that one of the main use cases of portable Git is
to run the Git Bash in GitHub for Windows, and it should start in the
top-level directory of a given project. Therefore, the concern to keep
double-clicking `git-bash.exe` consistent with the start menu item was
actually unfounded.

As to the start menu item: it can easily be changed to launch
`git-bash.exe` with a command-line option. So let's introduce the
--cd-to-home option for that purpose.

As a bonus, the Git wrapper can now also serve as a drop-in redirector
/bin/bash.exe to provide backwards-compatibility of Git for Windows 2.x
with 1.x: some 3rd-party software expects to find that executable there,
and it also expects it to leave the working directory unchanged.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2016-01-05 14:45:39 +01:00
Johannes Schindelin
36eb46465d 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>
2016-01-05 14:45:38 +01:00
Johannes Schindelin
6887996810 git wrapper: auto-grow buffer in expand_variables()
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2016-01-05 14:45:38 +01:00
Johannes Schindelin
734fd3f4e7 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>
2016-01-05 14:45:37 +01:00
Johannes Schindelin
ddd9ff0a81 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>
2016-01-05 14:45:36 +01:00
Johannes Schindelin
05541a296c 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>
2016-01-05 14:45:33 +01:00
lchiocca
2f0ba46dad The stat() function should be independent of core.symlinks
The contract for the stat() and lstat() function is:
> stat():  stats the file pointed to by path and fills in buf.
> lstat(): is identical to stat(), except that if path is a symbolic link,
>          then the link itself is stat-ed, not the file that it refers to.

stat() should always return the statistics of the file or directory a
symbolic link is pointing to. The lstat() function is used to get the
stats for the symlink. Hence the check should not be there.

Signed-off-by: Loris Chiocca <loris@chiocca.ch>
2016-01-05 14:45:31 +01:00
Johannes Schindelin
70349317be mingw: keep trailing slashes for _wchdir() and readlink()
This is needed so that `_wchdir()` can be used with drive root
directories, e.g. C:\ (`_wchdir("C:")` fails to switch the directory
to the root directory).

This fixes https://github.com/msysgit/git/issues/359 (in Git for Windows
2.x only, though).

Likewise, `readlink()`'s semantics require a trailing slash for symbolic
links pointing to directories. Otherwise all checked out symbolic links
pointing to directories would be marked as modified even directly after a
fresh clone.

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

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2016-01-05 14:45:30 +01:00
Karsten Blees
101c758211 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>
2016-01-05 14:45:29 +01:00
Karsten Blees
1cd29a3fb8 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>
2016-01-05 14:45:28 +01:00
Karsten Blees
ad504ca90b 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>
2016-01-05 14:45:27 +01:00
Karsten Blees
2752af9552 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>
2016-01-05 14:45:26 +01:00
Karsten Blees
d18741b197 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>
2016-01-05 14:45:25 +01:00
Karsten Blees
88f96d3da4 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>
2016-01-05 14:45:24 +01:00
Karsten Blees
cc22fae4f0 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>
2016-01-05 14:45:23 +01:00