Commit Graph

54271 Commits

Author SHA1 Message Date
Heiko Voigt
e76577893b help: correct behavior for is_executable on Windows
The previous implementation said that the filesystem information on
Windows is not reliable to determine whether a file is executable.
To find gather this information it was peeking into the first two bytes
of a file to see whether it looks executable.
Apart from the fact that on Windows executables are usually defined as
such by their extension it lead to slow opening of help file in some
situations.

When you have virus scanner running calling open on an executable file
is a potentially expensive operation. See the following measurements (in
seconds) for example.

With virus scanner running (coldcache):

$ ./a.exe /libexec/git-core/
before open (git-add.exe): 0.000000
after open (git-add.exe): 0.412873
before open (git-annotate.exe): 0.000175
after open (git-annotate.exe): 0.397925
before open (git-apply.exe): 0.000243
after open (git-apply.exe): 0.399996
before open (git-archive.exe): 0.000147
after open (git-archive.exe): 0.397783
before open (git-bisect--helper.exe): 0.000160
after open (git-bisect--helper.exe): 0.397700
before open (git-blame.exe): 0.000160
after open (git-blame.exe): 0.399136
...

With virus scanner running (hotcache):

$ ./a.exe /libexec/git-core/
before open (git-add.exe): 0.000000
after open (git-add.exe): 0.000325
before open (git-annotate.exe): 0.000229
after open (git-annotate.exe): 0.000177
before open (git-apply.exe): 0.000167
after open (git-apply.exe): 0.000150
before open (git-archive.exe): 0.000154
after open (git-archive.exe): 0.000156
before open (git-bisect--helper.exe): 0.000132
after open (git-bisect--helper.exe): 0.000180
before open (git-blame.exe): 0.000718
after open (git-blame.exe): 0.000724
...

This test did just list the given directory and open() each file in it.

With this patch I get:

$ time git help git
Launching default browser to display HTML ...

real    0m8.723s
user    0m0.000s
sys     0m0.000s

and without

$ time git help git
Launching default browser to display HTML ...

real    1m37.734s
user    0m0.000s
sys     0m0.031s

both tests with cold cache and giving the machine some time to settle
down after restart.

Signed-off-by: Heiko Voigt <heiko.voigt@mahr.de>
2015-10-04 15:32:16 +02:00
Johannes Schindelin
83610ba057 Start the merging-rebase to v2.6.1
This commit starts the rebase of b3b8b31 to defffe3
2015-10-04 15:31:30 +02:00
Johannes Schindelin
2bf148c14f fixup! git-gui: fix detection of Cygwin 2015-09-30 15:25:02 +02:00
Johannes Schindelin
038fb0e427 fixup! TO-UNDO
Whoops... ;-)

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2015-09-30 13:17:34 +00:00
Johannes Schindelin
82cec6a5f1 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>
2015-09-30 13:08:46 +00:00
Johannes Schindelin
51afad7c6c git-gui (Windows): use git-gui.exe in Create Desktop Shortcut
When calling `Repository>Create Desktop Shortcut`, Git GUI assumes
that it is okay to call `wish.exe` directly on Windows. However, in
Git for Windows 2.x' context, that leaves several crucial environment
variables uninitialized, resulting in a shortcut that does not work.

