]> git.ipfire.org Git - thirdparty/git.git/log
thirdparty/git.git
3 years agoMerge branch 'sg/tests-prereq'
Junio C Hamano [Wed, 25 Nov 2020 23:24:54 +0000 (15:24 -0800)] 
Merge branch 'sg/tests-prereq'

A lazily defined test prerequisite can now be defined in terms of
another lazily defined test prerequisite.

* sg/tests-prereq:
  tests: fix description of 'test_set_prereq'
  tests: make sure nested lazy prereqs work reliably

3 years agoMerge branch 'rs/plug-diff-cache-leak'
Junio C Hamano [Wed, 25 Nov 2020 23:24:53 +0000 (15:24 -0800)] 
Merge branch 'rs/plug-diff-cache-leak'

Memleak fix.

* rs/plug-diff-cache-leak:
  diff-lib: plug minor memory leaks in do_diff_cache()

3 years agoMerge branch 'rs/gc-sort-func-cast-fix'
Junio C Hamano [Wed, 25 Nov 2020 23:24:53 +0000 (15:24 -0800)] 
Merge branch 'rs/gc-sort-func-cast-fix'

Fix broken sorting of maintenance tasks.

* rs/gc-sort-func-cast-fix:
  gc: fix cast in compare_tasks_by_selection()

3 years agoMerge branch 'jc/ci-github-set-env'
Junio C Hamano [Wed, 25 Nov 2020 23:24:53 +0000 (15:24 -0800)] 
Merge branch 'jc/ci-github-set-env'

Another CI adjustment.

* jc/ci-github-set-env:
  ci: avoid `set-env` construct in print-test-failures.sh

3 years agoMerge branch 'sg/t5310-jgit-wants-sha1'
Junio C Hamano [Wed, 25 Nov 2020 23:24:53 +0000 (15:24 -0800)] 
Merge branch 'sg/t5310-jgit-wants-sha1'

Since jgit does not yet work with SHA-256 repositories, mark the
tests that uses it not to run unless we are testing with ShA-1
repositories.

* sg/t5310-jgit-wants-sha1:
  t5310-pack-bitmaps: skip JGit tests with SHA256

3 years agoMerge branch 'rs/archive-plug-leak-refname'
Junio C Hamano [Wed, 25 Nov 2020 23:24:53 +0000 (15:24 -0800)] 
Merge branch 'rs/archive-plug-leak-refname'

Memleak fix.

* rs/archive-plug-leak-refname:
  archive: release refname after use

3 years agoMerge branch 'ma/list-object-filter-opt-msgfix'
Junio C Hamano [Wed, 25 Nov 2020 23:24:52 +0000 (15:24 -0800)] 
Merge branch 'ma/list-object-filter-opt-msgfix'

Error message fix.

* ma/list-object-filter-opt-msgfix:
  list-objects-filter-options: fix function name in BUG

3 years agoMerge branch 'pk/subsub-fetch-fix'
Junio C Hamano [Wed, 25 Nov 2020 23:24:52 +0000 (15:24 -0800)] 
Merge branch 'pk/subsub-fetch-fix'

"git fetch" did not work correctly with nested submodules where the
innermost submodule that is not of interest got updated in the
upstream, which has been corrected.

* pk/subsub-fetch-fix:
  submodules: fix of regression on fetching of non-init subsub-repo

3 years agoMerge branch 'jk/4gb-idx'
Junio C Hamano [Wed, 25 Nov 2020 23:24:52 +0000 (15:24 -0800)] 
Merge branch 'jk/4gb-idx'

The code was not prepared to deal with pack .idx file that is
larger than 4GB.

* jk/4gb-idx:
  packfile: detect overflow in .idx file size checks
  block-sha1: take a size_t length parameter
  fsck: correctly compute checksums on idx files larger than 4GB
  use size_t to store pack .idx byte offsets
  compute pack .idx byte offsets using size_t

3 years agoMerge branch 'jx/t5411-flake-fix'
Junio C Hamano [Wed, 25 Nov 2020 23:24:52 +0000 (15:24 -0800)] 
Merge branch 'jx/t5411-flake-fix'

The exchange between receive-pack and proc-receive hook did not
carefully check for errors.

* jx/t5411-flake-fix:
  receive-pack: use default version 0 for proc-receive
  receive-pack: gently write messages to proc-receive
  t5411: new helper filter_out_user_friendly_and_stable_output

3 years agoMerge branch 'rs/hashwrite-be64'
Junio C Hamano [Wed, 25 Nov 2020 23:24:52 +0000 (15:24 -0800)] 
Merge branch 'rs/hashwrite-be64'

Code simplification.

* rs/hashwrite-be64:
  pack-write: use hashwrite_be64()
  midx: use hashwrite_be64()
  csum-file: add hashwrite_be64()

3 years agoMerge branch 'sg/bisect-approximately-halfway'
Junio C Hamano [Wed, 25 Nov 2020 23:24:52 +0000 (15:24 -0800)] 
Merge branch 'sg/bisect-approximately-halfway'

"git bisect start/next" in a large span of history spends a lot of
time trying to come up with exactly the half-way point; this can be
optimized by stopping when we see a commit that is close enough to
the half-way point.

* sg/bisect-approximately-halfway:
  bisect: loosen halfway() check for a large number of commits

3 years agoMerge branch 'fc/bash-completion-alias-of-alias'
Junio C Hamano [Wed, 25 Nov 2020 23:24:51 +0000 (15:24 -0800)] 
Merge branch 'fc/bash-completion-alias-of-alias'

The command line completion script (in contrib/) learned to expand
commands that are alias of alias.

* fc/bash-completion-alias-of-alias:
  completion: bash: improve alias loop detection
  completion: bash: check for alias loop
  completion: bash: support recursive aliases

3 years agoSeventh batch
Junio C Hamano [Sat, 21 Nov 2020 23:12:41 +0000 (15:12 -0800)] 
Seventh batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoMerge branch 'pd/mergetool-nvimdiff'
Junio C Hamano [Sat, 21 Nov 2020 23:14:39 +0000 (15:14 -0800)] 
Merge branch 'pd/mergetool-nvimdiff'

Fix regression introduced when nvimdiff support in mergetool was added.

* pd/mergetool-nvimdiff:
  mergetool: avoid letting `list_tool_variants` break user-defined setups
  mergetools/bc: add `bc4` to the alias list for Beyond Compare

3 years agoMerge branch 'ab/config-mak-uname-simplify'
Junio C Hamano [Sat, 21 Nov 2020 23:14:38 +0000 (15:14 -0800)] 
Merge branch 'ab/config-mak-uname-simplify'

Build configuration cleanup.

* ab/config-mak-uname-simplify:
  config.mak.uname: remove unused NEEDS_SSL_WITH_CURL flag
  config.mak.uname: remove unused the NO_R_TO_GCC_LINKER flag

3 years agoMerge branch 'en/strmap'
Junio C Hamano [Sat, 21 Nov 2020 23:14:38 +0000 (15:14 -0800)] 
Merge branch 'en/strmap'

A specialization of hashmap that uses a string as key has been
introduced.  Hopefully it will see wider use over time.

* en/strmap:
  shortlog: use strset from strmap.h
  Use new HASHMAP_INIT macro to simplify hashmap initialization
  strmap: take advantage of FLEXPTR_ALLOC_STR when relevant
  strmap: enable allocations to come from a mem_pool
  strmap: add a strset sub-type
  strmap: split create_entry() out of strmap_put()
  strmap: add functions facilitating use as a string->int map
  strmap: enable faster clearing and reusing of strmaps
  strmap: add more utility functions
  strmap: new utility functions
  hashmap: provide deallocation function names
  hashmap: introduce a new hashmap_partial_clear()
  hashmap: allow re-use after hashmap_free()
  hashmap: adjust spacing to fix argument alignment
  hashmap: add usage documentation explaining hashmap_free[_entries]()

