]> git.ipfire.org Git - thirdparty/git.git/log
thirdparty/git.git
4 years agoMerge branch 'js/mingw-spawn-with-spaces-in-path'
Junio C Hamano [Wed, 9 Oct 2019 05:00:59 +0000 (14:00 +0900)] 
Merge branch 'js/mingw-spawn-with-spaces-in-path'

Test fix.

* js/mingw-spawn-with-spaces-in-path:
  t0061: fix test for argv[0] with spaces (MINGW only)

4 years agoMerge branch 'as/shallow-slab-use-fix'
Junio C Hamano [Wed, 9 Oct 2019 05:00:59 +0000 (14:00 +0900)] 
Merge branch 'as/shallow-slab-use-fix'

Correct code that tried to reference all entries in a sparse array
of pointers by mistake.

* as/shallow-slab-use-fix:
  shallow.c: don't free unallocated slabs

4 years agoMerge branch 'sg/name-rev-cutoff-underflow-fix'
Junio C Hamano [Wed, 9 Oct 2019 05:00:58 +0000 (14:00 +0900)] 
Merge branch 'sg/name-rev-cutoff-underflow-fix'

Integer arithmetic fix.

* sg/name-rev-cutoff-underflow-fix:
  name-rev: avoid cutoff timestamp underflow

4 years agoMerge branch 'am/visual-studio-config-fix'
Junio C Hamano [Wed, 9 Oct 2019 05:00:58 +0000 (14:00 +0900)] 
Merge branch 'am/visual-studio-config-fix'

Dev support.

* am/visual-studio-config-fix:
  contrib/buildsystems: fix Visual Studio Debug configuration

4 years agoxdiffi: fix typos and touch up comments
Johannes Schindelin [Tue, 8 Oct 2019 18:27:52 +0000 (11:27 -0700)] 
xdiffi: fix typos and touch up comments

Inspired by the thoroughly stale https://github.com/git/git/pull/159,
this patch fixes a couple of typos, rewraps and clarifies some comments.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agot0000: cover GIT_SKIP_TESTS blindspots
Denton Liu [Tue, 8 Oct 2019 09:22:47 +0000 (02:22 -0700)] 
t0000: cover GIT_SKIP_TESTS blindspots

Currently, the tests for GIT_SKIP_TESTS do not cover the situation where
we skip an entire test suite. The tests also do not cover the situation
where we have GIT_SKIP_TESTS defined but the test suite does not match.

Add two test cases so we cover this blindspot.

Signed-off-by: Denton Liu <liu.denton@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agosend-pack: never fetch when checking exclusions
Jonathan Tan [Tue, 8 Oct 2019 18:37:39 +0000 (11:37 -0700)] 
send-pack: never fetch when checking exclusions

When building the packfile to be sent, send_pack() is given a list of
remote refs to be used as exclusions. For each ref, it first checks if
the ref exists locally, and if it does, passes it with a "^" prefix to
pack-objects. However, in a partial clone, the check may trigger a lazy
fetch.

The additional commit ancestry information obtained during such fetches
may show that certain objects that would have been sent are already
known to the server, resulting in a smaller pack being sent. But this is
at the cost of fetching from many possibly unrelated refs, and the lazy
fetches do not help at all in the typical case where the client is
up-to-date with the upstream of the branch being pushed.

Ensure that these lazy fetches do not occur.

Signed-off-by: Jonathan Tan <jonathantanmy@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agot4014: treat rev-list output as the expected value
Denton Liu [Tue, 8 Oct 2019 09:14:11 +0000 (02:14 -0700)] 
t4014: treat rev-list output as the expected value

In 6bd26f58ea (t4014: use test_line_count() where possible, 2019-08-27),
we converted many test cases to take advantage of the test_line_count()
function. In one conversion, we inverted the expected and actual value
as tested by test_line_count(). Although functionally correct, if
format-patch ever produced incorrect output, the debugging output would
be a bunch of hashes which would be difficult to debug.

Invert the expected and actual values provided to test_line_count() so
that if format-patch produces incorrect output, the debugging output
will be a list of human-readable files instead.

Helped-by: SZEDER Gábor <szeder.dev@gmail.com>
Signed-off-by: Denton Liu <liu.denton@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agorange-diff: don't segfault with mode-only changes
Thomas Gummerer [Tue, 8 Oct 2019 17:38:43 +0000 (18:38 +0100)] 
range-diff: don't segfault with mode-only changes

In ef283b3699 ("apply: make parse_git_diff_header public", 2019-07-11)
the 'parse_git_diff_header' function was made public and useable by
callers outside of apply.c.

However it was missed that its (then) only caller, 'find_header' did
some error handling, and completing 'struct patch' appropriately.

range-diff then started using this function, and tried to handle this
appropriately itself, but fell short in some cases.  This in turn
would lead to range-diff segfaulting when there are mode-only changes
in a range.

Move the error handling and completing of the struct into the
'parse_git_diff_header' function, so other callers can take advantage
of it.  This fixes the segfault in 'git range-diff'.

Reported-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Thomas Gummerer <t.gummerer@gmail.com>
Acked-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agotransport: push codepath can take arbitrary repository
Junio C Hamano [Tue, 8 Oct 2019 04:18:24 +0000 (13:18 +0900)] 
transport: push codepath can take arbitrary repository

The previous step added annotations with "the_repository" to various
functions in the push codepath in the transport layer, but they all
can take arbitrary repository pointer, and may be working on a
repository that is not the_repository.  Fix them.

Signed-off-by: Josh Steadmon <steadmon@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agosq_quote_buf_pretty: don't drop empty arguments
Garima Singh [Mon, 7 Oct 2019 19:38:56 +0000 (12:38 -0700)] 
sq_quote_buf_pretty: don't drop empty arguments

Empty arguments passed on the command line can be represented by
a '', however sq_quote_buf_pretty was incorrectly dropping these
arguments altogether. Fix this problem by ensuring that such
arguments are emitted as '' instead.

Signed-off-by: Garima Singh <garima.singh@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agomerge-recursive: fix the fix to the diff3 common ancestor label
Elijah Newren [Mon, 7 Oct 2019 15:52:11 +0000 (08:52 -0700)] 
merge-recursive: fix the fix to the diff3 common ancestor label

