Commit Graph

46 Commits

Author SHA1 Message Date
Johannes Sixt
390b6df11c Quote the script name before invoking the interpreter.
When the argument vector for the interpreter invocation is assembled,
the original arguments were already quoted when necessary, but the
script name was not. If the script lives in a directory whose names
contains spaces, the interpreter would not find the script.
2007-04-13 10:20:06 +02:00
Johannes Sixt
f16b0ec3bd Let the fake readlink(2) and symlink(2) functions report ENOSYS.
Now that some symbolic link support is coming soon, let those functions
report a more correct error than EINVAL or EFAULT.
2007-03-12 10:05:27 +01:00
Johannes Sixt
a352bda010 Increase the pipe buffer size.
It commonly happens that git-fetch-pack and git-upload-pack hit a deadlock
in the initial commit id exchange, such that both try to write to the
other end, but do not succeed. I have the suspicion that the reason is
that both ends fill the pipe, but don't read.

Increasing the pipe buffer helps, but is this the real cure?
2007-03-06 09:26:40 +01:00
Johannes Schindelin
02560cdbcf Include regex.[ch] in compat/
They are both GPLed, so there is no problem with it.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2007-03-01 22:09:05 +01:00
Johannes Sixt
3077c83763 Really run scripts under the interpreter specified in the first line.
Earlier we would have run all scripts under 'sh', but only changed
the name (argv[0]) to the parsed interpreter.

While we are here, also ignore command line options specified in
the interpreter line; perl's -w is the common case.
2007-02-28 11:38:16 +01:00
Johannes Sixt
d5f1c1bbc0 Merge with git://repo.or.cz/git.git#master 2007-02-27 16:15:36 +01:00
Jason Riedy
bc6b4f52fc Add a compat/strtoumax.c for Solaris 8.
Solaris 8 was pre-c99, and they weren't willing to commit to
the strtoumax definition according to /usr/include/inttypes.h.

This adds NO_STRTOUMAX and NO_STRTOULL for ancient systems.
If NO_STRTOUMAX is defined, the routine in compat/strtoumax.c
will be used instead.  That routine passes its arguments to
strtoull unless NO_STRTOULL is defined.  If NO_STRTOULL, then
the routine uses strtoul (unsigned long).

Signed-off-by: Jason Riedy <ejr@cs.berkeley.edu>
Acked-by: Shawn O Pearce <spearce@spearce.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-02-19 18:20:30 -08:00
Johannes Sixt
0bcd515c57 mkstemp implementation: Specify a umask for open().
We have been lucky in the past that the missing argument was taken from
whatever random value was on the stack and it was still a somewhat
useful umask, but we should really specify 0600 there.
2007-02-15 12:20:48 +01:00
Johannes Sixt
f48ce084de MinGW: Make git native protocol work.
As it turns out, the things returned by Winsock2's socket() are handles
that can be passed to ReadFile()/WriteFile() - almost. The way this works
is by wrapping those handles into file descriptors with _open_osfhandle().
But it turns out that the sockets created by the plain socket() function
are prepared for "overlapped" I/O, which confuses ReadFile()/WriteFile().
Therefore, a reimplementation is provided that uses WSASocket() to
explicitly asks for non-overlapped sockets.

Special thanks got to H. Peter Anvin, who provided the necessary clues.
2007-02-02 16:03:07 +01:00
Johannes Sixt
f002a73f04 Implement a usable gettimeofday().
For simplicity, my_mktime() of date.c is reused to avoid the convolutions
that gmtime() and localtime() would implicate.
2007-01-29 13:41:10 +01:00
Johannes Sixt
45c0d8773d Remove the unused strptime() stub.
strptime() is only used in convert-objects.c, but we do not build that one
(for reasons I do not recall anymore). That tool should be unnecessary
anyway.
2007-01-23 14:19:48 +01:00
Johannes Sixt
c823cea00e Implement sleep(). 2007-01-19 16:35:40 +01:00
Johannes Sixt
85e94b981e Do not leak pipe file handles into the child processes.
Windows's _pipe() by default allocates inheritable pipes. However,
when a spawn happens, we do not have a possiblility to close the unused
pipe ends in the child process. This is a problem.

Consider the following situation: The child process only reads from the
pipe and the parent process uses only the writable end; the parent even
closes the writable end. As it happens, the child at this time usually
still waits for input in a read(). But since the child has inherited
an open writable end, it does not get EOF and hangs ad infinitum.

