Commit Graph

28643 Commits

Author SHA1 Message Date
Karsten Blees
1eccee6ac4 Win32: move main macro to a function
The code in the MinGW main macro is getting more and more complex, move to
a separate initialization function for readabiliy and extensibility.

Signed-off-by: Karsten Blees <blees@dcon.de>
Signed-off-by: Erik Faye-Lund <kusmabite@gmail.com>
2012-04-06 16:47:20 -05:00
Karsten Blees
24b7005223 Win32: fix potential multi-threading issue
...by removing a static buffer in do_stat_internal.

Signed-off-by: Karsten Blees <blees@dcon.de>
Signed-off-by: Erik Faye-Lund <kusmabite@gmail.com>
2012-04-06 16:47:19 -05:00
Karsten Blees
8dc8a639fb Win32 dirent: improve dirent implementation
Improve the dirent implementation by removing the relics that were once
necessary to plug into the now unused MinGW runtime, in preparation for
Unicode file name support.

Move FindFirstFile to opendir, and FindClose to closedir, with the
following implications:
- DIR.dd_name is no longer needed
- chdir(one); opendir(relative); chdir(two); readdir() works as expected
  (i.e. lists one/relative instead of two/relative)
- DIR.dd_handle is a valid handle for the entire lifetime of the DIR struct
- thus, all checks for dd_handle == INVALID_HANDLE_VALUE and dd_handle == 0
  have been removed
- the special case that the directory has been fully read (which was
  previously explicitly tracked with dd_handle == INVALID_HANDLE_VALUE &&
  dd_stat != 0) is now handled implicitly by the FindNextFile error
  handling code (if a client continues to call readdir after receiving
  NULL, FindNextFile will continue to fail with ERROR_NO_MORE_FILES, to
  the same effect)
- extracting dirent data from WIN32_FIND_DATA is needed in two places, so
  moved to its own method
- GetFileAttributes is no longer needed. The same information can be
  obtained from the FindFirstFile error code, which is ERROR_DIRECTORY if
  the name is NOT a directory (-> ENOTDIR), otherwise we can use
  err_win_to_posix (e.g. ERROR_PATH_NOT_FOUND -> ENOENT). The
  ERROR_DIRECTORY case could be fixed in err_win_to_posix, but this
  probably breaks other functionality.

Removes the ERROR_NO_MORE_FILES check after FindFirstFile (this was
fortunately a NOOP (searching for '*' always finds '.' and '..'),
otherwise the subsequent code would have copied data from an uninitialized
buffer).

Changes malloc to git support function xmalloc, so opendir will die() if
out of memory, rather than failing with ENOMEM and letting git work on
incomplete directory listings (error handling in dir.c is quite sparse).

Signed-off-by: Karsten Blees <blees@dcon.de>
Signed-off-by: Erik Faye-Lund <kusmabite@gmail.com>
2012-04-06 16:47:18 -05:00
Karsten Blees
a311684a1c Win32 dirent: clarify #include directives
Git-compat-util.h is two dirs up, and already includes <dirent.h> (which
is the same as "dirent.h" due to -Icompat/win32 in the Makefile).

