Commit Graph

23579 Commits

Author SHA1 Message Date
Karsten Blees
432d94ff32 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>
2010-09-20 15:53:34 +01:00
Karsten Blees
928579782e 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>
2010-09-20 15:53:33 +01:00
Karsten Blees
e38a3894c4 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>
2010-09-20 15:53:32 +01:00
Chris West (Faux)
71f29474aa Fix another invocation of git from gitk with an overly long command-line
Signed-off-by: Sebastian Schuberth <sschuberth@gmail.com>
2010-09-20 15:53:31 +01:00
Johannes Schindelin
682bf55e3a git gui: set GIT_ASKPASS=git-gui--askpass if not set yet
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2010-09-20 15:53:30 +01:00
Johannes Schindelin
8fe759ee4f Make sure that git_getpass() never returns NULL
The result of git_getpass() is used without checking for NULL, so let's
just die() instead of returning NULL.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2010-09-20 15:53:29 +01:00
Eric Sunshine
05a5eb9498 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>
2010-09-20 15:53:28 +01:00
Erik Faye-Lund
18d6e75843 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>
2010-09-20 15:53:27 +01:00
Cezary Zawadka
34e0dfd7c3 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>
2010-09-20 15:53:26 +01:00
Eric Sunshine
1744e90acc Fix 'clone' failure at DOS root directory.
Cloning via relative path fails for a project residing immediately under
the root directory of a DOS drive.  For instance, for project c:/foo,
issuing "cd c:/" followed by "git clone foo bar" fails with error
"Unable to find remote helper for 'c'".  The problem is caused by
make_nonrelative_path() incorrectly returning c://foo rather than
c:/foo for input "foo".  The bogus path c://foo is misinterpreted by
transport_get() as a URL with unrecognized protocol "c", hence the
missing remote helper error.  Fix make_nonrelative_path() to return
c:/foo rather than c://foo (and /foo rather than //foo on Unix).

Resolves msysgit issue #501:
http://code.google.com/p/msysgit/issues/detail?id=501

Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2010-09-20 15:53:25 +01:00
Heiko Voigt
d5e570eedb 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>
2010-09-20 15:53:24 +01:00
Johannes Schindelin
9710a650a9 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>
2010-09-20 15:53:23 +01:00
Johannes Schindelin
f0aa451bc3 merge-octopus: Work around environment issue on Windows
For some reason, the environment variables get upper-cased when a
subprocess is launched on Windows. Cope with that.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2010-09-20 15:53:23 +01:00
Johannes Schindelin
a99f0360e4 t7602: cope with CR/LF
The output of git-merge-octopus has CR/LF line endings, so let's just
strip the CR out.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2010-09-20 15:53:22 +01:00
Johannes Schindelin
8ae74eb3b8 Tests: make sure that $DIFF is non-empty
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2010-09-20 15:53:21 +01:00
Johannes Schindelin
31b96ca5c0 Add a Windows-specific fallback to getenv("HOME");
This fixes msysGit issue 482 properly.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2010-09-20 15:53:20 +01:00
Johannes Schindelin
7699369407 mingw_rmdir: set errno=ENOTEMPTY when appropriate
On Windows, EACCES overrules ENOTEMPTY when calling rmdir(). But if the
directory is busy, we only want to retry deleting the directory if it
is empty, so test specifically for that case and set ENOTEMPTY rather
than EACCES.

Noticed by Greg Hazel.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2010-09-20 15:53:19 +01:00
bert Dvornik
42b0b0f338 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>
2010-09-20 15:53:18 +01:00
Erik Faye-Lund
eda4e1f0cc send-email: accept absolute path even on Windows
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2010-09-20 15:53:17 +01:00
bert Dvornik
783f6398c7 mingw: Don't ask the user yes/no questions if they can't see the question.
If the stdout of the command is connected to a terminal but the stderr
has been redirected, the odds are good that the user can't see any
question we print out to stderr.  This will result in a "mysterious
hang" while the app is waiting for user input.

It seems better to be conservative, and avoid asking for input
whenever the stderr is not a terminal, just like we do for stdin.

