Commit Graph

37905 Commits

Author SHA1 Message Date
Sebastian Schuberth
4f1c5cfec3 gitk: Use an external icon file on Windows
Git for Windows now ships with the new Git icon from git-scm.com. Use that
icon file if it exists instead of the old procedurally drawn one.

This patch was sent upstream but so far no decision on its inclusion was
made, so commit it to our fork.

Signed-off-by: Sebastian Schuberth <sschuberth@gmail.com>
2012-10-01 14:35:49 +01:00
Pat Thoyts
49ab06eb05 git-subtree: add the generated script to the ignore file
Signed-off-by: Pat Thoyts <patthoyts@users.sourceforge.net>
2012-10-01 14:35:48 +01:00
Heiko Voigt
880ec444de 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>
2012-10-01 14:35:47 +01:00
Erik Faye-Lund
580ceb1c65 compat/terminal: header-fixup
getch is declared in conio.h, which was only included from
compat/mingw.c and compat/msvc.c.

Fix this, by moving the inclusion of getch to git-compat-util.h
instead.

Signed-off-by: Erik Faye-Lund <kusmabite@gmail.com>
2012-10-01 14:35:46 +01:00
Erik Faye-Lund
431fa8f83c compat/terminal: support echoing on windows
Without /dev/tty support, git_terminal_prompt simply ignores the
'echo'-parameter. On Windows we can do better by clevering up our
getpass-implementation a bit so it can conditionally echo.

While we're at it, plug a small memory-leak by returning a pointer
to a static strbuf instead of detaching it. This is the same thing
the /dev/tty-version of git_terminal_prompt does, and the callee
doesn't expect to have to free it's memory.

Signed-off-by: Erik Faye-Lund <kusmabite@gmail.com>
2012-10-01 14:35:45 +01:00
Pat Thoyts
760e559f68 Set the default help format to html for msys builds.
This resolves issue #19 by setting the compiled default to html in msys
builds following the changes introduced by commit
1cc8af0 "help: use HTML as the default help format on Windows"

Signed-off-by: Pat Thoyts <patthoyts@users.sourceforge.net>
2012-10-01 14:35:44 +01:00
Adam Roben
01403ffb1b Make non-.exe externals work again
7ebac8cb94 made launching of .exe
externals work when installed in Unicode paths. But it broke launching
of non-.exe externals, no matter where they were installed. We now
correctly maintain the UTF-8 and UTF-16 paths in tandem in lookup_prog.

This fixes t5526, among others.

Signed-off-by: Adam Roben <adam@roben.org>
2012-10-01 14:35:43 +01:00
Pat Thoyts
719f78a9ba Ensure the resource file is rebuilt when the version changes.
Acked-by: Erik Faye-Lund <kusmabite@gmail.com>
Acked-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Pat Thoyts <patthoyts@users.sourceforge.net>
2012-10-01 14:35:42 +01:00
Johannes Schindelin
1c7bf9984b Windows resource: handle dashes in the Git version gracefully
Reported by postiffm as issue #14.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2012-10-01 14:35:41 +01:00
Pat Thoyts
83f96d7c0b Provide a Windows version resource for the git executables.
Embeds the git version and description into the git executable thus
implementing the request in issue #5.

Acked-by: Heiko Voigt <hvoigt@hvoigt.net>
Acked-by: Sebastian Schuberth <sschuberth@gmail.com>
Acked-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Pat Thoyts <patthoyts@users.sourceforge.net>
2012-10-01 14:35:40 +01:00
theoleblond
174dd17b3e Sleep 1 millisecond in poll() to avoid busy wait
I played around with this quite a bit. After trying some more complex
schemes, I found that what worked best is to just sleep 1 millisecond
between iterations. Though it's a very short time, it still completely
eliminates the busy wait condition, without hurting perf.

There code uses SleepEx(1, TRUE) to sleep. See this page for a good
discussion of why that is better than calling SwitchToThread, which
is what was used previously:
http://stackoverflow.com/questions/1383943/switchtothread-vs-sleep1