Signed-off-by: Karsten Blees <blees@dcon.de>
Signed-off-by: Erik Faye-Lund <kusmabite@gmail.com>
2012-04-06 16:47:17 -05:00
Karsten Blees
53b02733ec Win32 dirent: change FILENAME_MAX to MAX_PATH
FILENAME_MAX and MAX_PATH are both 260 on Windows, however, MAX_PATH is
used throughout the other Win32 code in Git, and also defines the length
of file name buffers in the Win32 API (e.g. WIN32_FIND_DATA.cFileName,
from which we're copying the dirent data).

Signed-off-by: Karsten Blees <blees@dcon.de>
Signed-off-by: Erik Faye-Lund <kusmabite@gmail.com>
2012-04-06 16:47:16 -05:00
Karsten Blees
5b9bfb51f3 Win32 dirent: remove unused dirent.d_reclen member
Remove the union around dirent.d_type and the unused dirent.d_reclen member
(which was necessary for compatibility with the MinGW dirent runtime, which
is no longer used).

Signed-off-by: Karsten Blees <blees@dcon.de>
Signed-off-by: Erik Faye-Lund <kusmabite@gmail.com>
2012-04-06 16:47:14 -05:00
Karsten Blees
c9ebaff1a6 Win32 dirent: remove unused dirent.d_ino member
There are no proper inodes on Windows, so remove dirent.d_ino and #define
NO_D_INO_IN_DIRENT in the Makefile (this skips e.g. an ineffective qsort in
fsck.c).

Signed-off-by: Karsten Blees <blees@dcon.de>
Signed-off-by: Erik Faye-Lund <kusmabite@gmail.com>
2012-04-06 16:47:13 -05:00
Sebastian Schuberth
6fad55f2d1 submodule: Fix t7400, t7405, t7406 for msysGit
Again, avoid using echo (which issues DOS line endings on msysGit) to not mix
with Unix line-endings issued by git built-ins, even if this is at the cost of
calling an external executable (cat) instead of a shell built-in (echo).
2012-04-06 16:47:12 -05:00
Pat Thoyts
f94e8a6e00 t5407: Fix line-ending dependency in post-rewrite.args
On msysGit creating the post-rewrite.args file using 'echo' has different
line endings from the expected comparison. Using perl normalizes the line
endings for each generated file.

Signed-off-by: Pat Thoyts <patthoyts@users.sourceforge.net>
2012-04-06 16:47:11 -05:00
Sebastian Schuberth
51a80673e8 submodule: Use cat instead of echo to avoid DOS line-endings
In msysGit, echo used in scripts outputs DOS line-endings while built-ins
use Unix line-endings in their output. This causes t7508-status to fail
due to mixed line endings in the output of git status (which calls
git-submodule).

Signed-off-by: Sebastian Schuberth <sschuberth@gmail.com>
2012-04-06 16:47:10 -05:00
Pat Thoyts
2cb6123129 t3102: Windows filesystems may not use a literal asterisk in filenames.
Exclude these tests when using MINGW.

Signed-off-by: Pat Thoyts <patthoyts@users.sourceforge.net>
2012-04-06 16:47:09 -05:00
Johannes Schindelin
f0bdde47f8 MinGW: Skip test redirecting to fd 4
... because that does not work in MinGW.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2012-04-06 16:47:07 -05:00
Erik Faye-Lund
f44e2549db mingw: do not hide bare repositories
As reported in msysGit issue 450 the recent change to set the windows
hidden attribute on the .git directory is being applied to bare git
directories. This patch excludes bare repositories.

Tested-by: Pat Thoyts <patthoyts@users.sourceforge.net>
Signed-off-by: Erik Faye-Lund <kusmabite@gmail.com>
2012-04-06 16:47:05 -05:00
Gregor Uhlenheuer
4f0d01ab8e Git.pm: Use stream-like writing in cat_blob()
This commit fixes the issue with the handling of large files causing an
'Out of memory' perl exception. Instead of reading and writing the whole
blob at once now the blob is written in small pieces.

The problem was raised and discussed in this mail to the msysGit mailing
list: http://thread.gmane.org/gmane.comp.version-control.msysgit/12080

Signed-off-by: Gregor Uhlenheuer <kongo2002@googlemail.com>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2012-04-06 16:47:04 -05:00
Johannes Schindelin
fad3722efd git grep -O -i: if the pager is 'less', pass the '-i' option
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2012-04-06 16:47:03 -05:00
Johannes Schindelin
8275cf772d Handle new t1501 test case properly with MinGW
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2012-04-06 16:47:02 -05:00
Johannes Schindelin
f5ba0c5581 Do not compile compat/**/*.c with -Wold-style-definition
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2012-04-06 16:47:01 -05:00
Johannes Schindelin
72300af344 Fix old-style function declaration
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2012-04-06 16:46:59 -05:00
Johannes Schindelin
4d0fc2038d Make CFLAGS more strict
This is a gcc-ism, but as we use gcc exclusively, we can use them.

Taken from one of Junio's mails. (Reminded to cherry-pick this patch
by one of Karsten Blees' mails.)

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2012-04-06 16:46:58 -05:00
Johannes Schindelin
1743aae8c8 grep -I: do not bother to read known-binary files
Incidentally, this makes grep -I respect the "binary" attribute (actually,
the "-text" attribute, but "binary" implies that).

Since the attributes are not thread-safe, we now need to switch off
threading if -I was passed.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2012-04-06 16:46:57 -05:00
Johannes Schindelin
0a8611c416 Let deny.currentBranch=updateInstead ignore submodules
They are not affected by the update anyway.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2012-04-06 16:46:56 -05:00
Johannes Schindelin
e1de98ddde Handle http.* config variables pointing to files gracefully on Windows
On Windows, we would like to be able to have a default http.sslCAinfo
that points to an MSys path (i.e. relative to the installation root of
Git).  As Git is a MinGW program, it has to handle the conversion
of the MSys path into a MinGW32 path itself.

Since system_path() considers paths starting with '/' as absolute, we
have to convince it to make a Windows path by stripping the leading
slash.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2012-04-06 16:46:55 -05:00
Johannes Schindelin
b890607030 Gitweb: make line number toggling work for Firefox and Safari
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2012-04-06 16:46:54 -05:00
Johannes Schindelin
a83c5b8172 gitweb: Allow line number toggling with Javascript
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2012-04-06 16:46:52 -05:00
Johannes Schindelin
638a2f6a7e Give commit message reencoding for output on MinGW a chance
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2012-04-06 16:46:51 -05:00
Karsten Blees
6a36cac842 Warn if the Windows console font doesn't support Unicode
Unicode console output won't display correctly with default settings
because the default console font ("Terminal") only supports the system's
OEM charset. Unfortunately, this is a user specific setting, so it cannot
be easily fixed by e.g. some registry tricks in the setup program.

This change prints a warning on exit if console output contained non-ascii
characters and the console font is supposedly not a TrueType font (which
usually have decent Unicode support).

Signed-off-by: Karsten Blees <blees@dcon.de>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2012-04-06 16:46:50 -05:00
Karsten Blees
f4d368fef6 Detect console streams more reliably on Windows
GetStdHandle(STD_OUTPUT_HANDLE) doesn't work for stderr if stdout is
redirected. Use _get_osfhandle of the FILE* instead.

_isatty() is true for all character devices (including parallel and serial
ports). Check return value of GetConsoleScreenBufferInfo instead to
reliably detect console handles (also don't initialize internal state from
an uninitialized CONSOLE_SCREEN_BUFFER_INFO structure if the function
fails).

Signed-off-by: Karsten Blees <blees@dcon.de>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2012-04-06 16:46:49 -05:00
Karsten Blees
8e4a3e4060 Support Unicode console output on Windows
WriteConsoleW seems to be the only way to reliably print unicode to the
console (without weird code page conversions).

Also redirects vfprintf to the winansi.c version.

Signed-off-by: Karsten Blees <blees@dcon.de>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2012-04-06 16:46:48 -05:00
Karsten Blees
56fe11bb6c Enable color output in Windows cmd.exe
Git requires the TERM environment variable to be set for all color*
settings. Simulate the TERM variable if it is not set (default on Windows).

Signed-off-by: Karsten Blees <blees@dcon.de>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2012-04-06 16:46:47 -05:00
Chris West (Faux)
4de825ae30 Fix another invocation of git from gitk with an overly long command-line
Signed-off-by: Sebastian Schuberth <sschuberth@gmail.com>
2012-04-06 16:46:45 -05:00
Johannes Schindelin
7265f630ca git gui: set GIT_ASKPASS=git-gui--askpass if not set yet
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2012-04-06 16:46:44 -05:00
Eric Sunshine
7c9acdb95d Make mingw_offset_1st_component() behave consistently for all paths.
mingw_offset_1st_component() returns "foo" for inputs "/foo" and
"c:/foo", but inconsistently returns "/foo" for UNC input
"/machine/share/foo".  Fix it to return "foo" for all cases.

Reference: http://groups.google.com/group/msysgit/browse_thread/thread/c0af578549b5dda0

Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2012-04-06 16:46:43 -05:00
Erik Faye-Lund
c8d7577126 config.c: trivial fix for compile-time warning
The warning ("builtin/config.c:351: warning: initialization
discards qualifiers from pointer target type") was introduced
in commit 6754497c.

Signed-off-by: Erik Faye-Lund <kusmabite@gmail.com>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2012-04-06 16:46:42 -05:00
Cezary Zawadka
e626201283 Allow using UNC path for git repository
[efl: moved MinGW-specific part to compat/]

[jes: fixed compilation on non-Windows]

Signed-off-by: Cezary Zawadka <czawadka@gmail.com>
Signed-off-by: Erik Faye-Lund <kusmabite@gmail.com>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2012-04-06 16:46:41 -05:00
Heiko Voigt
babf8d530d work around misdetection of stdin attached to a tty
Git on Windows was made aware of the fact that sometimes a file may be
used by another process and so an operation may fail but the user might
be able to fix it and is asking for confirmation whether it should
retry.

This is implemented in a way that git only asks in case stdin and stderr
are attached to a tty. Unfortunately this seems to be misdetected
sometimes causing the testsuite to hang when git is waiting for a user
answer.

This patch works around the situation.

Signed-off-by: Heiko Voigt <hvoigt@hvoigt.net>
2012-04-06 16:46:39 -05:00
Johannes Schindelin
f7ed539f09 git am: ignore dirty submodules
This fixes a rebase in the presence of dirty submodules. This is
orthogonal to the application of patches changing submodules.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2012-04-06 16:46:38 -05:00
Johannes Schindelin
2054a1c1ba Add a Windows-specific fallback to getenv("HOME");
This fixes msysGit issue 482 properly.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2012-04-06 16:46:37 -05:00
bert Dvornik
35e117173b send-email: handle Windows paths for display just like we do for processing
In git-send-email.perl, here are two checks to determine if
$smtp_server is an absolute path (so it'll be treated as a mailer) or
not (so it'll be treated as a hostname).  The one that handles actual
mail processing has been taught to recognize Windows pathnames by
commit 33b2e81f.

The other check is just to tell the user what happened, so it's far
less important, but the current state is that we will still claim to
the user that c:/foo/bar is a server. =)  This makes the second check
consistent with the first.

Signed-off-by: bert Dvornik <dvornik+git@gmail.com>
2012-04-06 16:46:36 -05:00
Erik Faye-Lund
1198b74e21 send-email: accept absolute path even on Windows
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2012-04-06 16:46:35 -05:00
Johannes Schindelin
41c4f31fae Add a few more values for receive.denyCurrentBranch
For a long time, this developer thought that Git's insistence that
pushing into the current branch is evil was completely merited.

Just for fun, the original patch tried to show people that Git is right
there, and that it causes more trouble than it does good when Git allows
you to try to update the working tree for fast-forwards, or to detach the
HEAD, depending on some config settings.

Surprisingly, the opposite was shown.

So here is the support for two new options you can give the config
variable receive.denyCurrentBranch:

'updateInstead':
	Try to merge the working tree with the new tip of the branch
	(which can lead to really horrible merge conflicts).

'detachInstead':
	Detach the HEAD, thereby avoiding a disagreement between the
	HEAD and the index (as well as the working tree), possibly
	leaving the local user wondering how on earth her HEAD became
	so detached.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2012-04-06 16:46:33 -05:00
Johannes Schindelin
f1d8386384 Work around funny CR issue
This is really a problem with shell scripts being called on msysGit,
but there are more important bugs to fix for the moment.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2012-04-06 16:46:32 -05:00
Pat Thoyts
689e6d32bc mingw: add tests for the hidden attribute on the git directory
With msysGit the .git directory is supposed to be hidden, unless it is
a bare git repository. Test this.

Signed-off-by: Pat Thoyts <patthoyts@users.sourceforge.net>
2012-04-06 16:46:31 -05:00
Johannes Schindelin
795f156341 Work around the command line limit on Windows
On Windows, there are dramatic problems when a command line grows
beyond PATH_MAX, which is restricted to 8191 characters on XP and
later (according to http://support.microsoft.com/kb/830473).

Work around this by just cutting off the command line at that length
(actually, at a space boundary) in the hope that only negative
refs are chucked: gitk will then do unnecessary work, but that is
still better than flashing the gitk window and exiting with exit
status 5 (which no Windows user is able to make sense of).

The first fix caused Tcl to fail to compile the regexp, see msysGit issue
427. Here is another fix without using regexp, and using a more relaxed
command line length limit to fix the original issue 387.

Signed-off-by: Sebastian Schuberth <sschuberth@gmail.com>
Signed-off-by: Pat Thoyts <patthoyts@users.sourceforge.net>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2012-04-06 16:46:30 -05:00
Heiko Voigt
abfc9ffa93 git-gui: provide question helper for retry fallback on Windows
Make use of the new environment variable GIT_ASK_YESNO to support the
recently implemented fallback in case unlink, rename or rmdir fail for
files in use on Windows. The added dialog will present a yes/no question
to the the user which will currently be used by the windows compat layer
to let the user retry a failed file operation.

Signed-off-by: Heiko Voigt <hvoigt@hvoigt.net>
2012-04-06 16:46:28 -05:00
Heiko Voigt
9b84196199 Revert "git-gui: set GIT_DIR and GIT_WORK_TREE after setup"
This reverts commit a9fa11fe5b.
2012-04-06 16:46:27 -05:00
Johannes Sixt
e3d7115824 criss cross rename failure workaround
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2012-04-06 16:46:26 -05:00
Johannes Schindelin
e06710e043 When initializing .git/, record the current setting of core.hideDotFiles
This is on Windows only, of course.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2012-04-06 16:46:25 -05:00
Erik Faye-Lund
9636ced595 core.hidedotfiles: hide '.git' dir by default
At least for cross-platform projects, it makes sense to hide the
files starting with a dot, as this is the behavior on Unix/MacOSX.

However, at least Eclipse has problems interpreting the hidden flag
correctly, so the default is to hide only the .git/ directory.

The config setting core.hideDotFiles therefore supports not only
'true' and 'false', but also 'dotGitOnly'.

[jes: clarified the commit message, made git init respect the setting
by marking the .git/ directory only after reading the config, and added
documentation, and rebased on top of current junio/next]

Signed-off-by: Erik Faye-Lund <kusmabite@gmail.com>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2012-04-06 16:46:24 -05:00
Karsten Blees
7d409158ff MSVC: link dynamically to the CRT
Dynamic linking is generally preferred over static linking, and MSVCRT.dll
has been integral part of Windows for a long time.

This also fixes linker warnings for _malloc and _free in zlib.lib, which
seems to be compiled for MSVCRT.dll already.

The DLL version also exports some of the CRT initialization functions,
which are hidden in the static libcmt.lib (e.g. __wgetmainargs, required by
subsequent Unicode patches).

Signed-off-by: Karsten Blees <blees@dcon.de>
2012-04-06 16:46:22 -05:00
Matthieu Moy
799a2243e9 bash-completion: don't add quoted space for ZSH (fix regression)
Commit a31e626 (completion: optimize refs completion) introduced a
regression for ZSH users: ref names were completed with a quoted trailing
space (i.e. "git checkout ma" completes to "git checkout master\ "). The
space is convenient for bash users since we use "-o nospace", but a
quoted space is worse than nothing. The absence of trailing space for ZSH
is a long-standing issue, that this patch is not fixing. We just fix the
regression by not appending a space when the shell is ZSH.

Original-patch-by: SZEDER Gábor <szeder@ira.uka.de>
Reported-by: Stefan Haller <lists@haller-berlin.de>
Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-04-06 16:46:21 -05:00