For this reason, pipe handles must not be inheritable. At the first
glance, this is curious, since after all it is the purpose of pipes to be
inherited by child processes.  However, in all cases where this
inheritance is needed for a file descriptor, it is dup2()'d to stdin or
stdout anyway, and, lo and behold, Windows's dup2() creates inheritable
duplicates.
2007-01-19 16:35:16 +01:00
Johannes Sixt
09653a29cf Move script detection into a helper function that returns the interpreter.
This will be needed later in the spawn helper functions, too,
where we want to start a shell or perl script from an exe.
2007-01-19 16:32:23 +01:00
Johannes Sixt
0400c502c3 Factor fork()/exec() work into a spawn() like function.
Windows does not have fork(), but something called spawn() that is roughly
equivalent to a fork()/exec() pair, factor out the Unix style code into
a function that does it more similarly to spawn(). Now the Windows style
spawn() can more easily be employed to achieve the same that the Unix style
code does.
2007-01-19 16:32:23 +01:00
Johannes Sixt
4b5821b21b Implement a subset of waitpid() in terms of Windows's _cwait(). 2007-01-19 16:32:23 +01:00
Johannes Sixt
48f967a161 Make a pipe() wrapper that uses Windows's _pipe(). 2007-01-19 16:27:30 +01:00
Johannes Sixt
2de27f2cbb Implement a wrapper of execve that can invoke shell scripts.
When an external git command is invoked, it can be a Bourne shell script.
This patch looks into the command file to see whether it is one.
In this case, the command line is rearranged to invoke the shell
with the proper arguments.