3 years agoMerge branch 'jk/diff-release-filespec-fix'
Junio C Hamano [Sat, 21 Nov 2020 23:14:38 +0000 (15:14 -0800)] 
Merge branch 'jk/diff-release-filespec-fix'

Running "git diff" while allowing external diff in a state with
unmerged paths used to segfault, which has been corrected.

* jk/diff-release-filespec-fix:
  t7800: simplify difftool test
  diff: allow passing NULL to diff_free_filespec_data()

3 years agoMerge branch 'jk/rev-parse-end-of-options'
Junio C Hamano [Sat, 21 Nov 2020 23:14:38 +0000 (15:14 -0800)] 
Merge branch 'jk/rev-parse-end-of-options'

"git rev-parse" learned the "--end-of-options" to help scripts to
safely take a parameter that is supposed to be a revision, e.g.
"git rev-parse --verify -q --end-of-options $rev".

* jk/rev-parse-end-of-options:
  rev-parse: handle --end-of-options
  rev-parse: put all options under the "-" check
  rev-parse: don't accept options after dashdash

3 years agoMerge branch 'jc/format-patch-name-max'
Junio C Hamano [Sat, 21 Nov 2020 23:14:38 +0000 (15:14 -0800)] 
Merge branch 'jc/format-patch-name-max'

The maximum length of output filenames "git format-patch" creates
has become configurable (used to be capped at 64).

* jc/format-patch-name-max:
  format-patch: make output filename configurable

3 years agogc: fix cast in compare_tasks_by_selection()
René Scharfe [Tue, 17 Nov 2020 21:59:49 +0000 (22:59 +0100)] 
gc: fix cast in compare_tasks_by_selection()

compare_tasks_by_selection() is used with QSORT and gets passed pointers
to the elements of "static struct maintenance_task tasks[]".  It casts
the *addresses* of these passed pointers to element pointers, though,
and thus effectively compares some unrelated values from the stack.  Fix
the casts to actually compare array elements.

Detected by USan (make SANITIZE=undefined test).

Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoSixth batch
Junio C Hamano [Wed, 18 Nov 2020 21:33:25 +0000 (13:33 -0800)] 
Sixth batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoMerge branch 'jc/blame-ignore-fix'
Junio C Hamano [Wed, 18 Nov 2020 21:32:54 +0000 (13:32 -0800)] 
Merge branch 'jc/blame-ignore-fix'

"git blame --ignore-revs-file=<file>" learned to ignore a
non-existent object name in the input, instead of complaining.

* jc/blame-ignore-fix:
  blame: silently ignore invalid ignore file objects

3 years agoMerge branch 'jc/sparse-error-for-developer-build'
Junio C Hamano [Wed, 18 Nov 2020 21:32:53 +0000 (13:32 -0800)] 
Merge branch 'jc/sparse-error-for-developer-build'

"make DEVELOPER=1 sparse" used to run sparse and let it emit
warnings; now such warnings will cause an error.

* jc/sparse-error-for-developer-build:
  Makefile: enable -Wsparse-error for DEVELOPER build

3 years agoMerge branch 'pb/blame-funcname-range-userdiff'
Junio C Hamano [Wed, 18 Nov 2020 21:32:53 +0000 (13:32 -0800)] 
Merge branch 'pb/blame-funcname-range-userdiff'

"git blame -L :funcname -- path" did not work well for a path for
which a userdiff driver is defined.

* pb/blame-funcname-range-userdiff:
  blame: simplify 'setup_blame_bloom_data' interface
  blame: simplify 'setup_scoreboard' interface
  blame: enable funcname blaming with userdiff driver
  line-log: mention both modes in 'blame' and 'log' short help
  doc: add more pointers to gitattributes(5) for userdiff
  blame-options.txt: also mention 'funcname' in '-L' description
  doc: line-range: improve formatting
  doc: log, gitk: move '-L' description to 'line-range-options.txt'

3 years agoMerge branch 'en/merge-ort-api-null-impl'
Junio C Hamano [Wed, 18 Nov 2020 21:32:53 +0000 (13:32 -0800)] 
Merge branch 'en/merge-ort-api-null-impl'

Preparation for a new merge strategy.

* en/merge-ort-api-null-impl:
  merge,rebase,revert: select ort or recursive by config or environment
  fast-rebase: demonstrate merge-ort's API via new test-tool command
  merge-ort-wrappers: new convience wrappers to mimic the old merge API
  merge-ort: barebones API of new merge strategy with empty implementation

3 years agoMerge branch 'ds/maintenance-part-3'
Junio C Hamano [Wed, 18 Nov 2020 21:32:53 +0000 (13:32 -0800)] 
Merge branch 'ds/maintenance-part-3'

Parts of "git maintenance" to ease writing crontab entries (and
other scheduling system configuration) for it.

* ds/maintenance-part-3:
  maintenance: add troubleshooting guide to docs
  maintenance: use 'incremental' strategy by default
  maintenance: create maintenance.strategy config
  maintenance: add start/stop subcommands
  maintenance: add [un]register subcommands
  for-each-repo: run subcommands on configured repos
  maintenance: add --schedule option and config
  maintenance: optionally skip --auto process

3 years agoMerge branch 'pw/rebase-i-orig-head'
Junio C Hamano [Wed, 18 Nov 2020 21:32:53 +0000 (13:32 -0800)] 
Merge branch 'pw/rebase-i-orig-head'

"git rebase -i" did not store ORIG_HEAD correctly.

* pw/rebase-i-orig-head:
  rebase -i: simplify get_revision_ranges()
  rebase -i: use struct object_id when writing state
  rebase -i: use struct object_id rather than looking up commit
  rebase -i: stop overwriting ORIG_HEAD buffer

3 years agoMerge branch 'rs/archive-high-compression'
Junio C Hamano [Wed, 18 Nov 2020 21:32:52 +0000 (13:32 -0800)] 
Merge branch 'rs/archive-high-compression'

"git archive" now allows compression level higher than "-9"
when generating tar.gz output.

* rs/archive-high-compression:
  archive: support compression levels beyond 9

3 years agoMerge branch 'dg/bswap-msvc'
Junio C Hamano [Wed, 18 Nov 2020 21:32:52 +0000 (13:32 -0800)] 
Merge branch 'dg/bswap-msvc'

Define ARM64 compiled with MSVC to be little-endian.

* dg/bswap-msvc:
  compat/bswap.h: don't assume MSVC is little-endian
  compat/bswap.h: simplify MSVC endianness detection

3 years agoMerge branch 'jk/format-patch-output'
Junio C Hamano [Wed, 18 Nov 2020 21:32:52 +0000 (13:32 -0800)] 
Merge branch 'jk/format-patch-output'

"git format-patch --output=there" did not work as expected and
instead crashed.  The option is now supported.

* jk/format-patch-output:
  format-patch: support --output option
  format-patch: tie file-opening logic to output_directory
  format-patch: refactor output selection

3 years agoMerge branch 'jc/line-log-takes-no-pathspec'
Junio C Hamano [Wed, 18 Nov 2020 21:32:52 +0000 (13:32 -0800)] 
Merge branch 'jc/line-log-takes-no-pathspec'

"git log -L<range>:<path>" is documented to take no pathspec, but
this was not enforced by the command line option parser, which has
been corrected.

* jc/line-log-takes-no-pathspec:
  log: diagnose -L used with pathspec as an error

3 years agoMerge branch 'rs/empty-reflog-check-fix'
Junio C Hamano [Wed, 18 Nov 2020 21:32:52 +0000 (13:32 -0800)] 
Merge branch 'rs/empty-reflog-check-fix'

The code to see if "git stash drop" can safely remove refs/stash
has been made more carerful.

* rs/empty-reflog-check-fix:
  stash: simplify reflog emptiness check

3 years agoMerge branch 'nk/perf-fsmonitor'
Junio C Hamano [Wed, 18 Nov 2020 21:32:52 +0000 (13:32 -0800)] 
Merge branch 'nk/perf-fsmonitor'

