Commit Graph

72284 Commits

Author SHA1 Message Date
Johannes Schindelin
877a83bf47 Merge 'git-gui' into HEAD 2017-05-09 23:35:55 +02:00
Johannes Schindelin
2f213cae37 Merge 'readme' into HEAD
Add a README.md for GitHub goodness.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2017-05-09 23:35:47 +02:00
Johannes Schindelin
c65564a673 Merge branch 'redirect-std-handles'
This topic branch introduces a highly-experimental feature allowing to
override stdin/stdout/stderr by setting environment variables e.g. to
named pipes, solving a problem in highly multi-threaded applications
where inheritable handles could cause blocked Git operations.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2017-05-09 23:35:39 +02:00
Johannes Schindelin
1e1741ebbb git gui: set GIT_ASKPASS=git-gui--askpass if not set yet
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2017-05-09 23:34:18 +02:00
Heiko Voigt
7b634a101f 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>
2017-05-09 23:34:18 +02:00
Heiko Voigt
d7b0e55d0d Revert "git-gui: set GIT_DIR and GIT_WORK_TREE after setup"
This reverts commit a9fa11fe5b.
2017-05-09 23:34:18 +02:00
Brendan Forster
a4869ef9f6 Add an issue template
With improvements by Clive Chan, Adric Norris, Ben Bodenmiller and
Philip Oakley.

Signed-off-by: Clive Chan <cc@clive.io>
Signed-off-by: Adric Norris <landstander668@gmail.com>
Signed-off-by: Ben Bodenmiller <bbodenmiller@hotmail.com>
Signed-off-by: Philip Oakley <philipoakley@iee.org>
Signed-off-by: Brendan Forster <brendan@github.com>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2017-05-09 23:34:17 +02:00
Johannes Schindelin
1490d52886 README.md: Add a Windows-specific preamble
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2017-05-09 23:34:17 +02:00
Johannes Schindelin
b1f9a0c34f Add a Code of Conduct
It is better to state clearly expectations and intentions than to assume
quietly that everybody agrees.

This Code of Conduct is the Open Code of Conduct as per
http://todogroup.org/opencodeofconduct/ (the only modifications are the
adjustments to reflect that there is no "response team" in addition to the
Git for Windows maintainer, and the addition of the link to the Open Code
of Conduct itself).

[Completely revamped, based on the Covenant 1.4 by Brendan Forster]

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2017-05-09 23:34:17 +02:00
Johannes Schindelin
ef9105d0c7 mingw: document the experimental standard handle redirection
This feature is still highly experimental and has not even been
contributed to the Git mailing list yet: the feature still needs to be
battle-tested more.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2017-05-09 23:34:16 +02:00
Johannes Schindelin
60be77d609 mingw: special-case GIT_REDIRECT_STDERR=2>&1
The "2>&1" notation in POSIX shells implies that stderr is redirected to
stdout. Let's special-case this value for the environment variable
GIT_REDIRECT_STDERR to allow writing to the same destination as stdout.

The functionality was suggested by Jeff Hostetler.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2017-05-09 23:34:16 +02:00
Johannes Schindelin
0b1647e7be mingw: add experimental feature to redirect standard handles
On Windows, file handles need to be marked inheritable when they need to
be used as standard input/output/error handles for a newly spawned
process. The problem with that, of course, is that the "inheritable" flag
is global and therefore can wreak havoc with highly multi-threaded
applications: other spawned processes will *also* inherit those file
handles, despite having *other* input/output/error handles, and never
close the former handles because they do not know about them.

Let's introduce a set of environment variables (GIT_REDIRECT_STDIN and
friends) that point to files, or even better, named pipes and that are
used by the spawned Git process. This helps work around above-mentioned
issue: those named pipes will be opened in a non-inheritable way upon
startup, and no handles are passed around.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2017-05-09 23:34:16 +02:00
Johannes Schindelin
e0df4975e3 Start the merging-rebase to v2.13.0
This commit starts the rebase of 2cb4c91b59 to 074ffb61b4, and marks
the final steps toward Git for Windows v2.13.0.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2017-05-09 23:32:12 +02:00
Johannes Schindelin
3994f3e499 Merge branch 'coverity-v4-plus-fixup'
Coverity is a tool to analyze code statically, trying to find common (or
not so common) problems before they occur in production.