To fix those environment variable woes, Git for Windows comes with a
convenient `git-gui.exe`, so let's just use it when it is available.

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

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2015-09-30 12:42:52 +00:00
Johannes Schindelin
15c3576703 TO-UNDO 2015-09-30 12:42:45 +00:00
Johannes Schindelin
6a2c2acd50 git-gui: fix detection of Cygwin
MSys2 might *look* like Cygwin, but it is *not* Cygwin... Unless it
is run with `MSYSTEM=MSYS`, that is.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2015-09-30 12:41:52 +00:00
Johannes Schindelin
b73d37caf3 fixup! Add a test demonstrating a problem with long submodule paths 2015-09-29 16:51:41 +02:00
Johannes Schindelin
43b6eee9dc Merge branch 'home-bin' 2015-09-29 16:45:56 +02:00
Johannes Schindelin
254e6e8f96 Merge branch 'work-tree-icase'
This topic branch fixes the "is inside work tree" test when it fails
solely due to lower/upper case differences despite the config setting
`core.ignoreCase = true` (Git for Windows' default).

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2015-09-29 16:45:56 +02:00
Johannes Schindelin
a755cd8f68 git-wrapper: append $HOME/bin to the PATH
`$HOME/bin/` is quite convenient a place to put user-specific Git
helpers, such as credential or remote helpers.

When run in Git Bash, it is therefore already appended to the PATH;
Let's do the equivalent when run in Git CMD: when `git.exe` is
called, Git is told to look also for scripts and programs in
`$HOME/bin` (this does not modify Git CMD's `PATH`, of course).

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

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2015-09-29 16:45:55 +02:00
Johannes Schindelin
a369f3299f Merge branch 'racy-dissociate'
This fixes a file-locking problem with `git clone --dissociate`.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2015-09-29 16:45:55 +02:00
Johannes Schindelin
18d354275a Fix "inside work tree" detection on case-insensitive filesystems
Git has a config variable to indicate that it is operating on a file
system that is case-insensitive: core.ignoreCase. But the
`dir_inside_of()` function did not respect that. As a result, if Git's
idea of the current working directory disagreed in its upper/lower case
from the `GIT_WORK_TREE` variable (e.g. `C:\test` vs `c:\test`) the
user would be greeted by the error message

	fatal: git-am cannot be used without a working tree.

when trying to run a rebase.

This fixes https://github.com/git-for-windows/git/issues/402 (reported by
Daniel Harding).

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2015-09-29 16:45:55 +02:00
Johannes Schindelin
7272771770 clone --dissociate: avoid locking pack files
When `git clone` is asked to dissociate the repository from the
reference repository whose objects were used, it is quite possible that
the pack files need to be repacked. In that case, the pack files need to
be deleted that were originally hard-links to the reference repository's
pack files.

On platforms where a file cannot be deleted if another process still
holds a handle on it, we therefore need to take pains to release all
pack files and indexes before dissociating.

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

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2015-09-29 16:45:55 +02:00
Johannes Schindelin
05192d55c1 Merge branch 'conhost-git-bash' 2015-09-29 16:45:54 +02:00
Johannes Schindelin
ec5e5c6b83 Merge pull request #443 from kblees/kb/nanosecond-file-times-v2.5.3
nanosecond file times for v2.5.3
2015-09-29 16:45:54 +02:00
Johannes Schindelin
755b62287e Merge branch 'getcwd-fix-case'
This makes sure that Git's idea of the current working directory matches
what is recorded on disk (which should be the same as Git's idea).

This helps in particular PowerShell users where the current working
directory can differ in case from what's stored on disk.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2015-09-29 16:45:54 +02:00
Johannes Schindelin
5b472674cc git-wrapper: support COMSPEC better
The quoting rules of `cmd.exe` are really, really quirky. In particular,
if there are more than two quotes, the entire set of rules changes. That
is the reason why

	CMD /C "C:\Program Files\Git\usr\bin\bash.exe" -l -i

works, but

	CMD /C "C:\Program Files\Git\usr\bin\bash.exe" -l -i "test.sh"

fails with this error message:

	'C:\Program' is not recognized as an internal or external command,
	operable program or batch file.

The recommended fix is to pass the /S option to `cmd.exe` and surround
the entire command-line by an extra set of quotes. And here lies the
rub: for that to work, we have to append an extra quote. At the end of
the command-line. *After* the last argument was appended, if any.

This commit supports that use case by introducing the option
"APPEND_QUOTE". The intended usage is to use the following string
resource:

	SHOW_CONSOLE=1 APPEND_QUOTE=1
	@@COMSPEC@@ /S /C \"\"@@EXEPATH@@\\usr\\bin\\bash.exe\" --login -i

(Note that there are only three quotes on that command-line, the fourth
to be appended due to the `APPEND_QUOTE` setting.)

This is (1/3) to fix https://github.com/git-for-windows/git/issues/396

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2015-09-29 16:45:54 +02:00
Karsten Blees
b1c32caaa2 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>
2015-09-29 16:45:54 +02:00
Karsten Blees
72768d824c Win32: replace MSVCRT's fstat() with a Win32-based implementation
fstat() is the only stat-related CRT function for which we don't have a
full replacement yet (and thus the only reason to stick with MSVCRT's
'struct stat' definition).

Fully implement fstat(), in preparation of implementing a POSIX 2013
compatible 'struct stat' with nanosecond-precision file times.

Signed-off-by: Karsten Blees <blees@dcon.de>
2015-09-29 16:45:54 +02:00
Johannes Schindelin
c7a9700d8f t0302: add forgotten quotes
This was probably missed because nobody had a left-over `trash/`
directory and the `-f` flag made sure that no error message was
produced when the file was not found that *actually* wanted to
be removed.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2015-09-29 16:45:53 +02:00
Johannes Schindelin
a249a6f05d mingw: ensure getcwd() reports the correct case
When switching the current working directory, say, in PowerShell, it is
quite possible to use a different capitalization than the one that is
recorded on disk. While doing the same in `cmd.exe` adjusts the
capitalization magically, that does not happen in PowerShell so that
`getcwd()` returns the current directory in a different way than is
recorded on disk.

Typically this creates no problems except when you call

	git log .

in a subdirectory called, say, "GIT/" but you switched to "Git/" and
your `getcwd()` reports the latter, then Git won't understand that you
wanted to see the history as per the `GIT/` subdirectory but it thinks you
wanted to see the history of some directory that may have existed in the
past (but actually never did).

So let's be extra careful to adjust the capitalization of the current
directory before working with it.

Reported by a few PowerShell power users ;-)

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2015-09-29 16:45:53 +02:00
Johannes Schindelin
3b584d1c10 Merge pull request #305 from dscho/msysgit_issues_182
Allow `add -p` and `add -i` with a large number of files
2015-09-29 16:45:53 +02:00
Johannes Schindelin
384a256dbe t3701: verify that we can add *lots* of files interactively
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2015-09-29 16:45:53 +02:00
Kelly Heller
a6fe57b8e5 Allow add -p and add -i with a large number of files
This fixes https://github.com/msysgit/git/issues/182.

Inspired by Pull Request 218 using code from @PhilipDavis.

[jes: simplified code quite a bit]

Signed-off-by: Kelly Heller <kkheller@cedrus.com>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2015-09-29 16:45:53 +02:00
Johannes Schindelin
1718ab23a1 Merge branch 'bash-redirector' 2015-09-29 16:45:52 +02:00
Johannes Schindelin
d920a88694 Merge pull request #286 from dscho/unc-alternates
Make alternates work on UNC paths
2015-09-29 16:45:52 +02:00
Johannes Schindelin
8357d2120c mingw: let the Git wrapper determine the top-level directory
The Git wrapper is also used as a redirector for Git for Windows'
bin\bash.exe dropin: for backwards-compatibility, bin\bash.exe exists
and simply sets up the environment variables before executing the
*real* bash.

However, due to our logic to use the directory in which the `.exe`
lives as top-level directory (or one directory below for certain, known
basenames such as `git.exe` and `gitk.exe`), the `PATH` environment
variable was prefixed with the `/bin/bin` and `/bin/mingw/bin`
directories -- which makes no sense.

Instead, let's just auto-detect the top-level directory in the common
case.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2015-09-29 16:45:52 +02:00
Johannes Schindelin
ed829f4a76 Merge branch 'issue-231'
This branch hopefully addresses

	https://github.com/git-for-windows/git/issues/231

where `git repack` could not delete the object directory because there
was still an open handle on it.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2015-09-29 16:45:52 +02:00
Johannes Schindelin
9a88f5e474 Merge pull request #275 from cs96and/cygwin_fixes
winansi.c: Fix colourization on Cygwin pseudo terminals.
2015-09-29 16:45:52 +02:00
Johannes Schindelin
bf40775e1b 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>
2015-09-29 16:45:52 +02:00
Johannes Schindelin
1d384f0491 Merge pull request #276 from dscho/issue-0xff
mingw: Suppress warning that <commit>:.gitattributes does not exist
2015-09-29 16:45:52 +02:00
Johannes Schindelin
c1cdb876a6 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>
2015-09-29 16:45:51 +02:00
Johannes Schindelin
111835d2d7 mingw: clean up the Git wrapper a bit
We should not conflate the 'exepath' with the 'top-level
directory'. The former should be the directory in which the executable
lives while the latter should be the top-level directory ("POSIX root
directory") as far as Git is concerned.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2015-09-29 16:45:51 +02:00
Johannes Sixt
1810e4398f prune: close directory earlier during loose-object directory traversal
27e1e22d (prune: factor out loose-object directory traversal, 2014-10-16)
introduced a new function for_each_loose_file_in_objdir() with a helper
for_each_file_in_obj_subdir(). The latter calls callbacks for each file
found during a directory traversal and finally also a callback for the
directory itself.

git-prune uses the function to clean up the object directory. In
particular, in the directory callback it calls rmdir(). On Windows XP,
this rmdir call fails, because the directory is still open while the
callback is called. Close the directory before calling the callback.

Signed-off-by: Johannes Sixt <j6t@kdbg.org>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2015-09-29 16:45:51 +02:00
Alan Davies
8cdf27b5e2 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>
2015-09-29 16:45:51 +02:00
Johannes Schindelin
1bb9d8334b 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>
2015-09-29 16:45:50 +02:00
Johannes Schindelin
728749a568 Merge pull request #200 from dscho/code-of-conduct
Add a brief "code of conduct" section to the Governance Model
2015-09-29 16:45:50 +02:00
Johannes Schindelin
13d8d4f303 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>
2015-09-29 16:45:50 +02:00
Johannes Schindelin
fd15ef6d04 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>
2015-09-29 16:45:50 +02:00
Johannes Schindelin
d4a786e36f Merge pull request #246 from uecasm/patch-1
Verify memoized files can be reloaded before using them
2015-09-29 16:45:50 +02:00
Johannes Schindelin
a559efd4f2 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-09-29 16:45:49 +02:00
Johannes Schindelin
9401bc2c3f 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-09-29 16:45:49 +02:00
Johannes Schindelin
df96b0807a Merge pull request #159 from dscho/vagrant
Add Vagrant support (easy Linux VM setup)
2015-09-29 16:45:49 +02:00
Johannes Schindelin
08966b0c40 Merge pull request #156 from kblees/kb/symlinks
Symlink support
2015-09-29 16:45:49 +02:00
Johannes Schindelin
708d36cb82 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-09-29 16:45:49 +02:00
Johannes Schindelin
e0a1f89e8a Merge 'non-win-fixes' into HEAD 2015-09-29 16:45:49 +02:00
Johannes Schindelin
9ab63b1b03 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-09-29 16:45:49 +02:00
Johannes Schindelin
524f8f1cdd Merge 'readme' into HEAD
Add a README.md for GitHub goodness.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2015-09-29 16:45:48 +02:00