Note that calling SleepEx(0, TRUE) does *not* solve the busy wait.

The most striking case was when testing on a UNC share with a large repo,
on a single CPU machine. Without the fix, it took 4 minutes 15 seconds,
and with the fix it took just 1:08! I think it's because git-upload-pack's
busy wait was eating the CPU away from the git process that's doing the
real work. With multi-proc, the timing is not much different, but tons of
CPU time is still wasted, which can be a killer on a server that needs to
do bunch of other things.

I also tested the very fast local case, and didn't see any measurable
difference. On a big repo with 4500 files, the upload-pack took about 2
seconds with and without the fix.
2012-10-01 14:35:39 +01:00
Johannes Schindelin
5ab15f45ae Work around a problem identified by BuildHive
Apparently the signal handling is not quite correct in the fsckobject
handling (most likely we rely on a side effect that lets us still output
some message after receiving a signal 13 but in the BuildHive setup this
fails intermittently).

As a consequence, the push in t5504 does fail as expected, but fails to
output anything (unexpected). Since this is good enough for now, let's
handle an empty output as success, too.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2012-10-01 14:35:38 +01:00
Johannes Schindelin
8a82b1c9a7 t1050: Fix invalid call to dd(1)
This is a companion patch to fce52b4(t4012: Fix invalid call to dd(1)).

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2012-10-01 14:35:37 +01:00
Michael J Gruber
1e000d4efc t5801: skip without hg
The tests for remote-hg require hg, so skip them all when there is no
hg available.
2012-10-01 14:35:36 +01:00
Johannes Schindelin
ac772564f6 Always auto-gc after calling a fast-import transport
After importing anything with fast-import, we should always let the
garbage collector do its job, since the objects are written to disk
inefficiently.

This brings down an initial import of http://selenic.com/hg from about
230 megabytes to about 14.

In the future, we may want to make this configurable on a per-remote
basis, or maybe teach fast-import about it in the first place.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2012-10-01 14:35:35 +01:00
Johannes Schindelin
a79990424a remote-hg: do not interfer with hg's revs() method
Matt Mackall introduced a revs() method to the localrepo class on Wed
Nov 2 13:37:34 2011 in the commit 'localrepo: add revs helper method'.
It is used when constructing a commit in memory.

If we store the set of revs we want to handle under the same name, it
overrides that method, resulting in an unpleasant 'TypeError: 'set'
object is not callable' whenever we want to push (as we are constructing
commits in memory, then).

So let's work around that by renaming our field to 'revs_' and hope that
upstream Mercurial does not introduce a field of that name, too.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2012-10-01 14:35:34 +01:00
Johannes Schindelin
9f934c9987 remote-hg: handle another funny author line from http://scelenic.com/hg
In this case: David Soria Parra <dsp <at> php.net>.

With this last of three Postel patches, remote-hg can import the
Mercurial repository completely.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2012-10-01 14:35:33 +01:00
Johannes Schindelin
2587cc6afc remote-hg: another case of Postel's law
This change allows invalid input from Mercurial repositories where the
author is recorded as 'Name <email@blah' (missing the closing '>').

With this change, importing http://scelenic.com/hg itself no longer fails
with:

	fatal: Missing > in ident string: Benoit Boissinot
	<benoit.boissinot@ens-lyon.org <none@none> 1129685868 -0700

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2012-10-01 14:35:32 +01:00
Johannes Schindelin
48b2769813 remote-hg: Postel's law dictates we should handle Author<author@mail>
We should handle a missing space before the email part of an author ident
gracefully. See for example the icedtea6 repository.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2012-10-01 14:35:31 +01:00
Sverre Rabbelier
4dcc671b85 git-remote-hg: add tests 2012-10-01 14:35:30 +01:00
Sverre Rabbelier
1b470072b1 git-remote-hg: add the helper
The helper uses the previously added infrastructure.

Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
2012-10-01 14:35:29 +01:00
Michael J Gruber
5c73277da9 remote-hg: adjust to hg 1.9
hg 1.0 changed the signature of hg.clone(). Adjust to it.