Add t/perf support for fsmonitor.

* nk/perf-fsmonitor:
  t/perf/fsmonitor: add benchmark for dirty status
  t/perf/fsmonitor: perf comparison of multiple fsmonitor integrations
  t/perf/fsmonitor: initialize test with git reset
  t/perf/fsmonitor: factor setup for fsmonitor into function
  t/perf/fsmonitor: silence initial git commit
  t/perf/fsmonitor: shorten DESC to basename
  t/perf/fsmonitor: factor description out for readability
  t/perf/fsmonitor: improve error message if typoing hook name
  t/perf/fsmonitor: move watchman setup to one-time-repo-setup
  t/perf/fsmonitor: separate one time repo initialization

3 years agoMerge branch 'en/merge-tests'
Junio C Hamano [Wed, 18 Nov 2020 21:32:52 +0000 (13:32 -0800)] 
Merge branch 'en/merge-tests'

Preparation for a new merge strategy.

* en/merge-tests:
  t6423: add more details about direct resolution of directories
  t6423: note improved ort handling with untracked files
  t6423, t6436: note improved ort handling with dirty files
  merge tests: expect slight differences in output for recursive vs. ort
  t6423: expect improved conflict markers labels in the ort backend
  t6404, t6423: expect improved rename/delete handling in ort backend
  t6416: correct expectation for rename/rename(1to2) + directory/file
  merge tests: expect improved directory/file conflict handling in ort
  t/: new helper for tests that pass with ort but fail with recursive

3 years agoMerge branch 'js/default-branch-name-adjust-t5515'
Junio C Hamano [Wed, 18 Nov 2020 21:32:51 +0000 (13:32 -0800)] 
Merge branch 'js/default-branch-name-adjust-t5515'

Prepare a test script to transition of the default branch name to
'main'.

* js/default-branch-name-adjust-t5515:
  t5515: use `main` as the name of the main branch for testing (conclusion)
  t5515: use `main` as the name of the main branch for testing (part 3)
  t5515: use `main` as the name of the main branch for testing (part 2)
  t5515: use `main` as the name of the main branch for testing (part 1)

3 years agoMerge branch 'dd/upload-pack-stateless-eof'
Junio C Hamano [Wed, 18 Nov 2020 21:32:51 +0000 (13:32 -0800)] 
Merge branch 'dd/upload-pack-stateless-eof'

"git fetch --depth=<n>" over the stateless RPC / smart HTTP
transport handled EOF from the client poorly at the server end.

* dd/upload-pack-stateless-eof:
  upload-pack: allow stateless client EOF just prior to haves

3 years agotests: fix description of 'test_set_prereq'
SZEDER Gábor [Wed, 18 Nov 2020 19:04:14 +0000 (20:04 +0100)] 
tests: fix description of 'test_set_prereq'

'test_set_prereq's description claims that prereqs can be specified to
'test_expect_code', but that is not the case (it is not meant to run a
test _case_, but a git command), so remove it.

OTOH that description doesn't mention 'test_external' and
'test_external_without_stderr' that do accept prereqs, so mention
them.

Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agotests: make sure nested lazy prereqs work reliably
SZEDER Gábor [Wed, 18 Nov 2020 19:04:13 +0000 (20:04 +0100)] 
tests: make sure nested lazy prereqs work reliably

Some test prereqs depend on other prereqs, so in a couple of cases we
have nested prereqs that look something like this:

  test_lazy_prereq FOO '
      test_have_prereq BAR &&
      check-foo
  '

This can be problematic, because lazy prereqs are evaluated in the
'$TRASH_DIRECTORY/prereq-test-dir' directory, which is the same for
every prereq, and which is automatically removed after the prereq has
been evaluated.  So if the inner prereq (BAR above) is a lazy prereq
that hasn't been evaluated yet, then after its evaluation the
'prereq-test-dir' shared with the outer prereq will be removed.
Consequently, 'check-foo' will find itself in a non-existing
directory, and won't be able to create/access any files in its cwd,
which could result in an unfulfilled outer prereq.

Luckily, this doesn't affect any of our current nested prereqs, either
because the inner prereq is not a lazy prereq (e.g. MINGW, CYGWIN or
PERL), or because the outer prereq happens to be checked without
touching any paths in its cwd (GPGSM and RFC1991 in 'lib-gpg.sh').

So to prevent nested prereqs from interfering with each other let's
evaluate each prereq in its own dedicated directory by appending the
prereq's name to the directory name, e.g. 'prereq-test-dir-SYMLINKS'.
In the test we check not only that the prereq test dir is still there,
but also that the inner prereq can't mess with the outer prereq's
files.

Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoci: avoid `set-env` construct in print-test-failures.sh
Junio C Hamano [Tue, 17 Nov 2020 20:10:35 +0000 (12:10 -0800)] 
ci: avoid `set-env` construct in print-test-failures.sh

Imitating cac42e47 (ci: avoid using the deprecated `set-env`
construct, 2020-11-07), avoid deprecated ::set-env and use the
recommended alternative instead in print-test-failures.sh

Helped-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agocompletion: bash: improve alias loop detection
Felipe Contreras [Thu, 12 Nov 2020 22:34:52 +0000 (16:34 -0600)] 
completion: bash: improve alias loop detection

It is possible for the name of an alias to end with the name of another
alias, in which case the code will incorrectly detect a loop.

We can fix that by adding an extra space between words.

Suggested-by: SZEDER Gábor <szeder.dev@gmail.com>
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agolist-objects-filter-options: fix function name in BUG
Martin Ågren [Sat, 14 Nov 2020 08:43:26 +0000 (09:43 +0100)] 
list-objects-filter-options: fix function name in BUG

Fix the function name we give in the BUG message. It's "config", not
"choice".

Signed-off-by: Martin Ågren <martin.agren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoarchive: release refname after use
René Scharfe [Sat, 14 Nov 2020 22:01:04 +0000 (23:01 +0100)] 
archive: release refname after use

parse_treeish_arg() uses dwim_ref() to set refname to a strdup'd string.
Release it after use.  Also remove the const qualifier from the refname
member to signify that ownership of the string is handed to the struct,
leaving cleanup duty with the caller of parse_treeish_arg(), thus
avoiding a cast.

Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agodiff-lib: plug minor memory leaks in do_diff_cache()
René Scharfe [Sat, 14 Nov 2020 18:37:03 +0000 (19:37 +0100)] 
diff-lib: plug minor memory leaks in do_diff_cache()

do_diff_cache() builds a struct rev_info to hand to diff_cache() from
scratch by initializing it using repo_init_revisions() and then
replacing its diffopt and prune_data members.

The diffopt member is initialized to a heap-allocated list of options,
though.  Release it using diff_setup_done() before overwriting it.

The initial value of the prune_data member doesn't need to be released,
but the copy created using copy_pathspec() does.  Clear it after use.

Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agopackfile: detect overflow in .idx file size checks
Jeff King [Fri, 13 Nov 2020 05:07:19 +0000 (00:07 -0500)] 
packfile: detect overflow in .idx file size checks

In load_idx(), we check that the .idx file is sized appropriately for
the number of objects it claims to have. We recently fixed the case
where the number of objects caused our expected size to overflow a
32-bit unsigned int, and we switched to size_t.

On a 64-bit system, this is fine; our size_t covers any expected size.
On a 32-bit system, though, it won't. The file may claim to have 2^31
objects, which will overflow even a size_t.

This doesn't hurt us at all for a well-formed idx file. A 32-bit system
would already have failed to mmap such a file, since it would be too
big. But an .idx file which _claims_ to have 2^31 objects but is
actually much smaller would fool our check.

This is a broken file, and for the most part we don't care that much
what happens. But:

  - it's a little friendlier to notice up front "woah, this file is
    broken" than it is to get nonsense results

  - later access of the data assumes that the loading function
    sanity-checked that we have at least enough bytes for the regular
    object-id table. A malformed .idx file could lead to an
    out-of-bounds read.

