Commit Graph

73547 Commits

Author SHA1 Message Date
Heiko Voigt
44c0d84ff5 Revert "git-gui: set GIT_DIR and GIT_WORK_TREE after setup"
This reverts commit a9fa11fe5b.
2017-04-26 16:56:48 +02:00
Johannes Schindelin
2407e1300a 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-04-26 16:56:47 +02:00
Johannes Schindelin
25fd5d081f README.md: Add a Windows-specific preamble
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2017-04-26 16:56:47 +02:00
Johannes Schindelin
9f537c7580 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-04-26 16:56:47 +02:00
Johannes Schindelin
6340101bf7 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-04-26 16:56:46 +02:00
Johannes Schindelin
35f89e1ae7 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-04-26 16:56:46 +02:00
Johannes Schindelin
b2185ebf1a Start the merging-rebase to upstream/maint
This commit starts the rebase of b213911f46 to 49800c9407

This merging rebase was started not because upstream's `maint` branch
advanced (it did not), but to replace a couple of patches with newer
iterations, as sent to the upstream Git project independently. In
particular, those are:

- The patch series merged by fe73baf344
  (jeffhostetler/jeffhostetler/quick_add_index_entry) was replaced by
  the most recent iteration of 'jh/add-index-entry-optim' (b986df5c35)

- The Pull Request jeffhostetler/jeffhostetler/string_list_realloc
  merged via c775bdd100 was replaced by the latest iteration of
  'jh/string-list-micro-optim' (950a234cbd)

- The jh/memihash-opt patches merged by 2862058e9d were replaced by the
  newest iteration (41b3eb4a6b)

- The bug fix where difftool used a buffer after freeing it
  (d33e487771) was replaced by the one that made it into upstream
  (882add136f)

- The patch in the `coverity` series that tried to fix a resource leak
  in git-am (a5208164e2) was replaced by a better patch submitted by
  Ren_ Scharfe (ac8ce18d89)

- The patch in the `coverity` series that tried to fix a resource leak
  in the `handle_ssh_variant()` function (f07be76f51) has been dropped,
  as a different patch had been accepted into `pu` already

- The rebase-i-extra patches (e1be548aaf) were replaced by the latest
  iteration (1d3d10b9e15)

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2017-04-26 16:55:54 +02:00
Jeff Hostetler
6b24a526d9 Makefile: clean PDBs when MSVC=1
Teach main Makefile to also delete the PDB files for the
various EXE files during "make MSVC=1 clean".

Previously, we only deleted the PDB files associated with
individual .o files.

Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
2017-04-26 09:39:58 -04:00
Johannes Schindelin
bf1cd086d6 Merge branch 'coverity'
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-04-26 12:24:06 +02:00
Johannes Schindelin
37dabece6d 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-04-26 12:24:05 +02:00
Johannes Schindelin
f07be76f51 handle_ssh_variant: plug memory leak
The split_cmdline() function either assigns an allocated array to the argv
parameter or NULL. In the first case, we have to free() it, in the latter
it does no harm.

Reported via Coverity.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2017-04-26 12:24:04 +02:00
Johannes Schindelin
a5208164e2 am: close input stream even in case of an error
Reported via Coverity.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2017-04-26 12:24:04 +02:00
Johannes Schindelin
6b88dd4e15 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-04-26 12:24:04 +02:00
Johannes Schindelin
219dce8722 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-04-26 12:24:03 +02:00
Johannes Schindelin
272448d64f 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-04-26 12:24:03 +02:00
Johannes Schindelin
25dc863baf 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-04-26 12:24:03 +02:00
Johannes Schindelin
2042ba35f6 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).

