Commit Graph

50419 Commits

Author SHA1 Message Date
Karsten Blees
a89cf7f0a0 Win32: add symlink-specific error codes
Signed-off-by: Karsten Blees <blees@dcon.de>
2015-05-24 01:55:48 +02:00
Karsten Blees
d3b84b812a 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-24 01:55:05 +02:00
Karsten Blees
31a1302660 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-24 00:20:41 +02:00
Karsten Blees
f55a25a02f 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-24 00:20:41 +02:00
Karsten Blees
9dd538aa14 Win32: lstat(): return adequate stat.st_size for symlinks
Git typically doesn't trust the stat.st_size member of symlinks (e.g. see
strbuf_readlink()). However, some functions take shortcuts if st_size is 0
(e.g. diff_populate_filespec()).

In mingw_lstat() and fscache_lstat(), make sure to return an adequate size.

The extra overhead of opening and reading the reparse point to calculate
the exact size is not necessary, as git doesn't rely on the value anyway.

Signed-off-by: Karsten Blees <blees@dcon.de>
2015-05-24 00:20:40 +02:00
Karsten Blees
dd7f51b836 Win32: teach fscache and dirent about symlinks
Move S_IFLNK detection to file_attr_to_st_mode() and reuse it in fscache.

Implement DT_LNK detection in dirent.c and the fscache readdir version.

Signed-off-by: Karsten Blees <blees@dcon.de>
2015-05-24 00:20:39 +02:00
Karsten Blees
554a6ca265 Win32: let mingw_lstat() error early upon problems with reparse points
When obtaining lstat information for reparse points, we need to call
FindFirstFile() in addition to GetFileInformationEx() to obtain the type
of the reparse point (symlink, mount point etc.). However, currently there
is no error handling whatsoever if FindFirstFile() fails.

Call FindFirstFile() before modifying the stat *buf output parameter and
error out if the call fails.

Note: The FindFirstFile() return value includes all the data that we get
from GetFileAttributesEx(), so we could replace GetFileAttributesEx() with
FindFirstFile(). We don't do that because GetFileAttributesEx() is about
twice as fast for single files. I.e. we only pay the extra cost of calling
FindFirstFile() in the rare case that we encounter a reparse point.

Note: The indentation of the remaining reparse point code will be fixed in
the next patch.

Signed-off-by: Karsten Blees <blees@dcon.de>
2015-05-24 00:17:56 +02:00
Karsten Blees
5d5651784f Win32: remove separate do_lstat() function
With the new mingw_stat() implementation, do_lstat() is only called from
mingw_lstat() (with follow == 0). Remove the extra function and the old
mingw_stat()-specific (follow == 1) logic.

Signed-off-by: Karsten Blees <blees@dcon.de>
2015-05-16 01:18:24 +02:00
Karsten Blees
b908441ea5 Win32: implement stat() with symlink support
With respect to symlinks, the current stat() implementation is almost the
same as lstat(): except for the file type (st_mode & S_IFMT), it returns
information about the link rather than the target.

Implement stat by opening the file with as little permissions as possible
and calling GetFileInformationByHandle on it. This way, all link resoltion
is handled by the Windows file system layer.

If symlinks are disabled, use lstat() as before, but fail with ELOOP if a
symlink would have to be resolved.

Signed-off-by: Karsten Blees <blees@dcon.de>
2015-05-16 01:18:14 +02:00
Karsten Blees
643694d1bf Win32: don't call GetFileAttributes twice in mingw_lstat()
GetFileAttributes cannot handle paths with trailing dir separator. The
current [l]stat implementation calls GetFileAttributes twice if the path
has trailing slashes (first with the original path passed to [l]stat, and
and a second time with a path copy with trailing '/' removed).

With Unicode conversion, we get the length of the path for free and also
have a (wide char) buffer that can be modified.

Remove trailing directory separators before calling the Win32 API.

Signed-off-by: Karsten Blees <blees@dcon.de>
2015-05-12 11:09:01 +02:00
Karsten Blees
6b1da48c5b lockfile.c: use is_dir_sep() instead of hardcoded '/' checks
Signed-off-by: Karsten Blees <blees@dcon.de>
2015-05-11 22:15:53 +02:00
Karsten Blees
27c549fc85 strbuf_readlink: support link targets that exceed PATH_MAX
strbuf_readlink() refuses to read link targets that exceed PATH_MAX (even
if a sufficient size was specified by the caller).

As some platforms support longer paths, remove this restriction (similar
to strbuf_getcwd()).