So let's use our overflow-checking functions to make sure that we're not
fooled by a malformed file.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoblock-sha1: take a size_t length parameter
Jeff King [Fri, 13 Nov 2020 05:07:17 +0000 (00:07 -0500)] 
block-sha1: take a size_t length parameter

The block-sha1 implementation takes an "unsigned long" for the length of
a buffer to hash, but our hash algorithm wrappers take a size_t, as do
other implementations we support like openssl or sha1dc. On many
systems, including Linux, these two are equivalent, but they are not on
Windows (where only a "long long" is 64 bits). As a result, passing
large chunks to a single the_hash_algo->update_fn() would produce wrong
answers there.

Note that we don't need to update any other sizes outside of the
function interface. We store the cumulative size in a "long long" (which
we must do since we hash things bigger than 4GB, like packfiles, even on
32-bit platforms). And internally, we break that size_t len down into
64-byte blocks to feed into the guts of the algorithm.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agofsck: correctly compute checksums on idx files larger than 4GB
Jeff King [Fri, 13 Nov 2020 05:07:14 +0000 (00:07 -0500)] 
fsck: correctly compute checksums on idx files larger than 4GB

When checking the trailing checksum hash of a .idx file, we pass the
whole buffer (minus the trailing hash) into a single call to
the_hash_algo->update_fn(). But we cast it to an "unsigned int". This
comes from c4001d92be (Use off_t when we really mean a file offset.,
2007-03-06). That commit started storing the index_size variable as an
off_t, but our mozilla-sha1 implementation from the time was limited to
a smaller size. Presumably the cast was a way of annotating that we
expected .idx files to be small, and so we didn't need to loop (as we do
for arbitrarily-large .pack files). Though as an aside it was still
wrong, because the mozilla function actually took a signed int.

These days our hash-update functions are defined to take a size_t, so we
can pass the whole buffer in directly. The cast is actually causing a
buggy truncation!

While we're here, though, let's drop the confusing off_t variable in the
first place. We're getting the size not from the filesystem anyway, but
from p->index_size, which is a size_t. In fact, we can make the code a
bit more readable by dropping our local variable duplicating
p->index_size, and instead have one that stores the size of the actual
index data, minus the trailing hash.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agouse size_t to store pack .idx byte offsets
Jeff King [Fri, 13 Nov 2020 05:07:01 +0000 (00:07 -0500)] 
use size_t to store pack .idx byte offsets

We sometimes store the offset into a pack .idx file as an "unsigned
long", but the mmap'd size of a pack .idx file can exceed 4GB. This is
sufficient on LP64 systems like Linux, but will be too small on LLP64
systems like Windows, where "unsigned long" is still only 32 bits. Let's
use size_t, which is a better type for an offset into a memory buffer.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agocompute pack .idx byte offsets using size_t
Jeff King [Fri, 13 Nov 2020 05:06:48 +0000 (00:06 -0500)] 
compute pack .idx byte offsets using size_t

A pack and its matching .idx file are limited to 2^32 objects, because
the pack format contains a 32-bit field to store the number of objects.
Hence we use uint32_t in the code.

But the byte count of even a .idx file can be much larger than that,
because it stores at least a hash and an offset for each object. So
using SHA-1, a v2 .idx file will cross the 4GB boundary at 153,391,650
objects. This confuses load_idx(), which computes the minimum size like
this:

  unsigned long min_size = 8 + 4*256 + nr*(hashsz + 4 + 4) + hashsz + hashsz;

Even though min_size will be big enough on most 64-bit platforms, the
actual arithmetic is done as a uint32_t, resulting in a truncation. We
actually exceed that min_size, but then we do:

  unsigned long max_size = min_size;
  if (nr)
          max_size += (nr - 1)*8;

to account for the variable-sized table. That computation doesn't
overflow quite so low, but with the truncation for min_size, we end up
with a max_size that is much smaller than our actual size. So we
complain that the idx is invalid, and can't find any of its objects.

We can fix this case by casting "nr" to a size_t, which will do the
multiplication in 64-bits (assuming you're on a 64-bit platform; this
will never work on a 32-bit system since we couldn't map the whole .idx
anyway). Likewise, we don't have to worry about further additions,
because adding a smaller number to a size_t will convert the other side
to a size_t.

A few notes:

  - obviously we could just declare "nr" as a size_t in the first place
    (and likewise, packed_git.num_objects).  But it's conceptually a
    uint32_t because of the on-disk format, and we correctly treat it
    that way in other contexts that don't need to compute byte offsets
    (e.g., iterating over the set of objects should and generally does
    use a uint32_t). Switching to size_t would make all of those other
    cases look wrong.

  - it could be argued that the proper type is off_t to represent the
    file offset. But in practice the .idx file must fit within memory,
    because we mmap the whole thing. And the rest of the code (including
    the idx_size variable we're comparing against) uses size_t.

  - we'll add the same cast to the max_size arithmetic line. Even though
    we're adding to a larger type, which will convert our result, the
    multiplication is still done as a 32-bit value and can itself
    overflow. I didn't check this with my test case, since it would need
    an even larger pack (~530M objects), but looking at compiler output
    shows that it works this way. The standard should agree, but I
    couldn't find anything explicit in 6.3.1.8 ("usual arithmetic
    conversions").

The case in load_idx() was the most immediate one that I was able to
trigger. After fixing it, looking up actual objects (including the very
last one in sha1 order) works in a test repo with 153,725,110 objects.
That's because bsearch_hash() works with uint32_t entry indices, and the
actual byte access:

  int cmp = hashcmp(table + mi * stride, sha1);

is done with "stride" as a size_t, causing the uint32_t "mi" to be
promoted to a size_t. This is the way most code will access the index
data.

However, I audited all of the other byte-wise accesses of
packed_git.index_data, and many of the others are suspect (they are
similar to the max_size one, where we are adding to a properly sized
offset or directly to a pointer, but the multiplication in the
sub-expression can overflow). I didn't trigger any of these in practice,
but I believe they're potential problems, and certainly adding in the
cast is not going to hurt anything here.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agot5310-pack-bitmaps: skip JGit tests with SHA256
SZEDER Gábor [Fri, 13 Nov 2020 21:53:07 +0000 (22:53 +0100)] 
t5310-pack-bitmaps: skip JGit tests with SHA256

In 't5310-pack-bitmaps.sh' two tests make sure that our pack bitmaps
are compatible with JGit's bitmaps.  Alas, not even the most recent
JGit version (5.9.0.202009080501-r) supports SHA256 yet, so when this
test script is run with GIT_TEST_DEFAULT_HASH=sha256 on a setup with
JGit installed in PATH, then these two tests fail.

Protect these two tests with the SHA1 prereq in order to skip them
when testing with SHA256.

Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
Reviewed-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agosubmodules: fix of regression on fetching of non-init subsub-repo
Peter Kaestle [Thu, 12 Nov 2020 16:00:53 +0000 (17:00 +0100)] 
submodules: fix of regression on fetching of non-init subsub-repo

A regression has been introduced by a62387b (submodule.c: fetch in
submodules git directory instead of in worktree, 2018-11-28).

The scenario in which it triggers is when one has a remote repository
with a subrepository inside a subrepository like this:
superproject/middle_repo/inner_repo

Person A and B have both a clone of it, while Person B is not working
with the inner_repo and thus does not have it initialized in his working
copy.

Now person A introduces a change to the inner_repo and propagates it
through the middle_repo and the superproject.

Once person A pushed the changes and person B wants to fetch them using
"git fetch" on superproject level, B's git call will return with error
saying:

Could not access submodule 'inner_repo'
Errors during submodule fetch:
         middle_repo

Expectation is that in this case the inner submodule will be recognized
as uninitialized subrepository and skipped by the git fetch command.

This used to work correctly before 'a62387b (submodule.c: fetch in
submodules git directory instead of in worktree, 2018-11-28)'.

