Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/compat
AgeCommit message (Collapse)Author
2008-06-26Windows: Fix ntohl() related warnings about printf formattingSteffen Prohaska
On Windows, ntohl() returns unsigned 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> Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at>
2008-06-26Windows: TMP and TEMP environment variables specify a temporary directory.Johannes Sixt
Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at>
2008-06-26Windows: Use a customized struct stat that also has the st_blocks member.Johannes Sixt
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>
2008-06-26Windows: Add a custom implementation for utime().Johannes Sixt
This is a necessary pendant to our lstat implementation: MSVCRT's implementations of lstat and utime do some adjustments if daylight saving time is in effect, but our lstat implementation doesn't do these adjustments and report the correct UTC time. With this implementation we omit the adjustments in utime() as well and always write UTC. Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at>
2008-06-26Windows: Add a new lstat and fstat implementation based on Win32 API.Marius Storm-Olsen
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> Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at>
2008-06-26Windows: Implement a custom spawnve().Johannes Sixt
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 window. 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. Eric Raible suggested to also quote '{'. Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at>
2008-06-26Windows: Implement wrappers for gethostbyname(), socket(), and connect().Johannes Sixt
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>
2008-06-26Windows: A rudimentary poll() emulation.Johannes Sixt
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 not to needlessly burn CPU time, the CPU 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>
2008-06-23Windows: Implement start_command().Johannes Sixt
On Windows, we have spawnv() variants to run a child process instead of fork()/exec(). In order to attach pipe ends to stdin, stdout, and stderr, we have to use this idiom: save1 = dup(1); dup2(pipe[1], 1); spawnv(); dup2(save1, 1); close(pipe[1]); assuming that the descriptors created by pipe() are not inheritable. Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at>
2008-06-23Windows: A pipe() replacement whose ends are not inherited to children.Johannes Sixt
On Unix the idiom to use a pipe is as follows: pipe(fd); pid = fork(); if (!pid) { dup2(fd[1], 1); close(fd[1]); close(fd[0]); ... } close(fd[1]); i.e. the child process closes the both pipe ends after duplicating one to the file descriptors where they are needed. On Windows, which does not have fork(), we never have an opportunity to (1) duplicate a pipe end in the child, (2) close unused pipe ends. Instead, we must use this idiom: save1 = dup(1); pipe(fd); dup2(fd[1], 1); spawn(...); dup2(save1, 1); close(fd[1]); i.e. save away the descriptor at the destination slot, replace by the pipe end, spawn process, restore the saved file. But there is a problem: Notice that the child did not only inherit the dup2()ed descriptor, but also *both* original pipe ends. Although the one end that was dup()ed could be closed before the spawn(), we cannot close the other end - the child inherits it, no matter what. The solution is to generate non-inheritable pipes. At the first glance, this looks strange: The purpose of pipes is usually to be inherited to child processes. But notice that in the course of actions as outlined above, the pipe descriptor that we want to inherit to the child is dup2()ed, and as it so happens, Windows's dup2() creates inheritable duplicates. Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at>
2008-06-23Windows: Wrap execve so that shell scripts can be invoked.Johannes Sixt
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. With this change, scripted git commands work. Command line arguments to those scripts cannot be complex (contain spaces or double-quotes), yet. Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at>
2008-06-23Windows: Implement setitimer() and sigaction().Johannes Sixt
The timer is implemented using a thread that calls the signal handler at regular intervals. We also replace Windows's signal() function because we must intercept that SIGALRM is set (which is used when a timer is canceled). Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at>
2008-06-23Windows: Fix PRIuMAX definition.Johannes Sixt
Since GIT calls into Microsoft's MSVCRT.DLL, it must use the printf format that this DLL uses for 64-bit integers, which is %I64u instead of %llu. Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at>
2008-06-23Windows: Implement gettimeofday().Johannes Sixt
Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at>
2008-06-23Windows: Work around misbehaved rename().Johannes Sixt
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. Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at>
2008-06-23Windows: always chmod(, 0666) before unlink().Johannes Schindelin
On Windows, read-only files cannot be deleted. To make sure that deletion does not fail because of this, always call chmod() before unlink(). Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de> Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at>
2008-06-23Windows: A minimal implemention of getpwuid().Johannes Sixt
getpwuid() is implemented just enough that GIT does not issue errors. Since the information that it returns is not very useful, users are required to set up user.name and user.email configuration. All uses of getpwuid() are like getpwuid(getuid()), hence, the return value of getuid() is irrelevant and the uid parameter is not even looked at. Side note: getpwnam() is only used to resolve '~' and '~username' paths, which is an idiom not known on Windows, hence, we don't implement it. Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at>
2008-06-23Windows: Implement a wrapper of the open() function.Johannes Sixt
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 on Windows fails with EACCES; this is changed to EISDIR. Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at>
2008-06-23Windows: Treat Windows style path names.Johannes Sixt
GIT's guts work with a forward slash as a path separators. We do not change that. Rather we make sure that only "normalized" paths enter the depths of the machinery. We have to translate backslashes to forward slashes in the prefix and in command line arguments. Fortunately, all of them are passed through functions in setup.c. A macro has_dos_drive_path() is defined that checks whether a path begins with a drive letter+colon combination. This predicate is always false on Unix. Another macro is_dir_sep() abstracts that a backslash is also a directory separator on Windows. Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at>
2008-06-22Windows: Use the Windows style PATH separator ';'.Johannes Sixt
Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at>
2008-06-22Add target architecture MinGW.Johannes Sixt
With this change GIT can be compiled and linked using MinGW. Builtins that only read the repository such as the log family and grep already work. Simple stubs are provided for a number of functions that the Windows C runtime does not offer. They will be completed in later patches. However, a fix for the snprintf/vsnprintf replacement is applied here to avoid buffer overflows. Dmitry Kakurin pointed out that access(..., X_OK) would always fails on Vista and suggested the -D__USE_MINGW_ACCESS workaround. Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at>
2008-06-22Add compat/regex.[ch] and compat/fnmatch.[ch].Johannes Sixt
We don't have fnmatch and regular expressions on Windows. We borrow fnmatch.[ch] from the GNU C library (license is LGPL 2 or later) and GNU regexp (regexp.c[ch], license is GPL 2 or later). Note that regexp.c was changed slightly to avoid warnings with gcc. We make the addition of these files an extra commit so as not to clutter the next commits. Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at>
2008-05-09compat/fopen.c: avoid clobbering the system defined fopen macroBrandon Casey
Some systems define fopen as a macro based on compiler settings. The previous technique for reverting to the system fopen function by merely undefining fopen is inadequate in this case. Instead, avoid defining fopen entirely when compiling this source file. Signed-off-by: Brandon Casey <casey@nrlssc.navy.mil> Tested-by: Mike Ralphson <mike@abacus.co.uk> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-03-06Add compat/snprintf.c for systems that return bogusMichal Rokos
Some systems (namely HPUX and Windows) return -1 when maxsize in snprintf() and in vsnprintf() is reached. So replace snprintf() and vsnprintf() functions with our own ones that return correct value upon overflow. [jc: verified that review comments by J6t have been incorporated, and tightened the check to verify the resulting buffer contents, suggested by Wayne Davison] Signed-off-by: Michal Rokos <michal.rokos@nextsoft.cz> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-02-21Merge branch 'bc/fopen'Junio C Hamano
* bc/fopen: Add compat/fopen.c which returns NULL on attempt to open directory
2008-02-12Add compat/fopen.c which returns NULL on attempt to open directoryBrandon Casey
Some systems do not fail as expected when fread et al. are called on a directory stream. Replace fopen on such systems which will fail when the supplied path is a directory. Signed-off-by: Brandon Casey <casey@nrlssc.navy.mil> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-02-07compat: Add simplified merge sort implementation from glibcBrian Downing
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>
2007-11-06Merge branch 'maint'Junio C Hamano
* 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
2007-11-06Remove a couple of duplicated includeMarco Costalba
Signed-off-by: Marco Costalba <mcostalba@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-10-21Define compat version of mkdtemp for systems lacking itShawn O. Pearce
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-09-07add memmem()René Scharfe
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-06-16Merge branch 'maint' to sync with GIT 1.5.2.2Junio C Hamano
2007-06-16Add a local implementation of hstrerror for the system which do not have itAlex Riesen
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-07War on whitespaceJunio C Hamano
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-02-20Add a compat/strtoumax.c for Solaris 8.Jason Riedy
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-01-10Replacing the system call pread() with lseek()/xread()/lseek() sequence.Stefan-W. Hahn
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>
2006-12-24Switch git_mmap to use pread.Shawn O. Pearce
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-24Rename gitfakemmap to git_mmap.Shawn O. Pearce
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-21compat/inet_ntop: do not use u_intJunio C Hamano
It is pointless. Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-12-20simplify inclusion of system header files.Junio C Hamano
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-11-22remove merge-recursive-oldJunio C Hamano
This frees the Porcelain-ish that comes with the core Python-free. Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-11-15Seek back to current filepos when mmap()ing with NO_MMAPJohannes Schindelin
"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-09-28Cleaned up git-daemon virtual hosting support.Jon Loeliger
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-07-10Fix more typos, primarily in the codePavel Roskin
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-06-25Rename safe_strncpy() to strlcpy().Peter Eriksen
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-05-22NO_INET_NTOP and compat/inet_ntop.c for some systems (e.g. old Cygwin).Yakov Lerner
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-01-26Add compat/unsetenv.c .Jason Riedy
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>
2005-12-06Clean up compatibility definitions.Junio C Hamano
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-05compat/setenv: do not free what we fed putenv(3).Junio C Hamano
Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-12-04Add compat/setenv.c, use in git.c.Jason Riedy
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>