Coverity offers its services to Open Source software, and just like
upstream Git, Git for Windows applied and was granted the use.

While Coverity reports a lot of false positives due to Git's (ab-)use of
the FLEX_ARRAY feature (where it declares a 0-byte or 1-byte array at the
end of a struct, and then allocates a variable-length data structure
holding a variable-length string at the end, so that the struct as well as
the string can be released with a single free()), there were a few issues
reported that are true positives, and not all of them were resource leaks
in builtins (for which it is considered kind of okay to not release memory
just before exit() is called anyway).

This topic branch tries to address a couple of those issues.

Note: there are a couple more issues left, either because they are tricky
to resolve (in some cases, the custody of occasionally-allocated memory is
very unclear) or because it is unclear whether they are false positives
(due to the hard-to-reason-about nature of the code). It's a start,
though.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2017-05-09 22:52:23 +02:00
Johannes Schindelin
8a20a46330 Merge branch 'drive-prefix'
This topic branch allows us to specify absolute paths without the drive
prefix e.g. when cloning.

Example:

	C:\Users\me> git clone https://github.com/git/git \upstream-git

This will clone into a new directory C:\upstream-git, in line with how
Windows interprets absolute paths.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2017-05-09 22:52:22 +02:00
Junio C Hamano
7d7acef258 fixup! checkout: fix memory leak 2017-05-09 22:52:20 +02:00
Johannes Schindelin
fd262f59fe submodule_uses_worktrees(): plug memory leak
There is really no reason why we would need to hold onto the allocated
string longer than necessary.

Reported by Coverity.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2017-05-09 22:52:20 +02:00
Johannes Schindelin
51d1b4ac56 show_worktree(): plug memory leak
The buffer allocated by shorten_unambiguous_ref() needs to be released.

Discovered by Coverity.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2017-05-09 22:52:20 +02:00
Johannes Schindelin
b9ca2ff028 name-rev: avoid leaking memory in the deref case
When the `name_rev()` function is asked to dereference the tip name, it
allocates memory. But when it turns out that another tip already
described the commit better than the current one, we forgot to release
the memory.

Pointed out by Coverity.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2017-05-09 22:52:20 +02:00
Johannes Schindelin
ad13b509c3 remote: plug memory leak in match_explicit()
The `guess_ref()` returns an allocated buffer of which `make_linked_ref()`
does not take custody (`alloc_ref()` makes a copy), therefore we need to
release the buffer afterwards.

Noticed via Coverity.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2017-05-09 22:52:20 +02:00
Johannes Schindelin
bfecffdace add_reflog_for_walk: avoid memory leak
We free()d the `log` buffer when dwim_log() returned 1, but not when it
returned a larger value (which meant that it still allocated the buffer
but we simply ignored it).

While in the vicinity, make sure that the `reflogs` structure as well as
the `branch` variable are released properly, too.

Identified by Coverity.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2017-05-09 22:52:20 +02:00
Johannes Schindelin
fbd4bf9853 shallow: avoid memory leak
Reported by Coverity.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2017-05-09 22:52:19 +02:00
Johannes Schindelin
d7a184271a line-log: avoid memory leak
Discovered by Coverity.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2017-05-09 22:52:19 +02:00
Johannes Schindelin
b4e3d8ca62 receive-pack: plug memory leak in update()
Reported via Coverity.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2017-05-09 22:52:19 +02:00
Johannes Schindelin
eb7cffb132 fast-export: avoid leaking memory in handle_tag()
Reported by, you guessed it, Coverity.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2017-05-09 22:52:19 +02:00
Johannes Schindelin
cd17533d07 mktree: plug memory leaks reported by Coverity
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2017-05-09 22:52:19 +02:00
Johannes Schindelin
82f76b9835 pack-redundant: plug memory leak
Identified via Coverity.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2017-05-09 22:52:19 +02:00
Johannes Schindelin
1806b41aff setup_discovered_git_dir(): plug memory leak
The setup_explicit_git_dir() function does not take custody of the string
passed as first parameter; we have to release it if we turned the value of
git_dir into an absolute path.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2017-05-09 22:52:19 +02:00
Johannes Schindelin
b0f2a371a1 setup_bare_git_dir(): help static analysis
Coverity reported a memory leak in this function. However, it can only
be called once, as setup_git_directory() changes global state and hence
is not reentrant.