Starting with a62387b the code wants to evaluate "is_empty_dir()" inside
.git/modules for a directory only existing in the worktree, delivering
then of course wrong return value.

This patch reverts the changes of a62387b and introduces a regression
test.

Signed-off-by: Peter Kaestle <peter.kaestle@nokia.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agopack-write: use hashwrite_be64()
René Scharfe [Thu, 12 Nov 2020 12:23:10 +0000 (13:23 +0100)] 
pack-write: use hashwrite_be64()

Call hashwrite_be64() to write a 64-bit value instead of open-coding it
using htonl() and hashwrite().  This shortens the code, gets rid of a
buffer and several magic numbers, and makes the intent clearer.

Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agomidx: use hashwrite_be64()
René Scharfe [Thu, 12 Nov 2020 12:22:16 +0000 (13:22 +0100)] 
midx: use hashwrite_be64()

Call hashwrite_be64() to write 64-bit values instead of open-coding it
using hashwrite_be32() and sizeof.  This shortens the code and makes its
intent clearer.

Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agocsum-file: add hashwrite_be64()
René Scharfe [Thu, 12 Nov 2020 12:20:19 +0000 (13:20 +0100)] 
csum-file: add hashwrite_be64()

Add a helper function for hashing and writing 64-bit integers in network
byte order.  It returns the number of written bytes.  This simplifies
callers that keep track of the file offset, even though this number is a
constant.

Suggested-by: Derrick Stolee <dstolee@microsoft.com>
Original-patch-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agobisect: loosen halfway() check for a large number of commits
SZEDER Gábor [Thu, 12 Nov 2020 16:19:38 +0000 (17:19 +0100)] 
bisect: loosen halfway() check for a large number of commits

'git bisect start ...' and subsequent 'git bisect (good|bad)' commands
can take quite a while when the given/remaining revision range between
good and bad commits is big and contains a lot of merge commits, e.g.
in git.git:

  $ git rev-list --count v1.6.0..v2.28.0
  44284
  $ time git bisect start v2.28.0 v1.6.0
  Bisecting: 22141 revisions left to test after this (roughly 15 steps)
  [e197c21807dacadc8305250baa0b9228819189d4] unable_to_lock_die(): rename function from unable_to_lock_index_die()

  real    0m15.472s
  user    0m15.220s
  sys     0m0.255s

The majority of the runtime is spent in do_find_bisection(), where we
try to find a commit as close as possible to the halfway point between
the bad and good revisions, i.e. a commit from which the number of
reachable commits that are in the good-bad range is half the total
number of commits in that range.  So we count how many commits are
reachable in the good-bad range for each commit in that range, which
is quick and easy for a linear history, even over 300k commits in a
linear range are handled in ~0.3s on my machine.  Alas, handling merge
commits is non-trivial and quite expensive as the algorithm used seems
to be quadratic, causing the long runtime shown above.

Interestingly, look at what a big difference one additional commit
can make:

  $ git rev-list --count v1.6.0^..v2.28.0
  44285
  $ time git bisect start v2.28.0 v1.6.0^
  Bisecting: 22142 revisions left to test after this (roughly 15 steps)
  [565301e41670825ceedf75220f2918ae76831240] Sync with 2.1.2

  real  0m5.848s
  user  0m5.600s
  sys   0m0.252s

The difference is caused by one of the optimizations attempting to cut
down the runtime added in 1c4fea3a40 (git-rev-list --bisect:
optimization, 2007-03-21):

    Another small optimization is whenever we find a half-way commit
    (that is, a commit that can reach exactly half of the commits),
    we stop giving counts to remaining commits, as we will not find
    any better commit than we just found.

In this second 'git bisect start' command we happen to find a commit
exactly at the halfway point and can return early, but in the first
case there is no such commit, so we can't return early and end up
counting the number of reachable commits from all commits in the
good-bad range.

However, when we have thousands of commits it's not all that important
to find the _exact_ halfway point, a few commits more or less doesn't
make any real difference for the bisection.

So let's loosen the check in the halfway() helper to consider commits
within about 0.1% of the exact halfway point as halfway as well, and
rename the function to approx_halfway() accordingly.  This will allow
us to return early on a bigger good-bad range, even when there is no
commit exactly at the halfway point, thereby reducing the runtime of
the first command above considerably, from ~15s to 4.901s.
Furthermore, even if there is a commit exactly at the halfway point,
we might still stumble upon a commit within that 0.1% range before
finding the exact halfway point, allowing us to return a bit earlier,
slightly reducing the runtime of the second command from 5.848s to
5.058s.  Note that this change doesn't affect good-bad ranges
containing ~2000 commits or less, because that 0.1% tolerance becomes
zero due to integer arithmetic; however, if the range is that small
then counting the reachable commits for all commits is already fast
enough anyway.

Naturally, this will likely change which commits get picked at each
bisection step, and, in turn, might change how many bisection steps
are necessary to find the first bad commit.  If the number of
necessary bisection steps were to increase often, then this change
could backfire, because building and testing at each step might take
much longer than the time spared.  OTOH, if the number of steps were
to decrease, then it would be a double win.

So I ran some tests to see how often that happens: picked random good
and bad starting revisions at least 50k commits apart and a random
first bad commit in between in git.git, and used 'git bisect run git
merge-base --is-ancestor HEAD $first_bad_commit' to check the number
of necessary bisection steps.  After repeating all this 1000 times
both with and without this patch I found that:

  - 146 cases needed one more bisection step than before, 149 cases
    needed one less step, while in the remaining 705 cases the number
    of steps didn't change.  So the number of bisection steps does
    indeed change in a non-negligible number of cases, but it seems
    that the average number of steps doesn't change in the long run.

  - The first 'git bisect start' command got over 3x faster in 456
    cases, so this "no commit at the exact halfway point" case seems
    to be common enough to care about.

Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoFifth batch
Junio C Hamano [Wed, 11 Nov 2020 21:16:45 +0000 (13:16 -0800)] 
Fifth batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoMerge branch 'jc/sequencer-stopped-sha-simplify'
Junio C Hamano [Wed, 11 Nov 2020 21:18:39 +0000 (13:18 -0800)] 
Merge branch 'jc/sequencer-stopped-sha-simplify'

Recently the format of an internal state file "rebase -i" uses has
been tightened up for consistency, which would hurt those who start
"rebase -i" with old git and then continue with new git.  Loosen
the reader side a bit (which we may want to tighten again in a year
or so).

* jc/sequencer-stopped-sha-simplify:
  sequencer: tolerate abbreviated stopped-sha file

3 years agoMerge branch 'js/test-file-size'
Junio C Hamano [Wed, 11 Nov 2020 21:18:39 +0000 (13:18 -0800)] 
Merge branch 'js/test-file-size'

Test clean-up.

* js/test-file-size:
  tests: consolidate the `file_size` function into `test-lib-functions.sh`

3 years agoMerge branch 'js/ci-github-set-env'
Junio C Hamano [Wed, 11 Nov 2020 21:18:39 +0000 (13:18 -0800)] 
Merge branch 'js/ci-github-set-env'

CI update.

* js/ci-github-set-env:
  ci: avoid using the deprecated `set-env` construct

3 years agoMerge branch 'js/p4-default-branch'
Junio C Hamano [Wed, 11 Nov 2020 21:18:38 +0000 (13:18 -0800)] 
Merge branch 'js/p4-default-branch'

"git p4" now honors init.defaultBranch configuration.

* js/p4-default-branch:
  p4: respect init.defaultBranch

3 years agoMerge branch 'js/test-whitespace-fixes'
Junio C Hamano [Wed, 11 Nov 2020 21:18:38 +0000 (13:18 -0800)] 
Merge branch 'js/test-whitespace-fixes'

Test code clean-up.