Identified by Coverity.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2017-04-26 12:24:03 +02:00
Johannes Schindelin
1d3003b2d7 shallow: avoid memory leak
Reported by Coverity.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2017-04-26 12:24:03 +02:00
Johannes Schindelin
9b4901d6f5 line-log: avoid memory leak
Discovered by Coverity.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2017-04-26 12:24:03 +02:00
Johannes Schindelin
58a3b2b273 receive-pack: plug memory leak in update()
Reported via Coverity.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2017-04-26 12:24:03 +02:00
Johannes Schindelin
297da394ed fast-export: avoid leaking memory in handle_tag()
Reported by, you guessed it, Coverity.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2017-04-26 12:24:02 +02:00
Johannes Schindelin
c7e0a2e8ec mktree: plug memory leaks reported by Coverity
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2017-04-26 12:24:02 +02:00
Johannes Schindelin
c867f5692f pack-redundant: plug memory leak
Identified via Coverity.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2017-04-26 12:24:02 +02:00
Johannes Schindelin
7a8ea2c461 setup_discovered_git_dir(): fix memory leak
Identified by Coverity.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2017-04-26 12:24:02 +02:00
Johannes Schindelin
52b6bc73ac setup_bare_git_dir(): fix memory leak
Reported by Coverity.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2017-04-26 12:24:02 +02:00
Johannes Schindelin
c1de0a778e split_commit_in_progress(): fix memory leak
Reported via Coverity.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2017-04-26 12:24:02 +02:00
Johannes Schindelin
665a95f7e7 checkout: fix memory leak
Discovered via Coverity.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2017-04-26 12:24:02 +02:00
Johannes Schindelin
7cc78ac6fc cat-file: fix memory leak
Discovered by Coverity.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2017-04-26 12:24:01 +02:00
Johannes Schindelin
917eead1fb Check for EOF while parsing mails
Reported via Coverity.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2017-04-26 12:24:01 +02:00
Johannes Schindelin
152312932e status: close file descriptor after reading git-rebase-todo
Reported via Coverity.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2017-04-26 12:24:01 +02:00
Johannes Schindelin
48c8dccc9b difftool: close file descriptors after reading
Spotted by Coverity.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2017-04-26 12:24:01 +02:00
Johannes Schindelin
34fa615f97 http-backend: avoid memory leaks
Reported via Coverity.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2017-04-26 12:24:01 +02:00
Johannes Schindelin
cf05da96a3 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-04-26 12:24:01 +02:00
Johannes Schindelin
523ea055e8 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-04-26 12:24:01 +02:00
Johannes Schindelin
5fe7e42028 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-04-26 12:24:00 +02:00
Johannes Schindelin
a655c11256 sequencer: plug resource leak when skipping unnecessary picks
The resource leak only happens in case of an error writing or truncating
the file, therefore it seems less critical, but we should still fix it
nonetheless.

Discovered by Coverity.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2017-04-26 12:24:00 +02:00
Johannes Schindelin
09b998a6af 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-04-26 12:24:00 +02:00
Johannes Schindelin
2c9bc7ed8d winansi: avoid use of uninitialized value
When stdout is not connected to a Win32 console, we incorrectly used an
uninitialized value for the "plain" character attributes.

Detected by Coverity.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2017-04-26 12:24:00 +02:00
Johannes Schindelin
edffb73b20 mingw: avoid memory leak when splitting PATH
In the (admittedly, concocted) case that PATH consists only of colons, we
would leak the duplicated string.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2017-04-26 12:24:00 +02:00
Johannes Schindelin
f811241018 fixup! Help debugging with MSys2 by optionally executing bash with strace
Identified by Coverity.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2017-04-26 12:24:00 +02:00
Johannes Schindelin
57295d8f55 fixup! mingw: use domain information for default email
Noticed by Coverity.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2017-04-26 12:23:59 +02:00
Johannes Schindelin
156b911e83 mingw: allow absolute paths without drive prefix
When specifying an absolute path without a drive prefix, we convert that
path internally. Let's make sure that we handle that case properly, too
;-)

