Commit graph

477 commits

Author SHA1 Message Date
Marat Radchenko da8daa367b MSVC: allow linking with the cURL library
Teach the clink.pl script that -lcurl is a request to link with the
cURL library, and drop NO_CURL from config.mak.uname for the MSVC
platform.

Signed-off-by: Marat Radchenko <marat@slonopotamus.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2014-03-27 12:05:14 -07:00
Junio C Hamano 650c90a185 Merge branch 'nd/no-more-fnmatch'
We started using wildmatch() in place of fnmatch(3); complete the
process and stop using fnmatch(3).

* nd/no-more-fnmatch:
  actually remove compat fnmatch source code
  stop using fnmatch (either native or compat)
  Revert "test-wildmatch: add "perf" command to compare wildmatch and fnmatch"
  use wildmatch() directly without fnmatch() wrapper
2014-03-14 14:25:31 -07:00
Junio C Hamano 0f9e62e084 Merge branch 'jk/pack-bitmap'
Borrow the bitmap index into packfiles from JGit to speed up
enumeration of objects involved in a commit range without having to
fully traverse the history.

* jk/pack-bitmap: (26 commits)
  ewah: unconditionally ntohll ewah data
  ewah: support platforms that require aligned reads
  read-cache: use get_be32 instead of hand-rolled ntoh_l
  block-sha1: factor out get_be and put_be wrappers
  do not discard revindex when re-preparing packfiles
  pack-bitmap: implement optional name_hash cache
  t/perf: add tests for pack bitmaps
  t: add basic bitmap functionality tests
  count-objects: recognize .bitmap in garbage-checking
  repack: consider bitmaps when performing repacks
  repack: handle optional files created by pack-objects
  repack: turn exts array into array-of-struct
  repack: stop using magic number for ARRAY_SIZE(exts)
  pack-objects: implement bitmap writing
  rev-list: add bitmap mode to speed up object lists
  pack-objects: use bitmaps when packing objects
  pack-objects: split add_object_entry
  pack-bitmap: add support for bitmap indexes
  documentation: add documentation for the bitmap format
  ewah: compressed bitmap implementation
  ...
2014-02-27 14:01:48 -08:00
Nguyễn Thái Ngọc Duy 2c0a1bd616 actually remove compat fnmatch source code
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2014-02-20 14:16:25 -08:00
Junio C Hamano 7b4e2b7e6a Merge branch 'ef/mingw-write'
* ef/mingw-write:
  mingw: remove mingw_write
  prefer xwrite instead of write
2014-01-27 10:44:59 -08:00
Jeff King c3d8da571f read-cache: use get_be32 instead of hand-rolled ntoh_l
Commit d60c49c (read-cache.c: allow unaligned mapping of the
index file, 2012-04-03) introduced helpers to access
unaligned data. However, we already have get_be32, which has
a few advantages:

  1. It's already written, so we avoid duplication.

  2. It's probably faster, since it does the endian
     conversion and the alignment fix at the same time.

  3. The get_be32 code is well-tested, having been in
     block-sha1 for a long time. By contrast, our custom
     helpers were probably almost never used, since the user
     needed to manually define a macro to enable them.

We have to add a get_be16 implementation to the existing
get_be32, but that is very simple to do.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2014-01-23 14:03:48 -08:00
Jeff King 802b123366 block-sha1: factor out get_be and put_be wrappers
The BLK_SHA1 code has optimized wrappers for doing endian
conversions on memory that may not be aligned. Let's pull
them out so that we can use them elsewhere, especially the
time-tested list of platforms that prefer each strategy.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2014-01-23 14:03:21 -08:00
Erik Faye-Lund c9df6f4574 mingw: remove mingw_write
Since 0b6806b9 ("xread, xwrite: limit size of IO to 8MB"), this
wrapper is no longer needed, as read and write are already split
into small chunks.

Signed-off-by: Erik Faye-Lund <kusmabite@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2014-01-17 12:09:52 -08:00
Jonathan Nieder bc380fca60 mark Windows build scripts executable
On Windows the convention is to rely on filename extensions to decide
whether a file is executable so Windows users are probably not relying
on the executable bit of these scripts, but on other platforms it can
be useful documentation.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-11-25 15:01:22 -08:00
Vicent Marti 7e3dae4943 compat: add endianness helpers
The POSIX standard doesn't currently define a `ntohll`/`htonll`
function pair to perform network-to-host and host-to-network
swaps of 64-bit data. These 64-bit swaps are necessary for the on-disk
storage of EWAH bitmaps if they are not in native byte order.

Many thanks to Ramsay Jones <ramsay@ramsay1.demon.co.uk> and
Torsten Bögershausen <tboegi@web.de> for cygwin/mingw/msvc
portability fixes.

Signed-off-by: Vicent Marti <tanoku@gmail.com>
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-11-18 10:57:42 -08:00
Junio C Hamano c01499ef69 C: have space around && and || operators
Correct all hits from

    git grep -e '\(&&\|||\)[^ ]' -e '[^	 ]\(&&\|||\)' -- '*.c'

i.e. && or || operators that are followed by anything but a SP,
or that follow something other than a SP or a HT, so that these
operators have a SP around it when necessary.

We usually refrain from making this kind of a tree-wide change in
order to avoid unnecessary conflicts with other "real work" patches,
but in this case, the end result does not have a potentially
cumbersome tree-wide impact, while this is a tree-wide cleanup.

Fixes to compat/regex/regcomp.c and xdiff/xemit.c are to replace a
HT immediately after && with a SP.

This is based on Felipe's patch to bultin/symbolic-ref.c; I did all
the finding out what other files in the whole tree need to be fixed
and did the fix and also the log message while reviewing that single
liner, so any screw-ups in this version are mine.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-10-16 10:26:39 -07:00
Jonathan Nieder d0c789084c Merge branch 'kb/msvc-compile'
* kb/msvc-compile:
  Windows: do not redefine _WIN32_WINNT
  MinGW: Fix stat definitions to work with MinGW runtime version 4.0
  MSVC: fix stat definition hell
  MSVC: fix compile errors due to macro redefinitions
  MSVC: fix compile errors due to missing libintl.h
2013-09-24 23:31:58 -07:00
Junio C Hamano 79e46c9fed Merge branch 'jk/config-int-range-check'
* jk/config-int-range-check:
  compat/mingw.h: define PRId64
2013-09-19 11:04:25 -07:00
Johannes Sixt 1562f3be48 compat/mingw.h: define PRId64
Provide PRId64 alongside PRIuMAX.

Signed-off-by: Johannes Sixt <j6t@kdbg.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-09-19 11:03:38 -07:00
Junio C Hamano f2ded0f807 Merge branch 'tb/precompose-autodetect-fix'
On MacOS X, we detected if the filesystem needs the "pre-composed
unicode strings" workaround, but did not automatically enable it.
Now we do.

* tb/precompose-autodetect-fix:
  Set core.precomposeunicode to true on e.g. HFS+
2013-09-17 11:39:59 -07:00
Sebastian Schuberth 8453c1259a Windows: do not redefine _WIN32_WINNT
With MinGW runtime version 4.0 this interferes with the previous
definition from sdkddkver.h.

Signed-off-by: Sebastian Schuberth <sschuberth@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-09-11 14:50:19 -07:00
Sebastian Schuberth fa93bb20d7 MinGW: Fix stat definitions to work with MinGW runtime version 4.0
For an overview of changes in mingwrt-4.0 see:

    http://sourceforge.net/p/mingw/mingw-org-wsl/ci/4.0.0/tree/NEWS

Signed-off-by: Sebastian Schuberth <sschuberth@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-09-11 11:11:06 -07:00
Karsten Blees a2374f58e8 MSVC: fix stat definition hell
In msvc.h, there's a couple of stat related functions defined diffently
from mingw.h. When we remove these definitions, the only problem we get is
"warning C4005: '_stati64' : macro redefinition" for this line in mingw.h:

#define _stati64(x,y) mingw_stat(x,y)

The reason is that as of MSVCR80.dll (distributed with MSVC 2005), the
original _stati64 family of functions was renamed to _stat32i64, and the
former function names became macros (pointing to the appropriate function
based on the definition of _USE_32BIT_TIME_T).

Defining _stati64 works on MinGW because MinGW by default compiles against
the MSVCRT.DLL that is part of Windows (i.e. _stati64 is a function rather
than a macro).

