qsort in Windows 2000 (and possibly other older Windows' C libraries)
is a Quicksort with the usual O(n^2) worst case. Unfortunately, sorting
Git trees seems to get very close to that worst case quite often:
$ /git/gitbad runstatus
# On branch master
qsort, nmemb = 30842
done, 237838087 comparisons.
This patch adds a simplified version of the merge sort that is glibc's
qsort(3). As a merge sort, this needs a temporary array equal in size
to the array that is to be sorted.
The complexity that was removed is:
* Doing direct stores for word-size and -aligned data.
* Falling back to quicksort if the allocation required to perform the
merge sort would likely push the machine into swap.
Even with these simplifications, this seems to outperform the Windows
qsort(3) implementation, even in Windows XP (where it is "fixed" and
doesn't trigger O(n^2) complexity on trees).
[jes: moved into compat/qsort.c, as per Johannes Sixt's suggestion]
Signed-off-by: Brian Downing <bdowning@lavos.net>
Signed-off-by: Steffen Prohaska <prohaska@zib.de>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
A lookup routine is extracted from env_unsetenv() because we will need it
for env_setenv(). The environment data is now released, too.
Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at>
The PATH related functions are now static and can lose the mingw_ prefix.
path_lookup() no longer looks in the current directory, and it will now
actually return NULL. Previously, it returned the input program name
as a fallback.
Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at>
The entries are now arranged in categories.
inet_ntop(), kill(), and openlog() are unused and, hence, removed.
Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at>
Although we made sure that in->it_interval is either zero or equal to
in->it_value, we were still using in->it_interval to compute the timeout,
which could be zero, for example, with git-log's --early-output flag.
Use in->it_value instead.
On the otherhand, we used in->it_value to check for a single-shot timer.
Use in->it_interval instead.
Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at>
After a program was determined to be a script (which implies that it did
not have a file extension), then the interpreter is looked up. This change
makes sure that we will only find .exe files when we are looking for an
interpreter. Otherwise, we could find a directory 'perl' that is somewhere
earlier in the path than 'perl.exe'.
Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at>
The problem with Windows's own implementation is that it tries to be
clever when a console program is invoked from a GUI application: In this
case it sometimes automatically allocates a new console windows. As a
consequence, the IO channels of the spawned program are directed to the
console, but the invoking application listens on channels that are now
directed to nowhere.
In this implementation we use the lowlevel facilities of CreateProcess(),
which offers a flag to tell the system not to open a console. As a side
effect, only stdin, stdout, and stderr channels will be accessible from
C programs that are spawned. Other channels (file handles, pipe handles,
etc.) are still inherited by the spawned program, but it doesn't get
enough information to access them.
Johannes Schindelin integrated path quoting and unified the various
*execv* and *spawnv* helpers.
Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at>
By doing so the only external user of the path handling and functions
is removed, and these functions can be made static.
Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at>
We want to make them static later, and we need them in the proper order
for this. There is otherwise no code change.
Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at>
gethostbyname() is the first function that calls into the Winsock library,
and it is wrapped only to initialize the library.
socket() is wrapped for two reasons:
- Windows's socket() creates things that are like low-level file handles,
and they must be converted into file descriptors first.
- And these handles cannot be used with plain ReadFile()/WriteFile()
because they are opened for "overlapped IO". We have to use WSASocket()
to create non-overlapped IO sockets.
connect() must be wrapped because Windows's connect() expects the low-level
sockets, not file descriptors, and we must first unwrap the file descriptor
before we can pass it on to Windows's connect().
Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at>
read_in_full()'s is used in compat/pread.c. read_in_full() is
declared in cache.h. But we can't include cache.h because too
many macros are defined there. Using read_in_full() without
including cache.h is dangerous because we wouldn't recognize if
its prototyp changed. gcc issues a warning about that.
This commit adds a forward decl to git-compat-util.h.
git-compat-util.h is included by compat/pread.c _and_ cache.h.
Hence, changes in cache.h would be detected.
Signed-off-by: Steffen Prohaska <prohaska@zib.de>
This changes the prototypes to match
http://www.opengroup.org/onlinepubs/7990989775/xsh/exec.html
Note, spawnvpe uses a different type for argv and envp
than execve. So at some point we need to cast. This
commit shifts the cast into the compat functions. From
the outside, execve and execvp match Posix.
Signed-off-by: Steffen Prohaska <prohaska@zib.de>
There were some references to the progress indicator, where this
implementation originally appeared.
Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at>
In general, we don't add unnecessary braces. But in this case
gcc warns about them. So this commit adds a few braces.
The commit suppresses warnings about unitialized variables
by initializing them to NULL.
The change of bcmp_translate()'s parameter declaration is needed
to avoid warnings about "discards qualifiers from pointer target
type".
[sp: split original commit; more detailed commit message. ]
Signed-off-by: Dmitry Kakurin <Dmitry.Kakurin@gmail.com>
Signed-off-by: Steffen Prohaska <prohaska@zib.de>
This emulation of poll() is by far not general. It assumes that the
fds that are to be waited for are connected to pipes. The pipes are
polled in a loop until data becomes available in at least one of them.
If only a single fd is waited for, the implementation actually does
not wait at all, but assumes that a subsequent read() will block.
In order to not burn CPU time, it is yielded to other processes before
the next round in the poll loop using Sleep(0). Note that any sleep
timeout greater than zero will reduce the efficiency by a magnitude.
Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at>
We want to get rid of spawn-pipe.*, but these functions will be needed.
On the way, the function signature was changed to avoid warnings about
incompatible pointer types when the argument is the global variable
"environ".
Remove getpagesize() from sha1_file.c because is it now
included in git-compat-util.h.
Conflicts:
Makefile
compat/mingw.c
git-compat-util.h
Signed-off-by: Steffen Prohaska <prohaska@zib.de>
The wrapper does two things:
- Requests to open /dev/null are redirected to open the nul pseudo file.
- A request to open a file that currently exists as a directory, then
Windows's open fails with EACCES; this is changed to EISDIR.
Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at>
Quite a lot of stuff has accumulated or is now obsolete. The stubs of
POSIX functions that are not implemented or that always fail are now
implemented as inline functions so that they exist in only one place.
Windows's struct stat does not have a st_blocks member. Since we already
have our own stat/lstat/fstat implementations, we can just as well use
a customized struct stat. This patch introduces just that, and also fills
in the st_blocks member. On the other hand, we don't provide members that
are never used.
Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at>
getpwuid() is kept as simple as possible so that no errors are generated.
Since the information that it returns is not very useful, users are still
required to set up user.name and user.email configuration.
All uses of getpwuid() are like getpwuid(getuid()), hence, the return value
of getpwuid() is irrelevant. getpwnam() is only used to resolve '~' and
'~username' paths, which is an idiom not known on Windows, hence, we
don't implement it, either.
Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at>
* maint:
Remove a couple of duplicated include
grep with unmerged index
git-daemon: fix remote port number in log entry
git-svn: t9114: verify merge commit message in test
git-svn: fix dcommit clobbering when committing a series of diffs
Conflicts:
Makefile
RelNotes
builtin-ls-files.c
builtin-tag.c
cache.h
compat/mingw.c
config.c
connect.c
cpio.sh
diff.c
exec_cmd.c
git-gui/Makefile
git-gui/lib/commit.tcl
git-gui/lib/console.tcl
git-mergetool.sh
lockfile.c
path.c
rsh.c
run-command.c
setup.c
show-index.c
spawn-pipe.c
t/Makefile
t/t0000-basic.sh
t/t1300-repo-config.sh
t/t7501-commit.sh
t/test-lib.sh
Resolve as follows
--- Makefile
- mingw/devel removes
SHELL_PATH = /bin/sh
PERL_PATH = /bin/perl
This looks ok. Both are set early in the Makefile to sensible values.
mingw accepts to execute /usr/bin/perl.
- NO_SYMLINKS is no longer needed. Should be auto-detected.
- According to our 0e2bdc35af
we want
NO_R_TO_GCC_LINKER = YesPlease
take our before their change.
- Conflict prefix, SCRIPT_SH:
our 7999f434d7 set prefix =
their 4a7c98dbaf removes cpio emulator
resolve to achieve both.
- Conflict NO_MEMMEM, THREADED_DELTA_SEARCH: take theirs
--- RelNotes
take our: removed file
--- builtin-ls-files.c
Conflict write_name_quoted: take their change.
--- builtin-tag.c
Conflict strip CR
our 7734ad404c adds strip CR
their fd17f5b5f7 modifies code to use strbuf
resolve by removing our code. TODO: we probably need a replacement?
--- cache.h
Conflict is_absolute_path()
our ef5af72062 ifdef
their 637fc51696 ifndef
both achieve the same.
our is a bit more strict but we take their code because we want
to reduce differences to mingw.
--- compat/mingw.c
Conflict at end of file:
our 194c1dbb5a adds git_exit()
resolve by taking their first, followed by our.
--- config.c
Conflict 'fd ='
our 0a453a237e merge junio/master
introduced strange 'fd ='. Resolve by removing 'fd ='.
--- connect.c
- Conflict 'host must have at least 2 chars ...' take their code.
- git_connect(): take their implementation.
--- cpio.sh
Accepted their delete file.
--- diff.c
Resolve using their implementation.
--- exec_cmd.c
Resolve using their implementation.
--- git-gui/**
Resolve using our implementation.
--- git-mergetool.sh
Resolve using their implementation
--- lockfile.c
trivial resolution (empty line removed)
--- path.c
Conflict 'tmp': accepting their implementation, trying TMP, TEMP on all platforms.
--- rsh.c
Accept their delete file.
--- run-command.c
Resolve using their implementation
--- setup.c
Resolve using their implementation
--- show-index.c
Conflict PRIuMAX
our 89697a4c15 fix warning
their 5be507fc95 PRIuMAX
resolve fixing warning in their code.
--- spawn-pipe.c
Conflict environ vs lookup_prog: resolve taking neither
--- t/Makefile
our d1f83218dc --no-hardlinks
their c603988c10 automtically detect symlink support
Resolve using our --no-hardlinks but removing --no-symlinks.
--- t/0000-basic.sh
Resolve using their implementation.
--- t/t1300-repo-config.sh
Resolve using their implementation.
--- t/t7501-commit.sh
Resolve using their implementation.
--- t/test-lib.sh
our d1f83218dc --no-hardlink
their c603988c10 automatically detect symlink support
Resolve using our --no-hardlinks but removing --no-symlinks.
Signed-off-by: Steffen Prohaska <prohaska@zib.de>
Since these functions are MinGW-specific, they better belong into this
compatibility file. They will be needed there in a follow-up change that
reimplements execvp().
Note that cmd->err is not treated in run-command.c. In particular, the
pipe end is not inherited by the child process.
THIS IS IMPORTANT!
cmd->err is only required by upload-pack. But in the MinGW case upload-pack
does not support the sideband and the stderr of pack-objects is expected to
be routed to stderr: Since in the MinGW case the stderr pipe is not read
by upload-pack, the stderr of pack-objects must not be connected to the
pipe.
MS Windows command line is handled in a weird way. This patch addresses:
- Quote empty arguments
- Only escape backslashes and double quotation marks inside quoted arguments
- Quote arguments if they have asterisk or question marks to prevent expansion
The last one is not documented in the link provided in the patch. I encountered
that behavior on cmd.exe, Windows XP. MSYS not tested.
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Windows's vsnprintf() receives the number of characters to write, which
does not include the trailing NUL byte. But our vsnprintf() users pass
the available space, including the trailing NUL.
On Windows, vsnprintf returns -1 if the buffer is too small instead of
the number of characters needed. This wrapper computes the needed buffer
size by trying various sizes with exponential growth. A large growth
factor is used so as only few trials are required if a really large
result needs to be stored.
Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at>
Solaris 9 doesn't have mkdtemp() so we need to emulate it for the
rsync transport implementation. Since Solaris 9 is lacking this
function we can also reasonably assume it is not available on
Solaris 8 either. The new Makfile definition NO_MKDTEMP can be
set to enable the git compat version.
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
If an external git command (not a shell script) was invoked with arguments
that contain spaces, these arguments would be split into separate
arguments. They must be quoted. This also affected installations where
$prefix contained a space, as in "C:\Program Files\GIT". Both errors can
be triggered by invoking
git hash-object "a b"
where "a b" is an existing file.
If an external git command (not a shell script) was invoked with arguments
that contain spaces, these arguments would be split into separate
arguments. They must be quoted. This also affected installations where
$prefix contained a space, as in "C:\Program Files\GIT". Both errors can
be triggered by invoking
git hash-object "a b"
where "a b" is an existing file.