Moreover, the arguments are quoted if necessary because Windows'
spawn functions paste the arguments again into a command line that
is disassembled by the invoked process.
2007-01-19 16:27:30 +01:00
Johannes Sixt
861429a7c3 Be prepared for DOS-like drive letters in the getcwd() result.
An earlier patch has implemented getcwd() so that it converts the
drive letter into the POSIX-like path that is used internally by
MinGW (C:\foo => /c/foo), but this style does not work outside
the MinGW shell. It is better to just convert the backslashes
to forward slashes and handle the drive letter explicitly.
2007-01-19 16:25:15 +01:00
Johannes Sixt
4720571a2d Fix mkstemp emulation to not free the template string.
The template argument was strduped unnecessarily and then not used,
and the wrong string was freed.
2007-01-19 16:25:15 +01:00
Johannes Schindelin
8d1bfddd0c make default open mode O_BINARY 2007-01-19 16:24:49 +01:00
Johannes Schindelin
27317da439 implement mkstemp() 2007-01-19 16:24:49 +01:00
Johannes Schindelin
b4792a360e Include fnmatch from GNU make. 2007-01-19 16:24:48 +01:00
Johannes Schindelin
649a5ce8d6 require regex (http://ftp.gnu.org/pub/gnu/regex/) 2007-01-19 16:24:48 +01:00
Johannes Schindelin
65e40a6195 Provide inlined mkdir wrapper. 2007-01-19 16:24:48 +01:00
Johannes Sixt
14cd939112 Make git compile under MinGW.
These changes are courtesy Johannes Schindelin.
2007-01-19 16:21:41 +01:00
Stefan-W. Hahn
6900679c2f Replacing the system call pread() with lseek()/xread()/lseek() sequence.
Using cygwin with cygwin.dll before 1.5.22 the system call pread() is buggy.
This patch introduces NO_PREAD. If NO_PREAD is set git uses a sequence of
lseek()/xread()/lseek() to emulate pread.

Signed-off-by: Stefan-W. Hahn <stefan.hahn@s-hahn.de>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-01-09 16:40:40 -08:00
Shawn O. Pearce
8e554429e8 Switch git_mmap to use pread.
Now that Git depends on pread in index-pack its safe to say we can
also depend on it within the git_mmap emulation we activate when
NO_MMAP is set.  On most systems pread should be slightly faster
than an lseek/read/lseek sequence as its one system call vs. three
system calls.

We also now honor EAGAIN and EINTR error codes from pread and
restart the prior read.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-12-24 00:29:43 -08:00
Shawn O. Pearce
d6779124b9 Rename gitfakemmap to git_mmap.
This minor cleanup was suggested by Johannes Schindelin.

The mmap is still fake in the sense that we don't support PROT_WRITE
or MAP_SHARED with external modification at all, but that hasn't
stopped us from using mmap() thoughout the Git code.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-12-24 00:16:56 -08:00
Junio C Hamano
1d182bd5f4 compat/inet_ntop: do not use u_int
It is pointless.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-12-20 13:45:55 -08:00
Junio C Hamano
85023577a8 simplify inclusion of system header files.
This is a mechanical clean-up of the way *.c files include
system header files.

 (1) sources under compat/, platform sha-1 implementations, and
     xdelta code are exempt from the following rules;

 (2) the first #include must be "git-compat-util.h" or one of
     our own header file that includes it first (e.g. config.h,
     builtin.h, pkt-line.h);

 (3) system headers that are included in "git-compat-util.h"
     need not be included in individual C source files.

 (4) "git-compat-util.h" does not have to include subsystem
     specific header files (e.g. expat.h).

Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-12-20 09:51:35 -08:00
Junio C Hamano
7cdbff14d4 remove merge-recursive-old
This frees the Porcelain-ish that comes with the core Python-free.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-11-21 20:55:39 -08:00
Johannes Schindelin
0a3881d4cf Seek back to current filepos when mmap()ing with NO_MMAP
"git-index-pack --fix-thin" relies on mmap() not changing the current
file position (otherwise the pack will be corrupted when writing the
final SHA1). Meet that expectation.

Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-11-15 10:23:47 -08:00
Jon Loeliger
dd4676299d Cleaned up git-daemon virtual hosting support.
Standardized on lowercase hostnames from client.

Added interpolation values for the IP address, port and
canonical hostname of the server as it is contacted and
named by the client and passed in via the extended args.

Added --listen=host_or_ipaddr option suport.  Renamed port
variable as "listen_port" correspondingly as well.

Documented mutual exclusivity of --inetd option with
    --user, --group, --listen and --port options.

Added compat/inet_pton.c from Paul Vixie as needed.

Small memory leaks need to be cleaned up still.

Signed-off-by: Jon Loeliger <jdl@jdl.com>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-09-27 18:00:52 -07:00
Pavel Roskin
82e5a82fd7 Fix more typos, primarily in the code
The only visible change is that git-blame doesn't understand
"--compability" anymore, but it does accept "--compatibility" instead,
which is already documented.

Signed-off-by: Pavel Roskin <proski@gnu.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-07-10 00:36:44 -07:00
Peter Eriksen
817151e61a Rename safe_strncpy() to strlcpy().
This cleans up the use of safe_strncpy() even more.  Since it has the
same semantics as strlcpy() use this name instead.  Also move the
definition from inside path.c to its own file compat/strlcpy.c, and use
it conditionally at compile time, since some platforms already has
strlcpy().  It's included in the same way as compat/setenv.c.

Signed-off-by: Peter Eriksen <s022018@student.dtu.dk>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-06-24 23:16:25 -07:00
Yakov Lerner
6ba68ab288 NO_INET_NTOP and compat/inet_ntop.c for some systems (e.g. old Cygwin).
For systems which lack inet_ntop(), this adds compat/inet_ntop.c,
and related build constant, NO_INET_NTOP. Older Cygwin(s) lack
inet_ntop().

Signed-off-by: Yakov Lerner <iler.ml@gmail.com>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-05-21 16:44:36 -07:00
Jason Riedy
731043fd4d Add compat/unsetenv.c .
Implement a (slow) unsetenv() for older systems.

Signed-off-by: Jason Riedy <ejr@cs.berkeley.edu>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-01-25 15:10:39 -08:00
Junio C Hamano
4050c0df8e Clean up compatibility definitions.
This attempts to clean up the way various compatibility
functions are defined and used.

 - A new header file, git-compat-util.h, is introduced.  This
   looks at various NO_XXX and does necessary function name
   replacements, equivalent of -Dstrcasestr=gitstrcasestr in the
   Makefile.

 - Those function name replacements are removed from the Makefile.

 - Common features such as usage(), die(), xmalloc() are moved
   from cache.h to git-compat-util.h; cache.h includes
   git-compat-util.h itself.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-12-05 15:50:29 -08:00
Junio C Hamano
3a2674337c compat/setenv: do not free what we fed putenv(3).
Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-12-04 14:41:35 -08:00
Jason Riedy
e40b61fb6b Add compat/setenv.c, use in git.c.
There is no setenv() in Solaris 5.8.  The trivial calls to
setenv() were replaced by putenv() in a much earlier patch,
but setenv() was used again in git.c.  This patch just adds
a compat/setenv.c.

The rule for building git$(X) also needs to include compat.
objects and compiler flags.  Those are now in makefile vars
COMPAT_OBJS and COMPAT_CFLAGS.

Signed-off-by: E. Jason Riedy <ejr@cs.berkeley.edu>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-12-03 22:25:25 -08:00
Junio C Hamano
f48000fcbe Yank writing-back support from gitfakemmap.
We do not write through our use of mmap(), so make sure callers pass
MAP_PRIVATE and remove support for writing changes back.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-10-08 15:54:36 -07:00
Johannes Schindelin
730d48a2ef [PATCH] If NO_MMAP is defined, fake mmap() and munmap()
Since some platforms do not support mmap() at all, and others do only just
so, this patch introduces the option to fake mmap() and munmap() by
malloc()ing and read()ing explicitely.

Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
2005-10-08 15:54:36 -07:00
Junio C Hamano
dc56bc0341 Further clarify licensing status of compat/subprocess.py.
PSF license explicitly states the files in Python distribution is
compatible with GPL, and upstream clarified the licensing terms by
shortening its file header.  This version is a verbatim copy from
release24-maint branch form Python CVS.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-09-23 18:43:53 -07:00
Junio C Hamano
343d35c916 Ship our own copy of subprocess.py
so people without the latest Python could run merge-recursive.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-09-19 19:47:54 -07:00
Linus Torvalds
ef34af24dc [PATCH] strcasestr compatibility replacement
Some C libraries lack strcasestr(); add a stupid replacement
to help folks with such.

[jc: original Linus posting, updated with his "also need <ctype.h>",
 updated further with a fix from Joachim B Haga <cjhaga@fys.uio.no>"]

Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-09-19 08:49:39 -07:00