This fixes the command

	git clone https://github.com/git-for-windows/git \G4W

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2017-04-26 12:23:58 +02:00
Johannes Schindelin
ce8b4c0617 mingw: demonstrate a problem with certain absolute paths
On Windows, there are several categories of absolute paths. One such
category starts with a backslash and is implicitly relative to the
drive associated with the current working directory. Example:

	c:
	git clone https://github.com/git-for-windows/git \G4W

should clone into C:\G4W.

There is currently a problem with that, in that mingw_mktemp() does not
expect the _wmktemp() function to prefix the absolute path with the
drive prefix, and as a consequence, the resulting path does not fit into
the originally-passed string buffer. The symptom is a "Result too large"
error.

Reported by Juan Carlos Arevalo Baeza.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2017-04-26 12:23:58 +02:00
Johannes Schindelin
91e25e0ef0 Merge pull request #1149 from jeffhostetler/jeffhostetler/do_write_index_mtime
read-cache: close index.lock in do_write_index
2017-04-26 12:00:24 +02:00
Junio C Hamano
027a3b943b Git 2.13-rc1
Signed-off-by: Junio C Hamano <gitster@pobox.com>
v2.13.0-rc1
2017-04-26 15:44:07 +09:00
Junio C Hamano
77b34eaa07 Merge branch 'mh/separate-ref-cache'
The internals of the refs API around the cached refs has been
streamlined.

* mh/separate-ref-cache:
  do_for_each_entry_in_dir(): delete function
  files_pack_refs(): use reference iteration
  commit_packed_refs(): use reference iteration
  cache_ref_iterator_begin(): make function smarter
  get_loose_ref_cache(): new function
  get_loose_ref_dir(): function renamed from get_loose_refs()
  do_for_each_entry_in_dir(): eliminate `offset` argument
  refs: handle "refs/bisect/" in `loose_fill_ref_dir()`
  ref-cache: use a callback function to fill the cache
  refs: record the ref_store in ref_cache, not ref_dir
  ref-cache: introduce a new type, ref_cache
  refs: split `ref_cache` code into separate files
  ref-cache: rename `remove_entry()` to `remove_entry_from_dir()`
  ref-cache: rename `find_ref()` to `find_ref_entry()`
  ref-cache: rename `add_ref()` to `add_ref_entry()`
  refs_verify_refname_available(): use function in more places
  refs_verify_refname_available(): implement once for all backends
  refs_ref_iterator_begin(): new function
  refs_read_raw_ref(): new function
  get_ref_dir(): don't call read_loose_refs() for "refs/bisect"
2017-04-26 15:39:13 +09:00
Junio C Hamano
e31159746e Merge branch 'nd/worktree-add-lock'
Allow to lock a worktree immediately after it's created. This helps
prevent a race between "git worktree add; git worktree lock" and
"git worktree prune".

* nd/worktree-add-lock:
  worktree add: add --lock option
2017-04-26 15:39:12 +09:00
Junio C Hamano
7ba7bff629 Merge branch 'jk/update-links-in-docs'
Many stale HTTP(s) links have been updated in our documentation.

* jk/update-links-in-docs:
  docs/bisect-lk2009: update java code conventions link
  docs/bisect-lk2009: update nist report link
  docs/archimport: quote sourcecontrol.net reference
  gitcore-tutorial: update broken link
  doc: replace or.cz gitwiki link with git.wiki.kernel.org
  doc: use https links to avoid http redirect
2017-04-26 15:39:11 +09:00
Junio C Hamano
d4592d73ef Merge branch 'sf/putty-w-args'
Plug a memleak.

* sf/putty-w-args:
  connect.c: fix leak in handle_ssh_variant
2017-04-26 15:39:10 +09:00
Junio C Hamano
f70b541188 Merge branch 'ab/completion-push-delete-ref'
The completion script (in contrib/) learned to complete "git push
--delete b<TAB>" to complete branch name to be deleted.

* ab/completion-push-delete-ref:
  completion: expand "push --delete <remote> <ref>" for refs on that <remote>
2017-04-26 15:39:09 +09:00