Signed-off-by: Karsten Blees <blees@dcon.de>
2015-05-11 22:15:40 +02:00
Karsten Blees
81b096fac1 strbuf_readlink: don't call readlink twice if hint is the exact link size
strbuf_readlink() calls readlink() twice if the hint argument specifies the
exact size of the link target (e.g. by passing stat.st_size as returned by
lstat()). This is necessary because 'readlink(..., hint) == hint' could
mean that the buffer was too small.

Use hint + 1 as buffer size to prevent this.

Signed-off-by: Karsten Blees <blees@dcon.de>
2015-05-11 19:54:23 +02:00
Johannes Schindelin
438f3e75d1 fixup! git-wrapper: support the non-mintty fall-back for Git Bash
With this fix, SHOW_CONSOLE=1 will really force a new window to be
displayed.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2015-05-07 15:49:43 +00:00
Johannes Schindelin
a5c8f5e40d Merge branch 'git-bash-wo-mintty'
This branch helps with installing a `git-bash.exe` that uses ConHost
(i.e. the default Windows console window) instead of MinTTY.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2015-05-07 15:27:45 +00:00
Johannes Schindelin
27ae7e2b40 fixup! Git wrapper: allow overriding what executable is called
Avoid double initialization, pointed out by Eli Young.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2015-05-07 09:49:43 +00:00
dscho
2113021567 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-06 18:46:27 +02:00
dscho
b058360131 Merge pull request #140 from nalla/console-read-clarification
fixup! mingw: Support `git_terminal_prompt` with more terminals
2015-05-06 16:19:20 +02:00
마누엘
358701671b fixup! mingw: Support git_terminal_prompt with more terminals
During the next rebase merge the clarification of the *read from the
console* command with the previous commits. Then get rid of this commit
message.

Signed-off-by: 마누엘 <nalla@hamal.uberspace.de>
2015-05-06 15:27:20 +02:00
Johannes Schindelin
d207cffe9b git-wrapper: support the non-mintty fall-back for Git Bash
When we fall back to starting the Git Bash in the regular Windows
console, we need to show said console's window... So let's introduce yet
another configuration knob for use via string resources.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2015-05-06 12:09:03 +00:00
Johannes Schindelin
d56d2f8c48 squash! mingw: Support git_terminal_prompt with more terminals
Adjust the commit message with the following paragraph:

The most prominent user of `git_terminal_prompt()` is certainly
`git-remote-https.exe`. It is an interesting use case because both
`stdin` and `stdout` are redirected when Git calls said executable, yet
it still wants to access the terminal.

When running inside a `mintty`, the terminal is not accessible to the
`git-remote-https.exe` program, though, because it is a MinGW program
and the `mintty` terminal is not backed by a Win32 console.

To solve that problem, we simply call out to the shell -- which is an
*MSys2* program and can therefore access `/dev/tty`.
2015-05-06 07:52:05 +00:00
Johannes Schindelin
a105bde8d3 Merge branch 'xp-console'
This branch wants to be merged into the git-wrapper branch; it fixes an
issue with the way we called the MSys2 terminal `mintty` from the GUI
application `git-bash.exe`.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2015-05-04 16:24:35 +02:00
Johannes Schindelin
dbd0783837 git wrapper: allow _Git Bash_ to run with a newly allocated console
With a recent change in Cygwin (which is the basis of the msys2-runtime),
a GUI process desiring to launch an MSys2 executable needs to allocate a
console for the new process (otherwise the process will just hang on
Windows XP). _Git Bash_ is such a GUI process.

While at it, use correct handles when inheriting the stdin/stdout/stderr
handles: `GetStdHandle()` returns NULL for invalid handles, but the
STARTUPINFO must specify `INVALID_HANDLE_VALUE` instead.

Originally, the hope was that only this `NULL` => `INVALID_HANDLE_VALUE`
conversion would be required to fix the Windows XP issue mentioned above
(extensive debugging revealed that starting _Git Bash_ on Windows XP would
yield invalid handles for `stdin` and `stderr`, but *not* for `stdout`).

However, while _Git Bash_ eventually showed a `mintty` when not allocating
a new console, it took around one second to show it, and several seconds
to close it. So let's just include both fixes.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2015-05-04 06:38:44 -07:00
Johannes Schindelin
ab5cce0ac8 git-wrapper: prepare to allow more options than MINIMAL_PATH
With the resource-driven command-line configuration, we introduced the
option to ensure that only the PATH environment variable is edited only
minimally, i.e. only /cmd/ is added (as appropriate for _Git CMD_).

We are about to add another option, so let's refactor the equivalent of
Git's `strip_prefix()` function; It is not *quite* the same because we
have to `memmove()` the remainder to the beginning of the buffer.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2015-05-04 06:34:52 -07:00
Johannes Schindelin
dd07b7d2c3 fixup! Git wrapper: allow overriding what executable is called 2015-05-04 06:34:15 -07:00
Torsten Bögershausen
8354b03718 blame: CRLF in the working tree and LF in the repo
A typical setup under Windows is to set core.eol to CRLF, and text
files are marked as "text" in .gitattributes, or core.autocrlf is
set to true.