A real fix would need to check the hg version or try/catch.
2012-10-01 14:35:28 +01:00
Sverre Rabbelier
0edc8e9101 git-remote-hg: add GitExporter/GitImporter/NonLocalGit
This is inftrastructure required to implement git-remote-hg.
2012-10-01 14:35:27 +01:00
Sverre Rabbelier
e3cc5ed644 git-remote-hg: add hgexport, an hg-fast-export equivalent
This class will be used by git-remote-hg to do the heavy lifting.
2012-10-01 14:35:26 +01:00
Sverre Rabbelier
7de6ca0168 git-remote-hg: add GitHg, a helper class for converting hg commits to git
This class will be used by HgExport.
2012-10-01 14:35:25 +01:00
Sverre Rabbelier
088ad33d0f git-remote-hg: add hgimport, an hg-fast-import equivalent
This class will be used by git-remote-hg to do the heavy lifting.
2012-10-01 14:35:24 +01:00
Sverre Rabbelier
f835bb2c85 git_remote_helpers: add fastimport library 2012-10-01 14:35:23 +01:00
Sverre Rabbelier
049f093d7b git-remote-testgit: make local a function
Other helpers (such as git-remote-hg) require that 'self.local' is a
function, rather than a variable.
2012-10-01 14:35:22 +01:00
Sverre Rabbelier
5165e26cc2 remote-testgit: factor out RemoteHelper class
Facilitate writing import-export based helpers in python by
refactoring common code to a base class.

[jes: rebased to newer upstream Git]

Signed-off-by: Sverre Rabbelier <srabbelier@gmail.com>
Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
2012-10-01 14:35:21 +01:00
Sverre Rabbelier
026d07c92a remote-helper: check helper status after import/export
Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Signed-off-by: Sverre Rabbelier <srabbelier@gmail.com>
2012-10-01 14:35:20 +01:00
Sverre Rabbelier
2412a454c8 transport-helper: add trailing -- 2012-10-01 14:35:19 +01:00
Sverre Rabbelier
a85de2c9f9 t5800: point out that deleting branches does not work
This test actually breaks the repositories involved somehow, so it is
not enabled by default.
2012-10-01 14:35:18 +01:00
Sverre Rabbelier
512cb13251 t5800: test pushing a new branch with old content
This works now that fast-export has been fixed to properly handle
refs that point to a commit that was not exported during the current
fast-export run.
2012-10-01 14:35:17 +01:00
Johannes Schindelin
7655869cae setup_revisions: remember whether a ref was positive or not
This will be required by fast-export, when no commits were
exported, but the refs should be set, of course.

Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Signed-off-by: Sverre Rabbelier <srabbelier@gmail.com>
2012-10-01 14:35:16 +01:00
Johannes Schindelin
fb89a2c227 fast-export: do not export negative refs
When calling `git fast-export master..next` we want to export
refs/heads/next, but not refs/heads/master.

Currently this is not a problem, because negative refs' commits
are never shown. In the next commit this will be changed in order
to make sure that 'master..master' does export master. I.e. even
refs whose commits are not shown are exported.

Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Signed-off-by: Sverre Rabbelier <srabbelier@gmail.com>
2012-10-01 14:35:15 +01:00
Johannes Schindelin
b013fe02b6 setup_revisions: remember whether a ref was positive or not
This will be required by fast-export, when no commits were
exported, but the refs should be set, of course.

Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Signed-off-by: Sverre Rabbelier <srabbelier@gmail.com>
2012-10-01 14:35:14 +01:00
Johannes Schindelin
d3ac32cc68 fast-export: do not refer to non-existing marks
When calling `git fast-export a..a b` when a and b refer to the same
commit, nothing would be exported, and an incorrect reset line would
be printed for b ('from :0').

Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Signed-off-by: Sverre Rabbelier <srabbelier@gmail.com>
2012-10-01 14:35:13 +01:00
Erik Faye-Lund
7142f23405 MSVC: require pton and ntop emulation
Without this, git-daemon cannot be built with Microsoft Visual C++.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2012-10-01 14:35:12 +01:00
Erik Faye-Lund
b709e72409 MSVC: fix poll-related macro redefines
This seems to be related to the poll-emulation... I see that these things
are guarded by an "#if(_WIN32_WINNT >= 0x0600)" in <winsock2.h>, which
means it's supported for Windows Vista and above... We still support
Windows XP, so it seems someone has set this too high :)