* js/test-whitespace-fixes:
  t9603: use tabs for indentation
  t5570: remove trailing padding
  t5400,t5402: consistently indent with tabs, not with spaces
  t3427: adjust stale comment
  t3406: indent with tabs, not spaces
  t1004: insert missing "branch" in a message

3 years agoMerge branch 'mc/typofix'
Junio C Hamano [Wed, 11 Nov 2020 21:18:38 +0000 (13:18 -0800)] 
Merge branch 'mc/typofix'

Docfix.

* mc/typofix:
  doc: fixing two trivial typos in Documentation/

3 years agoMerge branch 'jc/abbrev-doc'
Junio C Hamano [Wed, 11 Nov 2020 21:18:38 +0000 (13:18 -0800)] 
Merge branch 'jc/abbrev-doc'

The documentation on the "--abbrev=<n>" option did not say the
output may be longer than "<n>" hexdigits, which has been
clarified.

* jc/abbrev-doc:
  doc: clarify that --abbrev=<n> is about the minimum length

3 years agoMerge branch 'cw/ci-ghwf-check-ws-errors'
Junio C Hamano [Wed, 11 Nov 2020 21:18:38 +0000 (13:18 -0800)] 
Merge branch 'cw/ci-ghwf-check-ws-errors'

Dev support update.

* cw/ci-ghwf-check-ws-errors:
  ci: make the whitespace checker more robust

3 years agoMerge branch 'rs/worktree-list-show-locked'
Junio C Hamano [Wed, 11 Nov 2020 21:18:38 +0000 (13:18 -0800)] 
Merge branch 'rs/worktree-list-show-locked'

Typofix.

* rs/worktree-list-show-locked:
  t2402: fix typo

3 years agoMerge branch 'rs/pack-write-hashwrite-simplify'
Junio C Hamano [Wed, 11 Nov 2020 21:18:38 +0000 (13:18 -0800)] 
Merge branch 'rs/pack-write-hashwrite-simplify'

Code clean-up.

* rs/pack-write-hashwrite-simplify:
  pack-write: use hashwrite_be32() instead of double-buffering array

3 years agoMerge branch 'sd/prompt-local-variable'
Junio C Hamano [Wed, 11 Nov 2020 21:18:38 +0000 (13:18 -0800)] 
Merge branch 'sd/prompt-local-variable'

Code clean-up.

* sd/prompt-local-variable:
  git-prompt.sh: localize `option` in __git_ps1_show_upstream

3 years agoMerge branch 'rs/clear-commit-marks-in-repo'
Junio C Hamano [Wed, 11 Nov 2020 21:18:37 +0000 (13:18 -0800)] 
Merge branch 'rs/clear-commit-marks-in-repo'

Code clean-up.

* rs/clear-commit-marks-in-repo:
  bisect: clear flags in passed repository
  object: allow clear_commit_marks_all to handle any repo

3 years agoMerge branch 'so/format-patch-doc-on-default-diff-format'
Junio C Hamano [Wed, 11 Nov 2020 21:18:37 +0000 (13:18 -0800)] 
Merge branch 'so/format-patch-doc-on-default-diff-format'

Docfix.

* so/format-patch-doc-on-default-diff-format:
  doc/diff-options: fix out of place mentions of '--patch/-p'

3 years agomergetool: avoid letting `list_tool_variants` break user-defined setups
Johannes Schindelin [Wed, 11 Nov 2020 20:33:18 +0000 (20:33 +0000)] 
mergetool: avoid letting `list_tool_variants` break user-defined setups

In 83bbf9b92ea8 (mergetool--lib: improve support for vimdiff-style tool
variants, 2020-07-29), we introduced a `list_tool_variants` function
in the spirit of Postel's Law: be lenient in what you accept as input.
In this particular instance, we wanted to allow not only `bc` but also
`bc3` as name for the Beyond Compare tool.

However, what this patch overlooked is that it is totally allowed for
users to override the defaults in `mergetools/`. But now that we strip
off trailing digits, the name that the user gave the tool might not
actually be in the list produced by `list_tool_variants`.

So let's do the same as for the `diff_cmd` and the `merge_cmd`: override
it with the trivial version in case a user-defined setup was detected.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agomergetools/bc: add `bc4` to the alias list for Beyond Compare
Johannes Schindelin [Wed, 11 Nov 2020 20:33:17 +0000 (20:33 +0000)] 
mergetools/bc: add `bc4` to the alias list for Beyond Compare

As of 83bbf9b92ea8 (mergetool--lib: improve support for vimdiff-style
tool variants, 2020-07-29), we already list `bc` and `bc3` as aliases
for that mergetool/difftool.

However, the current Beyond Compare version is _4_, therefore the `bc4`
alias is missing from that list.

Most notably, this is the root cause of the breakage reported in
https://github.com/git-for-windows/git/issues/2893 where a
well-configured `bc4` difftool stopped working as of v2.29.0:
`setup_tool` would notice that after stripping off the trailing digit,
it finds a match in `mergetools/` (the `bc` file), source it, and then
the alias would not match the list offered by the `list_tool_variants`
function, and simply exit without doing anything, but pretending
success.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoshortlog: use strset from strmap.h
Elijah Newren [Wed, 11 Nov 2020 20:02:21 +0000 (20:02 +0000)] 
shortlog: use strset from strmap.h

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoUse new HASHMAP_INIT macro to simplify hashmap initialization
Elijah Newren [Wed, 11 Nov 2020 20:02:20 +0000 (20:02 +0000)] 
Use new HASHMAP_INIT macro to simplify hashmap initialization

Now that hashamp has lazy initialization and a HASHMAP_INIT macro,
hashmaps allocated on the stack can be initialized without a call to
hashmap_init() and in some cases makes the code a bit shorter.  Convert
some callsites over to take advantage of this.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agostrmap: take advantage of FLEXPTR_ALLOC_STR when relevant
Elijah Newren [Wed, 11 Nov 2020 20:02:19 +0000 (20:02 +0000)] 
strmap: take advantage of FLEXPTR_ALLOC_STR when relevant

By default, we do not use a mempool and strdup_strings is true; in this
case, we can avoid both an extra allocation and an extra free by just
over-allocating for the strmap_entry leaving enough space at the end to
copy the key.  FLEXPTR_ALLOC_STR exists for exactly this purpose, so
make use of it.

Also, adjust the case when we are using a memory pool and strdup_strings
is true to just do one allocation from the memory pool instead of two so
that the strmap_clear() and strmap_remove() code can just avoid freeing
the key in all cases.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agostrmap: enable allocations to come from a mem_pool
Elijah Newren [Wed, 11 Nov 2020 20:02:18 +0000 (20:02 +0000)] 
strmap: enable allocations to come from a mem_pool

For heavy users of strmaps, allowing the keys and entries to be
allocated from a memory pool can provide significant overhead savings.
Add an option to strmap_init_with_options() to specify a memory pool.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoreceive-pack: use default version 0 for proc-receive
Jiang Xin [Wed, 11 Nov 2020 11:32:02 +0000 (19:32 +0800)] 
receive-pack: use default version 0 for proc-receive

In the verison negotiation phase between "receive-pack" and
"proc-receive", "proc-receive" can send an empty flush-pkt to end the
negotiation and use default version 0. Capabilities (such as
"push-options") are not supported in version 0.

Signed-off-by: Jiang Xin <zhiyou.jx@alibaba-inc.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoreceive-pack: gently write messages to proc-receive
Jiang Xin [Wed, 11 Nov 2020 11:32:01 +0000 (19:32 +0800)] 
receive-pack: gently write messages to proc-receive

Johannes found a flaky hang in `t5411/test-0013-bad-protocol.sh` in the
osx-clang job of the CI/PR builds, and ran into an issue when using
the `--stress` option with the following error messages:

    fatal: unable to write flush packet: Broken pipe
    send-pack: unexpected disconnect while reading sideband packet
    fatal: the remote end hung up unexpectedly

