Commit Graph

50409 Commits

Author SHA1 Message Date
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
Karsten Blees
d2a54a03dc git-wrapper: remove redundant TERM initialization
Remove redundant TERM initialization from git-wrapper in favor of TERM
initialization in git itself.

Signed-off-by: Karsten Blees <blees@dcon.de>
2015-05-01 15:35:25 +02:00
Karsten Blees
12723595c9 git-wrapper: fix HOME initialization
git-wrapper fails to initialize HOME correctly if $HOMEDRIVE$HOMEPATH
points to a disconnected network drive.

Check if the directory exists before using $HOMEDRIVE$HOMEPATH.

Signed-off-by: Karsten Blees <blees@dcon.de>
2015-05-01 15:35:24 +02:00
Vitaly Takmazov
01ecc42782 git-wrapper: case-insensitive path comparison 2015-05-01 15:35:24 +02:00
Johannes Schindelin
5205c42165 git-wrapper: interpret --cd=<directory> when configured via resources
This change accompanies the `--no-cd` option when configured via
resources. It is required to support `Git Bash Here`: when
right-clicking an icon in the Explorer to start a Bash, the working
directory is actually the directory that is displayed in the Explorer.
That means if the clicked icon actually refers to a directory, the
working directory would be its *parent* directory.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2015-05-01 15:35:24 +02:00
Johannes Schindelin
4527eda954 git-wrapper: serve as git-gui.exe, too
To avoid that ugly Console window when calling \cmd\git.exe gui...

To avoid confusion with builtins, we need to move the code block
handling gitk (and now git-gui, too) to intercept before git-gui is
mistaken for a builtin.

Unfortunately, git-gui is in libexec/git-core/ while gitk is in bin/,
therefore we need slightly more adjustments than just moving and
augmenting the gitk case.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2015-05-01 15:35:24 +02:00
nalla
b96b7d2362 git-wrapper: support git.exe and gitk.exe to be in a spaced dir
When *Git for Windows* is installed into a directory that has spaces in
it, e.g. `C:\Program Files\Git`, the `git-wrapper` appends this directory
unquoted when fixing up the command line. To resolve this, just quote the
provided `execpath`.

Signed-off-by: nalla <nalla@hamal.uberspace.de>
2015-05-01 15:35:24 +02:00
nalla
1e19f387b8 mingw: Support git_terminal_prompt with more terminals
The `git_terminal_prompt()` function expects the terminal window to be
attached to a Win32 Console. However, this is not the case with terminal
windows other than `cmd.exe`'s, e.g. with MSys2's own `mintty`.

Non-cmd terminals such as `mintty` still have to have a Win32 Console
to be proper console programs, but have to hide the Win32 Console to
be able to provide more flexibility (such as being resizeable not only
vertically but also horizontally). By writing to that Win32 Console,
`git_terminal_prompt()` manages only to send the prompt to nowhere and
to wait for input from a Console to which the user has no access.

This commit introduces a function specifically to support `mintty` -- or
other terminals that are compatible with MSys2's `/dev/tty` emulation. We
use the `TERM` environment variable as an indicator for that: if the value
starts with "xterm" (such as `mintty`'s "xterm_256color"), we prefer to
let `xterm_prompt()` handle the user interaction.

To handle the case when standard input/output are redirected – as is the
case when pushing via HTTPS: `git-remote-https`' standard input and
output are pipes from/to the main Git executable – we make use of the
`MSYS_TTY_HANDLES` environment variable that was introduced to
fix another bug in MSys2-based Git: this environment variable contains
the Win32 `HANDLE`s of the standard input, output and error as originally
passed from MSys2 to the Git executable, enclosed within space
characters, skipping handles that do not refer to the terminal window
(e.g. when they were redirected). We will only use those handles when
that environment variable lists all three handles because then we can be
100% certain that we are running inside a terminal window, and that we
know exactly which Win32 handles to use to communicate with it.

Helped-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: nalla <nalla@hamal.uberspace.de>
2015-05-01 15:35:24 +02:00
Johannes Schindelin
319bc66966 git-wrapper: Allow git-cmd.exe to add only /cmd/ to the PATH
The idea of having the Git wrapper in the /cmd/ directory is to allow
adding only a *tiny* set of executables to the search path, to allow
minimal interference with other software applications. It is quite
likely, for example, that other software applications require their own
version of zlib1.dll and would not be overly happy to find the version
Git for Windows ships.

The /cmd/ directory also gives us the opportunity to let the Git wrapper
handle the `gitk` script. It is a Tcl/Tk script that is not recognized
by Windows, therefore calling `gitk` in `cmd.exe` would not work, even
if we add all of Git for Windows' bin/ directories.

So let's use the /cmd/ directory instead of adding /mingw??/bin/ and
/usr/bin/ to the PATH when launching Git CMD.

The way we implemented Git CMD is to embed the appropriate command line
as string resource into a copy of the Git wrapper. Therefore we extended
that syntax to allow for configuring a minimal search path.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2015-05-01 15:35:24 +02:00
Johannes Schindelin
f4edc66bf1 git-wrapper: optionally skip cd $HOME when configured via resources
We recently added the ability to configure copies of the Git wrapper to
launch custom command-lines, configured via plain old Windows resources.
The main user is Git for Windows' `git-bash.exe`, of course. When the
user double-clicks the `git bash` icon, it makes sense to start the Bash
in the user's home directory.

Third-party software, such as TortoiseGit or GitHub for Windows, may
want to start the Git Bash in another directory, though.

Now, when third-party software wants to call Git, they already have to
construct a command-line, and can easily pass a command-line option
`--no-cd` (which this commit introduces), and since that option is not
available when the user double-clicks an icon on the Desktop or in the
Explorer, let's keep the default to switch to the home directory if the
`--no-cd` flag was not passed along.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2015-05-01 15:35:24 +02:00
Johannes Schindelin
fd691a6a75 git-wrapper: make command-line argument skipping more robust
When we rewrite the command-line to call the *real* Git, we want to skip
the first command-line parameter. The previous code worked in most
circumstances, but was a bit fragile because it assumed that no fancy
quoting would take place.

In the next commit, we will want to have the option to skip more than
just one command-line parameter, so we have to be much more careful with
the command-line handling.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2015-05-01 15:35:23 +02:00