Commit Graph

156 Commits

Author SHA1 Message Date
Steffen Prohaska
446c466821 Merge commit 'mingw/master' into devel
Conflicts:

	Makefile
	RelNotes
	compat/qsort.c
	help.c
	read-cache.c
2008-02-24 15:48:45 +01:00
Johannes Sixt
8221a4b1fb Merge branch 'master' of git://repo.or.cz/alt-git 2008-02-17 21:54:08 +01:00
Brian Downing
43fe901b71 compat: Add simplified merge sort implementation from glibc
qsort in Windows 2000 (and various other 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, but has a worst-case performance of
O(n log n).

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]
[bcd: removed gcc-ism, thanks to Edgar Toernig.  renamed make variable
      per Junio's comment.]

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>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-02-06 22:35:28 -08:00
Steffen Prohaska
b9c9fdb0f5 Merge commit 'mingw/master' into devel 2008-01-28 23:18:51 +01:00
Johannes Sixt
ec6a61de07 Merge branch 'master' of git://repo.or.cz/alt-git 2008-01-28 08:52:53 +01:00
Robert Schiele
2600973f2c pre-POSIX.1-2001 systems do not have <sys/select.h>
POSIX.1-2001 has declaration of select(2) in <sys/select.h>, but
in the previous version of SUS, it was declared in <sys/time.h>
(which is already included in git-compat-util.h).

This introduces NO_SYS_SELECT_H macro in the Makefile to be set
on older systems, to skip inclusion of <sys/select.h> that does
not exist on them.

We could check _POSIX_VERSION with 200112L and do this
automatically, but earlier it was reported that the approach
does not work well on some vintage of HP-UX.  Other systems may
get _POSIX_VERSION itself wrong.  At least for now, this manual
configuration is safer.

Signed-off-by: Robert Schiele <rschiele@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-01-24 14:01:28 -08:00
Steffen Prohaska
ebb79d06bf Merge commit 'mingw/master' into devel 2008-01-13 14:17:32 +01:00
Johannes Sixt
758eec41e2 Merge branch 'master' of git://repo.or.cz/alt-git 2008-01-12 20:37:40 +01:00
Junio C Hamano
698a68be7b Uninline prefixcmp()
Now the routine is an open-coded loop that avoids an extra
strlen() in the previous implementation, it got a bit too big to
be inlined.  Uninlining it makes code footprint smaller but the
result still retains the avoidance of strlen() cost.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-01-03 01:23:12 -08:00
Johannes Schindelin
99a6a97b1b Optimize prefixcmp()
Certain codepaths (notably "git log --pretty=format...") use
prefixcmp() extensively, with very short prefixes.  In those cases,
calling strlen() is a wasteful operation, so avoid it.

Initial patch by Marco Costalba.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-01-02 02:28:54 -08:00
Brian Downing
bc8e453867 mingw-compat: Add simplified merge sort implementation from glibc
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>
2007-12-30 14:06:47 +01:00
Steffen Prohaska
8da335b3fa Merge commit 'mingw/master' into work/merge-mingw
Conflicts:

	setup.c
2007-12-08 12:49:42 +01:00
Johannes Sixt
d63abd8dc5 Fixup the clean-up of environment handling.
Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at>
2007-12-07 22:45:20 +01:00
Steffen Prohaska
9467c5ac39 Merge commit 'mingw/master' into work/merge-mingw
Conflicts:

	Makefile
	git-compat-util.h
2007-12-07 00:45:00 +01:00
Johannes Sixt
9a930a2ecb Implement setting of environment variables in spawned programs.
Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at>
2007-12-05 21:41:40 +01:00
Johannes Sixt
f6df056f6c Rework environment manipulation.
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>
2007-12-05 21:41:40 +01:00
Johannes Sixt
2bd3a118a7 Clean up the MINGW section in git-compat-util.h.
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>
2007-12-01 21:36:07 +01:00
Steffen Prohaska
fd2641ab2e Merge commit 'mingw/master' into work/merge-mingw-master-2
Signed-off-by: Steffen Prohaska <prohaska@zib.de>
2007-11-25 22:09:14 +01:00
Johannes Sixt
a020210cc8 Move MinGW specific path lookup into compat/mingw.c.
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>
2007-11-25 20:13:28 +01:00
Steffen Prohaska
0bac9037f2 Merge commit 'mingw/master' into work/merge-mingw-master-2
Conflicts:

	Makefile
	git-clone.sh
	git-gui/README
	git-gui/git-gui.pot
	git-gui/glossary/Makefile
	git-gui/glossary/de.po
	git-gui/glossary/git-gui-glossary.pot
	git-gui/glossary/git-gui-glossary.txt
	git-gui/glossary/txt-to-pot.sh
	git-gui/glossary/zh_cn.po
	git-gui/lib/commit.tcl
	git-gui/lib/console.tcl
	git-gui/po/README
	git-gui/po/git-gui.pot
	git-gui/po/glossary/Makefile
	git-gui/po/glossary/de.po
	git-gui/po/glossary/git-gui-glossary.pot
	git-gui/po/glossary/git-gui-glossary.txt
	git-gui/po/glossary/txt-to-pot.sh
	git-gui/po/glossary/zh_cn.po
	po/README
	po/git-gui.pot
	po/glossary/Makefile
	po/glossary/de.po
	po/glossary/git-gui-glossary.pot
	po/glossary/git-gui-glossary.txt
	po/glossary/txt-to-pot.sh
	po/glossary/zh_cn.po

Signed-off-by: Steffen Prohaska <prohaska@zib.de>
2007-11-25 14:00:20 +01:00
Junio C Hamano
ab002e34e2 Merge branch 'js/mingw-fallouts'
* js/mingw-fallouts:
  fetch-pack: Prepare for a side-band demultiplexer in a thread.
  rehabilitate some t5302 tests on 32-bit off_t machines
  Allow ETC_GITCONFIG to be a relative path.
  Introduce git_etc_gitconfig() that encapsulates access of ETC_GITCONFIG.
  Allow a relative builtin template directory.
  Close files opened by lock_file() before unlinking.
  builtin run_command: do not exit with -1.
  Move #include <sys/select.h> and <sys/ioctl.h> to git-compat-util.h.
  Use is_absolute_path() in sha1_file.c.
  Skip t3902-quoted.sh if the file system does not support funny names.
  t5302-pack-index: Skip tests of 64-bit offsets if necessary.
  t7501-commit.sh: Not all seds understand option -i
  t5300-pack-object.sh: Split the big verify-pack test into smaller parts.
2007-11-24 16:31:25 -08:00
Johannes Sixt
bfd45616fb Merge branch 'master' of git://repo.or.cz/alt-git 2007-11-24 20:06:27 +01:00
Steffen Prohaska
b4389a3758 Merge commit 'mingw/master' into work/merge-mingw-master 2007-11-24 11:31:37 +01:00
Johannes Sixt
60db5000ab Implement wrappers for gethostbyname(), socket(), and connect().
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>
2007-11-21 22:47:00 +01:00
Steffen Prohaska
b3c41bf395 Merge commit 'mingw/master' into work/towards-mingw
Conflicts:

	compat/mingw.c
	exec_cmd.c
	git-compat-util.h
	run-command.c
	spawn-pipe.c
2007-11-21 21:54:43 +01:00
Steffen Prohaska
329bdf025b Fix ntohl() related warnings about printf formatting
On Windows, ntohl() returns unsinged long.  On Unix it returns
uint32_t.  This makes choosing a suitable printf format string
hard.

This commit introduces a mingw specific helper function
git_ntohl() that casts to unsigned int before returning.  This
makes gcc's printf format check happy.  It should be safe because
we expect ntohl to use 32-bit numbers.

Signed-off-by: Steffen Prohaska <prohaska@zib.de>
2007-11-21 20:31:15 +01:00
Steffen Prohaska
31023be999 compat/pread.c: Add foward decl to fix warning
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>
2007-11-21 20:31:10 +01:00
Steffen Prohaska
af18e7d9d3 Fix prototypes for mingw_execve and mingw_execvp to match Posix
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>
2007-11-21 20:05:43 +01:00
Steffen Prohaska
c2849fc4b1 Fix ntohl() related warnings about printf formatting
On Windows, ntohl() returns unsinged long.  On Unix it returns
uint32_t.  This makes choosing a suitable printf format string
hard.

This commit introduces a mingw specific helper function
git_ntohl() that casts to unsigned int before returning.  This
makes gcc's printf format check happy.  It should be safe because
we expect ntohl to use 32-bit numbers.

Signed-off-by: Steffen Prohaska <prohaska@zib.de>
2007-11-21 07:58:10 +01:00
Steffen Prohaska
5a09d6a3ac compat/pread.c: Add foward decl to fix warning
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>
2007-11-21 07:46:20 +01:00
Junio C Hamano
8e97399149 git-compat-util.h: auto-adjust to compiler support of FLEX_ARRAY a bit better
When declaring a structure with a flexible array member, instead
of defaulting to the c99 syntax for non-gnu compilers (which
burned people with older compilers), default to the traditional
and more portable "member[1]; /* more */" syntax.

At the same time, other c99 compilers should be able to take
advantage of the modern syntax to flexible array members without
being gcc.  Check __STDC_VERSION__ for that.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-11-20 15:03:56 -08:00
Junio C Hamano
e6cb314c08 Merge branch 'ph/diffopts'
* ph/diffopts:
  Reorder diff_opt_parse options more logically per topics.
  Make the diff_options bitfields be an unsigned with explicit masks.
  Use OPT_BIT in builtin-pack-refs
  Use OPT_BIT in builtin-for-each-ref
  Use OPT_SET_INT and OPT_BIT in builtin-branch
  parse-options new features.
2007-11-18 15:50:16 -08:00
Steffen Prohaska
a8d8425ec6 Fix prototypes for mingw_execve and mingw_execvp to match Posix
This changes the prototypes to match
http://www.opengroup.org/onlinepubs/7990989775/xsh/exec.html

[js: updated message]

Signed-off-by: Steffen Prohaska <prohaska@zib.de>
Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at>
2007-11-18 20:40:35 +01:00
Johannes Sixt
f8fd915d0c Move environment functions from spawn-pipe.c to compat/mingw.c
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".
2007-11-18 20:22:04 +01:00
Steffen Prohaska
fcdd78c3c3 Merge commit 'mingw/master' into work/merge-mingw-master
Conflicts:

	git-compat-util.h
	help.c
	pager.c

Signed-off-by: Steffen Prohaska <prohaska@zib.de>
2007-11-17 12:17:45 +01:00
Johannes Sixt
2d12ef8d57 Merge branch 'js/mingw-fallouts' 2007-11-16 23:14:51 +01:00
Steffen Prohaska
16df3f7e4c Merge commit 'mingw/master' into work/merge-mingw-master
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>
2007-11-16 07:33:14 +01:00
Johannes Sixt
fab21181f4 Implement a wrapper of the open() function.
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>
2007-11-15 22:27:09 +01:00
Johannes Sixt
6ee8b07d4c Merge branch 'master' of git://repo.or.cz/alt-git 2007-11-15 21:03:07 +01:00
Johannes Sixt
80bbe72b76 Move #include <sys/select.h> and <sys/ioctl.h> to git-compat-util.h.
... since all system headers are pulled in via git-compat-util.h

Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-11-14 15:18:39 -08:00
Johannes Sixt
cf1fd675d2 Implement a stub for fcntl().
This stub does nothing for F_GETFD and F_SETFD, and fails for all other
commands.

Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at>
2007-11-13 16:57:47 +01:00
Johannes Sixt
3e0ba4ccdc Clean up cruft from the MINGW32 section of git-compat-util.h
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.
2007-11-13 15:44:48 +01:00
Johannes Sixt
6d305e3341 Implement setitimer() and sigaction().
The timer is implemented using a thread.

Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at>
2007-11-13 10:14:45 +01:00
Johannes Sixt
726c8ef5a5 Fix preprocessor logic that determines the availablity of strchrnul().
Apart from the error in the condition (&& should actually be ||), the
construct

    #if !defined(A) || !A

leads to a syntax error in the C preprocessor if A is indeed not defined.

Tested-by: David Symonds <dsymonds@gmail.com>
Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-11-12 18:16:34 -08:00
Johannes Sixt
73c1250e77 Declare getpagesize() - gcc provides it for us.
It is in MinGW's libgcc.a, which appearently is always linked in.

Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at>
2007-11-12 15:08:18 +01:00
Johannes Sixt
e0c9a54e11 Clean up some dummy compatibility implementations.
In particular, sync() was never declared and caused a warning.
2007-11-12 14:00:35 +01:00
Johannes Sixt
e569ab2ae7 Use a customized struct stat that also has the st_blocks member.
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>
2007-11-12 14:00:31 +01:00
Johannes Sixt
50d1c4c745 Fake implementions of getpwuid(), getuid(), and getpwnam().
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>
2007-11-12 08:07:00 +01:00
Pierre Habouzit
db7244bd5b parse-options new features.
options flags:
~~~~~~~~~~~~~
  PARSE_OPT_NONEG allow the caller to disallow the negated option to exists.

option types:
~~~~~~~~~~~~
  OPTION_BIT: ORs (or NANDs) a mask.
  OPTION_SET_INT: force the value to be set to this integer.
  OPTION_SET_PTR: force the value to be set to this pointer.

helper:
~~~~~~
  HAS_MULTI_BITS (in git-compat-util.h) is a bit-hack to check if an
  unsigned integer has more than one bit set, useful to check if conflicting
  options have been used.

Signed-off-by: Pierre Habouzit <madcoder@debian.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-11-11 16:54:15 -08:00
Johannes Sixt
89e51c3105 Revert NO_ETC_PASSWD hack.
This hack was introduced to work around missing Unix-like user database.
But it turns out that the functionality required can easily be faked,
Which happens in a follow-up patch.
2007-11-11 21:36:19 +01:00