Mark the variable as static to indicate that this is a singleton.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2017-05-09 22:52:19 +02:00
Johannes Schindelin
ab71278ba1 split_commit_in_progress(): simplify & fix memory leak
This function did a whole lot of unnecessary work, such as reading in
four files just to figure out that, oh, hey, we do not need to look at
them after all because the HEAD is not detached.

Simplify the entire function to return early when possible, to read in
the files only when necessary, and to release the allocated memory
always (there was a leak, reported via Coverity, where we failed to
release the allocated strings if the HEAD is not detached).

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2017-05-09 22:52:19 +02:00
Johannes Schindelin
1e833c9b78 checkout: fix memory leak
This change addresses part of the NEEDSWORK comment above the code,
therefore the comment needs to be adjusted, too.

Discovered via Coverity.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2017-05-09 22:52:18 +02:00
Johannes Schindelin
a62d38d6aa cat-file: fix memory leak
Discovered by Coverity.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2017-05-09 22:52:18 +02:00
Johannes Schindelin
6a390e2f47 mailinfo & mailsplit: check for EOF while parsing
While POSIX states that it is okay to pass EOF to isspace() (and it seems
to be implied that EOF should *not* be treated as whitespace), and also to
pass EOF to ungetc() (which seems to be intended to fail without buffering
the character), it is much better to handle these cases explicitly. Not
only does it reduce head-scratching (and helps static analysis avoid
reporting false positives), it also lets us handle files containing
nothing but whitespace by erroring out.

Reported via Coverity.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2017-05-09 22:52:18 +02:00
Johannes Schindelin
c7f3785a55 status: close file descriptor after reading git-rebase-todo
Reported via Coverity.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2017-05-09 22:52:18 +02:00
Johannes Schindelin
86093647b4 difftool: address a couple of resource/memory leaks
This change plugs a couple of memory leaks and makes sure that the file
descriptor is closed in run_dir_diff().

Spotted by Coverity.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2017-05-09 22:52:18 +02:00
Johannes Schindelin
1a1c6633a0 get_mail_commit_oid(): avoid resource leak
When we fail to read, or parse, the file, we still want to close the file
descriptor and release the strbuf.

Reported via Coverity.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2017-05-09 22:52:18 +02:00
Johannes Schindelin
0420e993d8 git_config_rename_section_in_file(): avoid resource leak
In case of errors, we really want the file descriptor to be closed.

Discovered by a Coverity scan.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2017-05-09 22:52:18 +02:00
Johannes Schindelin
9b17eed597 add_commit_patch_id(): avoid allocating memory unnecessarily
It would appear that we allocate (and forget to release) memory if the
patch ID is not even defined.

Reported by the Coverity tool.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2017-05-09 22:52:18 +02:00
Johannes Schindelin
f7360da314 winansi: avoid buffer overrun
When we could not convert the UTF-8 sequence into Unicode for writing to
the Console, we should not try to write an insanely-long sequence of
invalid wide characters (mistaking the negative return value for an
unsigned length).

Reported by Coverity.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2017-05-09 22:52:18 +02:00
Johannes Schindelin
2db95b62c9 Merge pull request #1149 from jeffhostetler/jeffhostetler/do_write_index_mtime
read-cache: close index.lock in do_write_index
2017-05-09 22:52:17 +02:00
Johannes Schindelin
bd71388d86 winansi: avoid use of uninitialized value
To initialize the foreground color attributes of "plain text", our ANSI
emulation tries to infer them from the currently attached console while
running the is_console() function. This function first tries to detect any
console attached to stdout, then it is called with stderr.

If neither stdout nor stderr has any console attached, it does not
actually matter what we use for "plain text" attributes, as we never need
to output any text to any console in that case.