In commit 8e4ec337 ("merge-recursive: fix the diff3 common ancestor
label for virtual commits", 2019-10-01), which was a fix to commit
743474cbfa8b ("merge-recursive: provide a better label for diff3
common ancestor", 2019-08-17), the label for the common ancestor was
changed from always being

         "merged common ancestors"

to instead be based on the number of merge bases and whether the merge
base was a real commit or a virtual one:

    >=2: "merged common ancestors"
      1, via merge_recursive_generic: "constructed merge base"
      1, otherwise: <abbreviated commit hash>
      0: "<empty tree>"

The handling for "constructed merge base" worked by allowing
opt->ancestor to be set in merge_recursive_generic(), so we paid
attention to the setting of that variable in merge_recursive_internal().
Now, for the outer merge, the code flow was simply the following:

ancestor_name = "merged merge bases"
loop over merge_bases: merge_recursive_internal()

The first merge base not needing recursion would determine its own
ancestor_name however necessary and thus run

ancestor_name = $SOMETHING
empty loop over merge_bases...
opt->ancestor = ancestor_name
        merge_trees_internal()

Now, the next set of merge_bases that would need to be merged after this
particular merge had completed would note that opt->ancestor has been
set to something (to a local ancestor_name variable that has since been
popped off the stack), and thus it would run:

... else if (opt->ancestor) {
ancestor_name = opt->ancestor;  /* OOPS! */
        loop over merge_bases: merge_recursive_internal()
        opt->ancestor = ancestor_name
        merge_trees_internal()

This resulted in garbage strings being printed for the virtual merge
bases, which was visible in git.git by just merging commit b744c3af07
into commit 6d8cb22a4f.  There are two ways to fix this: set
opt->ancestor to NULL after using it to avoid re-use, or add a
!opt->priv->call_depth check to the if block for using a pre-defined
opt->ancestor.  Apply both fixes.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agoSixth batch
Junio C Hamano [Mon, 7 Oct 2019 02:33:44 +0000 (11:33 +0900)] 
Sixth batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agoMerge branch 'bw/submodule-helper-usage-fix'
Junio C Hamano [Mon, 7 Oct 2019 02:33:03 +0000 (11:33 +0900)] 
Merge branch 'bw/submodule-helper-usage-fix'

Typofix.

* bw/submodule-helper-usage-fix:
  builtin/submodule--helper: fix usage string for 'update-clone'

4 years agoMerge branch 'dl/honor-cflags-in-hdr-check'
Junio C Hamano [Mon, 7 Oct 2019 02:33:02 +0000 (11:33 +0900)] 
Merge branch 'dl/honor-cflags-in-hdr-check'

Dev support.

* dl/honor-cflags-in-hdr-check:
  ci: run `hdr-check` as part of the `Static Analysis` job
  Makefile: emulate compile in $(HCO) target better
  pack-bitmap.h: remove magic number
  promisor-remote.h: include missing header
  apply.h: include missing header

4 years agoMerge branch 'cb/do-not-use-test-cmp-with-a'
Junio C Hamano [Mon, 7 Oct 2019 02:33:02 +0000 (11:33 +0900)] 
Merge branch 'cb/do-not-use-test-cmp-with-a'

Test portability fix.

* cb/do-not-use-test-cmp-with-a:
  t4038: Remove non-portable '-a' option passed to test_cmp

4 years agoMerge branch 'cc/multi-promisor'
Junio C Hamano [Mon, 7 Oct 2019 02:33:02 +0000 (11:33 +0900)] 
Merge branch 'cc/multi-promisor'

Cleanup.

* cc/multi-promisor:
  promisor-remote: skip move_to_tail when no-op
  promisor-remote.h: drop extern from function declaration

4 years agoMerge branch 'jt/merge-recursive-symlink-is-not-a-dir-in-way'
Junio C Hamano [Mon, 7 Oct 2019 02:33:02 +0000 (11:33 +0900)] 
Merge branch 'jt/merge-recursive-symlink-is-not-a-dir-in-way'

A bug in merge-recursive code that triggers when a branch with a
symbolic link is merged with a branch that replaces it with a
directory has been fixed.

* jt/merge-recursive-symlink-is-not-a-dir-in-way:
  merge-recursive: symlink's descendants not in way

4 years agoMerge branch 'ps/my-first-contribution-alphasort'
Junio C Hamano [Mon, 7 Oct 2019 02:33:01 +0000 (11:33 +0900)] 
Merge branch 'ps/my-first-contribution-alphasort'

Docfix.

* ps/my-first-contribution-alphasort:
  doc: MyFirstContribution: fix cmd placement instructions

4 years agoMerge branch 'sg/travis-help-debug'
Junio C Hamano [Mon, 7 Oct 2019 02:33:01 +0000 (11:33 +0900)] 
Merge branch 'sg/travis-help-debug'

Dev support update.

* sg/travis-help-debug:
  travis-ci: do not skip successfully tested trees in debug mode

4 years agoMerge branch 'rs/alias-use-copy-array'
Junio C Hamano [Mon, 7 Oct 2019 02:33:01 +0000 (11:33 +0900)] 
Merge branch 'rs/alias-use-copy-array'

Code cleanup.

* rs/alias-use-copy-array:
  git: use COPY_ARRAY and MOVE_ARRAY in handle_alias()

4 years agoMerge branch 'sg/t-helper-gitignore'
Junio C Hamano [Mon, 7 Oct 2019 02:33:00 +0000 (11:33 +0900)] 
Merge branch 'sg/t-helper-gitignore'

Update the way build artifacts in t/helper/ directory are ignored.

* sg/t-helper-gitignore:
  t/helper: ignore only executable files

4 years agoMerge branch 'cc/svn-fe-py-shebang'
Junio C Hamano [Mon, 7 Oct 2019 02:33:00 +0000 (11:33 +0900)] 
Merge branch 'cc/svn-fe-py-shebang'

* cc/svn-fe-py-shebang:
  contrib/svn-fe: fix shebang for svnrdump_sim.py

4 years agoMerge branch 'ah/doc-submodule-ignore-submodules'
Junio C Hamano [Mon, 7 Oct 2019 02:33:00 +0000 (11:33 +0900)] 
Merge branch 'ah/doc-submodule-ignore-submodules'

Docfix.

* ah/doc-submodule-ignore-submodules:
  doc: fix reference to --ignore-submodules

4 years agoMerge branch 'rs/nth-switch-code-simplification'
Junio C Hamano [Mon, 7 Oct 2019 02:32:59 +0000 (11:32 +0900)] 
Merge branch 'rs/nth-switch-code-simplification'

Code simplification.

* rs/nth-switch-code-simplification:
  sha1_name: simplify strbuf handling in interpret_nth_prior_checkout()

4 years agoMerge branch 'hb/hg-to-git-py3'
Junio C Hamano [Mon, 7 Oct 2019 02:32:59 +0000 (11:32 +0900)] 
Merge branch 'hb/hg-to-git-py3'

The hg-to-git script (in contrib/) has been updated to work with
Python 3.

* hb/hg-to-git-py3:
  hg-to-git: make it compatible with both python3 and python2

4 years agoMerge branch 'sg/progress-fix'
Junio C Hamano [Mon, 7 Oct 2019 02:32:59 +0000 (11:32 +0900)] 
Merge branch 'sg/progress-fix'

Regression fix for progress output.

* sg/progress-fix:
  Test the progress display
  Revert "progress: use term_clear_line()"

4 years agoMerge branch 'js/doc-patch-text'
Junio C Hamano [Mon, 7 Oct 2019 02:32:59 +0000 (11:32 +0900)] 
Merge branch 'js/doc-patch-text'

Docfix.

* js/doc-patch-text:
  diff, log doc: small grammer, format, and language fixes
  diff, log doc: say "patch text" instead of "patches"

4 years agoMerge branch 'tb/commit-graph-harden'
Junio C Hamano [Mon, 7 Oct 2019 02:32:58 +0000 (11:32 +0900)] 
Merge branch 'tb/commit-graph-harden'

The code to parse and use the commit-graph file has been made more
robust against corrupted input.

* tb/commit-graph-harden:
  commit-graph.c: handle corrupt/missing trees
  commit-graph.c: handle commit parsing errors
  t/t5318: introduce failing 'git commit-graph write' tests

4 years agoMerge branch 'jt/cache-tree-avoid-lazy-fetch-during-merge'
Junio C Hamano [Mon, 7 Oct 2019 02:32:58 +0000 (11:32 +0900)] 
Merge branch 'jt/cache-tree-avoid-lazy-fetch-during-merge'

The cache-tree code has been taught to be less aggressive in
attempting to see if a tree object it computed already exists in
the repository.

* jt/cache-tree-avoid-lazy-fetch-during-merge:
  cache-tree: do not lazy-fetch tentative tree

4 years agoMerge branch 'dl/cocci-everywhere'
Junio C Hamano [Mon, 7 Oct 2019 02:32:58 +0000 (11:32 +0900)] 
Merge branch 'dl/cocci-everywhere'

Coccinelle checks are done on more source files than before now.

* dl/cocci-everywhere:
  Makefile: run coccicheck on more source files
  Makefile: strip leading ./ in $(FIND_SOURCE_FILES)
  Makefile: define THIRD_PARTY_SOURCES
  Makefile: strip leading ./ in $(LIB_H)

4 years agoMerge branch 'gs/commit-graph-progress'
Junio C Hamano [Mon, 7 Oct 2019 02:32:57 +0000 (11:32 +0900)] 
Merge branch 'gs/commit-graph-progress'

* gs/commit-graph-progress:
  commit-graph: add --[no-]progress to write and verify

4 years agoMerge branch 'ms/fetch-follow-tag-optim'
Junio C Hamano [Mon, 7 Oct 2019 02:32:57 +0000 (11:32 +0900)] 
Merge branch 'ms/fetch-follow-tag-optim'

The code used in following tags in "git fetch" has been optimized.

* ms/fetch-follow-tag-optim:
  fetch: use oidset to keep the want OIDs for faster lookup

4 years agoMerge branch 'rs/commit-graph-use-list-count'
Junio C Hamano [Mon, 7 Oct 2019 02:32:57 +0000 (11:32 +0900)] 
Merge branch 'rs/commit-graph-use-list-count'

Code cleanup.

* rs/commit-graph-use-list-count:
  commit-graph: use commit_list_count()

4 years agoMerge branch 'rs/nth-parent-parse'
Junio C Hamano [Mon, 7 Oct 2019 02:32:57 +0000 (11:32 +0900)] 
Merge branch 'rs/nth-parent-parse'

The object name parser for "Nth parent" syntax has been made more
robust against integer overflows.

* rs/nth-parent-parse:
  sha1-name: check for overflow of N in "foo^N" and "foo~N"
  rev-parse: demonstrate overflow of N for "foo^N" and "foo~N"

4 years agoMerge branch 'dl/submodule-set-branch'
Junio C Hamano [Mon, 7 Oct 2019 02:32:56 +0000 (11:32 +0900)] 
Merge branch 'dl/submodule-set-branch'

Docfix.

* dl/submodule-set-branch:
  git-submodule.txt: fix AsciiDoc formatting error

4 years agoMerge branch 'cs/pretty-formats-doc-typofix'
Junio C Hamano [Mon, 7 Oct 2019 02:32:56 +0000 (11:32 +0900)] 
Merge branch 'cs/pretty-formats-doc-typofix'

Doc fix.

* cs/pretty-formats-doc-typofix:
  doc: minor formatting fix

4 years agoMerge branch 'jk/list-objects-optim-wo-trees'
Junio C Hamano [Mon, 7 Oct 2019 02:32:56 +0000 (11:32 +0900)] 
Merge branch 'jk/list-objects-optim-wo-trees'

The object traversal machinery has been optimized not to load tree
objects when we are only interested in commit history.

* jk/list-objects-optim-wo-trees:
  list-objects: don't queue root trees unless revs->tree_objects is set

4 years agoMerge branch 'jk/disable-commit-graph-during-upload-pack'
Junio C Hamano [Mon, 7 Oct 2019 02:32:55 +0000 (11:32 +0900)] 
Merge branch 'jk/disable-commit-graph-during-upload-pack'

The "upload-pack" (the counterpart of "git fetch") needs to disable
commit-graph when responding to a shallow clone/fetch request, but
the way this was done made Git panic, which has been corrected.

* jk/disable-commit-graph-during-upload-pack:
  upload-pack: disable commit graph more gently for shallow traversal
  commit-graph: bump DIE_ON_LOAD check to actual load-time

4 years agoMerge branch 'mr/complete-more-for-log-etc'
Junio C Hamano [Mon, 7 Oct 2019 02:32:55 +0000 (11:32 +0900)] 
Merge branch 'mr/complete-more-for-log-etc'

Completion updates.

* mr/complete-more-for-log-etc:
  completion: add missing completions for log, diff, show

4 years agoMerge branch 'dl/complete-rebase-and-archive'
Junio C Hamano [Mon, 7 Oct 2019 02:32:55 +0000 (11:32 +0900)] 
Merge branch 'dl/complete-rebase-and-archive'

The command line completion for "git archive" and "git rebase" are
now made less prone to go out of sync with the binary.

* dl/complete-rebase-and-archive:
  completion: teach archive to use __gitcomp_builtin
  completion: teach rebase to use __gitcomp_builtin

4 years agoMerge branch 'jk/commit-graph-cleanup'
Junio C Hamano [Mon, 7 Oct 2019 02:32:55 +0000 (11:32 +0900)] 
Merge branch 'jk/commit-graph-cleanup'

A pair of small fixups to "git commit-graph" have been applied.

* jk/commit-graph-cleanup:
  commit-graph: turn off save_commit_buffer
  commit-graph: don't show progress percentages while expanding reachable commits

4 years agoMerge branch 'ss/get-time-cleanup'
Junio C Hamano [Mon, 7 Oct 2019 02:32:54 +0000 (11:32 +0900)] 
Merge branch 'ss/get-time-cleanup'

Code simplification.

* ss/get-time-cleanup:
  test_date.c: remove reference to GIT_TEST_DATE_NOW
  Quit passing 'now' to date code

4 years agoMerge branch 'rs/simplify-by-deco-with-deco-refs-exclude'
Junio C Hamano [Mon, 7 Oct 2019 02:32:54 +0000 (11:32 +0900)] 
Merge branch 'rs/simplify-by-deco-with-deco-refs-exclude'

"git log --decorate-refs-exclude=<pattern>" was incorrectly
overruled when the "--simplify-by-decoration" option is used, which
has been corrected.

* rs/simplify-by-deco-with-deco-refs-exclude:
  log-tree: call load_ref_decorations() in get_name_decoration()
  log: test --decorate-refs-exclude with --simplify-by-decoration

4 years agoMerge branch 'jk/partial-clone-sparse-blob'
Junio C Hamano [Mon, 7 Oct 2019 02:32:54 +0000 (11:32 +0900)] 
Merge branch 'jk/partial-clone-sparse-blob'

The name of the blob object that stores the filter specification
for sparse cloning/fetching was interpreted in a wrong place in the
code, causing Git to abort.

* jk/partial-clone-sparse-blob:
  list-objects-filter: use empty string instead of NULL for sparse "base"
  list-objects-filter: give a more specific error sparse parsing error
  list-objects-filter: delay parsing of sparse oid
  t5616: test cloning/fetching with sparse:oid=<oid> filter

4 years agoMerge branch 'tg/stash-refresh-index'
Junio C Hamano [Mon, 7 Oct 2019 02:32:53 +0000 (11:32 +0900)] 
Merge branch 'tg/stash-refresh-index'

"git stash" learned to write refreshed index back to disk.

* tg/stash-refresh-index:
  stash: make sure to write refreshed cache
  merge: use refresh_and_write_cache
  factor out refresh_and_write_cache function

4 years agohashmap_entry: remove first member requirement from docs
Eric Wong [Sun, 6 Oct 2019 23:30:43 +0000 (23:30 +0000)] 
hashmap_entry: remove first member requirement from docs

Comments stating that "struct hashmap_entry" must be the first
member in a struct are no longer valid.

Suggested-by: Phillip Wood <phillip.wood123@gmail.com>
Signed-off-by: Eric Wong <e@80x24.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agohashmap: remove type arg from hashmap_{get,put,remove}_entry
Eric Wong [Sun, 6 Oct 2019 23:30:42 +0000 (23:30 +0000)] 
hashmap: remove type arg from hashmap_{get,put,remove}_entry

Since these macros already take a `keyvar' pointer of a known type,
we can rely on OFFSETOF_VAR to get the correct offset without
relying on non-portable `__typeof__' and `offsetof'.

Argument order is also rearranged, so `keyvar' and `member' are
sequential as they are used as: `keyvar->member'

Signed-off-by: Eric Wong <e@80x24.org>
Reviewed-by: Derrick Stolee <stolee@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agoOFFSETOF_VAR macro to simplify hashmap iterators
Eric Wong [Sun, 6 Oct 2019 23:30:41 +0000 (23:30 +0000)] 
OFFSETOF_VAR macro to simplify hashmap iterators

While we cannot rely on a `__typeof__' operator being portable
to use with `offsetof'; we can calculate the pointer offset
using an existing pointer and the address of a member using
pointer arithmetic for compilers without `__typeof__'.

This allows us to simplify usage of hashmap iterator macros
by not having to specify a type when a pointer of that type
is already given.

In the future, list iterator macros (e.g. list_for_each_entry)
may also be implemented using OFFSETOF_VAR to save hackers the
trouble of using container_of/list_entry macros and without
relying on non-portable `__typeof__'.

v3: use `__typeof__' to avoid clang warnings

Signed-off-by: Eric Wong <e@80x24.org>
Reviewed-by: Derrick Stolee <stolee@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agohashmap: introduce hashmap_free_entries
Eric Wong [Sun, 6 Oct 2019 23:30:40 +0000 (23:30 +0000)] 
hashmap: introduce hashmap_free_entries

`hashmap_free_entries' behaves like `container_of' and passes
the offset of the hashmap_entry struct to the internal
`hashmap_free_' function, allowing the function to free any
struct pointer regardless of where the hashmap_entry field
is located.

`hashmap_free' no longer takes any arguments aside from
the hashmap itself.

Signed-off-by: Eric Wong <e@80x24.org>
Reviewed-by: Derrick Stolee <stolee@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agohashmap: hashmap_{put,remove} return hashmap_entry *
Eric Wong [Sun, 6 Oct 2019 23:30:39 +0000 (23:30 +0000)] 
hashmap: hashmap_{put,remove} return hashmap_entry *

And add *_entry variants to perform container_of as necessary
to simplify most callers.

Signed-off-by: Eric Wong <e@80x24.org>
Reviewed-by: Derrick Stolee <stolee@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agohashmap: use *_entry APIs for iteration
Eric Wong [Sun, 6 Oct 2019 23:30:38 +0000 (23:30 +0000)] 
hashmap: use *_entry APIs for iteration

Inspired by list_for_each_entry in the Linux kernel.
Once again, these are somewhat compromised usability-wise
by compilers lacking __typeof__ support.

Signed-off-by: Eric Wong <e@80x24.org>
Reviewed-by: Derrick Stolee <stolee@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agohashmap_cmp_fn takes hashmap_entry params
Eric Wong [Sun, 6 Oct 2019 23:30:37 +0000 (23:30 +0000)] 
hashmap_cmp_fn takes hashmap_entry params

Another step in eliminating the requirement of hashmap_entry
being the first member of a struct.

Signed-off-by: Eric Wong <e@80x24.org>
Reviewed-by: Derrick Stolee <stolee@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agohashmap_get{,_from_hash} return "struct hashmap_entry *"
Eric Wong [Sun, 6 Oct 2019 23:30:36 +0000 (23:30 +0000)] 
hashmap_get{,_from_hash} return "struct hashmap_entry *"

Update callers to use hashmap_get_entry, hashmap_get_entry_from_hash
or container_of as appropriate.

This is another step towards eliminating the requirement of
hashmap_entry being the first field in a struct.

Signed-off-by: Eric Wong <e@80x24.org>
Reviewed-by: Derrick Stolee <stolee@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agohashmap: use *_entry APIs to wrap container_of
Eric Wong [Sun, 6 Oct 2019 23:30:35 +0000 (23:30 +0000)] 
hashmap: use *_entry APIs to wrap container_of

Using `container_of' can be verbose and choosing names for
intermediate "struct hashmap_entry" pointers is a hard problem.
So introduce "*_entry" APIs inspired by similar linked-list
APIs in the Linux kernel.

Unfortunately, `__typeof__' is not portable C, so we need an
extra parameter to specify the type.

Signed-off-by: Eric Wong <e@80x24.org>
Reviewed-by: Derrick Stolee <stolee@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agohashmap_get_next returns "struct hashmap_entry *"
Eric Wong [Sun, 6 Oct 2019 23:30:34 +0000 (23:30 +0000)] 
hashmap_get_next returns "struct hashmap_entry *"

This is a step towards removing the requirement for
hashmap_entry being the first field of a struct.

Signed-off-by: Eric Wong <e@80x24.org>
Reviewed-by: Derrick Stolee <stolee@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agointroduce container_of macro
Eric Wong [Sun, 6 Oct 2019 23:30:33 +0000 (23:30 +0000)] 
introduce container_of macro

This macro is popular within the Linux kernel for supporting
intrusive data structures such as linked lists, red-black trees,
and chained hash tables while allowing the compiler to do
type checking.

Later patches will use container_of() to remove the limitation
of "hashmap_entry" being location-dependent. This will complete
the transition to compile-time type checking for the hashmap API.

This macro already exists in our source as "list_entry" in
list.h and making "list_entry" an alias to "container_of"
as the Linux kernel has done is a possibility.

Signed-off-by: Eric Wong <e@80x24.org>
Reviewed-by: Derrick Stolee <stolee@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agohashmap_put takes "struct hashmap_entry *"
Eric Wong [Sun, 6 Oct 2019 23:30:32 +0000 (23:30 +0000)] 
hashmap_put takes "struct hashmap_entry *"

This is less error-prone than "void *" as the compiler now
detects invalid types being passed.

Signed-off-by: Eric Wong <e@80x24.org>
Reviewed-by: Derrick Stolee <stolee@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agohashmap_remove takes "const struct hashmap_entry *"
Eric Wong [Sun, 6 Oct 2019 23:30:31 +0000 (23:30 +0000)] 
hashmap_remove takes "const struct hashmap_entry *"

This is less error-prone than "const void *" as the compiler
now detects invalid types being passed.

Signed-off-by: Eric Wong <e@80x24.org>
Reviewed-by: Derrick Stolee <stolee@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agohashmap_get takes "const struct hashmap_entry *"
Eric Wong [Sun, 6 Oct 2019 23:30:30 +0000 (23:30 +0000)] 
hashmap_get takes "const struct hashmap_entry *"

This is less error-prone than "const void *" as the compiler
now detects invalid types being passed.

Signed-off-by: Eric Wong <e@80x24.org>
Reviewed-by: Derrick Stolee <stolee@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agohashmap_add takes "struct hashmap_entry *"
Eric Wong [Sun, 6 Oct 2019 23:30:29 +0000 (23:30 +0000)] 
hashmap_add takes "struct hashmap_entry *"

This is less error-prone than "void *" as the compiler now
detects invalid types being passed.

Signed-off-by: Eric Wong <e@80x24.org>
Reviewed-by: Derrick Stolee <stolee@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agohashmap_get_next takes "const struct hashmap_entry *"
Eric Wong [Sun, 6 Oct 2019 23:30:28 +0000 (23:30 +0000)] 
hashmap_get_next takes "const struct hashmap_entry *"

This is less error-prone than "const void *" as the compiler
now detects invalid types being passed.

Signed-off-by: Eric Wong <e@80x24.org>
Reviewed-by: Derrick Stolee <stolee@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agohashmap_entry_init takes "struct hashmap_entry *"
Eric Wong [Sun, 6 Oct 2019 23:30:27 +0000 (23:30 +0000)] 
hashmap_entry_init takes "struct hashmap_entry *"

C compilers do type checking to make life easier for us.  So
rely on that and update all hashmap_entry_init callers to take
"struct hashmap_entry *" to avoid future bugs while improving
safety and readability.

Signed-off-by: Eric Wong <e@80x24.org>
Reviewed-by: Derrick Stolee <stolee@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agopackfile: use hashmap_entry in delta_base_cache_entry
Eric Wong [Sun, 6 Oct 2019 23:30:26 +0000 (23:30 +0000)] 
packfile: use hashmap_entry in delta_base_cache_entry

This hashmap_entry_init function is intended to take a
hashmap_entry struct pointer, not a hashmap struct pointer.

This was not noticed because hashmap_entry_init takes a "void *"
arg instead of "struct hashmap_entry *", and the hashmap struct
is larger and can be cast into a hashmap_entry struct without
data corruption.

This has the beneficial side effect of reducing the size of
a delta_base_cache_entry from 104 bytes to 72 bytes on 64-bit
systems.

Signed-off-by: Eric Wong <e@80x24.org>
Reviewed-by: Derrick Stolee <stolee@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agococcicheck: detect hashmap_entry.hash assignment
Eric Wong [Sun, 6 Oct 2019 23:30:25 +0000 (23:30 +0000)] 
coccicheck: detect hashmap_entry.hash assignment

Assigning hashmap_entry.hash manually leaves hashmap_entry.next
uninitialized, which can be dangerous once the hashmap_entry is
inserted into a hashmap.   Detect those assignments and use
hashmap_entry_init, instead.

Signed-off-by: Eric Wong <e@80x24.org>
Reviewed-by: Derrick Stolee <stolee@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agodiff: use hashmap_entry_init on moved_entry.ent
Eric Wong [Sun, 6 Oct 2019 23:30:24 +0000 (23:30 +0000)] 
diff: use hashmap_entry_init on moved_entry.ent

Otherwise, the hashmap_entry.next field appears to remain
uninitialized, which can lead to problems when
add_lines_to_move_detection calls hashmap_add.

I found this through manual inspection when converting
hashmap_add callers to take "struct hashmap_entry *".

Signed-off-by: Eric Wong <e@80x24.org>
Reviewed-by: Derrick Stolee <stolee@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agotests: remove "cat foo" before "test_i18ngrep bar foo"
René Scharfe [Sun, 6 Oct 2019 13:26:42 +0000 (15:26 +0200)] 
tests: remove "cat foo" before "test_i18ngrep bar foo"

Some tests print a file before searching for a pattern using
test_i18ngrep.  This is useful when debugging tests with --verbose when
the pattern is not found as expected.

Since 63b1a175ee (t: make 'test_i18ngrep' more informative on failure,
2018-02-08) test_i18ngrep already shows the contents of a file that
doesn't match the expected pattern, though.

So don't bother doing the same unconditionally up-front.  The contents
are not interesting if the expected pattern is found, and showing it
twice if it doesn't match is of no use.

Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agogit-p4: auto-delete named temporary file
Philip.McGraw [Tue, 27 Aug 2019 03:43:58 +0000 (06:43 +0300)] 
git-p4: auto-delete named temporary file

Avoid double-open exceptions on Windows platform when
calculating for lfs compressed size threshold
(git-p4.largeFileCompressedThreshold) comparisons.

Take new approach using the NamedTemporaryFile()
file-like object as input to the ZipFile() which
auto-deletes after implicit close leaving with scope.

Original code had double-open exception on Windows
platform because file still open from NamedTemporaryFile()
using generated filename instead of object.

Thanks to Andrey for patiently suggesting several
iterations on this change for avoiding exceptions!

Also print error details after resulting IOError to make
debugging cause of exception less mysterious when it has
nothing to do with "git version recent enough."

Signed-off-by: Philip.McGraw <Philip.McGraw@bentley.com>
Reviewed-by: Andrey Mazo <ahippo@yandex.com>
Acked-by: Luke Diamand <luke@diamand.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agoFifth batch
Junio C Hamano [Sun, 6 Oct 2019 03:25:51 +0000 (12:25 +0900)] 
Fifth batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agoMerge branch 'cb/skip-utf8-check-with-pcre1'
Junio C Hamano [Sun, 6 Oct 2019 03:25:17 +0000 (12:25 +0900)] 
Merge branch 'cb/skip-utf8-check-with-pcre1'

Make sure the grep machinery does not abort when seeing a payload
that is not UTF-8 even when JIT is not in use with PCRE1.

* cb/skip-utf8-check-with-pcre1:
  grep: skip UTF8 checks explicitly

4 years agoMerge branch 'ma/user-manual-markup-update'
Junio C Hamano [Sun, 6 Oct 2019 03:25:16 +0000 (12:25 +0900)] 
Merge branch 'ma/user-manual-markup-update'

The markup used in user-manual has been updated to work better with
asciidoctor.

* ma/user-manual-markup-update:
  user-manual.txt: render ASCII art correctly under Asciidoctor
  asciidoctor-extensions.rb: handle "book" doctype in linkgit
  user-manual.txt: change header notation
  user-manual.txt: add missing section label

4 years agoMerge branch 'bc/doc-use-docbook-5'
Junio C Hamano [Sun, 6 Oct 2019 03:25:16 +0000 (12:25 +0900)] 
Merge branch 'bc/doc-use-docbook-5'

Start using DocBook 5 (instead of DocBook 4.5) as Asciidoctor 2.0
no longer works with the older one.

* bc/doc-use-docbook-5:
  Documentation: fix build with Asciidoctor 2

4 years agoMerge branch 'ma/asciidoctor-more-fixes'
Junio C Hamano [Sun, 6 Oct 2019 03:25:16 +0000 (12:25 +0900)] 
Merge branch 'ma/asciidoctor-more-fixes'

Doc formatting updates.

* ma/asciidoctor-more-fixes:
  gitweb.conf.txt: switch pluses to backticks to help Asciidoctor
  git-merge-index.txt: wrap shell listing in "----"
  git-receive-pack.txt: wrap shell [script] listing in "----"
  git-ls-remote.txt: wrap shell listing in "----"
  Documentation: wrap config listings in "----"
  git-merge-base.txt: render indentations correctly under Asciidoctor
  Documentation: wrap blocks with "--"

4 years agoMerge branch 'ma/asciidoctor-refmiscinfo'
Junio C Hamano [Sun, 6 Oct 2019 03:25:15 +0000 (12:25 +0900)] 
Merge branch 'ma/asciidoctor-refmiscinfo'

Update support for Asciidoctor documentation toolchain.

* ma/asciidoctor-refmiscinfo:
  doc-diff: replace --cut-header-footer with --cut-footer
  asciidoctor-extensions: provide `<refmiscinfo/>`
  Doc/Makefile: give mansource/-version/-manual attributes

4 years agoMerge branch 'am/mailmap-andrey-mazo'
Junio C Hamano [Sun, 6 Oct 2019 03:25:15 +0000 (12:25 +0900)] 
Merge branch 'am/mailmap-andrey-mazo'

* am/mailmap-andrey-mazo:
  .mailmap: update email address of Andrey Mazo

4 years agoMerge branch 'jc/git-gui-has-maintainer'
Junio C Hamano [Sun, 6 Oct 2019 03:25:15 +0000 (12:25 +0900)] 
Merge branch 'jc/git-gui-has-maintainer'

* jc/git-gui-has-maintainer:
  SubmittingPatches: git-gui has a new maintainer

4 years agogit-rev-list.txt: prune options in synopsis
Denton Liu [Sat, 5 Oct 2019 00:13:08 +0000 (17:13 -0700)] 
git-rev-list.txt: prune options in synopsis

The synopsis section in git-rev-list.txt has grown to be a huge list
that probably needs its own synopsis. Since the list is huge, users may
be given the false impression that the list is complete, however it is
not. It is missing many of the available options.

Since the list of options in the synopsis is not only annoying but
actively harmful, replace it with `[<options>]` so users know to
explicitly look through the documentation for further information.

While we're at it, update the optional path notation so that it is more
modern.

Signed-off-by: Denton Liu <liu.denton@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agoDocumentation: update the location of the git-gui repo
Pratyush Yadav [Sat, 5 Oct 2019 12:57:42 +0000 (18:27 +0530)] 
Documentation: update the location of the git-gui repo

Signed-off-by: Pratyush Yadav <me@yadavpratyush.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agoconvert: fix handling of dashless UTF prefix in validate_encoding()
René Scharfe [Fri, 4 Oct 2019 19:25:50 +0000 (21:25 +0200)] 
convert: fix handling of dashless UTF prefix in validate_encoding()

Strip "UTF" and an optional dash from the start of 'upper' without
passing a NULL pointer to skip_prefix() in the second call, as it cannot
handle that.

Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agoci: also build and test with MS Visual Studio on Azure Pipelines
Johannes Schindelin [Fri, 4 Oct 2019 15:09:36 +0000 (08:09 -0700)] 
ci: also build and test with MS Visual Studio on Azure Pipelines

... because we can, now. Technically, we actually build using `MSBuild`,
which is however pretty close to building interactively in Visual
Studio.

As there is no convenient way to run Git's test suite in Visual Studio,
we unpack a Portable Git to run it, using the just-added test helper to
allow running test scripts in parallel.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agoci: really use shallow clones on Azure Pipelines
Johannes Schindelin [Fri, 4 Oct 2019 15:09:35 +0000 (08:09 -0700)] 
ci: really use shallow clones on Azure Pipelines

This was a left-over from the previous YAML schema, and it no longer
works. The problem was noticed while editing `azure-pipelines.yml` in VS
Code with the very helpful "Azure Pipelines" extension (syntax
highlighting and intellisense for `azure-pipelines.yml`...).

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agotests: let --immediate and --write-junit-xml play well together
Johannes Schindelin [Fri, 4 Oct 2019 15:09:34 +0000 (08:09 -0700)] 
tests: let --immediate and --write-junit-xml play well together

When the `--immediate` option is in effect, any test failure will
immediately exit the test script. Together with `--write-junit-xml`, we
will want the JUnit-style `.xml` file to be finalized (and not leave the
XML incomplete). Let's make it so.

This comes in particularly handy when trying to debug via Azure
Pipelines, where the JUnit-style XML is consumed to present the test
results in an informative and helpful way.

While at it, also handle the `error()` code path.

The only remaining code path that sets `GIT_EXIT_OK` happens whenever
the trash directory could not be set up, i.e. long before the JUnit XML
was written, therefore we should _not_ try to finalize that XML in that
case.

It is tempting to change the `immediate` code path to just hand off to
`error`, simplifying the code in the process. That would, however,
result in a change of behavior (an additional error message) in the test
suite, which is outside of the purview of the current patch series: its
goal is to allow building Git with Visual Studio and testing it with a
portable version of Git for Windows.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agotest-tool run-command: learn to run (parts of) the testsuite
Johannes Schindelin [Fri, 4 Oct 2019 15:09:33 +0000 (08:09 -0700)] 
test-tool run-command: learn to run (parts of) the testsuite

Git for Windows jumps through hoops to provide a development environment
that allows to build Git and to run its test suite. To that end, an
entire MSYS2 system, including GNU make and GCC is offered as "the Git
for Windows SDK". It does come at a price: an initial download of said
SDK weighs in with several hundreds of megabytes, and the unpacked SDK
occupies ~2GB of disk space.

A much more native development environment on Windows is Visual Studio.
To help contributors use that environment, we already have a Makefile
target `vcxproj` that generates a commit with project files (and other
generated files), and Git for Windows' `vs/master` branch is
continuously re-generated using that target.

The idea is to allow building Git in Visual Studio, and to run
individual tests using a Portable Git.

The one missing thing is a way to run the entire test suite: neither
`make` nor `prove` are required to run Git, therefore Git for Windows
does not support those commands in the Portable Git.

To help with that, add a simple test helper that exercises the
`run_processes_parallel()` function to allow for running test scripts in
parallel (which is really necessary, especially on Windows, as Git's
test suite takes such a long time to run).

This will also come in handy for the upcoming change to our Azure
Pipeline: we will use this helper in a Portable Git to test the Visual
Studio build of Git.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agovcxproj: include more generated files
Johannes Schindelin [Fri, 4 Oct 2019 15:09:32 +0000 (08:09 -0700)] 
vcxproj: include more generated files

In the CI builds, we bundle all generated files into a so-called
artifacts `.tar` file, so that the test phase can fan out into multiple
parallel builds.

This patch makes sure that all files are included in the `vcxproj`
target which are needed for that artifacts `.tar` file.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agovcxproj: only copy `git-remote-http.exe` once it was built
Johannes Schindelin [Fri, 4 Oct 2019 15:09:31 +0000 (08:09 -0700)] 
vcxproj: only copy `git-remote-http.exe` once it was built

In b18ae14a8f6 (vcxproj: also link-or-copy builtins, 2019-07-29), we
started to copy or hard-link the built-ins as a post-build step of the
`git` project.

At the same time, we tried to copy or hard-link `git-remote-http.exe`,
but it is quite possible that it was not built at that time.

Let's move that latter task into a post-install step of the
`git-remote-http` project instead.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agomsvc: work around a bug in GetEnvironmentVariable()
Johannes Schindelin [Fri, 4 Oct 2019 15:09:30 +0000 (08:09 -0700)] 
msvc: work around a bug in GetEnvironmentVariable()

The return value of that function is 0 both for variables that are
unset, as well as for variables whose values are empty. To discern those
two cases, one has to call `GetLastError()`, whose return value is
`ERROR_ENVVAR_NOT_FOUND` and `ERROR_SUCCESS`, respectively.

Except that it is not actually set to `ERROR_SUCCESS` in the latter
case, apparently, but the last error value seems to be simply unchanged.

To work around this, let's just re-set the last error value just before
inspecting the environment variable.

This fixes a problem that triggers failures in t3301-notes.sh (where we
try to override config settings by passing empty values for certain
environment variables).

This problem is hidden in the MINGW build by the fact that older
MSVC runtimes (such as the one used by MINGW builds) have a `calloc()`
that re-sets the last error value in case of success, while newer
runtimes set the error value only if `NULL` is returned by that
function.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agomsvc: handle DEVELOPER=1
Johannes Schindelin [Fri, 4 Oct 2019 15:09:30 +0000 (08:09 -0700)] 
msvc: handle DEVELOPER=1

We frequently build Git using the `DEVELOPER=1` make setting as a
shortcut to enable all kinds of more stringent compiler warnings.

Those compiler warnings are relatively specific to GCC, though, so let's
try our best to translate them to the equivalent options to pass to MS
Visual C++'s `cl.exe`.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agomsvc: ignore some libraries when linking
Johannes Schindelin [Fri, 4 Oct 2019 15:09:29 +0000 (08:09 -0700)] 
msvc: ignore some libraries when linking

To build with MSVC, we "translate" GCC options to MSVC options, and part
of those options refer to the libraries to link into the final
executable. Currently, this part looks somewhat like this on Windows:

-lcurl -lnghttp2 -lidn2 -lssl -lcrypto -lssl -lcrypto -lgdi32
-lcrypt32 -lwldap32 -lz -lws2_32 -lexpat

Some of those are direct dependencies (such as curl and ssl) and others
are indirect (nghttp2 and idn2, for example, are dependencies of curl,
but need to be linked in for reasons).

We already handle the direct dependencies, e.g. `-liconv` is already
handled as adding `libiconv.lib` to the list of libraries to link
against.

Let's just ignore the remaining `-l*` options so that MSVC does not have
to warn us that it ignored e.g. the `/lnghttp2` option. We do that by
extending the clause that already "eats" the `-R*` options to also eat
the `-l*` options.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agocompat/win32/path-utils.h: add #include guards
Johannes Schindelin [Fri, 4 Oct 2019 15:09:28 +0000 (08:09 -0700)] 
compat/win32/path-utils.h: add #include guards

This adds the common guards that allow headers to be #include'd multiple
times.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agowinansi: use FLEX_ARRAY to avoid compiler warning
Johannes Schindelin [Fri, 4 Oct 2019 15:09:27 +0000 (08:09 -0700)] 
winansi: use FLEX_ARRAY to avoid compiler warning

MSVC would complain thusly:

    C4200: nonstandard extension used: zero-sized array in struct/union

Let's just use the `FLEX_ARRAY` constant that we introduced for exactly
this type of scenario.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agomsvc: avoid using minus operator on unsigned types
Johannes Schindelin [Fri, 4 Oct 2019 15:09:26 +0000 (08:09 -0700)] 
msvc: avoid using minus operator on unsigned types

MSVC complains about this with `-Wall`, which can be taken as a sign
that this is indeed a real bug. The symptom is:

C4146: unary minus operator applied to unsigned type, result
still unsigned

Let's avoid this warning in the minimal way, e.g. writing `-1 -
<unsigned value>` instead of `-<unsigned value> - 1`.

Note that the change in the `estimate_cache_size()` function is
needed because MSVC considers the "return type" of the `sizeof()`
operator to be `size_t`, i.e. unsigned, and therefore it cannot be
negated using the unary minus operator.

Even worse, that arithmetic is doing extra work, in vain. We want to
calculate the entry extra cache size as the difference between the
size of the `cache_entry` structure minus the size of the
`ondisk_cache_entry` structure, padded to the appropriate alignment
boundary.

To that end, we start by assigning that difference to the `per_entry`
variable, and then abuse the `len` parameter of the
`align_padding_size()` macro to take the negative size of the ondisk
entry size. Essentially, we try to avoid passing the already calculated
difference to that macro by passing the operands of that difference
instead, when the macro expects operands of an addition:

#define align_padding_size(size, len) \
((size + (len) + 8) & ~7) - (size + len)

Currently, we pass A and -B to that macro instead of passing A - B and
0, where A - B is already stored in the `per_entry` variable, ready to
be used.

This is neither necessary, nor intuitive. Let's fix this, and have code
that is both easier to read and that also does not trigger MSVC's
warning.

While at it, we take care of reporting overflows (which are unlikely,
but hey, defensive programming is good!).

We _also_ take pains of casting the unsigned value to signed: otherwise,
the signed operand (i.e. the `-1`) would be cast to unsigned before
doing the arithmetic.

Helped-by: Denton Liu <liu.denton@gmail.com>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agostash apply: report status correctly even in a worktree's subdirectory
Johannes Schindelin [Fri, 4 Oct 2019 12:30:59 +0000 (05:30 -0700)] 
stash apply: report status correctly even in a worktree's subdirectory

When Git wants to spawn a child Git process inside a worktree's
subdirectory while `GIT_DIR` is set, we need to take care of specifying
the work tree's top-level directory explicitly because it cannot be
discovered: the current directory is _not_ the top-level directory of
the work tree, and neither is it inside the parent directory of
`GIT_DIR`.

This fixes the problem where `git stash apply` would report pretty much
everything deleted or untracked when run inside a worktree's
subdirectory.

To make sure that we do not introduce the "reverse problem", i.e. when
`GIT_WORK_TREE` is defined but `GIT_DIR` is not, we simply make sure
that both are set.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agofetch: let --jobs=<n> parallelize --multiple, too
Johannes Schindelin [Sat, 5 Oct 2019 18:46:40 +0000 (11:46 -0700)] 
fetch: let --jobs=<n> parallelize --multiple, too

So far, `--jobs=<n>` only parallelizes submodule fetches/clones, not
`--multiple` fetches, which is unintuitive, given that the option's name
does not say anything about submodules in particular.

Let's change that. With this patch, also fetches from multiple remotes
are parallelized.

For backwards-compatibility (and to prepare for a use case where
submodule and multiple-remote fetches may need different parallelization
limits), the config setting `submodule.fetchJobs` still only controls
the submodule part of `git fetch`, while the newly-introduced setting
`fetch.parallel` controls both (but can be overridden for submodules
with `submodule.fetchJobs`).

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agotrace2: write discard message to sentinel files
Josh Steadmon [Fri, 4 Oct 2019 22:08:21 +0000 (15:08 -0700)] 
trace2: write discard message to sentinel files

Add a new "discard" event type for trace2 event destinations. When the
trace2 file count check creates a sentinel file, it will include the
normal trace2 output in the sentinel, along with this new discard
event.

Writing this message into the sentinel file is useful for tracking how
often the file count check triggers in practice.

Bump up the event format version since we've added a new event type.

Signed-off-by: Josh Steadmon <steadmon@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agotrace2: discard new traces if target directory has too many files
Josh Steadmon [Fri, 4 Oct 2019 22:08:20 +0000 (15:08 -0700)] 
trace2: discard new traces if target directory has too many files

trace2 can write files into a target directory. With heavy usage, this
directory can fill up with files, causing difficulty for
trace-processing systems.

This patch adds a config option (trace2.maxFiles) to set a maximum
number of files that trace2 will write to a target directory. The
following behavior is enabled when the maxFiles is set to a positive
integer:
  When trace2 would write a file to a target directory, first check
  whether or not the traces should be discarded. Traces should be
  discarded if:
    * there is a sentinel file declaring that there are too many files
    * OR, the number of files exceeds trace2.maxFiles.
  In the latter case, we create a sentinel file named git-trace2-discard
  to speed up future checks.

The assumption is that a separate trace-processing system is dealing
with the generated traces; once it processes and removes the sentinel
file, it should be safe to generate new trace files again.

The default value for trace2.maxFiles is zero, which disables the file
count check.

The config can also be overridden with a new environment variable:
GIT_TRACE2_MAX_FILES.

Signed-off-by: Josh Steadmon <steadmon@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agot4214: demonstrate octopus graph coloring failure
Denton Liu [Fri, 4 Oct 2019 00:23:22 +0000 (17:23 -0700)] 
t4214: demonstrate octopus graph coloring failure

The graph coloring logic for octopus merges currently has a bug. This
can be seen git.git with 74c7cfa875 (Merge of
http://members.cox.net/junkio/git-jc.git, 2005-05-05), whose second
child is 211232bae6 (Octopus merge of the following five patches.,
2005-05-05).

If one runs

git log --graph 74c7cfa875

one can see that the octopus merge is colored incorrectly. In
particular, the horizontal dashes are off by one color. Each horizontal
dash should be the color of the line to their bottom-right. Instead, they
are currently the color of the line to their bottom.

Demonstrate this breakage with a few sets of test cases. These test
cases should show not only simple cases of the bug occuring but trickier
situations that may not be handled properly in any attempt to fix the
bug.

While we're at it, include a passing test case as a canary in case an
attempt to fix the bug breaks existing operation.

Signed-off-by: Denton Liu <liu.denton@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agot4214: explicitly list tags in log
Denton Liu [Fri, 4 Oct 2019 00:23:20 +0000 (17:23 -0700)] 
t4214: explicitly list tags in log

In a future test case, we will be extending the commit graph. As a
result, explicitly list the tags that will generate the graph so that
when future additions are made, the current graph illustrations won't be
affected.

Signed-off-by: Denton Liu <liu.denton@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agot4214: generate expect in their own test cases
Denton Liu [Fri, 4 Oct 2019 00:23:17 +0000 (17:23 -0700)] 
t4214: generate expect in their own test cases

Before, the expect files of the test case were being generated in the
setup method. However, it would make more sense to generate these files
within the test cases that actually use them so that it's obvious to
future readers where the expected values are coming from.

Move the generation of the expect files in their own respective test
cases.

While we're at it, we want to establish a pattern in this test suite
that, firstly, a non-colored test case is given then, immediately after,
the colored version is given.

Switch test cases "log --graph with tricky octopus merge, no color" and
"log --graph with tricky octopus merge with colors" so that the "no
color" version appears first.

This patch is best viewed with `--color-moved`.

Signed-off-by: Denton Liu <liu.denton@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agot4214: use test_merge
Denton Liu [Fri, 4 Oct 2019 00:23:15 +0000 (17:23 -0700)] 
t4214: use test_merge

In the previous commit, we extended test_merge() so that it could
perform octopus merges. Now that the restriction is lifted, use
test_merge() to perform the octopus merge instead of manually
duplicating test_merge() functionality.

Signed-off-by: Denton Liu <liu.denton@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agotest-lib: let test_merge() perform octopus merges
Denton Liu [Fri, 4 Oct 2019 00:23:13 +0000 (17:23 -0700)] 
test-lib: let test_merge() perform octopus merges

Currently test_merge() only allows developers to merge in one branch.
However, this restriction is artificial and there is no reason why it
needs to be this way.

Extend test_merge() to allow the specification of multiple branches so
that octopus merges can be performed.

Signed-off-by: Denton Liu <liu.denton@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>