Commit Graph

72 Commits

Author SHA1 Message Date
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
Johannes Sixt
36e0147fe5 Move path handling functions from spawn-pipe.c to compat/mingw.c.
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().
2007-11-02 21:34:56 +01:00
Johannes Sixt
ab2ca02541 Merge branch 'js/forkexec'
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.
2007-10-28 21:14:04 +01:00
Nguyễn Thái Ngọc Duy
ee05d11762 Rework quote_arg()
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>
2007-10-28 20:50:10 +01:00
Johannes Sixt
e88aa8cbe8 Fix off-by-one error in the vsnprintf wrapper.
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.
2007-10-23 16:34:09 +02:00
Johannes Sixt
5fd41ffacd Implement a work-around for a mis-behaved vsnprintf on Windows.
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>
2007-10-22 14:01:27 +02:00
Shawn O. Pearce
ca5bb5d539 Define compat version of mkdtemp for systems lacking it
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>
2007-10-20 22:52:21 -04:00
Johannes Sixt
89afdd6d62 Merge commit 'spearce/master' 2007-10-19 22:50:43 +02:00
Johannes Sixt
fbb7b31c45 Fix invocation of external git commands with arguments with spaces.
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.
2007-10-17 00:06:18 +02:00
Johannes Sixt
524344cdf5 Fix invocation of external git commands with arguments with spaces.
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.
2007-10-10 09:00:39 +02:00
Johannes Sixt
56dc8fc47a Fix fstat() implementation for pipes and sockets again.
It turns out that GetFileInformationByHandle() succeeds even for pipes
and sockets. Hence, we fall back to Windows's own fstat() implementation
for everything except files. This also takes care of any error codes
(again, except for files - but we don't expect any errors here).
2007-09-25 12:37:06 +02:00
Johannes Sixt
b0eef9af24 Do not return EFAULT for ERROR_INVALID_NAME.
A file name that contains a colon will be rejected by GeFileInformation()
with ERROR_INVALID_NAME. This must be treated as ENOENT. Such a file name
ends up in do_lstat() when the rev:path notation is used (eg. in
'git show').
2007-09-24 21:13:50 +02:00
Johannes Sixt
b49fa05b92 Handle fstat() of a socket descriptor.
GetFileInformationByHandle() fails if it is passed a WinSock handle.
Fortunately, the failure can be distinguished by the error code, and we
can in this case pretend that the fstat() was actually successful.

This is a valid thing to do: Calling fstat() on a descriptor makes only
sense if either the caller needs information on the file (in which case
we would not reach this error condition), or if it wants to distinguish
a socket from a file (which implies that the caller will have to test
st_mode, which happens to be the only field that we can fill in).

Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at>
2007-09-21 21:36:15 +02:00
René Scharfe
b21b9f1de3 add memmem()
memmem() is a nice GNU extension for searching a length limited string
in another one.

This compat version is based on the version found in glibc 2.2 (GPL 2);
I only removed the optimization of checking the first char by hand, and
generally tried to keep the code simple.  We can add it back if memcmp
shows up high in a profile, but for now I prefer to keep it (almost
trivially) simple.

Since I don't really know which platforms beside those with a glibc
have their own memmem(), I used a heuristic: if NO_STRCASESTR is set,
then NO_MEMMEM is set, too.

Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-09-06 22:46:00 -07:00
Marius Storm-Olsen
0cce83445c Add a new lstat and fstat implementation based on Win32 API
This gives us a significant speedup when adding, committing and stat'ing files.
Also, since Windows doesn't really handle symlinks, we let stat just uses lstat.
We also need to replace fstat, since our implementation and the standard stat()
functions report slightly different timestamps, possibly due to timezones.

We simply report UTC in our implementation, and do our FILETIME to time_t
conversion based on the document at http://support.microsoft.com/kb/167296.

With Moe's repo structure (100K files in 100 dirs, containing 2-4 bytes)
    mkdir bummer && cd bummer; for ((i=0;i<100;i++)); do
      mkdir $i && pushd $i;
        for ((j=0;j<1000;j++)); do echo "$j" >$j; done;
      popd;
    done

We get the following performance boost:

    With normal lstat & stat  Custom lstat/fstat
    ------------------------  ------------------------
    Command: git init         Command: git init
    ------------------------  ------------------------
    real    0m 0.047s          real   0m 0.063s
    user    0m 0.031s          user   0m 0.015s
    sys     0m 0.000s          sys    0m 0.015s
    ------------------------  ------------------------
    Command: git add .        Command: git add .
    ------------------------  ------------------------
    real    0m19.390s         real    0m12.031s       1.6x
    user    0m 0.015s         user    0m 0.031s
    sys     0m 0.030s         sys     0m 0.000s
    ------------------------  ------------------------
    Command: git commit -a..  Command: git commit -a..
    ------------------------  ------------------------
    real    0m30.812s         real    0m16.875s       1.8x
    user    0m 0.015s         user    0m 0.015s
    sys     0m 0.000s         sys     0m 0.015s
    ------------------------  ------------------------
    3x Command: git-status    3x Command: git-status
    ------------------------  ------------------------
    real    0m11.860s         real    0m 5.266s       2.2x
    user    0m 0.015s         user    0m 0.015s
    sys     0m 0.015s         sys     0m 0.015s

    real    0m11.703s         real    0m 5.234s
    user    0m 0.015s         user    0m 0.015s
    sys     0m 0.000s         sys     0m 0.000s

    real    0m11.672s         real    0m 5.250s
    user    0m 0.031s         user    0m 0.015s
    sys     0m 0.000s         sys     0m 0.000s
    ------------------------  ------------------------
    Command: git commit...    Command: git commit...
    (single file)             (single file)
    ------------------------  ------------------------
    real    0m14.234s         real    0m 7.735s       1.8x
    user    0m 0.015s         user    0m 0.031s
    sys     0m 0.000s         sys     0m 0.000s

Signed-off-by: Marius Storm-Olsen <mstormo_git@storm-olsen.com>
2007-09-04 08:55:33 +02:00
Johannes Schindelin
194c1dbb5a Provide git_exit() for MinGW
Apparently, MinGW's exit function has problems with negative
exit codes.  Substitute them by 1.

This fixes at least t1300, which failed because the exit code of
git-config with an invalid file was 0.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2007-08-29 14:28:48 +01:00
Dmitry Kakurin
89697a4c15 Issue 20: Fix all build warnings
Fixed all warnings. Code compiles cleanly now.

Full test pass: OK

Signed-off-by: Dmitry Kakurin <Dmitry.Kakurin@gmail.com>
2007-08-12 05:30:07 -07:00
Johannes Sixt
ab793ce235 Work around misbehaved rename() on Windows.
Windows's rename() is based on the MoveFile() API, which fails if the
destination exists. Here we work around the problem by using MoveFileEx().
Furthermore, the posixly correct error is returned if the destination is
a directory.

The implementation is still slightly incomplete, however, because of the
missing error code translation: We assume that the failure is due to
permissions.
2007-08-08 23:38:31 +02:00
Johannes Sixt
91a4c3a6dd Merge commit '952c8c56380734d45bddf369fe478895672c5a3a' 2007-07-21 16:51:27 +02:00
Johannes Sixt
ec96b992e0 Merge branch 'maint' of git://repo.or.cz/alt-git 2007-06-25 15:35:36 +02:00
Junio C Hamano
5bd148bfe8 Merge branch 'maint' to sync with GIT 1.5.2.2 2007-06-16 01:22:10 -07:00
Alex Riesen
fa0c87c344 Add a local implementation of hstrerror for the system which do not have it
The function converts the value of h_errno (last error of name
resolver library, see netdb.h).
One of systems which supposedly do not have the function is SunOS.
POSIX does not mandate its presence.

Signed-off-by: Alex Riesen <raa.lkml@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-06-15 22:48:34 -07:00
Junio C Hamano
a6080a0a44 War on whitespace
This uses "git-apply --whitespace=strip" to fix whitespace errors that have
crept in to our source files over time.  There are a few files that need
to have trailing whitespaces (most notably, test vectors).  The results
still passes the test, and build result in Documentation/ area is unchanged.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-06-07 00:04:01 -07:00
Johannes Sixt
afd5e6acb2 Accept trailing slashes in lstat() implementation.
lstat() is sometimes invoked with a path that ends in a slash (in
particular, when dealing with subprojects). Windows's stat() does not
accept such paths and fails with ENOENT. In this case we try again
with a cleaned-up path.
2007-05-24 22:36:24 +02:00
Johannes Sixt
eba4aff8fe Remove now unused dummy functions related to timer signal handling. 2007-05-24 09:40:43 +02:00
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