Commit graph

55967 commits

Author SHA1 Message Date
Jeff King 9055384710 tree-walk: drop oid from traverse_info
As the previous commit shows, the presence of an oid in each level of
the traverse_info is confusing and ultimately not necessary. Let's drop
it to make it clear that it will not always be set (as well as convince
us that it's unused, and let the compiler catch any merges with other
branches that do add new uses).

Since the oid is part of name_entry, we'll actually stop embedding a
name_entry entirely, and instead just separately hold the pathname, its
length, and the mode.

This makes the resulting code slightly more verbose as we have to pass
those elements around individually. But it also makes it more clear what
each code path is going to use (and in most of the paths, we really only
care about the pathname itself).

A few of these conversions are noisier than they need to be, as they
also take the opportunity to rename "len" to "namelen" for clarity
(especially where we also have "pathlen" or "ce_len" alongside).

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2019-07-31 13:34:25 -07:00
Jeff King 947208b725 setup_traverse_info(): stop copying oid
We assume that if setup_traverse_info() is passed a non-empty "base"
string, that string is pointing into a tree object and we can read the
object oid by skipping past the trailing NUL.

As it turns out, this is not true for either of the two calls, and we
may end up reading garbage bytes:

  1. In git-merge-tree, our base string is either empty (in which case
     we'd never run this code), or it comes from our traverse_path()
     helper. The latter overallocates a buffer by the_hash_algo->rawsz
     bytes, but then fills it with only make_traverse_path(), leaving
     those extra bytes uninitialized (but part of a legitimate heap
     buffer).

  2. In unpack_trees(), we pass o->prefix, which is some arbitrary
     string from the caller. In "git read-tree --prefix=foo", for
     instance, it will point to the command-line parameter, and we'll
     read 20 bytes past the end of the string.

Interestingly, tools like ASan do not detect (2) because the process
argv is part of a big pre-allocated buffer. So we're reading trash, but
it's trash that's probably part of the next argument, or the
environment.

You can convince it to fail by putting something like this at the
beginning of common-main.c's main() function:

  {
	int i;
	for (i = 0; i < argc; i++)
		argv[i] = xstrdup_or_null(argv[i]);
  }

That puts the arguments into their own heap buffers, so running:

  make SANITIZE=address test

will find problems when "read-tree --prefix" is used (e.g., in t3030).

Doubly interesting, even with the hackery above, this does not fail
prior to ea82b2a085 (tree-walk: store object_id in a separate member,
2019-01-15). That commit switched setup_traverse_info() to actually
copying the hash, rather than simply pointing to it. That pointer was
always pointing to garbage memory, but that commit started actually
dereferencing the bytes, which is what triggers ASan.

That also implies that nobody actually cares about reading these oid
bytes anyway (or at least no path covered by our tests). And manual
inspection of the code backs that up (I'll follow this patch with some
cleanups that show definitively this is the case, but they're quite
invasive, so it's worth doing this fix on its own).

So let's drop the bogus hashcpy(), along with the confusing oversizing
in merge-tree.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2019-07-31 13:30:58 -07:00
Junio C Hamano 1feeaaf26b Merge fixes made on the 'master' front
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2019-07-29 12:38:23 -07:00
Junio C Hamano f91dbd8b49 Merge branch 'jc/post-c89-rules-doc' into maint
We have been trying out a few language features outside c89; the
coding guidelines document did not talk about them and instead had
a blanket ban against them.

* jc/post-c89-rules-doc:
  CodingGuidelines: spell out post-C89 rules
2019-07-29 12:38:23 -07:00
Junio C Hamano 7011ce12b8 Merge branch 'fc/fetch-with-import-fix' into maint
Code restructuring during 2.20 period broke fetching tags via
"import" based transports.

* fc/fetch-with-import-fix:
  fetch: fix regression with transport helpers
  fetch: make the code more understandable
  fetch: trivial cleanup
  t5801 (remote-helpers): add test to fetch tags
  t5801 (remote-helpers): cleanup refspec stuff
2019-07-29 12:38:23 -07:00
Junio C Hamano dea6737bb7 Merge branch 'ds/close-object-store' into maint
The commit-graph file is now part of the "files that the runtime
may keep open file descriptors on, all of which would need to be
closed when done with the object store", and the file descriptor to
an existing commit-graph file now is closed before "gc" finalizes a
new instance to replace it.

* ds/close-object-store:
  packfile: rename close_all_packs to close_object_store
  packfile: close commit-graph in close_all_packs
  commit-graph: use raw_object_store when closing
  commit-graph: extract write_commit_graph_file()
  commit-graph: extract copy_oids_to_commits()
  commit-graph: extract count_distinct_commits()
  commit-graph: extract fill_oids_from_all_packs()
  commit-graph: extract fill_oids_from_commit_hex()
  commit-graph: extract fill_oids_from_packs()
  commit-graph: create write_commit_graph_context
  commit-graph: remove Future Work section
  commit-graph: collapse parameters into flags
  commit-graph: return with errors during write
  commit-graph: fix the_repository reference
2019-07-29 12:38:22 -07:00
Junio C Hamano 689204ca88 Merge branch 'pw/add-p-recount' into maint
"git checkout -p" needs to selectively apply a patch in reverse,
which did not work well.

* pw/add-p-recount:
  add -p: fix checkout -p with pathological context
2019-07-29 12:38:22 -07:00
Junio C Hamano 0324b6f035 Merge branch 'rs/avoid-overflow-in-midpoint-computation' into maint
Code clean-up to avoid signed integer overlaps during binary search.

* rs/avoid-overflow-in-midpoint-computation:
  cleanup: fix possible overflow errors in binary search, part 2
2019-07-29 12:38:21 -07:00
Junio C Hamano 0100103d8e Merge branch 'jk/trailers-use-config' into maint
"git interpret-trailers" always treated '#' as the comment
character, regardless of core.commentChar setting, which has been
corrected.

* jk/trailers-use-config:
  interpret-trailers: load default config
2019-07-29 12:38:21 -07:00
Junio C Hamano 05ed24dc51 Merge branch 'tg/stash-ref-by-index-fix' into maint
"git stash show 23" used to work, but no more after getting
rewritten in C; this regression has been corrected.

* tg/stash-ref-by-index-fix:
  stash: fix show referencing stash index
2019-07-29 12:38:20 -07:00
Junio C Hamano 649cae69bc Merge branch 'pw/rebase-abort-clean-rewritten' into maint
"git rebase --abort" used to leave refs/rewritten/ when concluding
"git rebase -r", which has been corrected.

* pw/rebase-abort-clean-rewritten:
  rebase --abort/--quit: cleanup refs/rewritten
  sequencer: return errors from sequencer_remove_state()
  rebase: warn if state directory cannot be removed
  rebase: fix a memory leak
2019-07-29 12:38:20 -07:00
Junio C Hamano 39521d07be Merge branch 'nd/completion-no-cache-failure' into maint
An incorrect list of options was cached after command line
completion failed (e.g. trying to complete a command that requires
a repository outside one), which has been corrected.

* nd/completion-no-cache-failure:
  completion: do not cache if --git-completion-helper fails
2019-07-29 12:38:20 -07:00
Junio C Hamano 97cb523f00 Merge branch 'rs/config-unit-parsing' into maint
The code to parse scaled numbers out of configuration files has
been made more robust and also easier to follow.

* rs/config-unit-parsing:
  config: simplify parsing of unit factors
  config: don't multiply in parse_unit_factor()
  config: use unsigned_mult_overflows to check for overflows
2019-07-29 12:38:19 -07:00
Junio C Hamano e59150199c Merge branch 'jk/delta-islands-progress-fix' into maint
The codepath to compute delta islands used to spew progress output
without giving the callers any way to squelch it, which has been
fixed.

* jk/delta-islands-progress-fix:
  delta-islands: respect progress flag
2019-07-29 12:38:19 -07:00
Junio C Hamano 3e06e74e4c Merge branch 'sg/rebase-progress' into maint
Use "Erase in Line" CSI sequence that is already used in the editor
support to clear cruft in the progress output.

* sg/rebase-progress:
  progress: use term_clear_line()
  rebase: fix garbled progress display with '-x'
  pager: add a helper function to clear the last line in the terminal
  t3404: make the 'rebase.missingCommitsCheck=ignore' test more focused
  t3404: modernize here doc style
2019-07-29 12:38:19 -07:00
Junio C Hamano 292a0de998 Merge branch 'ms/submodule-foreach-fix' into maint
"git submodule foreach" did not protect command line options passed
to the command to be run in each submodule correctly, when the
"--recursive" option was in use.

* ms/submodule-foreach-fix:
  submodule foreach: fix recursion of options
2019-07-29 12:38:18 -07:00
Junio C Hamano 8eb5097bea Merge branch 'js/rebase-reschedule-applies-only-to-interactive' into maint
The configuration variable rebase.rescheduleFailedExec should be
effective only while running an interactive rebase and should not
affect anything when running an non-interactive one, which was not
the case.  This has been corrected.

* js/rebase-reschedule-applies-only-to-interactive:
  rebase --am: ignore rebase.rescheduleFailedExec
2019-07-29 12:38:18 -07:00
Junio C Hamano 1cf76b7010 Merge branch 'qn/clone-doc-use-long-form' into maint
The "git clone" documentation refers to command line options in its
description in the short form; they have been replaced with long
forms to make them more recognisable.

* qn/clone-doc-use-long-form:
  docs: git-clone: list short form of options first
  docs: git-clone: refer to long form of options
2019-07-29 12:38:18 -07:00
Junio C Hamano 9c65991abd Merge branch 'jc/denoise-rm-to-resolve' into maint
"git rm" to resolve a conflicted path leaked an internal message
"needs merge" before actually removing the path, which was
confusing.  This has been corrected.

* jc/denoise-rm-to-resolve:
  rm: resolving by removal is not a warning-worthy event
2019-07-29 12:38:17 -07:00
Junio C Hamano 2f72ebfcd0 Merge branch 'js/mingw-spawn-with-spaces-in-path' into maint
Window 7 update ;-)

* js/mingw-spawn-with-spaces-in-path:
  mingw: support spawning programs containing spaces in their names
2019-07-29 12:38:17 -07:00
Junio C Hamano c5d81d7f59 Merge branch 'sr/gpg-interface-stop-at-the-end' into maint
A codepath that reads from GPG for signed object verification read
past the end of allocated buffer, which has been fixed.

* sr/gpg-interface-stop-at-the-end:
  gpg-interface: do not scan past the end of buffer
2019-07-29 12:38:17 -07:00
Junio C Hamano 17952bd1bf Merge branch 'js/clean-report-too-long-a-path' into maint
"git clean" silently skipped a path when it cannot lstat() it; now
it gives a warning.

* js/clean-report-too-long-a-path:
  clean: show an error message when the path is too long
2019-07-29 12:38:16 -07:00
Junio C Hamano 1a27b78e34 Merge branch 'es/local-atomic-push-failure-with-http' into maint
"git push --atomic" that goes over the transport-helper (namely,
the smart http transport) failed to prevent refs to be pushed when
it can locally tell that one of the ref update will fail without
having to consult the other end, which has been corrected.

* es/local-atomic-push-failure-with-http:
  transport-helper: avoid var decl in for () loop control
  transport-helper: enforce atomic in push_refs_with_push
2019-07-29 12:38:16 -07:00
Junio C Hamano 0c47e8ddf5 Merge branch 'po/doc-branch' into maint
Doc update.

* po/doc-branch:
  doc branch: provide examples for listing remote tracking branches
2019-07-29 12:38:16 -07:00
Junio C Hamano 747201d0c8 Merge branch 'dl/config-alias-doc' into maint
Doc update.

* dl/config-alias-doc:
  config/alias.txt: document alias accepting non-command first word
  config/alias.txt: change " and ' to `
2019-07-29 12:38:15 -07:00
Junio C Hamano ea219657a3 Merge branch 'cb/fsmonitor-intfix' into maint
Variable type fix.

* cb/fsmonitor-intfix:
  fsmonitor: avoid signed integer overflow / infinite loop
2019-07-29 12:38:15 -07:00
Junio C Hamano 90334a8497 Merge branch 'rs/copy-array' into maint
Code clean-up.

* rs/copy-array:
  use COPY_ARRAY for copying arrays
  coccinelle: use COPY_ARRAY for copying arrays
2019-07-29 12:38:15 -07:00
Junio C Hamano 0726f13074 Merge branch 'js/t3404-typofix' into maint
Typofix.

* js/t3404-typofix:
  t3404: fix a typo
2019-07-29 12:38:14 -07:00
Junio C Hamano 82ac2fbaf9 Merge branch 'cb/mkstemps-uint-type-fix' into maint
Variable type fix.

* cb/mkstemps-uint-type-fix:
  wrapper: avoid undefined behaviour in macOS
2019-07-29 12:38:14 -07:00
Junio C Hamano dc55e3e3c2 Merge branch 'js/t0001-case-insensitive' into maint
Test update.

* js/t0001-case-insensitive:
  t0001: fix on case-insensitive filesystems
2019-07-29 12:38:14 -07:00
Junio C Hamano 63d9fa23cf Merge branch 'jw/gitweb-sample-update' into maint
Doc update.

* jw/gitweb-sample-update:
  doc: don't use git.kernel.org as example gitweb URL
2019-07-29 12:38:13 -07:00
Junio C Hamano 0a2e8387e9 Merge branch 'sg/t5551-fetch-smart-error-is-translated' into maint
Test update.

* sg/t5551-fetch-smart-error-is-translated:
  t5551: use 'test_i18ngrep' to check translated output
2019-07-29 12:38:13 -07:00
Junio C Hamano ca9eba84d1 Merge branch 'jt/t5551-test-chunked' into maint
Update smart-http test.

* jt/t5551-test-chunked:
  t5551: test usage of chunked encoding explicitly
2019-07-29 12:38:13 -07:00
Junio C Hamano bcb30d718a Merge branch 'sg/git-C-empty-doc' into maint
Doc update.

* sg/git-C-empty-doc:
  Document that 'git -C ""' works and doesn't change directory
2019-07-29 12:38:13 -07:00
Junio C Hamano 3846f5c325 Merge branch 'sg/ci-brew-gcc-workaround' into maint
Dev support update.

* sg/ci-brew-gcc-workaround:
  ci/lib.sh: update a comment about installed P4 and Git-LFS versions
  ci: disable Homebrew's auto cleanup
  ci: don't update Homebrew
2019-07-29 12:38:12 -07:00
Junio C Hamano 8926ea6a12 Merge branch 'js/trace2-signo-typofix' into maint
Documentation fix.

* js/trace2-signo-typofix:
  trace2: correct trace2 field name documentation
2019-07-29 12:38:12 -07:00
Junio C Hamano c8823b44f1 Merge branch 'di/readme-markup-fix' into maint
Docfix.

* di/readme-markup-fix:
  README: fix rendering of text in angle brackets
2019-07-29 12:38:12 -07:00
Junio C Hamano 9d98862bf5 Merge branch 'vn/xmmap-gently' into maint
Clean-up an error codepath.

* vn/xmmap-gently:
  read-cache.c: do not die if mmap fails
2019-07-29 12:38:12 -07:00
Junio C Hamano 2b312841a8 Merge branch 'rm/gpg-program-doc-fix' into maint
Docfix.

* rm/gpg-program-doc-fix:
  gpg(docs): use correct --verify syntax
2019-07-29 12:38:12 -07:00
Junio C Hamano 58f6cfd8ce Merge branch 'js/unmap-before-ext-diff' into maint
Windows update.

* js/unmap-before-ext-diff:
  diff: munmap() file contents before running external diff
2019-07-29 12:38:11 -07:00
Junio C Hamano 9147e5ae08 Merge branch 'js/gcc-8-and-9' into maint
Code clean-up for new compilers.
The 'kwset' one may get a wholesale replacement, either with new
version of kwset from upstream or removal of its users, but in the
meantime, it is probably OK to merge it down.

* js/gcc-8-and-9:
  config: avoid calling `labs()` on too-large data type
  winansi: simplify loading the GetCurrentConsoleFontEx() function
  kwset: allow building with GCC 8
  poll (mingw): allow compiling with GCC 8 and DEVELOPER=1
2019-07-29 12:38:11 -07:00
Junio C Hamano 98e06ded34 Flush fixes up to the third batch post 2.22.0
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2019-07-25 14:32:36 -07:00
Junio C Hamano 352253adf0 Merge branch 'ab/hash-object-doc' into maint
Doc update.

* ab/hash-object-doc:
  hash-object doc: stop mentioning git-cvsimport
2019-07-25 14:27:16 -07:00
Junio C Hamano 409813088a Merge branch 'cm/send-email-document-req-modules' into maint
A doc update.

* cm/send-email-document-req-modules:
  send-email: update documentation of required Perl modules
2019-07-25 14:27:15 -07:00
Junio C Hamano fe3ec21fb0 Merge branch 'sw/git-p4-unshelve-branched-files' into maint
"git p4" update.

* sw/git-p4-unshelve-branched-files:
  git-p4: allow unshelving of branched files
2019-07-25 14:27:15 -07:00
Junio C Hamano 2c30e34e1a Merge branch 'js/bisect-helper-check-get-oid-return-value' into maint
Code cleanup.

* js/bisect-helper-check-get-oid-return-value:
  bisect--helper: verify HEAD could be parsed before continuing
2019-07-25 14:27:14 -07:00
Junio C Hamano 24c161ddd6 Merge branch 'es/git-debugger-doc' into maint
Doc update.

* es/git-debugger-doc:
  doc: hint about GIT_DEBUGGER in CodingGuidelines
2019-07-25 14:27:14 -07:00
Junio C Hamano 27e4131bdd Merge branch 'mo/clang-format-for-each-update' into maint
The list of for-each like macros used by clang-format has been
updated.

* mo/clang-format-for-each-update:
  clang-format: use git grep to generate the ForEachMacros list
2019-07-25 14:27:14 -07:00
Junio C Hamano d7267d55ef Merge branch 'md/url-parse-harden' into maint
The URL decoding code has been updated to avoid going past the end
of the string while parsing %-<hex>-<hex> sequence.

* md/url-parse-harden:
  url: do not allow %00 to represent NUL in URLs
  url: do not read past end of buffer
2019-07-25 14:27:13 -07:00
Junio C Hamano 167d02aa58 Merge branch 'an/ignore-doc-update' into maint
The description about slashes in gitignore patterns (used to
indicate things like "anchored to this level only" and "only
matches directories") has been revamped.

* an/ignore-doc-update:
  gitignore.txt: make slash-rules more readable
2019-07-25 14:27:13 -07:00