In this test case, the "proc-receive" hook sends an error message and
dies earlier. While "receive-pack" on the other side of the pipe
should forward the error message of the "proc-receive" hook to the
client side, but it fails to do so. This is because "receive-pack"
uses `packet_write_fmt()` and `packet_flush()` to write pkt-line
message to "proc-receive" hook, and these functions die immediately
when pipe is broken. Using "gently" forms for these functions will get
more predicable output.

Add more "--die-*" options to test helper to test different stages of
the protocol between "receive-pack" and "proc-receive" hook.

Reported-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Suggested-by: Jeff King <peff@peff.net>
Signed-off-by: Jiang Xin <zhiyou.jx@alibaba-inc.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agot5411: new helper filter_out_user_friendly_and_stable_output
Jiang Xin [Wed, 11 Nov 2020 11:32:00 +0000 (19:32 +0800)] 
t5411: new helper filter_out_user_friendly_and_stable_output

New helper `filter_out_user_friendly_and_stable_output` will call
common helpr function `make_user_friendly_and_stable_output` and use
additional arguments to filter out messages for specific test cases.

Suggested-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Jiang Xin <zhiyou.jx@alibaba-inc.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoconfig.mak.uname: remove unused NEEDS_SSL_WITH_CURL flag
Ævar Arnfjörð Bjarmason [Wed, 11 Nov 2020 09:54:20 +0000 (10:54 +0100)] 
config.mak.uname: remove unused NEEDS_SSL_WITH_CURL flag

The NEEDS_SSL_WITH_CURL flag was still being set in one case, but
hasn't existed since 23c4bbe28e6 ("build: link with curl-defined
linker flags", 2018-11-03). Remove it, and a comment which referred to
it. See 6c109904bc8 ("Port to HP NonStop", 2012-09-19) for the initial
addition of the comment.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoconfig.mak.uname: remove unused the NO_R_TO_GCC_LINKER flag
Ævar Arnfjörð Bjarmason [Wed, 11 Nov 2020 09:54:19 +0000 (10:54 +0100)] 
config.mak.uname: remove unused the NO_R_TO_GCC_LINKER flag

The NO_R_TO_GCC_LINKER flag was still being on some platforms. It
hasn't been used since my 0f50c8e32c8 ("Makefile: remove the
NO_R_TO_GCC_LINKER flag", 2019-05-17).

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agocompat/bswap.h: don't assume MSVC is little-endian
Daniel Gurney [Wed, 11 Nov 2020 08:32:27 +0000 (10:32 +0200)] 
compat/bswap.h: don't assume MSVC is little-endian

In 1af265f0 (compat/bswap.h: simplify MSVC endianness
detection, 2020-11-08) we attempted to simplify code by assuming MSVC
builds will be for little-endian machines, since only unusably old
versions of MSVC supported big-endian MIPS and m68k architectures.

However, it's possible that MSVC could be ported to build for a
big-endian architecture again, so the simplification wasn't as
future-proof as hoped.

So let's go back to the old way of detecting MSVC, and then checking
architecture from a list of little-endian architecture macros.

Note that MSVC does not treat ARM64 as bi-endian, so we can safely treat
it as little-endian.

Helped-by: brian m. carlson <sandals@crustytoothpaste.net>
Helped-by: Jeff King <peff@peff.net>
Helped-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Helped-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Daniel Gurney <dgurney99@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agot7800: simplify difftool test
Jinoh Kang [Fri, 6 Nov 2020 17:14:52 +0000 (17:14 +0000)] 
t7800: simplify difftool test

The new test added by the previous commit can be simplified a lot.
Let's do so.

Helped-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Jinoh Kang <luke1337@theori.io>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agorev-parse: handle --end-of-options
Jeff King [Tue, 10 Nov 2020 21:40:19 +0000 (16:40 -0500)] 
rev-parse: handle --end-of-options

We taught rev-list a new way to separate options from revisions in
19e8789b23 (revision: allow --end-of-options to end option parsing,
2019-08-06), but rev-parse uses its own parser. It should know about
--end-of-options not only for consistency, but because it may be
presented with similarly ambiguous cases. E.g., if a caller does:

  git rev-parse "$rev" -- "$path"

to parse an untrusted input, then it will get confused if $rev contains
an option-like string like "--local-env-vars". Or even "--not-real",
which we'd keep as an option to pass along to rev-list.

Or even more importantly:

  git rev-parse --verify "$rev"

can be confused by options, even though its purpose is safely parsing
untrusted input. On the plus side, it will always fail the --verify
part, as it will not have parsed a revision, so the caller will
generally "fail closed" rather than continue to use the untrusted
string. But it will still trigger whatever option was in "$rev"; this
should be mostly harmless, since rev-parse options are all read-only,
but I didn't carefully audit all paths.

This patch lets callers write:

  git rev-parse --end-of-options "$rev" -- "$path"

and:

  git rev-parse --verify --end-of-options "$rev"

which will both treat "$rev" always as a revision parameter. The latter
is a bit clunky. It would be nicer if we had defined "--verify" to
require that its next argument be the revision. But we have not
historically done so, and:

  git rev-parse --verify -q "$rev"

does currently work. I added a test here to confirm that we didn't break
that.

A few implementation notes:

 - We don't document --end-of-options explicitly in commands, but rather
   in gitcli(7). So I didn't give it its own section in git-rev-parse(1).
   But I did call it out specifically in the --verify section, and
   include it in the examples, which should show best practices.

 - We don't have to re-indent the main option-parsing block, because we
   can combine our "did we see end of options" check with "does it start
   with a dash". The exception is the pre-setup options, which need
   their own block.

 - We do however have to pull the "--" parsing out of the "does it start
   with dash" block, because we want to parse it even if we've seen
   --end-of-options.

 - We'll leave "--end-of-options" in the output. This is probably not
   technically necessary, as a careful caller will do:

     git rev-parse --end-of-options $revs -- $paths

   and anything in $revs will be resolved to an object id. However, it
   does help a slightly less careful caller like:

     git rev-parse --end-of-options $revs_or_paths

   where a path "--foo" will remain in the output as long as it also
   exists on disk. In that case, it's helpful to retain --end-of-options
   to get passed along to rev-list, s it would otherwise see just
   "--foo".

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agorev-parse: put all options under the "-" check
Jeff King [Tue, 10 Nov 2020 21:38:03 +0000 (16:38 -0500)] 
rev-parse: put all options under the "-" check

The option-parsing loop of rev-parse checks whether the first character
of an arg is "-". If so, then it enters a series of conditionals
checking for individual options. But some options are inexplicably
outside of that outer conditional.

This doesn't produce the wrong behavior; the conditional is actually
redundant with the individual option checks, and it's really only its
fallback "continue" that we care about. But we should at least be
consistent.

One obvious alternative is that we could get rid of the conditional
entirely. But we'll be using the extra block it provides in the next
patch.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agorev-parse: don't accept options after dashdash
Jeff King [Tue, 10 Nov 2020 21:37:27 +0000 (16:37 -0500)] 
rev-parse: don't accept options after dashdash

Because of the order in which we check options in rev-parse, there are a
few options we accept even after a "--". This is wrong, because the
whole point of "--" is to say "everything after here is a path". Let's
move the "did we see a dashdash" check (it's called "as_is" in the code)
to the top of the parsing loop.

Note there is one subtlety here. The options are ordered so that some
are checked before we even see if we're in a repository (they continue
the loop, and if we get past a certain point, then we do the repository
setup). By moving the as_is check higher, it's also in that "before
setup" section, even though it might look at the repository via
verify_filename(). However, this works out: we'd never set as_is until
we parse "--", and we don't parse that until after doing the setup.

An alternative here to avoid the subtlety is to put the as_is check at
the top of the post-setup options. But then every pre-setup option would
have to remember to check "if (!as_is && !strcmp(...))". So while this
is a bit magical, it's harder for future code to get wrong.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoblame: silently ignore invalid ignore file objects
René Scharfe [Tue, 10 Nov 2020 11:38:27 +0000 (12:38 +0100)] 
blame: silently ignore invalid ignore file objects