After 4d4813a5 "git blame" no longer works as expected for such a
set-up.  Every line is annotated as "Not Committed Yet", even though
the working directory is clean.  This is because the commit removed
the conversion in blame.c for all files, with or without CRLF in the
repo.

Having files with CRLF in the repo and core.autocrlf=input is a
temporary situation, and the files, if committed as is, will be
normalized in the repo, which _will_ be a notable change.  Blaming
them with "Not Committed Yet" is the right result.  Revert commit
4d4813a5 which was a misguided attempt to "solve" a non-problem.

Add two test cases in t8003 to verify the correct CRLF conversion.

Suggested-By: Stepan Kasal <kasal@ucw.cz>
Signed-off-by: Torsten Bögershausen <tboegi@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-05-04 05:26:05 +01:00
Johannes Schindelin
5294e722c6 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-01 15:36:00 +02:00
Johannes Schindelin
80b9abc664 Merge pull request #60 from weakcamel/fscanf-64bit-constants
Correct fscanf formatting string for I64u values

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2015-05-01 15:36:00 +02:00
Johannes Schindelin
2050b50192 Merge pull request #98 from nalla/stdout-unbuffered
mingw: explicitly `fflush` stdout
2015-05-01 15:36:00 +02:00
Johannes Schindelin
571f886c69 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-01 15:36:00 +02:00
Johannes Schindelin
5d433b4d10 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-01 15:35:59 +02:00
Johannes Schindelin
30bc1ec473 Merge 'non-win-fixes' into HEAD 2015-05-01 15:35:59 +02:00
Johannes Schindelin
0bb4374323 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-01 15:35:59 +02:00
Johannes Schindelin
5d68b693b8 Merge 'readme' into HEAD
Add a README.md for GitHub goodness.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2015-05-01 15:35:59 +02:00
Johannes Schindelin
586e4783d4 Merge 'fix-is-exe' into HEAD 2015-05-01 15:35:59 +02:00
Johannes Schindelin
40dc8e3160 Merge 'fix-externals' into HEAD 2015-05-01 15:35:58 +02:00
Johannes Schindelin
c89ba5920a 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-01 15:35:58 +02:00
Johannes Schindelin
97b66916d8 Merge 'win-tests-fixes' into HEAD 2015-05-01 15:35:58 +02:00
Johannes Schindelin
d4fa8dc8f7 Merge 'msys2' into HEAD
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2015-05-01 15:35:58 +02:00
Johannes Schindelin
5cb5da5d2b Merge 'pull-rebase-interactive' into HEAD 2015-05-01 15:35:58 +02:00
Johannes Schindelin
2ab8483fa8 Merge 'jberezanski/wincred-sso-r2' into HEAD 2015-05-01 15:35:58 +02:00
Johannes Schindelin
1428890caf Merge 'gitk' into HEAD 2015-05-01 15:35:57 +02:00
Johannes Schindelin
464845bec6 Merge 'git-gui' into HEAD 2015-05-01 15:35:57 +02:00
Johannes Schindelin
6748be8565 Merge 'criss-cross-merge' into HEAD 2015-05-01 15:35:57 +02:00
Johannes Schindelin
3d7087ec78 Merge 'hide-dotgit' into HEAD 2015-05-01 15:35:57 +02:00
Johannes Schindelin
f60c36e995 Merge 'unicode' into HEAD 2015-05-01 15:35:57 +02:00
Johannes Schindelin
6320a15d73 Document the Windows-wide config file
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2015-05-01 15:35:56 +02:00
Johannes Schindelin
ba8c0399e6 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.

Therefore we came to a consensus to use %PROGRAMDATA%\Git as the
location for Git-specific files 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.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2015-05-01 15:35:56 +02:00
Waldek Maleska
2e8ecddd6a Correct fscanf formatting string for I64u values
Signed-off-by: Waldek Maleska <w.maleska@gmail.com>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2015-05-01 15:35:55 +02:00
nalla
20187194f8 mingw: explicitly fflush stdout
For performance reasons `stdout` is not unbuffered by default. That leads
to problems if after printing to `stdout` a read on `stdin` is performed.

For that reason interactive commands like `git clean -i` do not function
properly anymore if the `stdout` is not flushed by `fflush(stdout)` before
trying to read from `stdin`.

In the case of `git clean -i` all reads on `stdin` were preceded by a
`fflush(stdout)` call.

Signed-off-by: nalla <nalla@hamal.uberspace.de>
2015-05-01 15:35:54 +02:00