Signed-off-by: bert Dvornik <dvornik+git@gmail.com>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2010-09-20 15:53:16 +01:00
Johannes Schindelin
db906cd714 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>
2010-09-20 15:53:15 +01:00
Johannes Schindelin
096f679b43 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>
2010-09-20 15:53:14 +01:00
Johannes Schindelin
9d51925c5a git-am: fix absolute path logic on Windows
This fixes t4150 on msysGit.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2010-09-20 15:53:13 +01:00
Erik Faye-Lund
85240f5461 mingw: fix st_mode for symlink dirs
When encountering symlinks, do_lstat() currently overwrites
buf->st_mode with S_IFREG if follow is true. This is incorrect
when the symlink points to a directory.

get_file_attr calls GetFileAttributesExA, which follows symlinks
already. So our st_mode should already be correct at this point.

Tested-by: Pat Thoyts <patthoyts@users.sourceforge.net>
Signed-off-by: Erik Faye-Lund <kusmabite@gmail.com>
2010-09-20 15:53:13 +01:00
Erik Faye-Lund
239fafd45e 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>
2010-09-20 15:53:12 +01:00
Pat Thoyts
ca08398542 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>
2010-09-20 15:53:11 +01:00
Pat Thoyts
74187e9151 Report errors when failing to launch the html browser in mingw.
The mingw function to launch the system html browser is silent if the
target file does not exist leaving the user confused. Make it display
something.