However, after working on stdout and stderr, is_console() is called with
stdin, and it still tries to initialize the "plain text" attributes if
they had not been initialized earlier. In this case, we cannot detect any
attributes, and we used an uninitialized value for them.

Naturally, Coverity complained about this use case because it could not
reason about the code deeply enough to figure out that we do not even use
those attributes in that case.

Let's just initialize the value to 0 in that case, both to avoid future
Coverity reports, and to help catch future regressions in case anybody
changes the order of the is_console() calls (which would make the text
black on black).

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2017-05-09 22:52:17 +02:00
Johannes Schindelin
293aa074be mingw: avoid memory leak when splitting PATH
In the (admittedly, concocted) case that PATH consists only of path
delimiters, we would leak the duplicated string.

Reported by Coverity.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2017-05-09 22:52:17 +02:00
Johannes Schindelin
0eae91cf8d Merge 'case-insensitive-abspath' into HEAD 2017-05-09 22:52:16 +02:00
Johannes Schindelin
436dcd62f2 Merge branch 'skip-gettext-when-possible'
This topic branch allows us to skip the gettext initialization
when the locale directory does not even exist.

This saves 150ms out of 210ms for a simply `git version` call on
Windows, and it most likely will help scripts that call out to
`git.exe` hundreds of times.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2017-05-09 22:49:14 +02:00
Johannes Schindelin
a487e16fa0 mingw: fix isatty() after dup2()
We newly handle isatty() by special-casing the stdin/stdout/stderr file
descriptors, caching the return value. However, we missed the case where
dup2() overrides the respective file descriptor.

That poses a problem e.g. where the `show` builtin asks for a pager very
early, the `setup_pager()` function sets the pager depending on the
return value of `isatty()` and then redirects stdout. Subsequently,
`cmd_log_init_finish()` calls `setup_pager()` *again*. What should
happen now is that `isatty()` reports that stdout is *not* a TTY and
consequently stdout should be left alone.

Let's override dup2() to handle this appropriately.

This fixes https://github.com/git-for-windows/git/issues/1077

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2017-05-09 22:49:13 +02:00
Johannes Schindelin
9f36ae665e Merge branch 'dup-gui' of PhilipOakley/git-gui.git
This resolves a couple of Git GUI issues that seem not to have been
picked up from https://github.com/patthoyts/git-gui/pull/10 yet.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2017-05-09 22:49:13 +02:00
Johannes Schindelin
e4952fdce0 Merge branch 'strg-t-in-git-gui'
This does not (yet) resolve the problem that Strg+T with multiple
selected lines fails to (un)stage them all, but it addresses one of
the reported Ctrl+T issues.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2017-05-09 22:49:12 +02:00
Johannes Schindelin
8cde3d9cdc mingw: make is_hidden tests in t0001/t5611 more robust
We should not actually expect the first `attrib.exe` in the PATH to
be the one we are looking for. Or that it is in the PATH, for that
matter.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2017-05-09 22:49:12 +02:00
Johannes Schindelin
5eeb857723 mingw: ensure valid CTYPE
A change between versions 2.4.1 and 2.6.0 of the MSYS2 runtime modified
how Cygwin's runtime (and hence Git for Windows' MSYS2 runtime
derivative) handles locales: d16a56306d (Consolidate wctomb/mbtowc calls
for POSIX-1.2008, 2016-07-20).

An unintended side-effect is that "cold-calling" into the POSIX
emulation will start with a locale based on the current code page,
something that Git for Windows is very ill-prepared for, as it expects
to be able to pass a command-line containing non-ASCII characters to the
shell without having those characters munged.

One symptom of this behavior: when `git clone` or `git fetch` shell out
to call `git-upload-pack` with a path that contains non-ASCII
characters, the shell tried to interpret the entire command-line
(including command-line parameters) as executable path, which obviously
must fail.

This fixes https://github.com/git-for-windows/git/issues/1036

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2017-05-09 22:49:12 +02:00
Johannes Schindelin
e5f5c41fd3 Merge pull request #994 from jeffhostetler/jeffhostetler/fscache_nfd
fscache: add not-found directory cache to fscache
2017-05-09 22:49:12 +02:00