Commit Graph

150 Commits

Author SHA1 Message Date
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
Andreas Ericsson
9e79f00f06 Simplify strchrnul() compat code
strchrnul() was introduced in glibc in April 1999 and included in
glibc-2.1. Checking for that version means the majority of all git
users would get to use the optimized version in glibc. Of the
remaining few some might get to use a slightly slower version
than necessary but probably not slower than what we have today.

Unfortunately, __GLIBC_PREREQ() macro was not available in glibc 2.1.1
which was short lived but already supported strchrnul().  Odd minority
users of that library needs to live with our compatibility inline version.

Rediffed-against-next-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-11-11 12:10:35 -08:00
Steffen Prohaska
be5eefb382 Merge commit 'mingw/master' into work/merge-mingw-master
Conflicts:

	Makefile
	builtin-prune-packed.c

Signed-off-by: Steffen Prohaska <prohaska@zib.de>
2007-11-11 10:42:37 +01:00
René Scharfe
659c69cfef Add strchrnul()
As suggested by Pierre Habouzit, add strchrnul().  It's a useful GNU
extension and can simplify string parser code.  There are several
places in git that can be converted to strchrnul(); as a trivial
example, this patch introduces its usage to builtin-fetch--tool.c.

Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-11-09 01:30:07 -08:00
Johannes Sixt
97116248a1 Merge branch 'master' of git://repo.or.cz/alt-git 2007-11-06 08:24:22 +01:00
Steffen Prohaska
69cadd4e60 Merge commit 'mingw/master' into msysgit/merge-mingw-v2
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>
2007-11-05 21:55:44 +01:00
Johannes Sixt
2952476e8e Reimplement execvp() such that it can invoke shell scripts.
We conveniently reuse mingw_execve(), which does the shbang interpretation
as well as other painful Windows compatibility stuff.
2007-11-02 21:38:57 +01:00