I'd prefer to set this from the Makefile, but this generates a warning in
compat/win32/poll.c about redefining a macro (poll.c wants it to be 0x502,
which is Windows XP with SP2, rather than 0x501 which is normal Windows
XP).

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2012-10-01 14:35:11 +01:00
Karsten Blees
379f9c99e7 MSVC: link dynamically to the CRT
Dynamic linking is generally preferred over static linking, and MSVCRT.dll
has been integral part of Windows for a long time.

This also fixes linker warnings for _malloc and _free in zlib.lib, which
seems to be compiled for MSVCRT.dll already.

The DLL version also exports some of the CRT initialization functions,
which are hidden in the static libcmt.lib (e.g. __wgetmainargs, required by
subsequent Unicode patches).

Signed-off-by: Karsten Blees <blees@dcon.de>
2012-10-01 14:35:10 +01:00
Karsten Blees
1aef23cfae Win32: fix broken pipe detection
As of "Win32: Thread-safe windows console output", git-log no longer
terminates when the pager process dies. This is due to disabling buffering
for the replaced stdout / stderr streams. Git-log will periodically fflush
stdout (see write_or_die.c/mayble_flush_or_die()), but with no buffering,
this is a NOP that always succeeds (so we never detect the EPIPE error).

Exchange the original console handles with our console thread pipe handles
by accessing the internal MSVCRT data structures directly (which are
exposed via __pioinfo for some reason).

Implement this with minimal assumptions about the actual data structure to
make it work with different (hopefully even future) MSVCRT versions.

While messing with internal data structures is ugly, this patch solves the
problem at the source instead of adding more workarounds. We no longer need
the special winansi_isatty override, and the limitations documented in
"Win32: Thread-safe windows console output" are gone (i.e. fdopen(1/2)
returns unbuffered streams now, and isatty() for duped console file
descriptors works as expected).

Signed-off-by: Karsten Blees <blees@dcon.de>
2012-10-01 14:35:09 +01:00
Karsten Blees
17d11a8fc6 Win32: fix detection of empty directories in is_dir_empty
On Windows XP (not Win7), directories cannot be deleted while a find handle
is open, causing "Deletion of directory '...' failed. Should I try again?"
prompts.

Prior to 19d1e75d "Win32: Unicode file name support (except dirent)",
these failures were silently ignored due to strbuf_free in is_dir_empty
resetting GetLastError to ERROR_SUCCESS.

Close the find handle in is_dir_empty so that git doesn't block deletion
of the directory even after all other applications have released it.

Reported-by: John Chen <john0312@gmail.com>
Signed-off-by: Karsten Blees <blees@dcon.de>
2012-10-01 14:35:08 +01:00
Karsten Blees
b3910ea0df Win32: patch Windows environment on startup
Fix Windows specific environment settings on startup rather than checking
for special values on every getenv call.

As a side effect, this makes the patched environment (i.e. with properly
initialized TMPDIR and TERM) available to child processes.

Signed-off-by: Karsten Blees <blees@dcon.de>
2012-10-01 14:35:07 +01:00
Karsten Blees
921bf369b6 Win32: keep the environment sorted
The Windows environment is sorted, keep it that way for O(log n)
environment access.

Change compareenv to compare only the keys, so that it can be used to
find an entry irrespective of the value.