Since 610e2b9240 (blame: validate and peel the object names on the
ignore list, 2020-09-24) git blame reports checks if objects specified
with --ignore-rev and in files loaded with --ignore-revs-file and config
option blame.ignoreRevsFile are actual objects and dies if they aren't.
The intent is to report typos to the user.

This also breaks the ability to use a single ignore file for multiple
repositories.  Typos are presumably less likely in files than on the
command line, so alerting is less useful here.  Restore that feature by
skipping non-commits without dying.

Reported-by: Jean-Yves Avenard <jyavenard@mozilla.com>
Signed-off-by: René Scharfe <l.s.r@web.de>
Reviewed-by: Barret Rhoden <brho@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agocompletion: bash: check for alias loop
Felipe Contreras [Tue, 10 Nov 2020 02:03:43 +0000 (20:03 -0600)] 
completion: bash: check for alias loop

We don't want to be stuck in an endless cycle.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agocompletion: bash: support recursive aliases
Felipe Contreras [Tue, 10 Nov 2020 02:03:42 +0000 (20:03 -0600)] 
completion: bash: support recursive aliases

It is possible to have recursive aliases like:

  l = log --oneline
  lg = l --graph

So the completion should detect such aliases as well.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoformat-patch: make output filename configurable
Junio C Hamano [Fri, 6 Nov 2020 21:56:24 +0000 (13:56 -0800)] 
format-patch: make output filename configurable

For the past 15 years, we've used the hardcoded 64 as the length
limit of the filename of the output from the "git format-patch"
command.  Since the value is shorter than the 80-column terminal, it
could grow without line wrapping a bit.  At the same time, since the
value is longer than half of the 80-column terminal, we could fit
two or more of them in "ls" output on such a terminal if we allowed
to lower it.

Introduce a new command line option --filename-max-length=<n> and a
new configuration variable format.filenameMaxLength to override the
hardcoded default.

While we are at it, remove a check that the name of output directory
does not exceed PATH_MAX---this check is pointless in that by the
time control reaches the function, the caller would already have
done an equivalent of "mkdir -p", so if the system does not like an
overly long directory name, the control wouldn't have reached here,
and otherwise, we know that the system allowed the output directory
to exist.  In the worst case, we will get an error when we try to
open the output file and handle the error correctly anyway.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoFourth batch
Junio C Hamano [Mon, 9 Nov 2020 21:31:58 +0000 (13:31 -0800)] 
Fourth batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoMerge branch 'js/default-branch-name-adjust-t5411'
Junio C Hamano [Mon, 9 Nov 2020 22:06:29 +0000 (14:06 -0800)] 
Merge branch 'js/default-branch-name-adjust-t5411'

Prepare a test script to transition of the default branch name to
'main'.

* js/default-branch-name-adjust-t5411:
  t5411: finish preparing for `main` being the default branch name
  t5411: adjust the remaining support files for init.defaultBranch=main
  t5411: start adjusting the support files for init.defaultBranch=main
  t5411: start using the default branch name "main"

3 years agoMerge branch 'fc/zsh-completion'
Junio C Hamano [Mon, 9 Nov 2020 22:06:29 +0000 (14:06 -0800)] 
Merge branch 'fc/zsh-completion'

Zsh autocompletion (in contrib/) update.

* fc/zsh-completion: (29 commits)
  zsh: update copyright notices
  completion: bash: remove old compat wrappers
  completion: bash: cleanup cygwin check
  completion: bash: trivial cleanup
  completion: zsh: add simple version check
  completion: zsh: trivial simplification
  completion: zsh: add alias descriptions
  completion: zsh: improve command tags
  completion: zsh: refactor command completion
  completion: zsh: shuffle functions around
  completion: zsh: simplify file_direct
  completion: zsh: simplify nl_append
  completion: zsh: trivial cleanup
  completion: zsh: simplify direct compadd
  completion: zsh: simplify compadd functions
  completion: zsh: fix splitting of words
  completion: zsh: add missing direct_append
  completion: fix conflict with bashcomp
  completion: zsh: fix completion for --no-.. options
  completion: bash: remove zsh wrapper
  ...

3 years agoMerge branch 'jk/sideband-more-error-checking'
Junio C Hamano [Mon, 9 Nov 2020 22:06:29 +0000 (14:06 -0800)] 
Merge branch 'jk/sideband-more-error-checking'

The code to detect premature EOF in the sideband demultiplexer has
been cleaned up.

* jk/sideband-more-error-checking:
  sideband: diagnose more sideband anomalies

3 years agoMerge branch 'jk/committer-date-is-author-date-fix-simplify'
Junio C Hamano [Mon, 9 Nov 2020 22:06:27 +0000 (14:06 -0800)] 
Merge branch 'jk/committer-date-is-author-date-fix-simplify'

Code simplification.

* jk/committer-date-is-author-date-fix-simplify:
  am, sequencer: stop parsing our own committer ident

3 years agoMerge branch 'ab/git-remote-exit-code'
Junio C Hamano [Mon, 9 Nov 2020 22:06:26 +0000 (14:06 -0800)] 
Merge branch 'ab/git-remote-exit-code'

Exit codes from "git remote add" etc. were not usable by scripted
callers.

* ab/git-remote-exit-code:
  remote: add meaningful exit code on missing/existing

3 years agoMerge branch 'pb/ref-filter-with-crlf'
Junio C Hamano [Mon, 9 Nov 2020 22:06:26 +0000 (14:06 -0800)] 
Merge branch 'pb/ref-filter-with-crlf'

A commit and tag object may have CR at the end of each and
every line (you can create such an object with hash-object or
using --cleanup=verbatim to decline the default clean-up
action), but it would make it impossible to have a blank line
to separate the title from the body of the message.  Be lenient
and accept a line with lone CR on it as a blank line, too.

* pb/ref-filter-with-crlf:
  log, show: add tests for messages containing CRLF
  ref-filter: handle CRLF at end-of-line more gracefully

3 years agoMerge branch 'jk/checkout-index-errors'
Junio C Hamano [Mon, 9 Nov 2020 22:06:26 +0000 (14:06 -0800)] 
Merge branch 'jk/checkout-index-errors'

"git checkout-index" did not consistently signal an error with its
exit status.

* jk/checkout-index-errors:
  checkout-index: propagate errors to exit code
  checkout-index: drop error message from empty --stage=all

3 years agoMerge branch 'jk/perl-warning'
Junio C Hamano [Mon, 9 Nov 2020 22:06:25 +0000 (14:06 -0800)] 
Merge branch 'jk/perl-warning'

Dev support.

* jk/perl-warning:
  perl: check for perl warnings while running tests

3 years agoMerge branch 'nk/diff-files-vs-fsmonitor'
Junio C Hamano [Mon, 9 Nov 2020 22:06:25 +0000 (14:06 -0800)] 
Merge branch 'nk/diff-files-vs-fsmonitor'

"git diff" and other commands that share the same machinery to
compare with working tree files have been taught to take advantage
of the fsmonitor data when available.

* nk/diff-files-vs-fsmonitor:
  p7519-fsmonitor: add a git add benchmark
  p7519-fsmonitor: refactor to avoid code duplication
  perf lint: add make test-lint to perf tests
  t/perf: add fsmonitor perf test for git diff
  t/perf/p7519-fsmonitor.sh: warm cache on first git status
  t/perf/README: elaborate on output format
  fsmonitor: use fsmonitor data in `git diff`

3 years agoMerge branch 'as/tests-cleanup'
Junio C Hamano [Mon, 9 Nov 2020 22:06:25 +0000 (14:06 -0800)] 
Merge branch 'as/tests-cleanup'

Micro clean-up of a couple of test scripts.

* as/tests-cleanup:
  t2200,t9832: avoid using 'git' upstream in a pipe