Signed-off-by: Pat Thoyts <patthoyts@users.sourceforge.net>
Reviewed-by: Erik Faye-Lund <kusmabite@gmail.com>
2010-09-20 15:53:10 +01:00
Pat Thoyts
fb2eae9835 fix mingw stat() and lstat() implementations for handling symlinks
In msysGit the stat() function has been implemented using mingw_lstat
which sets the st_mode member to S_IFLNK when a symbolic links is found.
This causes the is_executable function to return when git attempts to
build a list of available commands in the help code and we end up missing
most git commands. (msysGit issue #445)

This patch modifies the implementation so that lstat() will return the link
flag but if we are called as stat() we read the size of the target and set
the mode to that of a regular file.

Signed-off-by: Pat Thoyts <patthoyts@users.sourceforge.net>
2010-09-20 15:53:09 +01:00
Johannes Schindelin
05cac183f5 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>
2010-09-20 15:53:08 +01:00
Heiko Voigt
485a508191 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>
2010-09-20 15:53:07 +01:00
Heiko Voigt
2fe90c25bd mingw: add fallback for rmdir in case directory is in use
The same logic as for unlink and rename also applies to rmdir. For
example in case you have a shell open in a git controlled folder. This
will easily fail. So lets be nice for such cases as well.

Signed-off-by: Heiko Voigt <heiko.voigt@mahr.de>
2010-09-20 15:53:06 +01:00
Heiko Voigt
2bc740a12a mingw: make failures to unlink or move raise a question
On Windows in case a program is accessing a file unlink or
move operations may fail. To give the user a chance to correct
this we simply wait until the user asks us to retry or fail.

This is useful because of the following use case which seem
to happen rarely but when it does it is a mess:

After making some changes the user realizes that he was on the
incorrect branch. When trying to change the branch some file
is still in use by some other process and git stops in the
middle of changing branches. Now the user has lots of files
with changes mixed with his own. This is especially confusing
on repositories that contain lots of files.

Although the recent implementation of automatic retry makes
this scenario much more unlikely lets provide a fallback as
a last resort.

Signed-off-by: Heiko Voigt <hvoigt@hvoigt.net>
2010-09-20 15:53:05 +01:00
Heiko Voigt
189fa92929 mingw: work around irregular failures of unlink on windows
If a file is opened by another process (e.g. indexing of an IDE) for
reading it is not allowed to be deleted. So in case unlink fails retry
after waiting for some time. This extends the workaround from 6ac6f878.

Signed-off-by: Heiko Voigt <hvoigt@hvoigt.net>
2010-09-20 15:53:04 +01:00
Heiko Voigt
73d1f2d5b2 mingw: move unlink wrapper to mingw.c
The next patch implements a workaround in case unlink fails on Windows.

Signed-off-by: Heiko Voigt <hvoigt@hvoigt.net>
2010-09-20 15:53:03 +01:00
Heiko Voigt
3150e566b9 Revert "git-gui: set GIT_DIR and GIT_WORK_TREE after setup"
This reverts commit a9fa11fe5b.
2010-09-20 15:53:03 +01:00
Pat Thoyts
7096283fca Skip t1300.70 and 71 on msysGit.
These two tests fail on msysGit because /dev/null is an alias for nul on
Windows and when reading the value back from git config the alias does
not match the real filename. Also the HOME environment variable has a
unix-style path but git returns a native equivalent path for '~'.  As
these are platform-dependent equivalent results it seems simplest to
skip the test entirely.

Signed-off-by: Pat Thoyts <patthoyts <at> users.sourceforge.net>
2010-09-20 15:53:02 +01:00
Johannes Sixt
ece38054c9 criss cross rename failure workaround
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2010-09-20 15:53:01 +01:00
Johannes Schindelin
b46d1f6fdd 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>
2010-09-20 15:53:00 +01:00
Erik Faye-Lund
38d839b2e8 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>
2010-09-20 15:52:59 +01:00
Sebastian Schuberth
fb33a74dc3 MinGW: Add missing file mode bit defines
Signed-off-by: Sebastian Schuberth <sschuberth@gmail.com>
2010-09-20 15:52:58 +01:00
Sebastian Schuberth
13c3ff9519 MinGW: Use pid_t more consequently, introduce uid_t for greater compatibility
Signed-off-by: Sebastian Schuberth <sschuberth@gmail.com>
2010-09-20 15:52:57 +01:00
Johannes Schindelin
784fd5e7af Avoid TAGS/tags warning from GNU Make
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2010-09-20 15:52:56 +01:00
Junio C Hamano
7bba3ddda6 Merge branch 'master' into next
* master:
  Git 1.7.3
  ls-files documentation: reword for consistency
  git-ls-files.txt: clarify -x/--exclude option
2010-09-18 14:55:29 -07:00
Junio C Hamano
87b50542a0 Git 1.7.3
Signed-off-by: Junio C Hamano <gitster@pobox.com>
v1.7.3
2010-09-18 14:55:08 -07:00
Junio C Hamano
1125297ca1 Merge branch 'js/ls-files-x-doc'
* js/ls-files-x-doc:
  ls-files documentation: reword for consistency
  git-ls-files.txt: clarify -x/--exclude option

Conflicts:
	Documentation/git-ls-files.txt
2010-09-18 14:46:44 -07:00
Junio C Hamano
df51bf2791 Merge branch 'dm/mergetool-vimdiff' into next
* dm/mergetool-vimdiff:
  mergetool-lib: add a three-way diff view for vim/gvim
  mergetool-lib: combine vimdiff and gvimdiff run blocks
2010-09-18 14:44:57 -07:00
Junio C Hamano
1b2e2a35db Merge branch 'ab/send-email-catfile' into next
* ab/send-email-catfile:
  send-email: use catfile() to concatenate files
2010-09-18 14:44:57 -07:00
Junio C Hamano
ac22cbce5d Merge branch 'jc/no-branch-name-with-dash-at-front' into next
* jc/no-branch-name-with-dash-at-front:
  disallow branch names that start with a hyphen
2010-09-18 14:44:57 -07:00
Junio C Hamano
380305cf59 Merge branch 'jc/grep-header-all-match-fix' into next
* jc/grep-header-all-match-fix:
  log --author: take union of multiple "author" requests
  grep: move logic to compile header pattern into a separate helper
2010-09-18 14:44:57 -07:00
Junio C Hamano
0fedaefa83 Merge branch 'tr/send-email-refuse-sending-unedited-cover-letter' into next
* tr/send-email-refuse-sending-unedited-cover-letter:
  send-email: Refuse to send cover-letter template subject
2010-09-18 14:44:56 -07:00