Change lookupenv to binary seach for an entry. Return one's complement of
the insert position if not found (libc's bsearch returns NULL).

Replace MSVCRT's getenv with a minimal do_getenv based on the binary search
function.

Change do_putenv to insert new entries at the correct position. Simplify
the function by swapping if conditions and using memmove instead of for
loops.

Move qsort from make_environment_block to mingw_startup. We still need to
sort on startup to make sure that the environment is sorted according to
our compareenv function (while Win32 / CreateProcess requires the
environment block to be sorted case-insensitively, CreateProcess currently
doesn't enforce this, and some applications such as bash just don't care).

Note that environment functions are _not_ thread-safe and are not required
to be so by POSIX, the application is responsible for synchronizing access
to the environment. MSVCRT's getenv and our new getenv implementation are
better than that in that they are thread-safe with respect to other getenv
calls as long as the environment is not modified. Git's indiscriminate use
of getenv in background threads currently requires this property.

Signed-off-by: Karsten Blees <blees@dcon.de>
2012-10-01 14:35:06 +01:00
Karsten Blees
e2b52a8ea8 Win32: use low-level memory allocation during initialization
As of d41489a6 "Add more large blob test cases", git's high-level memory
allocation functions (xmalloc, xmemdupz etc.) access the environment to
simulate limited memory in tests (see 'getenv("GIT_ALLOC_LIMIT")' in
memory_limit_check()). These functions should not be used before the
environment is fully initialized (particularly not to initialize the
environment itself).

The current solution ('environ = NULL; ALLOC_GROW(environ...)') only works
because MSVCRT's getenv() reinitializes environ when it is NULL (i.e. it
leaves us with two sets of unusabe (non-UTF-8) and unfreeable (CRT-
allocated) environments).

Add our own set of malloc-or-die functions to be used in startup code.

Also check the result of __wgetmainargs, which may fail if there's not
enough memory for wide-char arguments and environment.

This patch is in preparation of the sorted environment feature, which
completely replaces MSVCRT's getenv() implementation.

Signed-off-by: Karsten Blees <blees@dcon.de>
2012-10-01 14:35:05 +01:00
Karsten Blees
17eb945683 Win32: reduce environment array reallocations
Move environment array reallocation from do_putenv to the respective
callers. Keep track of the environment size in a global variable. Use
ALLOC_GROW in mingw_putenv to reduce reallocations. Allocate a
sufficiently sized environment array in make_environment_block to prevent
reallocations.

Signed-off-by: Karsten Blees <blees@dcon.de>
2012-10-01 14:35:04 +01:00
Karsten Blees
93b85d13cb Win32: don't copy the environment twice when spawning child processes
When spawning child processes via start_command(), the environment and all
environment entries are copied twice. First by make_augmented_environ /
copy_environ to merge with child_process.env. Then a second time by
make_environment_block to create a sorted environment block string as
required by CreateProcess.

Move the merge logic to make_environment_block so that we only need to copy
the environment once. This changes semantics of the env parameter: it now
expects a delta (such as child_process.env) rather than a full environment.
This is not a problem as the parameter is only used by start_command()
(all other callers previously passed char **environ, and now pass NULL).

The merge logic no longer xstrdup()s the environment strings, so do_putenv
must not free them. Add a parameter to distinguish this from normal putenv.

Remove the now unused make_augmented_environ / free_environ API.

Signed-off-by: Karsten Blees <blees@dcon.de>
2012-10-01 14:35:03 +01:00
Karsten Blees
733a8af889 Win32: factor out environment block creation
Signed-off-by: Karsten Blees <blees@dcon.de>
2012-10-01 14:35:02 +01:00
Karsten Blees
a7d5ca783d Win32: unify environment function names
Environment helper functions use random naming ('env' prefix or suffix or
both, with or without '_'). Change to POSIX naming scheme ('env' suffix,
no '_').

Env_setenv has more in common with putenv than setenv. Change to do_putenv.

Signed-off-by: Karsten Blees <blees@dcon.de>
2012-10-01 14:35:01 +01:00
Karsten Blees
8e3e4a5906 Win32: move environment functions
Move environment helper functions up so that they can be reused by
mingw_getenv and mingw_spawnve_fd in subsequent patches.

Signed-off-by: Karsten Blees <blees@dcon.de>
2012-10-01 14:35:00 +01:00