Note: MinGW *can* compile for newer MSVC runtime versions, and MSVC
apparently can also compile for the Windows MSVCRT.DLL via the DDK (see
http://www.syndicateofideas.com/posts/fighting-the-msvcrt-dll-hell ).

Remove the stat definitions from msvc.h, as they are not compiler related.

In mingw.h, determine the runtime version in use from the definitions of
_stati64 and _USE_32BIT_TIME_T, and define stat() accordingly.

This also fixes that stat() in MSVC builds still resolves to mingw_lstat()
instead of mingw_stat().

Signed-off-by: Karsten Blees <blees@dcon.de>
Acked-by: Sebastian Schuberth <sschuberth@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-09-11 11:08:52 -07:00
Karsten Blees 61542f7735 MSVC: fix compile errors due to macro redefinitions
Skip errno.h definitions if they are already defined.

Signed-off-by: Karsten Blees <blees@dcon.de>
Acked-by: Sebastian Schuberth <sschuberth@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-09-11 11:08:52 -07:00
Junio C Hamano a23274e127 Merge branch 'sp/clip-read-write-to-8mb'
Send a large request to read(2)/write(2) as a smaller but still
reasonably large chunks, which would improve the latency when the
operation needs to be killed and incidentally works around broken
64-bit systems that cannot take a 2GB write or read in one go.

* sp/clip-read-write-to-8mb:
  Revert "compat/clipped-write.c: large write(2) fails on Mac OS X/XNU"
  xread, xwrite: limit size of IO to 8MB
2013-09-09 14:50:39 -07:00
Junio C Hamano 05584b2a4e Merge branch 'nd/gc-lock-against-each-other'
* nd/gc-lock-against-each-other:
  gc: reject if another gc is running, unless --force is given
2013-09-04 12:35:34 -07:00
Junio C Hamano 9a7eaad65f Merge branch 'da/darwin'
* da/darwin:
  OS X: Fix redeclaration of die warning
  Makefile: Fix APPLE_COMMON_CRYPTO with BLK_SHA1
  imap-send: use Apple's Security framework for base64 encoding
2013-09-04 12:28:15 -07:00
Torsten Bögershausen 92b0c8bed0 Set core.precomposeunicode to true on e.g. HFS+
When core.precomposeunicode was introduced in 76759c7d,
it was set to false on a unicode decomposing file system like HFS+
to be compatible with older versions of Git.

The Mac OS users need to find out that this configuration exist
and change it manually from false to true.

A smoother workflow can be achieved,
so set core.precomposeunicode to true on a decomposing file system.

Signed-off-by: Torsten Bögershausen <tboegi@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-08-27 07:41:32 -07:00
Steffen Prohaska a487916dd5 Revert "compat/clipped-write.c: large write(2) fails on Mac OS X/XNU"
This reverts commit 6c642a8786.

The previous commit introduced a size limit on IO chunks on all
platforms.  The compat clipped_write() is not needed anymore.

Signed-off-by: Steffen Prohaska <prohaska@zib.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-08-20 11:11:08 -07:00
Nguyễn Thái Ngọc Duy 64a99eb476 gc: reject if another gc is running, unless --force is given
This may happen when `git gc --auto` is run automatically, then the
user, to avoid wait time, switches to a new terminal, keeps working
and `git gc --auto` is started again because the first gc instance has
not clean up the repository.

This patch tries to avoid multiple gc running, especially in --auto
mode. In the worst case, gc may be delayed 12 hours if a daemon reuses
the pid stored in gc.pid.

kill(pid, 0) support is added to MinGW port so it should work on
Windows too.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-08-09 09:10:05 -07:00
Junio C Hamano d6cbf2fa7a Merge branch 'rj/cygwin-clarify-use-of-cheating-lstat'
Cygwin port added a "not quite correct but a lot faster and good
enough for many lstat() calls that are only used to see if the
working tree entity matches the index entry" lstat() emulation some
time ago, and it started biting us in places.  This removes it and
uses the standard lstat() that comes with Cygwin.

Recent topic that uses lstat on packed-refs file is broken when
this cheating lstat is used, and this is a simplest fix that is
also the cleanest direction to go in the long run.

* rj/cygwin-clarify-use-of-cheating-lstat:
  cygwin: Remove the Win32 l/stat() implementation
2013-08-02 11:01:01 -07:00
Jeremy Huddleston 3ef2bcad02 imap-send: use Apple's Security framework for base64 encoding
Use Apple's supported functions for base64 encoding instead
of the deprecated OpenSSL functions.

Signed-off-by: Jeremy Huddleston <jeremyhu@apple.com>
Signed-off-by: David Aguilar <davvid@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-07-30 08:53:24 -07:00
Junio C Hamano 0def7126fd Merge branch 'ob/typofixes'
* ob/typofixes:
  typofix: in-code comments
  typofix: documentation
  typofix: release notes
2013-07-24 19:23:01 -07:00
Junio C Hamano fc5894bc72 Merge branch 'rj/sparse'
* rj/sparse:
  Revert "compat/unsetenv.c: Fix a sparse warning"
2013-07-24 19:21:30 -07:00
Ondřej Bílka 749f763dbb typofix: in-code comments
Signed-off-by: Ondřej Bílka <neleai@seznam.cz>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-07-22 16:06:49 -07:00
Benoit Sigoure f1e2a48d18 Revert "compat/unsetenv.c: Fix a sparse warning"
This reverts commit ec535cc27e.

POSIX explicitly states "the [environ] variable, which
must be declared by the user if it is to be used directly".
Not declaring it causes compilation to fail on OS X.

Instead don't declare the variable on MinGW, as it causes
a spurious warning there.

Signed-off-by: Benoit Sigoure <tsunanet@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-07-21 15:09:56 -07:00
Ramsay Jones f66450ae94 cygwin: Remove the Win32 l/stat() implementation
Commit adbc0b6b ("cygwin: Use native Win32 API for stat", 30-09-2008)
added a Win32 specific implementation of the stat functions. In order
to handle absolute paths, cygwin mount points and symbolic links, this
implementation may fall back on the standard cygwin l/stat() functions.
Also, the choice of cygwin or Win32 functions is made lazily (by the
first call(s) to l/stat) based on the state of some config variables.

Unfortunately, this "schizophrenic stat" implementation has been the
source of many problems ever since. For example, see commits 7faee6b8,
79748439, 452993c2, 085479e7, b8a97333, 924aaf3e, 05bab3ea and 0117c2f0.

In order to avoid further problems, such as the issue raised by the new
reference handling API, remove the Win32 l/stat() implementation.

Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-07-18 10:44:17 -07:00
Junio C Hamano e936318aa6 Merge branch 'rj/mingw-cygwin'
Update build for Cygwin 1.[57].  Torsten Bögershausen reports that
this is fine with Cygwin 1.7 ($gmane/225824) so let's try moving it
ahead.

* rj/mingw-cygwin:
  cygwin: Remove the CYGWIN_V15_WIN32API build variable
  mingw: rename WIN32 cpp macro to GIT_WINDOWS_NATIVE
2013-06-11 13:30:20 -07:00
Junio C Hamano 39fd762572 Sync with 1.8.3.1
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-06-10 12:35:45 -07:00
Erik Faye-Lund a45406585b mingw: make mingw_signal return the correct handler
Returning the SIGALRM handler for SIGINT is not very useful.

Signed-off-by: Erik Faye-Lund <kusmabite@gmail.com>
Signed-off-by: Johannes Sixt <j6t@kdbg.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-06-10 12:34:03 -07:00
Junio C Hamano 29d5350c01 Merge branch 'fc/macos-x-clipped-write'
Mac OS X does not like to write(2) more than INT_MAX number of
bytes.

* fc/macos-x-clipped-write:
  compate/clipped-write.c: large write(2) fails on Mac OS X/XNU
2013-06-02 15:54:54 -07:00
Filipe Cabecinhas 6c642a8786 compate/clipped-write.c: large write(2) fails on Mac OS X/XNU
Due to a bug in the Darwin kernel, write(2) calls have a maximum size
of INT_MAX bytes.

Introduce a new compat function, clipped_write(), that only writes
at most INT_MAX bytes and returns the number of bytes written, as
a substitute for write(2), and allow platforms that need this to
enable it from the build mechanism with NEEDS_CLIPPED_WRITE.

Set it for Mac OS X by default.  It may be necessary to include this
function on Windows, too.

Signed-off-by: Filipe Cabecinhas <filcab+git@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-05-17 12:16:30 -07:00
Ramsay Jones 83ff1da3e8 cygwin: Remove the CYGWIN_V15_WIN32API build variable
Commit 380a4d92 ("Update cygwin.c for new mingw-64 win32 api headers",
11-11-2012) solved an header include order problem on cygwin 1.7 when
using the new mingw-64 WIN32 API headers. The solution involved using
a new build variable (V15_MINGW_HEADERS) to conditionally compile the
cygwin.c source file to use an include order appropriate for the old
and new header files. (The build variable was later renamed in commit
9fca6cff to CYGWIN_V15_WIN32API).

The include order used for cygwin 1.7 includes the "win32.h" header
before "../git-compat-util.h". This order was problematic on cygwin
1.5, since it lead to the WIN32 symbol being defined along with the
inclusion of some WIN32 API headers (e.g. <winsock2.h>) which cause
compilation errors.

The header include order problem on cygwin 1.5 has since been fixed
(see commit "mingw: rename WIN32 cpp macro to GIT_WINDOWS_NATIVE"),
so we can now remove the conditional compilation along with the
associated CYGWIN_V15_WIN32API build variable.

Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-05-08 12:15:44 -07:00
Jonathan Nieder 380395d094 mingw: rename WIN32 cpp macro to GIT_WINDOWS_NATIVE
Throughout git, it is assumed that the WIN32 preprocessor symbol is
defined on native Windows setups (mingw and msvc) and not on Cygwin.
On Cygwin, most of the time git can pretend this is just another Unix
machine, and Windows-specific magic is generally counterproductive.

Unfortunately Cygwin *does* define the WIN32 symbol in some headers.
Best to rely on a new git-specific symbol GIT_WINDOWS_NATIVE instead,
defined as follows:

	#if defined(WIN32) && !defined(__CYGWIN__)
	# define GIT_WINDOWS_NATIVE
	#endif

After this change, it should be possible to drop the
CYGWIN_V15_WIN32API setting without any negative effect.

[rj: %s/WINDOWS_NATIVE/GIT_WINDOWS_NATIVE/g ]

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-05-08 12:14:35 -07:00
Ramsay Jones 84d32bf767 sparse: Fix mingw_main() argument number/type errors
Sparse issues 68 errors (two errors for each main() function) such
as the following:

      SP git.c
  git.c:510:5: error: too many arguments for function mingw_main
  git.c:510:5: error: symbol 'mingw_main' redeclared with different type \
    (originally declared at git.c:510) - different argument counts

The errors are caused by the 'main' macro used by the MinGW build
to provide a replacement main() function. The original main function
is effectively renamed to 'mingw_main' and is called from the new
main function. The replacement main is used to execute certain actions
common to all git programs on MinGW (e.g. ensure the standard I/O
streams are in binary mode).

In order to suppress the errors, we change the macro to include the
parameters in the declaration of the mingw_main function.

Unfortunately, this change provokes both sparse and gcc to complain
about 9 calls to mingw_main(), such as the following:

      CC git.o
  git.c: In function 'main':
  git.c:510: warning: passing argument 2 of 'mingw_main' from \
    incompatible pointer type
  git.c:510: note: expected 'const char **' but argument is of \
    type 'char **'

In order to suppress these warnings, since both of the main
functions need to be declared with the same prototype, we
change the declaration of the 9 main functions, thus:

    int main(int argc, char **argv)

Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-04-28 12:32:08 -07:00
Ramsay Jones 657b35f4be compat/mingw.c: Fix some sparse warnings
Sparse issues the following warnings:

        SP compat/mingw.c
    compat/mingw.c:795:3: warning: symbol 'pinfo_t' was not declared. \
        Should it be static?
    compat/mingw.c:796:16: warning: symbol 'pinfo' was not declared. \
        Should it be static?
    compat/mingw.c:797:18: warning: symbol 'pinfo_cs' was not declared. \
        Should it be static?
    compat/mingw.c:1207:23: warning: Using plain integer as NULL pointer

In 'pinfo_t' variable, defined on line 795, seems to have been a
mistake (a missing typedef keyword?), so we simply remove it.

The 'pinfo' variable does not require more than file scope, so we
simply add the static modifier to the declaration.

The 'pinfo_cs' variable, in contrast, requires initialisation in the
mingw replacement main() function, so we add an extern declaration to
the compat/mingw.h header file.

The remaining warning is suppressed by replacing the rhs of the
pointer assignment with the NULL pointer literal.

Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-04-28 12:27:11 -07:00
Ramsay Jones 15b7f601fc compat/win32mmap.c: Fix some sparse warnings
Sparse issues two 'Using plain integer as NULL pointer' warnings
against the call to the CreateFileMapping() function. The warnings
relate to the second and sixth parameters, which both have pointer
type. In order to suppress the warnings, we simply pass the NULL
pointer, rather than '0', to those parameters in the function call.

Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-04-28 12:27:08 -07:00
Ramsay Jones 1c31596a4b compat/poll/poll.c: Fix a sparse warning
Sparse issues an 'Using plain integer as NULL pointer' warning when
passing the constant '0' as the second parameter in the call to the
WSAEventSelect() function. The function parameter has a pointer type
(WSAEVENT, aka HANDLE, aka void *) so that, in order to suppress the
warning, we simply pass NULL for that parameter in the function call
expression.

Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-04-28 12:27:04 -07:00
Ramsay Jones 9c3b051f93 compat/win32/pthread.c: Fix a sparse warning
Sparse issues a 'Using plain integer as NULL pointer' warning when
initializing an pthread_t structure with an '{ 0 }' initializer.
The first field of the pthread_t structure has type HANDLE (void *),
so in order to suppress the warning, we replace the initializer
expression with '{ NULL }'.

Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-04-28 12:26:45 -07:00
Ramsay Jones ec535cc27e compat/unsetenv.c: Fix a sparse warning
The gitunsetenv function includes an (redundant) declaration of the
'environ' symbol, which is a pointer to the table of environment
variables. Unfortunately, on MinGW, this provokes sparse to issue
the following warning:

    compat/unsetenv.c:5:20: warning: non-ANSI function declaration of \
    function '__p__environ'

On MinGW, the <stdlib.h> header defines the 'environ' symbol as a
preprocessor macro (via _environ) which obtains the environ table
pointer via a call to the __p__environ() function.

In order to suppress the warning, we simply remove the redundant
declaration of the 'environ' symbol, since the symbol is already
declared correctly in <stdlib.h> (included via git-compat-util.h).

Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-04-28 12:26:38 -07:00
Ramsay Jones eec7fd8bc5 compat/nedmalloc: Fix compiler warnings on linux
On linux, when the build variable USE_NED_ALLOCATOR is set, gcc
issues the following warnings:

    In file included from compat/nedmalloc/nedmalloc.c:63:
    .../malloc.c.h: In function 'mmap_resize':
    .../malloc.c.h:3762: warning: implicit declaration of function 'mremap'
    .../malloc.c.h: In function 'sys_trim':
    .../malloc.c.h:4195: warning: comparison between pointer and integer

The warnings are caused by the <sys/mman.h> header not enabling the
(conditional) declaration of the mremap() function.  The declaration
can be enabled by defining the _GNU_SOURCE symbol prior to including
certain system header files. In particular, it may not be sufficient
to simply define _GNU_SOURCE just prior to including the <sys/mman.h>
header. (e.g. defining the symbol after including <sys/types.h> will
be completely ineffective.)

In order to suppress the warnings, we define the _GNU_SOURCE symbol
at the start of the malloc.c.h header file.

Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-04-28 12:26:09 -07:00
Ramsay Jones 241c957d89 compat/nedmalloc: Fix some sparse warnings
Sparse issues many "Using plain integer as NULL pointer" warnings
while checking nedmalloc.c (at least 98 such warnings before giving
up due to "too many warnings"). In addition, sparse issues some
"non-ANSI function declaration" type warnings for the symbols
'win32_getcurrentthreadid', 'malloc_stats' and 'malloc_footprint'.

In order to suppress the NULL pointer warnings, rather than replace
all uses of '0' as a null pointer representation with NULL, we add
-Wno-non-pointer-null to SPARSE_FLAGS while checking nedmalloc.c.

In order to suppress the "non-ANSI function declaration" warnings,
we simply include the missing 'empty parameter list' prototype (void)
in the function declarations.

Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-04-28 12:24:48 -07:00
Ramsay Jones 4fc8fb48e9 compat/fnmatch/fnmatch.c: Fix a sparse error
Sparse issues the following error and warnings:

    SP compat/fnmatch/fnmatch.c
.../fnmatch.c:144:17: warning: Using plain integer as NULL pointer
.../fnmatch.c:238:67: warning: Using plain integer as NULL pointer
.../fnmatch.c:303:40: error: too many arguments for function getenv

The error is caused by the extern declaration for the getenv function
not including the function prototype. Without the prototype, sparse
effectively sees the declaration as 'char *getenv(void)'. In order to
suppress the error, we simply include the function prototype.

In order to suppress the warnings, we include the <stddef.h> header
which provides an appropriate definition of the NULL macro, rather
than using the (inappropriate) default definition at fnmatch.c:132.

Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-04-28 12:24:40 -07:00
Ramsay Jones 5b62e6374a compat/regex/regexec.c: Fix some sparse warnings
Sparse issues an "Using plain integer as NULL pointer" warning along
with two "symbol was not declared. Should it be static?" type warnings
for the 'merge_state_with_log' and 'find_recover_state' functions.

In order to suppress the warnings, we replace the use of '0' as a null
pointer constant with NULL and add the static modifier to the function
definitions.

Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-04-28 12:24:18 -07:00
Nguyễn Thái Ngọc Duy b782bbab94 utf8.c: add reencode_string_len() that can handle NULs in string
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-04-18 16:28:28 -07:00
Junio C Hamano caa7d79f1f Sync with 'maint'
* maint:
  Correct common spelling mistakes in comments and tests
  kwset: fix spelling in comments
  precompose-utf8: fix spelling of "want" in error message
  compat/nedmalloc: fix spelling in comments
  compat/regex: fix spelling and grammar in comments
  obstack: fix spelling of similar
  contrib/subtree: fix spelling of accidentally
  git-remote-mediawiki: spelling fixes
  doc: various spelling fixes
  fast-export: fix argument name in error messages
  Documentation: distinguish between ref and offset deltas in pack-format
  i18n: make the translation of -u advice in one go
2013-04-12 13:54:01 -07:00
Stefano Lattarini 0f7b4c2e77 precompose-utf8: fix spelling of "want" in error message
Noticed using Lucas De Marchi's codespell tool.

Signed-off-by: Stefano Lattarini <stefano.lattarini@gmail.com>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Acked-by: Matthieu Moy <Matthieu.Moy@imag.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-04-12 12:24:04 -07:00
Stefano Lattarini 4283b8e408 compat/nedmalloc: fix spelling in comments
Correct some typos found using Lucas De Marchi's codespell tool.

Signed-off-by: Stefano Lattarini <stefano.lattarini@gmail.com>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Acked-by: Matthieu Moy <Matthieu.Moy@imag.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-04-12 12:23:58 -07:00
Stefano Lattarini ce9171cd63 compat/regex: fix spelling and grammar in comments
Some of these were found using Lucas De Marchi's codespell tool.
Others noticed by Eric Sunshine.

Helped-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Stefano Lattarini <stefano.lattarini@gmail.com>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Acked-by: Matthieu Moy <Matthieu.Moy@imag.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-04-12 12:23:44 -07:00
Stefano Lattarini 7323513d28 obstack: fix spelling of similar
Noticed using Lucas De Marchi's codespell tool.

Signed-off-by: Stefano Lattarini <stefano.lattarini@gmail.com>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Acked-by: Matthieu Moy <Matthieu.Moy@imag.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-04-12 12:23:20 -07:00
Torsten Bögershausen 0117c2f043 Make core.sharedRepository work under cygwin 1.7
When core.sharedRepository is used, set_shared_perm() in path.c
needs lstat() to return the correct POSIX permissions.

The default for cygwin is core.ignoreCygwinFSTricks = false, which
means that the fast implementation in do_stat() is used instead of
lstat().

lstat() under cygwin uses the Windows security model to implement
POSIX-like permissions.  The user, group or everyone bits can be set
individually.

do_stat() simplifes the file permission bits, and may return a wrong
value.  The read-only attribute of a file is used to calculate the
permissions, resulting in either rw-r--r-- or r--r--r--

One effect of the simplified do_stat() is that t1301 fails.

Add a function cygwin_get_st_mode_bits() which returns the POSIX
permissions.  When not compiling for cygwin, true_mode_bits() in
path.c is used.

Side note:

t1301 passes under cygwin 1.5.

The "user write" bit is synchronized with the "read only" attribute
of a file:

    $ chmod 444 x
    $ attrib x
    A    R     C:\temp\pt\x

    cygwin 1.7 would show
    A          C:\temp\pt\x

Signed-off-by: Torsten Bögershausen <tboegi@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-03-25 14:57:33 -07:00
Junio C Hamano 9b79956018 Merge branch 'rj/msvc-build'
* rj/msvc-build:
  msvc: avoid collisions between "tags" and "TAGS"
  msvc: test-svn-fe: Fix linker "unresolved external" error
  msvc: Fix build by adding missing symbol defines
  msvc: git-daemon: Fix linker "unresolved external" errors
  msvc: Fix compilation errors caused by poll.h emulation
2013-03-19 12:20:40 -07:00
Erik Faye-Lund 13a2319919 Revert "compat: add strtok_r()"
This reverts commit 78457bc0cc.

commit 28c5d9e ("vcs-svn: drop string_pool") previously removed
the only call-site for strtok_r. So let's get rid of the compat
implementation as well.

Signed-off-by: Erik Faye-Lund <kusmabite@gmail.com>
Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-02-26 09:16:58 -08:00
Ramsay Jones d0f9dbb9e2 msvc: test-svn-fe: Fix linker "unresolved external" error
In particular, while linking test-svn-fe.exe, the linker complains
that the external symbol _strtoull is unresolved. A call to this
function was added in commit ddcc8c5b ("vcs-svn: skeleton of an svn
delta parser", 25-12-2010).

The NO_STRTOULL build variable attempts to provide support to old
systems which can't even declare 'unsigned long long' variables,
let alone provide the strtoll() or strtoull() functions. Setting
this build variable does not provide an implementation of these
functions. Rather, it simply allows the compat implementations
of strto{i,u}max() to use strtol() and strtoul() instead.

In order to fix the linker error on systems with NO_STRTOULL set,
currently MSVC and OSF1, we can substitute a call to strtoumax().

However, we can easily provide support for the strtoull() and
strtoll() functions on MSVC, since they are essentially already
available as _strtoui64() and _strtoi64(). This allows us to
remove NO_STRTOULL for MSVC.

Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
Tested-by: Johannes Sixt <j6t@kdbg.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-02-25 12:40:34 -08:00
Ramsay Jones 93e38ed0c5 msvc: Fix build by adding missing symbol defines
In particular, remote-testsvn.c fails to compile with two
undeclared identifier errors relating to the 'UINT32_MAX'
and 'STDIN_FILENO' symbols.

In order to fix the compilation errors, we add appropriate
definitions for the UINT32_MAX and STDIN_FILENO constants
to an msvc compat header file.

Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
Tested-by: Johannes Sixt <j6t@kdbg.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-02-25 12:40:03 -08:00
Ramsay Jones 41f2999180 msvc: Fix compilation errors caused by poll.h emulation
Commit 0f77dea9 ("mingw: move poll out of sys-folder", 24-10-2011), along
with other commits in the 'ef/mingw-upload-archive' branch (see commit
7406aa20), effectively reintroduced the same problem addressed by commit
56fb3ddc ("msvc: Fix compilation errors in compat/win32/sys/poll.c",
04-12-2010).

In order to fix the compilation errors, we use the same solution adopted
in that earlier commit. In particular, we set _WIN32_WINNT to 0x0502
(which would target Windows Server 2003) prior to including the winsock2.h
header file.

Also, we delete the compat/vcbuild/include/sys/poll.h header file, since
it is now redundant and it's presence may cause some confusion.

Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
Tested-by: Johannes Sixt <j6t@kdbg.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-02-25 12:39:56 -08:00
Junio C Hamano 2adf7247ec Merge branch 'nd/wildmatch'
Allows pathname patterns in .gitignore and .gitattributes files
with double-asterisks "foo/**/bar" to match any number of directory
hierarchies.

* nd/wildmatch:
  wildmatch: replace variable 'special' with better named ones
  compat/fnmatch: respect NO_FNMATCH* even on glibc
  wildmatch: fix "**" special case
  t3070: Disable some failing fnmatch tests
  test-wildmatch: avoid Windows path mangling
  Support "**" wildcard in .gitignore and .gitattributes
  wildmatch: make /**/ match zero or more directories
  wildmatch: adjust "**" behavior
  wildmatch: fix case-insensitive matching
  wildmatch: remove static variable force_lower_case
  wildmatch: make wildmatch's return value compatible with fnmatch
  t3070: disable unreliable fnmatch tests
  Integrate wildmatch to git
  wildmatch: follow Git's coding convention
  wildmatch: remove unnecessary functions
  Import wildmatch from rsync
  ctype: support iscntrl, ispunct, isxdigit and isprint
  ctype: make sane_ctype[] const array

Conflicts:
	Makefile
2013-01-10 13:47:20 -08:00
Junio C Hamano 0266f4688c Merge branch 'ss/nedmalloc-compilation'
* ss/nedmalloc-compilation:
  nedmalloc: Fix a compile warning (exposed as error) with GCC 4.7.2
2013-01-03 10:14:10 -08:00
Junio C Hamano cd46f2e59d Merge branch 'jc/maint-fnmatch-old-style-definition'
Update old-style function definition "int foo(bar) int bar; {}"
to "int foo(int bar) {}".

* jc/maint-fnmatch-old-style-definition:
  compat/fnmatch: update old-style definition to ANSI
2013-01-03 10:14:05 -08:00
Nguyễn Thái Ngọc Duy 889316d252 compat/fnmatch: respect NO_FNMATCH* even on glibc
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-01-01 15:32:36 -08:00
Junio C Hamano 38104ca6b9 compat/fnmatch: update old-style definition to ANSI
We try to avoid touching borrowed code, but we encourage people to
write without old-style definition and compile with -Werror these
days, and on platforms that need to use NO_FNMATCH, these three
functions make the compilation fail.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-12-19 10:20:59 -08:00
Sebastian Schuberth 8e679e08a6 nedmalloc: Fix a compile warning (exposed as error) with GCC 4.7.2
On MinGW, GCC 4.7.2 complains about

    operation on 'p->m[end]' may be undefined

Fix this by replacing the faulty lines with those of 69825ca from

    https://github.com/ned14/nedmalloc/blob/master/nedmalloc.c

Signed-off-by: Sebastian Schuberth <sschuberth@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-12-11 22:10:22 -08:00
Junio C Hamano 7348159380 Merge branch 'ef/mingw-rmdir'
MinGW has a workaround when rmdir unnecessarily fails to retry with
a prompt, but the logic was kicking in when the rmdir failed with
ENOTEMPTY, i.e. was expected to fail and there is no point retrying.

* ef/mingw-rmdir:
  mingw_rmdir: do not prompt for retry when non-empty
2012-12-11 15:51:14 -08:00
Erik Faye-Lund a83b2b578c mingw_rmdir: do not prompt for retry when non-empty
in ab1a11be ("mingw_rmdir: set errno=ENOTEMPTY when appropriate"),
a check was added to prevent us from retrying to delete a directory
that is both in use and non-empty.

However, this logic was slightly flawed; since we didn't return
immediately, we end up falling out of the retry-loop, but right into
the prompting-loop.

Fix this by setting errno, and guarding the prompting-loop with an
errno-check.

Signed-off-by: Erik Faye-Lund <kusmabite@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-12-10 08:23:53 -08:00
Erik Faye-Lund f7a4cea25e mingw: get rid of getpass implementation
There's no remaining call-sites, and as pointed out in the
previous commit message, it's not quite ideal. So let's just
lose it.

Signed-off-by: Erik Faye-Lund <kusmabite@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-12-04 08:03:42 -08:00
Erik Faye-Lund afb43561b8 mingw: reuse tty-version of git_terminal_prompt
The getpass-implementation we use on Windows isn't at all ideal;
it works in raw-mode (as opposed to cooked mode), and as a result
does not deal correcly with deletion, arrow-keys etc.

Instead, use cooked mode to read a line at the time, allowing the
C run-time to process the input properly.

Since we set files to be opened in binary-mode by default on
Windows, introduce a FORCE_TEXT macro that expands to the "t"
modifier that forces the terminal to be opened in text-mode so we
do not have to deal with CRLF issues.

Signed-off-by: Erik Faye-Lund <kusmabite@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-12-04 08:03:08 -08:00
Erik Faye-Lund 67fe735653 compat/terminal: separate input and output handles
On Windows, the terminal cannot be opened in read-write mode, so
we need distinct pairs for reading and writing. Since this works
fine on other platforms as well, always open them in pairs.

Signed-off-by: Erik Faye-Lund <kusmabite@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-12-04 08:02:55 -08:00
Erik Faye-Lund 9df92e6369 compat/terminal: factor out echo-disabling
By moving the echo-disabling code to a separate function, we can
implement OS-specific versions of it for non-POSIX platforms.

Signed-off-by: Erik Faye-Lund <kusmabite@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-12-04 08:01:59 -08:00
Erik Faye-Lund 176478a8bd mingw: make fgetc raise SIGINT if apropriate
Set a control-handler to prevent the process from terminating, and
simulate SIGINT so it can be handled by a signal-handler as usual.

Signed-off-by: Erik Faye-Lund <kusmabite@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-12-04 08:00:58 -08:00
Erik Faye-Lund f4f549892a mingw: correct exit-code for SIGALRM's SIG_DFL
Make sure SIG_DFL for SIGALRM exits with 128 + SIGALRM so other
processes can diagnose why it exits.

While we're at it, make sure we only write to stderr if it's a
terminal, and  change the output to match that of Linux.

Signed-off-by: Erik Faye-Lund <kusmabite@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-12-04 08:00:29 -08:00
Junio C Hamano 86ef7b37f9 Merge branch 'nd/maint-compat-fnmatch-fix' into maint
* nd/maint-compat-fnmatch-fix:
  compat/fnmatch: fix off-by-one character class's length check
2012-11-27 13:29:00 -08:00
Junio C Hamano 5ab539bb00 Merge branch 'nd/maint-compat-fnmatch-fix'
* nd/maint-compat-fnmatch-fix:
  compat/fnmatch: fix off-by-one character class's length check
2012-11-25 18:44:41 -08:00
Nguyễn Thái Ngọc Duy f10e3864dc compat/fnmatch: fix off-by-one character class's length check
Character class "xdigit" is the only one that hits 6 character limit
defined by CHAR_CLASS_MAX_LENGTH. All other character classes are 5
character long and therefore never caught by this.

This should make xdigit tests in t3070 pass on Windows.

Reported-by: Johannes Sixt <j6t@kdbg.org>
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-11-20 12:13:09 -08:00
Mark Levedahl 9fca6cffc0 USE CGYWIN_V15_WIN32API as macro to select api for cygwin
The previous macro was confusing to some, and did not include "cygwin" in
its name. The updated name more clearly expresses a choice of the
win32api implementation that shipped with version 1.5 of cygwin.

Signed-off-by: Mark Levedahl <mlevedahl@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-11-18 20:02:40 -08:00
Mark Levedahl 380a4d927b Update cygwin.c for new mingw-64 win32 api headers
The cygwin project recently switched to a new implementation of the
windows api, now using header files from the mingw-64 project. These
new header files are incompatible with the way cygwin.c included the
old headers: cygwin.c can be compiled using the new or the older (mingw)
headers, but different files must be included in different order for each
to work. The new headers are in use only for the current release series
(based upon the v1.7.x dll version). The previous release series using
the v1.5 dll is kept available but unmaintained for use on older versions
of Windows. So, patch cygwin.c to use the new include ordering only if
the dll version is 1.7 or higher.

Signed-off-by: Mark Levedahl <mlevedahl@gmail.com>
Signed-off-by: Jeff King <peff@peff.net>
2012-11-12 15:47:50 -05:00
Jeff King bbbd057389 Merge branch 'js/mingw-fflush-errno'
* js/mingw-fflush-errno:
  maybe_flush_or_die: move a too-loose Windows specific error
2012-10-25 06:43:01 -04:00
Johannes Sixt 84adb64154 maybe_flush_or_die: move a too-loose Windows specific error
check to compat

Commit b2f5e268 (Windows: Work around an oddity when a pipe with no reader
is written to) introduced a check for EINVAL after fflush() to fight
spurious "Invalid argument" errors on Windows when a pipe was broken. But
this check may hide real errors on systems that do not have the this odd
behavior. Introduce an fflush wrapper in compat/mingw.* so that the treatment
is only applied on Windows.

Signed-off-by: Johannes Sixt <j6t@kdbg.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-10-17 00:33:42 -07:00
Joachim Schmitz a6772946a5 make poll() work on platforms that can't recv() on a non-socket
This way it just got added to gnulib too the other day.

Signed-off-by: Joachim Schmitz <jojo@schmitz-digital.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-09-17 15:44:20 -07:00
Joachim Schmitz 32fde6575e poll() exits too early with EFAULT if 1st arg is NULL
If poll() is used as a milli-second sleep, like in help.c, by passing a NULL
in the 1st and a 0 in the 2nd arg, it exits with EFAULT.

As per Paolo Bonzini, the original author, this is a bug and to be fixed
Like in this commit, which is not to exit if the 2nd arg is 0. It got fixed
In gnulib in the same manner the other day.

Signed-off-by: Joachim Schmitz <jojo@schmitz-digital.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-09-17 15:43:44 -07:00
Joachim Schmitz 98c573a902 fix some win32 specific dependencies in poll.c
In order for non-win32 platforms to be able to use poll.c, #ifdef the
inclusion of two header files properly

Signed-off-by: Joachim Schmitz <jojo@schmitz-digital.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-09-17 15:43:20 -07:00
Joachim Schmitz 6d45eb1720 make poll available for other platforms lacking it
move poll.[ch] out of compat/win32/ into compat/poll/ and adjust
Makefile with the changed paths. Adding comments to Makefile about
how/when to enable it and add logic for this

Signed-off-by: Joachim Schmitz <jojo@schmitz-digital.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-09-17 15:42:57 -07:00
Junio C Hamano 8bc72fc7fe Merge branch 'rr/precompose-utf8-cleanup' into maint
* rr/precompose-utf8-cleanup:
  precompose-utf8: do not call checks for non-ascii "utf8"
  cleanup precompose_utf8
2012-09-11 11:07:14 -07:00
Junio C Hamano a795b324b7 Merge branch 'js/compat-mkdir'
Some mkdir(2) implementations do not want to see trailing slash in
its parameter.

* js/compat-mkdir:
  compat: some mkdir() do not like a slash at the end
2012-09-03 15:54:37 -07:00
Junio C Hamano 183154bac8 Merge branch 'rr/precompose-utf8-cleanup'
* rr/precompose-utf8-cleanup:
  precompose-utf8: do not call checks for non-ascii "utf8"
  cleanup precompose_utf8
2012-08-29 14:50:35 -07:00
Junio C Hamano 3f988231ae Merge branch 'bw/maint-1.7.9-solaris-getpass' into maint-1.7.11
* bw/maint-1.7.9-solaris-getpass:
  Enable HAVE_DEV_TTY for Solaris
  terminal: seek when switching between reading and writing
2012-08-24 12:05:11 -07:00
Joachim Schmitz 0539ecfdfc compat: some mkdir() do not like a slash at the end
Introduce a compatibility helper for platforms with such a mkdir().

Signed-off-by: Joachim Schmitz <jojo@schmitz-digital.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-08-24 09:48:51 -07:00
Junio C Hamano 9a27f96705 precompose-utf8: do not call checks for non-ascii "utf8"
As suggested by Linus, this function is not checking UTF-8-ness of the
string; it only is seeing if it is pure US-ASCII.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-08-20 11:12:58 -07:00
Robin Rosenberg 5f8580ad47 cleanup precompose_utf8
- Remove extraneous parentheses and braces;

 - Remove redundant NUL-termination before strcpy();

 - Check result of unlink when probing for decomposed file names;

 - Adjust for the coding style by adding missing whitespaces;

 - Move storage class "static" at the beginning of the decl.

Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-08-17 10:29:56 -07:00
Junio C Hamano e5acacfb48 Merge branch 'bw/maint-1.7.9-solaris-getpass'
The recent update to terminal I/O interface to get passwords &c
interactively didn't quite work on Solaris.

* bw/maint-1.7.9-solaris-getpass:
  Enable HAVE_DEV_TTY for Solaris
  terminal: seek when switching between reading and writing
2012-08-08 15:14:58 -07:00
Jeff King 67ba123fd1 terminal: seek when switching between reading and writing
When a stdio stream is opened in update mode (e.g., "w+"),
the C standard forbids switching between reading or writing
without an intervening positioning function. Many
implementations are lenient about this, but Solaris libc
will flush the recently-read contents to the output buffer.
In this instance, that meant writing the non-echoed password
that the user just typed to the terminal.

Fix it by inserting a no-op fseek between the read and
write.

The opposite direction (writing followed by reading) is also
disallowed, but our intervening fflush is an acceptable
positioning function for that alternative.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-08-06 22:11:47 -07:00
Junio C Hamano b856ad623e Merge branch 'tb/sanitize-decomposed-utf-8-pathname'
Teaches git to normalize pathnames read from readdir(3) and all
arguments from the command line into precomposed UTF-8 (assuming
that they come as decomposed UTF-8) to work around issues on Mac OS.

I think there still are other places that need conversion
(e.g. paths that are read from stdin for some commands), but this
should be a good first step in the right direction.

* tb/sanitize-decomposed-utf-8-pathname:
  git on Mac OS and precomposed unicode
2012-07-13 15:37:51 -07:00
Torsten Bögershausen 76759c7dff git on Mac OS and precomposed unicode
Mac OS X mangles file names containing unicode on file systems HFS+,
VFAT or SAMBA.  When a file using unicode code points outside ASCII
is created on a HFS+ drive, the file name is converted into
decomposed unicode and written to disk. No conversion is done if
the file name is already decomposed unicode.

Calling open("\xc3\x84", ...) with a precomposed "Ä" yields the same
result as open("\x41\xcc\x88",...) with a decomposed "Ä".

As a consequence, readdir() returns the file names in decomposed
unicode, even if the user expects precomposed unicode.  Unlike on
HFS+, Mac OS X stores files on a VFAT drive (e.g. an USB drive) in
precomposed unicode, but readdir() still returns file names in
decomposed unicode.  When a git repository is stored on a network
share using SAMBA, file names are send over the wire and written to
disk on the remote system in precomposed unicode, but Mac OS X
readdir() returns decomposed unicode to be compatible with its
behaviour on HFS+ and VFAT.

The unicode decomposition causes many problems:

- The names "git add" and other commands get from the end user may
  often be precomposed form (the decomposed form is not easily input
  from the keyboard), but when the commands read from the filesystem
  to see what it is going to update the index with already is on the
  filesystem, readdir() will give decomposed form, which is different.

- Similarly "git log", "git mv" and all other commands that need to
  compare pathnames found on the command line (often but not always
  precomposed form; a command line input resulting from globbing may
  be in decomposed) with pathnames found in the tree objects (should
  be precomposed form to be compatible with other systems and for
  consistency in general).

- The same for names stored in the index, which should be
  precomposed, that may need to be compared with the names read from
  readdir().

NFS mounted from Linux is fully transparent and does not suffer from
the above.

As Mac OS X treats precomposed and decomposed file names as equal,
we can

 - wrap readdir() on Mac OS X to return the precomposed form, and

 - normalize decomposed form given from the command line also to the
   precomposed form,

to ensure that all pathnames used in Git are always in the
precomposed form.  This behaviour can be requested by setting
"core.precomposedunicode" configuration variable to true.

The code in compat/precomposed_utf8.c implements basically 4 new
functions: precomposed_utf8_opendir(), precomposed_utf8_readdir(),
precomposed_utf8_closedir() and precompose_argv().  The first three
are to wrap opendir(3), readdir(3), and closedir(3) functions.

The argv[] conversion allows to use the TAB filename completion done
by the shell on command line.  It tolerates other tools which use
readdir() to feed decomposed file names into git.

When creating a new git repository with "git init" or "git clone",
"core.precomposedunicode" will be set "false".

The user needs to activate this feature manually.  She typically
sets core.precomposedunicode to "true" on HFS and VFAT, or file
systems mounted via SAMBA.

Helped-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Torsten Bögershausen <tboegi@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-07-08 22:03:46 -07:00
Leila Muhtasib 8d8136c37a Documentation: Fix misspellings
Signed-off-by: Leila Muhtasib <muhtasib@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-06-22 14:25:04 -07:00
Junio C Hamano cc13431a49 Merge branch 'nd/threaded-index-pack'
Enables threading in index-pack to resolve base data in parallel.

By Nguyễn Thái Ngọc Duy (3) and Ramsay Jones (1)
* nd/threaded-index-pack:
  index-pack: disable threading if NO_PREAD is defined
  index-pack: support multithreaded delta resolving
  index-pack: restructure pack processing into three main functions
  compat/win32/pthread.h: Add an pthread_key_delete() implementation
2012-05-14 11:50:40 -07:00
Pete Wyckoff 82247e9bd5 remove superfluous newlines in error messages
The error handling routines add a newline.  Remove
the duplicate ones in error messages.

Signed-off-by: Pete Wyckoff <pw@padd.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-04-30 15:45:51 -07:00
Junio C Hamano e7779c2eca Merge branch 'rj/mingw-isguid'
By Ramsay Jones
* rj/mingw-isguid:
  compat/mingw.h: Set S_ISUID to prevent a fast-import test failure
2012-04-23 13:01:42 -07:00
Junio C Hamano bd6f71d1fc Merge branch 'jk/run-command-eacces'
When PATH contains an unreadable directory, alias expansion code did not
kick in, and failed with an error that said "git-subcmd" was not found.

By Jeff King (1) and Ramsay Jones (1)
* jk/run-command-eacces:
  run-command: treat inaccessible directories as ENOENT
  compat/mingw.[ch]: Change return type of exec functions to int
2012-04-20 15:50:03 -07:00
Ramsay Jones 90110d7645 compat/mingw.h: Set S_ISUID to prevent a fast-import test failure
The current t9300-fast-import.sh test number 62 ("L: nested tree
copy does not corrupt deltas") was introduced in commit 9a0edb79
("fast-import: add a test for tree delta base corruption",
15-08-2011). A fix for the demonstrated problem was introduced
by commit 8fb3ad76 ("fast-import: prevent producing bad delta",
15-08-2011). However, this fix didn't work on MinGW and so this
test has always failed on MinGW.

Part of the solution in commit 8fb3ad76 was to add an NO_DELTA
preprocessor constant which was defined as follows:

  +/*
  + * We abuse the setuid bit on directories to mean "do not delta".
  + */
  +#define NO_DELTA S_ISUID
  +

Unfortunately, the S_ISUID constant on MinGW is defined as zero.

In order to fix the problem, we simply alter the definition of
S_ISUID in the mingw header file to a more appropriate value.
Also, we take the opportunity to similarly define S_ISGID and
S_ISVTX.

Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-04-18 13:00:57 -07:00
Ramsay Jones 9ba604a9e4 compat/win32/pthread.h: Add an pthread_key_delete() implementation
Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-04-11 11:08:43 -07:00
Ramsay Jones 1696d72321 compat/mingw.[ch]: Change return type of exec functions to int
The POSIX standard specifies a return type of int for all six exec
functions. In addition, all exec functions return -1 on error, and
simply do not return on success. However, the current emulation of
the exec functions on mingw are declared with a void return type.

This would cause a problem should any code attempt to call the
exec function in a non-void context. In particular, if an exec
function were used in a conditional it would fail to compile.

In order to improve the fidelity of the emulation, we change the
return type of the mingw_execv[p] functions to int and return -1
on error.

Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-04-05 16:22:48 -07:00
Junio C Hamano 8ed9f5d6a7 Merge branch 'bw/inet-pton-ntop-compat'
* bw/inet-pton-ntop-compat:
  Drop system includes from inet_pton/inet_ntop compatibility wrappers
2012-02-12 22:42:14 -08:00
Ben Walton cd4c4e2481 Drop system includes from inet_pton/inet_ntop compatibility wrappers
As both of these compatibility wrappers include git-compat-utils.h,
all of the system includes were redundant.

Dropping these system includes also makes git-compat-utils.h the first
include which avoids a compiler warning on Solaris due to the
redefinition of _FILE_OFFSET_BITS.

Signed-off-by: Ben Walton <bwalton@artsci.utoronto.ca>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-02-05 16:32:33 -08:00
Junio C Hamano 340c54ae55 Merge branch 'ef/setenv-putenv'
* ef/setenv-putenv:
  compat/setenv.c: error if name contains '='
  compat/setenv.c: update errno when erroring out
2011-12-22 11:27:24 -08:00
Junio C Hamano ded408fd20 Merge branch 'jk/git-prompt'
* jk/git-prompt:
  contrib: add credential helper for OS X Keychain
  Makefile: OS X has /dev/tty
  Makefile: linux has /dev/tty
  credential: use git_prompt instead of git_getpass
  prompt: use git_terminal_prompt
  add generic terminal prompt function
  refactor git_getpass into generic prompt function
  move git_getpass to its own source file
  imap-send: don't check return value of git_getpass
  imap-send: avoid buffer overflow

Conflicts:
	Makefile
2011-12-22 11:27:23 -08:00
Junio C Hamano ea4ef30487 Merge branch 'jk/maint-snprintf-va-copy'
* jk/maint-snprintf-va-copy:
  compat/snprintf: don't look at va_list twice
2011-12-19 16:05:38 -08:00
Erik Faye-Lund 6ac1b2a3b8 compat/setenv.c: error if name contains '='
According to POSIX, setenv should error out with EINVAL if it's
asked to set an environment variable whose name contains an equals
sign. Implement this detail in our compatibility-fallback.

Signed-off-by: Erik Faye-Lund <kusmabite@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-12-14 19:31:03 -08:00
Erik Faye-Lund 57590c72b4 compat/setenv.c: update errno when erroring out
Previously, gitsetenv didn't update errno as it should when
erroring out. Fix this.

Signed-off-by: Erik Faye-Lund <kusmabite@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-12-14 19:30:41 -08:00
Jeff King 21aeafceda add generic terminal prompt function
When we need to prompt the user for input interactively, we
want to access their terminal directly. We can't rely on
stdio because it may be connected to pipes or files, rather
than the terminal. Instead, we use "getpass()", because it
abstracts the idea of prompting and reading from the
terminal.  However, it has some problems:

  1. It never echoes the typed characters, which makes it OK
     for passwords but annoying for other input (like usernames).

  2. Some implementations of getpass() have an extremely
     small input buffer (e.g., Solaris 8 is reported to
     support only 8 characters).

  3. Some implementations of getpass() will fall back to
     reading from stdin (e.g., glibc). We explicitly don't
     want this, because our stdin may be connected to a pipe
     speaking a particular protocol, and reading will
     disrupt the protocol flow (e.g., the remote-curl
     helper).

  4. Some implementations of getpass() turn off signals, so
     that hitting "^C" on the terminal does not break out of
     the password prompt. This can be a mild annoyance.

Instead, let's provide an abstract "git_terminal_prompt"
function that addresses these concerns. This patch includes
an implementation based on /dev/tty, enabled by setting
HAVE_DEV_TTY. The fallback is to use getpass() as before.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-12-12 16:09:38 -08:00
Jeff King a9bfbc5b69 compat/snprintf: don't look at va_list twice
If you define SNPRINTF_RETURNS_BOGUS, we use a special
git_vsnprintf wrapper assumes that vsnprintf returns "-1"
instead of the number of characters that you would need to
store the result.

To do this, it invokes vsnprintf multiple times, growing a
heap buffer until we have enough space to hold the result.
However, this means we evaluate the va_list parameter
multiple times, which is generally a bad thing (it may be
modified by calls to vsnprintf, yielding undefined
behavior).

Instead, we must va_copy it and hand the copy to vsnprintf,
so we always have a pristine va_list.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-12-12 09:09:35 -08:00
Junio C Hamano 51f737e350 Merge branch 'maint'
* maint:
  am: don't persist keepcr flag
  mingw: give waitpid the correct signature
  git symbolic-ref: documentation fix
2011-12-09 13:34:18 -08:00
Junio C Hamano 10dd3b2bf1 Merge branch 'maint-1.7.7' into maint
* maint-1.7.7:
  am: don't persist keepcr flag
  mingw: give waitpid the correct signature
  git symbolic-ref: documentation fix
2011-12-09 13:33:39 -08:00
Erik Faye-Lund 956d86d1c9 mingw: give waitpid the correct signature
POSIX says that last parameter to waitpid should be 'int',
so let's make it so.

Signed-off-by: Erik Faye-Lund <kusmabite@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-12-09 10:46:52 -08:00
Junio C Hamano cd17abdf75 Merge branch 'vr/msvc'
* vr/msvc:
  MSVC: Remove unneeded header stubs
  Compile fix for MSVC: Include <io.h>
  Compile fix for MSVC: Do not include sys/resources.h
2011-12-05 15:12:54 -08:00
Junio C Hamano 5d6c53bb23 Merge branch 'na/strtoimax'
* na/strtoimax:
  Support sizes >=2G in various config options accepting 'g' sizes.
  Compatibility: declare strtoimax() under NO_STRTOUMAX
  Add strtoimax() compatibility function.
2011-12-05 15:12:49 -08:00
Junio C Hamano f0c7fd49c0 Revert "upload-archive: use start_command instead of fork"
This reverts commit c09cd77ea2, expecting a
better version to be rerolled soon.
2011-11-15 15:39:33 -08:00
Nick Alcock e3eed7f8d2 Add strtoimax() compatibility function.
Since systems that omit strtoumax() will likely omit strtomax() too, and
likewise for strtoull() and strtoll(), we arrange for the make variables
NO_STRTOUMAX and NO_STRTOULL to cover both the signed and unsigned
functions, and define compatibility implementations for them.

Signed-off-by: Nick Alcock <nix@esperi.org.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-11-02 13:06:30 -07:00
Vincent van Ravesteijn 439fbb8072 MSVC: Remove unneeded header stubs
These headers are no longer needed since they are no longer
unnecessarily included in git-compat-util.h.

Signed-off-by: Vincent van Ravesteijn <vfr@lyx.org>
Acked-by: Erik Faye-Lund <kusmabite@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-10-31 20:06:06 -07:00
Vincent van Ravesteijn 7b05949be0 Compile fix for MSVC: Include <io.h>
This include is needed for _commit(..) which is used in mingw.h.

Signed-off-by: Vincent van Ravesteijn <vfr@lyx.org>
Acked-by: Erik Faye-Lund <kusmabite@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-10-31 20:06:03 -07:00
Erik Faye-Lund c09cd77ea2 upload-archive: use start_command instead of fork
The POSIX-function fork is not supported on Windows. Use our
start_command API instead.

As this is the last call-site that depends on the fork-stub in
compat/mingw.h, remove that as well.

Add an undocumented flag to git-archive that tells it that the
action originated from a remote, so features can be disabled.
Thanks to Jeff King for work on this part.

Remove the NOT_MINGW-prereq for t5000, as git-archive --remote
now works.

Signed-off-by: Erik Faye-Lund <kusmabite@gmail.com>
Helped-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-10-30 18:45:21 -07:00
Erik Faye-Lund f0bd664977 compat/win32/poll.c: upgrade from upstream
poll.c is updated from revision adc3a5b in
git://git.savannah.gnu.org/gnulib.git

The changes are applied with --whitespace=fix to reduce noise.

poll.h is not upgraded, because the most recent version now
contains template-stuff that breaks compilation for us.

Signed-off-by: Erik Faye-Lund <kusmabite@gmail.com>
Acked-by: Johannes Sixt <j6t@kdbg.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-10-30 18:45:16 -07:00
Erik Faye-Lund 0f77dea9a8 mingw: move poll out of sys-folder
Both XSI and upstream Gnulib versions expects to find poll.h at
the root of some include path, not inside the sys-folder.

This helps us when upgrading Gnulib.

Signed-off-by: Erik Faye-Lund <kusmabite@gmail.com>
Acked-by: Johannes Sixt <j6t@kdbg.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-10-30 18:44:28 -07:00
Junio C Hamano 8d3c0cb08d Merge branch 'ss/inet-ntop'
* ss/inet-ntop:
  inet_ntop.c: Work around GCC 4.6's detection of uninitialized variables
2011-10-21 16:04:35 -07:00
Junio C Hamano 578183bcb0 Merge branch 'pt/mingw-misc-fixes'
* pt/mingw-misc-fixes:
  t9901: fix line-ending dependency on windows
  mingw: ensure sockets are initialized before calling gethostname
  mergetools: use the correct tool for Beyond Compare 3 on Windows
  t9300: do not run --cat-blob-fd related tests on MinGW
  git-svn: On MSYS, escape and quote SVN_SSH also if set by the user
  t9001: do not fail only due to CR/LF issues
  t1020: disable the pwd test on MinGW
2011-10-18 21:59:11 -07:00
Sebastian Schuberth 185528a859 inet_ntop.c: Work around GCC 4.6's detection of uninitialized variables
GCC 4.6 claims that

    error: 'best.len' may be used uninitialized in this function

so silence that warning which is treated as an error by also initializing
the "len" members of the struct.

Signed-off-by: Sebastian Schuberth <sschuberth@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-10-18 10:34:07 -07:00
Junio C Hamano a200dc8e62 Merge branch 'bc/attr-ignore-case'
* bc/attr-ignore-case:
  attr.c: respect core.ignorecase when matching attribute patterns
  attr: read core.attributesfile from git_default_core_config
  builtin/mv.c: plug miniscule memory leak
  cleanup: use internal memory allocation wrapper functions everywhere
  attr.c: avoid inappropriate access to strbuf "buf" member

Conflicts:
	transport-helper.c
2011-10-17 21:37:14 -07:00
Junio C Hamano d2843da029 Merge branch 'ef/mingw-syslog'
* ef/mingw-syslog:
  mingw: avoid using strbuf in syslog
2011-10-17 21:37:11 -07:00
Pat Thoyts 13d24b018f mingw: ensure sockets are initialized before calling gethostname
If the Windows sockets subsystem has not been initialized yet then an
attempt to get the hostname returns an error and prints a warning to the
console. This solves this issue for msysGit as seen with 'git fetch'.

Signed-off-by: Pat Thoyts <patthoyts@users.sourceforge.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-10-15 20:14:39 -07:00
Erik Faye-Lund 2a6b149c64 mingw: avoid using strbuf in syslog
strbuf can call die, which again can call syslog from git-daemon.

Endless recursion is no fun; fix it by hand-rolling the logic. As
a side-effect malloc/realloc errors are changed into non-fatal
warnings; this is probably an improvement anyway.

Signed-off-by: Erik Faye-Lund <kusmabite@gmail.com>
Noticed-by: Johannes Sixt <j.sixt@viscovery.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-10-07 16:12:25 -07:00
Brandon Casey 040a655116 cleanup: use internal memory allocation wrapper functions everywhere
The "x"-prefixed versions of strdup, malloc, etc. will check whether the
allocation was successful and terminate the process otherwise.

A few uses of malloc were left alone since they already implemented a
graceful path of failure or were in a quasi external library like xdiff.

Additionally, the call to malloc in compat/win32/syslog.c was not modified
since the syslog() implemented there is a die handler and a call to the
x-wrappers within a die handler could result in recursion should memory
allocation fail.  This will have to be addressed separately.

Signed-off-by: Brandon Casey <drafnel@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-10-06 13:54:32 -07:00
Ramsay Jones 3254310863 obstack.c: Fix some sparse warnings
In particular, sparse issues the following warnings:

    compat/obstack.c:176:17: warning: Using plain integer as NULL pointer
    compat/obstack.c:224:17: warning: Using plain integer as NULL pointer
    compat/obstack.c:324:16: warning: Using plain integer as NULL pointer
    compat/obstack.c:329:16: warning: Using plain integer as NULL pointer
    compat/obstack.c:347:16: warning: Using plain integer as NULL pointer
    compat/obstack.c:362:19: warning: Using plain integer as NULL pointer
    compat/obstack.c:379:29: warning: Using plain integer as NULL pointer
    compat/obstack.c:399:1: error: symbol 'print_and_abort' redeclared with \
        different type (originally declared at compat/obstack.c:95) \
        - different modifiers

Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-09-11 14:43:33 -07:00
Fredrik Kuivinen d190a0875f obstack: Fix portability issues
i686-apple-darwin10-gcc-4.2.1 (GCC) 4.2.1, SunOS 5.10, and possibly
others do not have exit.h and exitfail.h. Remove the use of these in
obstack.c.

The __block variable was renamed to block to avoid a gcc error:

compat/obstack.h:190: error: __block attribute can be specified on variables only

Initial-patch-by: David Aguilar <davvid@gmail.com>
Reported-by: Brian Gernhardt <brian@gernhardtsoftware.com>
Signed-off-by: Fredrik Kuivinen <frekui@gmail.com>
Acked-by: David Aguilar <davvid@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-08-28 22:03:26 -07:00
Fredrik Kuivinen e831171d67 Add obstack.[ch] from EGLIBC 2.10
Signed-off-by: Fredrik Kuivinen <frekui@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-08-20 22:30:46 -07:00
Junio C Hamano df9b29ce82 Merge branch 'jc/maint-cygwin-trust-executable-bit-default'
* jc/maint-cygwin-trust-executable-bit-default:
  cygwin: trust executable bit by default
2011-07-13 14:31:36 -07:00
Junio C Hamano 551d75dbd8 Merge branch 'rj/config-cygwin'
* rj/config-cygwin:
  config.c: Make git_config() work correctly when called recursively
  t1301-*.sh: Fix the 'forced modes' test on cygwin
  help.c: Fix detection of custom merge strategy on cygwin
2011-07-13 14:31:36 -07:00
Junio C Hamano 033c2dc436 Merge branch 'ef/maint-win-verify-path'
* ef/maint-win-verify-path:
  verify_dotfile(): do not assume '/' is the path seperator
  verify_path(): simplify check at the directory boundary
  verify_path: consider dos drive prefix
  real_path: do not assume '/' is the path seperator
  A Windows path starting with a backslash is absolute
2011-06-29 17:09:17 -07:00
Junio C Hamano 1fd7ef2e8f Merge branch 'js/i18n-windows'
* js/i18n-windows:
  Windows: teach getenv to do a case-sensitive search
  mingw.c: move definition of mingw_getenv down
  sh-i18n--envsubst: do not crash when no arguments are given
2011-06-29 17:03:13 -07:00
Junio C Hamano 085479e700 cygwin: trust executable bit by default
Earlier 7974843 (compat/cygwin.c: make runtime detection of lstat/stat
lessor impact, 2008-10-23) fixed the low-level "do we use cygwin specific
hacks for stat/lstat?" logic not to call into git_default_config() from
random codepaths that are typically very late in the program, to prevent
the call from potentially overwriting other variables that are initialized
from the configuration.

However, it forgot that on Cygwin, trust-executable-bit should default to
true.

Noticed by J6t, confirmed by Ramsay Jones, and the brown paper bag is on
Gitster's head.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-06-20 13:09:04 -07:00
Ramsay Jones 452993c297 t1301-*.sh: Fix the 'forced modes' test on cygwin
The 'forced modes' test fails on cygwin because the post-update
hook loses it's executable bit when copied from the templates
directory by git-init. The template loses it's executable bit
because the lstat() function resolves to the "native Win32 API"
implementation.

This call to lstat() happens after git-init has set the "git_dir"
(so has_git_dir() returns true), but before the configuration has
been fully initialised. At this point git_config() does not find
any config files to parse and returns 0. Unfortunately, the code
used to determine the cygwin l/stat() function bindings did not
check the return from git_config() and assumed that the config
was complete and accessible once "git_dir" was set.

In order to fix the test, we simply change the binding code to
test the return value from git_config(), to ensure that it actually
had config values to read, before determining the requested binding.

Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-06-16 15:10:54 -07:00
Johannes Sixt df599e9612 Windows: teach getenv to do a case-sensitive search
getenv() on Windows looks up environment variables in a case-insensitive
manner. Even though all documentations claim that the environment is
case-insensitive, it is possible for applications to pass an environment
to child processes that has variables that differ only in case. Bash on
Windows does this, for example, and sh-i18n--envsubst depends on this
behavior.

With this patch environment variables are first looked up in a
case-sensitive manner; only if this finds nothing, the system's getenv() is
used as a fallback.

Signed-off-by: Johannes Sixt <j6t@kdbg.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-06-06 11:35:10 -07:00
Johannes Sixt 06bc4b796a mingw.c: move definition of mingw_getenv down
We want to use static lookup_env() in a subsequent change.

At first sight, this change looks innocent. But it is not due to the
#undef getenv. There is one caller of getenv between the old location and
the new location whose behavior could change. But as can be seen from the
defintion of mingw_getenv, the behavior for this caller does not change
substantially.

To ensure consistent behavior in the future, change all getenv callers
in mingw.c to use mingw_getenv.

With this patch, this is not a big deal, yet, but with the subsequent
change, where we teach getenv to do a case-sensitive lookup, the behavior
of all call sites is changed.

Signed-off-by: Johannes Sixt <j6t@kdbg.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-06-06 11:35:06 -07:00
Theo Niessink d1c69255a1 real_path: do not assume '/' is the path seperator
real_path currently assumes it's input had '/' as path seperator.
This assumption does not hold true for the code-path from
prefix_path (on Windows), where real_path can be called before
normalize_path_copy.

Fix real_path so it doesn't make this assumption. Create a helper
function to reverse-search for the last path-seperator in a string.

Signed-off-by: Theo Niessink <theo@taletn.com>
Signed-off-by: Erik Faye-Lund <kusmabite@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-05-27 10:59:16 -07:00
Junio C Hamano a02cf90144 compat/fnmatch/fnmatch.c: give a fall-back definition for NULL
Somebody tried to compile fnmatch.c compatibility file on Interix and got
an error because no header included in the file on that platform defined
NULL.  It usually comes from stddef.h and indirectly from other headers
like string.h, unistd.h, stdio.h, stdlib.h, etc., but with the way we
compile this file from our Makefile, inclusion of the header files that
are expected to define NULL in fnmatch.c do not happen because they are
protected with "#ifdef STDC_HEADERS", etc. which we do not pass.

As the least-impact workaround, give a fall-back definition when none of
the headers define NULL.

Noticed-by: Markus Duft <mduft@gentoo.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-05-26 09:25:47 -07:00
Junio C Hamano c3c7797e1d Merge branch 'js/mingw-shutdown'
* js/mingw-shutdown:
  Windows: add a wrapper for the shutdown() system call
2011-05-23 10:27:12 -07:00
Johannes Sixt a7941795b1 Windows: add a wrapper for the shutdown() system call
Even though Windows's socket functions look like their POSIX counter parts,
they do not operate on file descriptors, but on "socket objects". To bring
the functions in line with POSIX, we have proxy functions that wrap and
unwrap the socket objects in file descriptors using open_osfhandle and
get_osfhandle. But shutdown() was not proxied, yet. Fix this.

Signed-off-by: Johannes Sixt <j6t@kdbg.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-05-18 14:24:48 -07:00
Jim Meyering 0353a0c4ec remove doubled words, e.g., s/to to/to/, and fix related typos
I found that some doubled words had snuck back into projects from which
I'd already removed them, so now there's a "syntax-check" makefile rule in
gnulib to help prevent recurrence.

Running the command below spotted a few in git, too:

  git ls-files | xargs perl -0777 -n \
    -e 'while (/\b(then?|[iao]n|i[fst]|but|f?or|at|and|[dt])\s+\1\b/gims)' \
    -e '{$n=($` =~ tr/\n/\n/ + 1); ($v=$&)=~s/\n/\\n/g;' \
    -e 'print "$ARGV:$n:$v\n"}'

Signed-off-by: Jim Meyering <meyering@redhat.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-04-13 11:59:11 -07:00