]> git.ipfire.org Git - thirdparty/git.git/log
thirdparty/git.git
3 years agossh signing: retrieve a default key from ssh-agent
Fabian Stelzer [Fri, 10 Sep 2021 20:07:37 +0000 (20:07 +0000)] 
ssh signing: retrieve a default key from ssh-agent

If user.signingkey is not set and a ssh signature is requested we call
gpg.ssh.defaultKeyCommand (typically "ssh-add -L") and use the first key we get

Signed-off-by: Fabian Stelzer <fs@gigacodes.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agossh signing: add ssh key format and signing code
Fabian Stelzer [Fri, 10 Sep 2021 20:07:36 +0000 (20:07 +0000)] 
ssh signing: add ssh key format and signing code

Implements the actual sign_buffer_ssh operation and move some shared
cleanup code into a strbuf function

Set gpg.format = ssh and user.signingkey to either a ssh public key
string (like from an authorized_keys file), or a ssh key file.
If the key file or the config value itself contains only a public key
then the private key needs to be available via ssh-agent.

gpg.ssh.program can be set to an alternative location of ssh-keygen.
A somewhat recent openssh version (8.2p1+) of ssh-keygen is needed for
this feature. Since only ssh-keygen is needed it can this way be
installed seperately without upgrading your system openssh packages.

Signed-off-by: Fabian Stelzer <fs@gigacodes.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agossh signing: add test prereqs
Fabian Stelzer [Fri, 10 Sep 2021 20:07:35 +0000 (20:07 +0000)] 
ssh signing: add test prereqs

Generate some ssh keys and a allowedSignersFile for testing

Signed-off-by: Fabian Stelzer <fs@gigacodes.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agossh signing: preliminary refactoring and clean-up
Fabian Stelzer [Fri, 10 Sep 2021 20:07:34 +0000 (20:07 +0000)] 
ssh signing: preliminary refactoring and clean-up

Openssh v8.2p1 added some new options to ssh-keygen for signature
creation and verification. These allow us to use ssh keys for git
signatures easily.

In our corporate environment we use PIV x509 Certs on Yubikeys for email
signing/encryption and ssh keys which I think is quite common
(at least for the email part). This way we can establish the correct
trust for the SSH Keys without setting up a separate GPG Infrastructure
(which is still quite painful for users) or implementing x509 signing
support for git (which lacks good forwarding mechanisms).
Using ssh agent forwarding makes this feature easily usable in todays
development environments where code is often checked out in remote VMs / containers.
In such a setup the keyring & revocationKeyring can be centrally
generated from the x509 CA information and distributed to the users.

To be able to implement new signing formats this commit:
 - makes the sigc structure more generic by renaming "gpg_output" to
   "output"
 - introduces function pointers in the gpg_format structure to call
   format specific signing and verification functions
 - moves format detection from verify_signed_buffer into the check_signature
   api function and calls the format specific verify
 - renames and wraps sign_buffer to handle format specific signing logic
   as well

Signed-off-by: Fabian Stelzer <fs@gigacodes.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoThe fifth batch
Junio C Hamano [Fri, 16 Jul 2021 23:56:24 +0000 (16:56 -0700)] 
The fifth batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoMerge branch 'ds/gender-neutral-doc'
Junio C Hamano [Sat, 17 Jul 2021 00:42:53 +0000 (17:42 -0700)] 
Merge branch 'ds/gender-neutral-doc'

Update the documentation not to assume users are of certain gender
and adds to guidelines to do so.

* ds/gender-neutral-doc:
  *: fix typos
  comments: avoid using the gender of our users
  doc: avoid using the gender of other people

3 years agoMerge branch 'jt/partial-clone-submodule-1'
Junio C Hamano [Sat, 17 Jul 2021 00:42:53 +0000 (17:42 -0700)] 
Merge branch 'jt/partial-clone-submodule-1'

Prepare the internals for lazily fetching objects in submodules
from their promisor remotes.

* jt/partial-clone-submodule-1:
  promisor-remote: teach lazy-fetch in any repo
  run-command: refactor subprocess env preparation
  submodule: refrain from filtering GIT_CONFIG_COUNT
  promisor-remote: support per-repository config
  repository: move global r_f_p_c to repo struct

3 years agoMerge branch 'ab/struct-init'
Junio C Hamano [Sat, 17 Jul 2021 00:42:52 +0000 (17:42 -0700)] 
Merge branch 'ab/struct-init'

Code cleanup around struct_type_init() functions.

* ab/struct-init:
  string-list.h users: change to use *_{nodup,dup}()
  string-list.[ch]: add a string_list_init_{nodup,dup}()
  dir.[ch]: replace dir_init() with DIR_INIT
  *.c *_init(): define in terms of corresponding *_INIT macro
  *.h: move some *_INIT to designated initializers

3 years agoMerge branch 'dd/test-stdout-count-lines'
Junio C Hamano [Sat, 17 Jul 2021 00:42:52 +0000 (17:42 -0700)] 
Merge branch 'dd/test-stdout-count-lines'

Tiny test clean-up.

* dd/test-stdout-count-lines:
  t6402: preserve git exit status code
  t6400: preserve git ls-files exit status code
  test-lib-functions: introduce test_stdout_line_count

3 years agoMerge branch 'hn/refs-test-cleanup'
Junio C Hamano [Sat, 17 Jul 2021 00:42:52 +0000 (17:42 -0700)] 
Merge branch 'hn/refs-test-cleanup'

Test clean-up.

* hn/refs-test-cleanup:
  t7509: avoid direct file access for writing CHERRY_PICK_HEAD
  t1415: avoid direct filesystem access for writing refs

3 years agoMerge branch 'rs/khash-alloc-cleanup'
Junio C Hamano [Sat, 17 Jul 2021 00:42:51 +0000 (17:42 -0700)] 
Merge branch 'rs/khash-alloc-cleanup'

Code clean-up.

* rs/khash-alloc-cleanup:
  khash: clarify that allocations never fail

3 years agoMerge branch 'ar/help-micro-cleanup'
Junio C Hamano [Sat, 17 Jul 2021 00:42:51 +0000 (17:42 -0700)] 
Merge branch 'ar/help-micro-cleanup'

Tiny code clean-up.

* ar/help-micro-cleanup:
  help: convert git_cmd to page in one place

3 years agoMerge branch 'ar/submodule-helper-include-cleanup'
Junio C Hamano [Sat, 17 Jul 2021 00:42:51 +0000 (17:42 -0700)] 
Merge branch 'ar/submodule-helper-include-cleanup'

Code clean-up.

* ar/submodule-helper-include-cleanup:
  submodule--helper: remove redundant include

3 years agoMerge branch 'ab/bundle-updates'
Junio C Hamano [Sat, 17 Jul 2021 00:42:49 +0000 (17:42 -0700)] 
Merge branch 'ab/bundle-updates'

Code clean-up and leak plugging in "git bundle".

* ab/bundle-updates:
  bundle: remove "ref_list" in favor of string-list.c API
  bundle.c: use a temporary variable for OIDs and names
  bundle cmd: stop leaking memory from parse_options_cmd_bundle()

3 years agoMerge branch 'hn/refs-iterator-peel-returns-boolean'
Junio C Hamano [Sat, 17 Jul 2021 00:42:49 +0000 (17:42 -0700)] 
Merge branch 'hn/refs-iterator-peel-returns-boolean'

Tiny API tweak.

* hn/refs-iterator-peel-returns-boolean:
  refs: make explicit that ref_iterator_peel returns boolean

3 years agoMerge branch 'ab/mktag-tests'
Junio C Hamano [Sat, 17 Jul 2021 00:42:48 +0000 (17:42 -0700)] 
Merge branch 'ab/mktag-tests'

Fill test gaps.

* ab/mktag-tests:
  mktag tests: test fast-export
  mktag tests: test for-each-ref
  mktag tests: test update-ref and reachable fsck
  mktag tests: test hash-object --literally and unreachable fsck
  mktag tests: invert --no-strict test
  mktag tests: parse out options in helper

3 years agoMerge branch 'ab/show-branch-tests'
Junio C Hamano [Sat, 17 Jul 2021 00:42:48 +0000 (17:42 -0700)] 
Merge branch 'ab/show-branch-tests'

Fill test gaps.

* ab/show-branch-tests:
  show-branch tests: add missing tests
  show-branch: don't <COLOR></RESET> for space characters
  show-branch tests: modernize test code
  show-branch tests: rename the one "show-branch" test file

3 years agoMerge branch 'ab/fetch-negotiate-segv-fix'
Junio C Hamano [Sat, 17 Jul 2021 00:42:48 +0000 (17:42 -0700)] 
Merge branch 'ab/fetch-negotiate-segv-fix'

Code recently added to support common ancestry negotiation during
"git push" did not sanity check its arguments carefully enough.

* ab/fetch-negotiate-segv-fix:
  fetch: fix segfault in --negotiate-only without --negotiation-tip=*
  fetch: document the --negotiate-only option
  send-pack.c: move "no refs in common" abort earlier

3 years agoMerge branch 'ab/make-delete-on-error'
Junio C Hamano [Sat, 17 Jul 2021 00:42:47 +0000 (17:42 -0700)] 
Merge branch 'ab/make-delete-on-error'

Use ".DELETE_ON_ERROR" pseudo target to simplify our Makefile.

* ab/make-delete-on-error:
  Makefile: add and use the ".DELETE_ON_ERROR" flag

3 years agoMerge branch 'ew/mmap-failures'
Junio C Hamano [Sat, 17 Jul 2021 00:42:47 +0000 (17:42 -0700)] 
Merge branch 'ew/mmap-failures'

Error message update.

* ew/mmap-failures:
  xmmap: inform Linux users of tuning knobs on ENOMEM

3 years agoMerge branch 'js/config-mak-windows-pcre-fix'
Junio C Hamano [Sat, 17 Jul 2021 00:42:47 +0000 (17:42 -0700)] 
Merge branch 'js/config-mak-windows-pcre-fix'

Whitespace fix.

* js/config-mak-windows-pcre-fix:
  config.mak.uname: PCRE1 cleanup

3 years agoMerge branch 'js/gfw-system-config-loc-fix'
Junio C Hamano [Sat, 17 Jul 2021 00:42:46 +0000 (17:42 -0700)] 
Merge branch 'js/gfw-system-config-loc-fix'

Update the location of system-side configuration file on Windows.

* js/gfw-system-config-loc-fix:
  config: normalize the path of the system gitconfig
  cmake(windows): set correct path to the system Git config
  mingw: move Git for Windows' system config where users expect it

3 years agoMerge branch 'ks/submodule-cleanup'
Junio C Hamano [Sat, 17 Jul 2021 00:42:46 +0000 (17:42 -0700)] 
Merge branch 'ks/submodule-cleanup'

Code cleanup.

* ks/submodule-cleanup:
  submodule: remove unnecessary `prefix` based option logic

3 years agoMerge branch 'tb/midx-use-checksum'
Junio C Hamano [Sat, 17 Jul 2021 00:42:46 +0000 (17:42 -0700)] 
Merge branch 'tb/midx-use-checksum'

When rebuilding the multi-pack index file reusing an existing one,
we used to blindly trust the existing file and ended up carrying
corrupted data into the updated file, which has been corrected.

* tb/midx-use-checksum:
  midx: report checksum mismatches during 'verify'
  midx: don't reuse corrupt MIDXs when writing
  commit-graph: rewrite to use checksum_valid()
  csum-file: introduce checksum_valid()

3 years agoMerge branch 'en/merge-dir-rename-corner-case-fix'
Junio C Hamano [Sat, 17 Jul 2021 00:42:45 +0000 (17:42 -0700)] 
Merge branch 'en/merge-dir-rename-corner-case-fix'

The merge code had funny interactions between content based rename
detection and directory rename detection.

* en/merge-dir-rename-corner-case-fix:
  merge-recursive: handle rename-to-self case
  merge-ort: ensure we consult df_conflict and path_conflicts
  t6423: test directory renames causing rename-to-self

3 years agoMerge branch 'en/ort-perf-batch-13'
Junio C Hamano [Sat, 17 Jul 2021 00:42:45 +0000 (17:42 -0700)] 
Merge branch 'en/ort-perf-batch-13'

Performance tweaks of "git merge -sort" around lazy fetching of objects.

* en/ort-perf-batch-13:
  merge-ort: add prefetching for content merges
  diffcore-rename: use a different prefetch for basename comparisons
  diffcore-rename: allow different missing_object_cb functions
  t6421: add tests checking for excessive object downloads during merge
  promisor-remote: output trace2 statistics for number of objects fetched

3 years agoMerge branch 'en/ort-perf-batch-12'
Junio C Hamano [Sat, 17 Jul 2021 00:42:45 +0000 (17:42 -0700)] 
Merge branch 'en/ort-perf-batch-12'

More fix-ups and optimization to "merge -sort".

* en/ort-perf-batch-12:
  merge-ort: miscellaneous touch-ups
  Fix various issues found in comments
  diffcore-rename: avoid unnecessary strdup'ing in break_idx
  merge-ort: replace string_list_df_name_compare with faster alternative

3 years agoThe fourth batch
Junio C Hamano [Tue, 13 Jul 2021 23:52:11 +0000 (16:52 -0700)] 
The fourth batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoMerge branch 'rs/grep-parser-fix'
Junio C Hamano [Tue, 13 Jul 2021 23:52:53 +0000 (16:52 -0700)] 
Merge branch 'rs/grep-parser-fix'

"git grep --and -e foo" ought to have been diagnosed as an error
but instead segfaulted, which has been corrected.

* rs/grep-parser-fix:
  grep: report missing left operand of --and

3 years agoMerge branch 'bk/doc-commit-typofix'
Junio C Hamano [Tue, 13 Jul 2021 23:52:52 +0000 (16:52 -0700)] 
Merge branch 'bk/doc-commit-typofix'

Doc typo/grammo-fix.

* bk/doc-commit-typofix:
  Documentation: fix typo in the --patch option of the commit command

3 years agoMerge branch 'dc/p4-binary-submit-fix'
Junio C Hamano [Tue, 13 Jul 2021 23:52:52 +0000 (16:52 -0700)] 
Merge branch 'dc/p4-binary-submit-fix'

Prevent "git p4" from failing to submit changes to binary file.

* dc/p4-binary-submit-fix:
  git-p4: fix failed submit by skip non-text data files

3 years agoMerge branch 'ab/pre-auto-gc-hook-test'
Junio C Hamano [Tue, 13 Jul 2021 23:52:52 +0000 (16:52 -0700)] 
Merge branch 'ab/pre-auto-gc-hook-test'

Test fix.

* ab/pre-auto-gc-hook-test:
  gc tests: add a test for the "pre-auto-gc" hook

3 years agoMerge branch 'jk/union-merge-binary'
Junio C Hamano [Tue, 13 Jul 2021 23:52:51 +0000 (16:52 -0700)] 
Merge branch 'jk/union-merge-binary'

The "union" conflict resolution variant misbehaved when used with
binary merge driver.

* jk/union-merge-binary:
  ll_union_merge(): rename path_unused parameter
  ll_union_merge(): pass name labels to ll_xdl_merge()
  ll_binary_merge(): handle XDL_MERGE_FAVOR_UNION

3 years agoMerge branch 'mr/cmake'
Junio C Hamano [Tue, 13 Jul 2021 23:52:51 +0000 (16:52 -0700)] 
Merge branch 'mr/cmake'

CMake update.

* mr/cmake:
  cmake: add warning for ignored MSGFMT_EXE
  cmake: create compile_commands.json by default
  cmake: add knob to disable vcpkg

3 years agoMerge branch 'ab/describe-tests-fix'
Junio C Hamano [Tue, 13 Jul 2021 23:52:51 +0000 (16:52 -0700)] 
Merge branch 'ab/describe-tests-fix'

Various updates to tests around "git describe"

* ab/describe-tests-fix:
  describe tests: support -C in "check_describe"
  describe tests: fix nested "test_expect_success" call
  describe tests: don't rely on err.actual from "check_describe"
  describe tests: refactor away from glob matching
  describe tests: improve test for --work-tree & --dirty

3 years agoMerge branch 'ab/pickaxe-pcre2'
Junio C Hamano [Tue, 13 Jul 2021 23:52:50 +0000 (16:52 -0700)] 
Merge branch 'ab/pickaxe-pcre2'

Rewrite the backend for "diff -G/-S" to use pcre2 engine when
available.

* ab/pickaxe-pcre2: (22 commits)
  xdiff-interface: replace discard_hunk_line() with a flag
  xdiff users: use designated initializers for out_line
  pickaxe -G: don't special-case create/delete
  pickaxe -G: terminate early on matching lines
  xdiff-interface: allow early return from xdiff_emit_line_fn
  xdiff-interface: prepare for allowing early return
  pickaxe -S: slightly optimize contains()
  pickaxe: rename variables in has_changes() for brevity
  pickaxe -S: support content with NULs under --pickaxe-regex
  pickaxe: assert that we must have a needle under -G or -S
  pickaxe: refactor function selection in diffcore-pickaxe()
  perf: add performance test for pickaxe
  pickaxe/style: consolidate declarations and assignments
  diff.h: move pickaxe fields together again
  pickaxe: die when --find-object and --pickaxe-all are combined
  pickaxe: die when -G and --pickaxe-regex are combined
  pickaxe tests: add missing test for --no-pickaxe-regex being an error
  pickaxe tests: test for -G, -S and --find-object incompatibility
  pickaxe tests: add test for "log -S" not being a regex
  pickaxe tests: add test for diffgrep_consume() internals
  ...

3 years agoMerge branch 'hn/prep-tests-for-reftable'
Junio C Hamano [Tue, 13 Jul 2021 23:52:50 +0000 (16:52 -0700)] 
Merge branch 'hn/prep-tests-for-reftable'

Preliminary clean-up of tests before the main reftable changes
hits the codebase.

* hn/prep-tests-for-reftable: (22 commits)
  t1415: set REFFILES for test specific to storage format
  t4202: mark bogus head hash test with REFFILES
  t7003: check reflog existence only for REFFILES
  t7900: stop checking for loose refs
  t1404: mark tests that muck with .git directly as REFFILES.
  t2017: mark --orphan/logAllRefUpdates=false test as REFFILES
  t1414: mark corruption test with REFFILES
  t1407: require REFFILES for for_each_reflog test
  test-lib: provide test prereq REFFILES
  t5304: use "reflog expire --all" to clear the reflog
  t5304: restyle: trim empty lines, drop ':' before >
  t7003: use rev-parse rather than FS inspection
  t5000: inspect HEAD using git-rev-parse
  t5000: reformat indentation to the latest fashion
  t1301: fix typo in error message
  t1413: use tar to save and restore entire .git directory
  t1401-symbolic-ref: avoid direct filesystem access
  t1401: use tar to snapshot and restore repo state
  t5601: read HEAD using rev-parse
  t9300: check ref existence using test-helper rather than a file system check
  ...

3 years agoMerge branch 'fc/push-simple-updates-cleanup'
Junio C Hamano [Tue, 13 Jul 2021 23:52:50 +0000 (16:52 -0700)] 
Merge branch 'fc/push-simple-updates-cleanup'

Some more code and doc clarification around "git push".

* fc/push-simple-updates-cleanup:
  push: don't get a full remote object
  push: only check same_remote when needed
  push: remove trivial function
  push: remove redundant check
  push: factor out the typical case
  push: get rid of all the setup_push_* functions
  push: trivial simplifications
  push: make setup_push_* return the dst
  push: only get the branch when needed
  push: factor out null branch check
  push: split switch cases
  push: return immediately in trivial switch case
  push: create new get_upstream_ref() helper

3 years agoMerge branch 'fc/push-simple-updates'
Junio C Hamano [Tue, 13 Jul 2021 23:52:49 +0000 (16:52 -0700)] 
Merge branch 'fc/push-simple-updates'

Some code and doc clarification around "git push".

* fc/push-simple-updates:
  doc: push: explain default=simple correctly
  push: remove unused code in setup_push_upstream()
  push: simplify setup_push_simple()
  push: reorganize setup_push_simple()
  push: copy code to setup_push_simple()
  push: hedge code of default=simple
  push: rename !triangular to same_remote

3 years agoMerge branch 'zh/cat-file-batch-fix'
Junio C Hamano [Tue, 13 Jul 2021 23:52:49 +0000 (16:52 -0700)] 
Merge branch 'zh/cat-file-batch-fix'

"git cat-file --batch-all-objects"" misbehaved when "--batch" is in
use and did not ask for certain object traits.

* zh/cat-file-batch-fix:
  cat-file: merge two block into one
  cat-file: handle trivial --batch format with --batch-all-objects

3 years agoThe third batch
Junio C Hamano [Thu, 8 Jul 2021 20:14:36 +0000 (13:14 -0700)] 
The third batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoMerge branch 'js/stop-exporting-bogus-columns'
Junio C Hamano [Thu, 8 Jul 2021 20:15:06 +0000 (13:15 -0700)] 
Merge branch 'js/stop-exporting-bogus-columns'

When we cannot figure out how wide the terminal is, we use a
fallback value of 80 ourselves (which cannot be avoided), but when
we run the pager, we export it in COLUMNS, which forces the pager
to use the hardcoded value, even when the pager is perfectly
capable to figure it out itself.  Stop exporting COLUMNS when we
fall back on the hardcoded default value for our own use.

* js/stop-exporting-bogus-columns:
  pager: avoid setting COLUMNS when we're guessing its value

3 years agoMerge branch 'dd/document-log-decorate-default'
Junio C Hamano [Thu, 8 Jul 2021 20:15:05 +0000 (13:15 -0700)] 
Merge branch 'dd/document-log-decorate-default'

Doc clean-up.

* dd/document-log-decorate-default:
  doc/log: correct default for --decorate

3 years agoMerge branch 'ar/test-code-cleanup'
Junio C Hamano [Thu, 8 Jul 2021 20:15:05 +0000 (13:15 -0700)] 
Merge branch 'ar/test-code-cleanup'

Test code clean-up.

* ar/test-code-cleanup:
  t: fix whitespace around &&

3 years agoMerge branch 'ba/object-info'
Junio C Hamano [Thu, 8 Jul 2021 20:15:05 +0000 (13:15 -0700)] 
Merge branch 'ba/object-info'

Code clean-up.

* ba/object-info:
  protocol-caps.h: add newline at end of file

3 years agoMerge branch 'ab/progress-cleanup'
Junio C Hamano [Thu, 8 Jul 2021 20:15:04 +0000 (13:15 -0700)] 
Merge branch 'ab/progress-cleanup'

Code clean-up.

* ab/progress-cleanup:
  read-cache.c: don't guard calls to progress.c API

3 years agoMerge branch 'ab/xdiff-bug-cleanup'
Junio C Hamano [Thu, 8 Jul 2021 20:15:04 +0000 (13:15 -0700)] 
Merge branch 'ab/xdiff-bug-cleanup'

Code clean-up.

* ab/xdiff-bug-cleanup:
  xdiff: use BUG(...), not xdl_bug(...)

3 years agoMerge branch 'ms/mergetools-kdiff3-on-windows'
Junio C Hamano [Thu, 8 Jul 2021 20:15:04 +0000 (13:15 -0700)] 
Merge branch 'ms/mergetools-kdiff3-on-windows'

On Windows, mergetool has been taught to find kdiff3.exe just like
it finds winmerge.exe.

* ms/mergetools-kdiff3-on-windows:
  mergetools/kdiff3: make kdiff3 work on Windows too

3 years agoMerge branch 'ab/cmd-foo-should-return'
Junio C Hamano [Thu, 8 Jul 2021 20:15:04 +0000 (13:15 -0700)] 
Merge branch 'ab/cmd-foo-should-return'

Code clean-up.

* ab/cmd-foo-should-return:
  builtins + test helpers: use return instead of exit() in cmd_*

3 years agoMerge branch 'ar/doc-libera-chat-in-my-first-contrib'
Junio C Hamano [Thu, 8 Jul 2021 20:15:03 +0000 (13:15 -0700)] 
Merge branch 'ar/doc-libera-chat-in-my-first-contrib'

Update MyFirst document.

* ar/doc-libera-chat-in-my-first-contrib:
  MyFirstContribution: link #git-devel to Libera Chat

3 years agoMerge branch 'ar/mailinfo-memcmp-to-skip-prefix'
Junio C Hamano [Thu, 8 Jul 2021 20:15:03 +0000 (13:15 -0700)] 
Merge branch 'ar/mailinfo-memcmp-to-skip-prefix'

Code clean-up.

* ar/mailinfo-memcmp-to-skip-prefix:
  mailinfo: use starts_with() when checking scissors

3 years agoMerge branch 'jk/doc-max-pack-size'
Junio C Hamano [Thu, 8 Jul 2021 20:15:03 +0000 (13:15 -0700)] 
Merge branch 'jk/doc-max-pack-size'

Doc update.

* jk/doc-max-pack-size:
  doc: warn people against --max-pack-size

3 years agoMerge branch 'ab/fix-columns-to-80-during-tests'
Junio C Hamano [Thu, 8 Jul 2021 20:15:02 +0000 (13:15 -0700)] 
Merge branch 'ab/fix-columns-to-80-during-tests'

Output from some of our tests were affected by the width of the
terminal that they were run in, which has been corrected by
exporting a fixed value in the COLUMNS environment.

* ab/fix-columns-to-80-during-tests:
  test-lib.sh: set COLUMNS=80 for --verbose repeatability

3 years agoMerge branch 'ar/more-typofix'
Junio C Hamano [Thu, 8 Jul 2021 20:15:02 +0000 (13:15 -0700)] 
Merge branch 'ar/more-typofix'

Typofixes.

* ar/more-typofix:
  git-worktree.txt: fix typo in example path
  t: fix typos in test messages
  blame: correct name of config option in docs

3 years agoMerge branch 'fw/complete-cmd-idx-fix'
Junio C Hamano [Thu, 8 Jul 2021 20:15:02 +0000 (13:15 -0700)] 
Merge branch 'fw/complete-cmd-idx-fix'

Recent update to completion script (in contrib/) broke those who
use the __git_complete helper to define completion to their custom
command.

* fw/complete-cmd-idx-fix:
  completion: bash: fix late declaration of __git_cmd_idx

3 years agoMerge branch 'jk/test-without-readlink-1'
Junio C Hamano [Thu, 8 Jul 2021 20:15:02 +0000 (13:15 -0700)] 
Merge branch 'jk/test-without-readlink-1'

Some test scripts assumed that readlink(1) was universally
installed and available, which is not the case.

* jk/test-without-readlink-1:
  t: use portable wrapper for readlink(1)

3 years agoMerge branch 'jx/sideband-cleanup'
Junio C Hamano [Thu, 8 Jul 2021 20:15:01 +0000 (13:15 -0700)] 
Merge branch 'jx/sideband-cleanup'

The side-band demultiplexer that is used to display progress output
from the remote end did not clear the line properly when the end of
line hits at a packet boundary, which has been corrected.  Also
comes with test clean-ups.

* jx/sideband-cleanup:
  test: refactor to use "get_abbrev_oid" to get abbrev oid
  test: refactor to use "test_commit" to create commits
  test: compare raw output, not mangle tabs and spaces
  sideband: don't lose clear-to-eol at packet boundary

3 years agoMerge branch 'jk/test-avoid-globmatch-with-skip-patterns'
Junio C Hamano [Thu, 8 Jul 2021 20:15:01 +0000 (13:15 -0700)] 
Merge branch 'jk/test-avoid-globmatch-with-skip-patterns'

We broke "GIT_SKIP_TESTS=t?000" to skip certain tests in recent
update, which got fixed.

* jk/test-avoid-globmatch-with-skip-patterns:
  test-lib: avoid accidental globbing in match_pattern_list()

3 years agoMerge branch 'jv/userdiff-csharp-update'
Junio C Hamano [Thu, 8 Jul 2021 20:15:01 +0000 (13:15 -0700)] 
Merge branch 'jv/userdiff-csharp-update'

The userdiff pattern for C# learned the token "record".

* jv/userdiff-csharp-update:
  userdiff: add support for C# record types

3 years agoMerge branch 'ab/config-hooks-path-testfix'
Junio C Hamano [Thu, 8 Jul 2021 20:15:00 +0000 (13:15 -0700)] 
Merge branch 'ab/config-hooks-path-testfix'

Test fix.

* ab/config-hooks-path-testfix:
  pre-commit hook tests: don't leave "actual" nonexisting on failure

3 years agoMerge branch 'fc/pull-cleanups'
Junio C Hamano [Thu, 8 Jul 2021 20:15:00 +0000 (13:15 -0700)] 
Merge branch 'fc/pull-cleanups'

Code cleanup.

* fc/pull-cleanups:
  pull: trivial whitespace style fix
  pull: trivial cleanup
  pull: cleanup autostash check

3 years agoMerge branch 'jk/bitmap-tree-optim'
Junio C Hamano [Thu, 8 Jul 2021 20:15:00 +0000 (13:15 -0700)] 
Merge branch 'jk/bitmap-tree-optim'

Avoid duplicated work while building reachability bitmaps.

* jk/bitmap-tree-optim:
  bitmaps: don't recurse into trees already in the bitmap

3 years agoMerge branch 'ah/graph-typofix'
Junio C Hamano [Thu, 8 Jul 2021 20:15:00 +0000 (13:15 -0700)] 
Merge branch 'ah/graph-typofix'

Typofix in an error message.

* ah/graph-typofix:
  graph: improve grammar of "invalid color" error message

3 years agoMerge branch 'jx/t6020-with-older-bash'
Junio C Hamano [Thu, 8 Jul 2021 20:14:59 +0000 (13:14 -0700)] 
Merge branch 'jx/t6020-with-older-bash'

Work around inefficient glob substitution in older versions of bash
by rewriting parts of a test.

* jx/t6020-with-older-bash:
  t6020: fix incompatible parameter expansion

3 years agoMerge branch 'ar/typofix'
Junio C Hamano [Thu, 8 Jul 2021 20:14:59 +0000 (13:14 -0700)] 
Merge branch 'ar/typofix'

Typofixes.

* ar/typofix:
  *: fix typos which duplicate a word

3 years agoMerge branch 'jk/revision-squelch-gcc-warning'
Junio C Hamano [Thu, 8 Jul 2021 20:14:59 +0000 (13:14 -0700)] 
Merge branch 'jk/revision-squelch-gcc-warning'

Warning fix.

* jk/revision-squelch-gcc-warning:
  add_pending_object_with_path(): work around "gcc -O3" complaint

3 years agoMerge branch 'ah/uninitialized-reads-fix'
Junio C Hamano [Thu, 8 Jul 2021 20:14:58 +0000 (13:14 -0700)] 
Merge branch 'ah/uninitialized-reads-fix'

Make the codebase MSAN clean.

* ah/uninitialized-reads-fix:
  builtin/checkout--worker: zero-initialise struct to avoid MSAN complaints
  split-index: use oideq instead of memcmp to compare object_id's
  bulk-checkin: make buffer reuse more obvious and safer

3 years agoMerge branch 'js/no-more-multimail'
Junio C Hamano [Thu, 8 Jul 2021 20:14:58 +0000 (13:14 -0700)] 
Merge branch 'js/no-more-multimail'

Remove multimail from contrib/

* js/no-more-multimail:
  multimail: stop shipping a copy

3 years agoMerge branch 'js/subtree-on-windows-fix'
Junio C Hamano [Thu, 8 Jul 2021 20:14:58 +0000 (13:14 -0700)] 
Merge branch 'js/subtree-on-windows-fix'

Update "git subtree" to work better on Windows.

* js/subtree-on-windows-fix:
  subtree: fix assumption about the directory separator
  subtree: fix the GIT_EXEC_PATH sanity check to work on Windows

3 years agoMerge branch 'dd/svn-test-wo-locale-a'
Junio C Hamano [Thu, 8 Jul 2021 20:14:58 +0000 (13:14 -0700)] 
Merge branch 'dd/svn-test-wo-locale-a'

"git-svn" tests assumed that "locale -a", which is used to pick an
available UTF-8 locale, is available everywhere.  A knob has been
introduced to allow testers to specify a suitable locale to use.

* dd/svn-test-wo-locale-a:
  t: use user-specified utf-8 locale for testing svn

3 years agoMerge branch 'fc/doc-default-to-upstream-config'
Junio C Hamano [Thu, 8 Jul 2021 20:14:57 +0000 (13:14 -0700)] 
Merge branch 'fc/doc-default-to-upstream-config'

Doc clean-up.

* fc/doc-default-to-upstream-config:
  doc: merge: mention default of defaulttoupstream

3 years agoMerge branch 'js/trace2-discard-event-docfix'
Junio C Hamano [Thu, 8 Jul 2021 20:14:57 +0000 (13:14 -0700)] 
Merge branch 'js/trace2-discard-event-docfix'

Docfix.

* js/trace2-discard-event-docfix:
  docs: fix api-trace2 doc for "too_many_files" event

3 years agoMerge branch 'tb/complete-diff-anchored'
Junio C Hamano [Thu, 8 Jul 2021 20:14:56 +0000 (13:14 -0700)] 
Merge branch 'tb/complete-diff-anchored'

The command line completion (in contrib/) learned that "git diff"
takes the "--anchored" option.

* tb/complete-diff-anchored:
  completion: add --anchored to diff's options

3 years agoMerge branch 'tk/partial-clone-repack-doc'
Junio C Hamano [Thu, 8 Jul 2021 20:14:56 +0000 (13:14 -0700)] 
Merge branch 'tk/partial-clone-repack-doc'

Docfix.

* tk/partial-clone-repack-doc:
  Remove warning that repack only works on non-promisor packfiles

3 years agofetch: fix segfault in --negotiate-only without --negotiation-tip=*
Ævar Arnfjörð Bjarmason [Thu, 8 Jul 2021 10:53:15 +0000 (12:53 +0200)] 
fetch: fix segfault in --negotiate-only without --negotiation-tip=*

The recent --negotiate-only option would segfault in the call to
oid_array_for_each() in negotiate_using_fetch() unless one or more
--negotiation-tip=* options were provided.

All of the other tests for the feature combine both, but nothing was
checking this assumption, let's do that and add a test for it. Fixes a
bug in 9c1e657a8fd (fetch: teach independent negotiation (no
packfile), 2021-05-04).

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agosubmodule--helper: remove redundant include
Atharva Raykar [Tue, 6 Jul 2021 18:24:08 +0000 (23:54 +0530)] 
submodule--helper: remove redundant include

"dir.h" should have been included only once.

Signed-off-by: Atharva Raykar <raykar.ath@gmail.com>
Mentored-by: Christian Couder <christian.couder@gmail.com>
Mentored-by: Shourya Shukla <periperidip@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agohelp: convert git_cmd to page in one place
Andrei Rybak [Sun, 4 Jul 2021 15:39:12 +0000 (17:39 +0200)] 
help: convert git_cmd to page in one place

Depending on the chosen format of help pages, git-help uses function
show_man_page, show_info_page, or show_html_page.  The first thing all
three functions do is to convert given `git_cmd` to a `page` using
function cmd_to_page.

Move the common part of these three functions to function cmd_help to
avoid code duplication.

Signed-off-by: Andrei Rybak <rybak.a.v@gmail.com>
Reviewed-by: Felipe Contreras <felipe.contreras@gmail.com>
Acked-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agokhash: clarify that allocations never fail
René Scharfe [Sat, 3 Jul 2021 12:57:30 +0000 (14:57 +0200)] 
khash: clarify that allocations never fail

We use our standard allocation functions and macros (xcalloc,
ALLOC_ARRAY, REALLOC_ARRAY) in our version of khash.h.  They terminate
the program on error instead, so code that's using them doesn't have to
handle allocation failures.  Make this behavior explicit by turning
kh_resize_ into a void function and removing the related unreachable
error handling code.

Helped-by: Jeff King <peff@peff.net>
Signed-off-by: René Scharfe <l.s.r@web.de>
Acked-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agot7509: avoid direct file access for writing CHERRY_PICK_HEAD
Han-Wen Nienhuys [Tue, 6 Jul 2021 18:47:57 +0000 (18:47 +0000)] 
t7509: avoid direct file access for writing CHERRY_PICK_HEAD

Signed-off-by: Han-Wen Nienhuys <hanwen@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agot1415: avoid direct filesystem access for writing refs
Han-Wen Nienhuys [Tue, 6 Jul 2021 18:47:56 +0000 (18:47 +0000)] 
t1415: avoid direct filesystem access for writing refs

Signed-off-by: Han-Wen Nienhuys <hanwen@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agot6402: preserve git exit status code
Đoàn Trần Công Danh [Sun, 4 Jul 2021 05:46:12 +0000 (12:46 +0700)] 
t6402: preserve git exit status code

In t6402, we're checking number of files in the index and the working
tree by piping the output of Git's command to "wc -l", thus losing the
exit status code of git.

Let's use the new helper test_stdout_line_count in order to preserve
Git's exit status code.

Signed-off-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agot6400: preserve git ls-files exit status code
Đoàn Trần Công Danh [Sun, 4 Jul 2021 05:46:11 +0000 (12:46 +0700)] 
t6400: preserve git ls-files exit status code

In t6400, we're checking number of files in the index and the working
tree by piping the output of "git ls-files" to "wc -l", thus losing the
exit status code of git.

Let's use the newly introduced test_stdout_line_count in order to check
the exit status code of Git's command.

Signed-off-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agotest-lib-functions: introduce test_stdout_line_count
Đoàn Trần Công Danh [Sun, 4 Jul 2021 05:46:10 +0000 (12:46 +0700)] 
test-lib-functions: introduce test_stdout_line_count

In some tests, we're checking the number of lines in output of some
commands, including but not limited to Git's command.

We're doing the check by running those commands in the left side of
a pipe, thus losing the exit status code of those commands. Meanwhile,
we really want to check the exit status code of Git's command.

Let's write the output of those commands to a temporary file, and use
test_line_count separately in order to check exit status code of
those commands properly.

Signed-off-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agobundle: remove "ref_list" in favor of string-list.c API
Ævar Arnfjörð Bjarmason [Fri, 2 Jul 2021 09:57:32 +0000 (11:57 +0200)] 
bundle: remove "ref_list" in favor of string-list.c API

Move away from the "struct ref_list" in bundle.c in favor of the
almost identical string-list.c API.

That API fits this use-case perfectly, but did not exist in its
current form when this code was added in 2e0afafebd (Add git-bundle:
move objects and references by archive, 2007-02-22), with hindsight we
could have used the path-list API, which later got renamed to
string-list. See 8fd2cb4069 (Extract helper bits from
c-merge-recursive work, 2006-07-25)

We need to change "name" to "string" and "oid" to "util" to make this
conversion, but other than that the APIs are pretty much identical for
what bundle.c made use of.

Let's also replace the memset(..,0,...) pattern with a more idiomatic
"INIT" macro, and finally add a *_release() function so to free the
allocated memory.

Before this the add_to_ref_list() would leak memory, now e.g. "bundle
list-heads" reports no memory leaks at all under valgrind.

In the bundle_header_init() function we're using a clever trick to
memcpy() what we'd get from the corresponding
BUNDLE_HEADER_INIT. There is a concurrent series to make use of that
pattern more generally, see [1].

1. https://lore.kernel.org/git/cover-0.5-00000000000-20210701T104855Z-avarab@gmail.com/

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Acked-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agobundle.c: use a temporary variable for OIDs and names
Ævar Arnfjörð Bjarmason [Fri, 2 Jul 2021 09:57:31 +0000 (11:57 +0200)] 
bundle.c: use a temporary variable for OIDs and names

In preparation for moving away from accessing the OID and name via the
"oid" and "name" slots in a subsequent commit, change the code that
accesses it to use named variables. This makes the subsequent change
smaller.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Acked-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agobundle cmd: stop leaking memory from parse_options_cmd_bundle()
Ævar Arnfjörð Bjarmason [Fri, 2 Jul 2021 09:57:30 +0000 (11:57 +0200)] 
bundle cmd: stop leaking memory from parse_options_cmd_bundle()

Fix a memory leak from the prefix_filename() function introduced with
its use in 3b754eedd5 (bundle: use prefix_filename with bundle path,
2017-03-20).

As noted in that commit the leak was intentional as a part of being
sloppy about freeing resources just before we exit, I'm changing this
because I'll be fixing other memory leaks in the bundle API (including
the library version) in subsequent commits. It's easier to reason
about those fixes if valgrind runs cleanly at the end without any
leaks whatsoever.

An earlier version of this change[1] went out of its way to not leak
memory on the die() codepaths here, but doing so will only avoid
reports of potential leaks under heap-only leak trackers such as
valgrind, not the SANITIZE=leak mode.

Avoiding those leaks as well might be useful to enable us to run
cleanly under the likes of valgrind in the future. But for now the
relative verbosity of the resulting code, and the fact that we don't
have some valgrind or SANITIZE=leak mode as part of our CI (it's only
run ad-hoc, see [2]), means we're not worrying about that for now.

1. https://lore.kernel.org/git/87v95vdxrc.fsf@evledraar.gmail.com/
2. https://lore.kernel.org/git/87czsv2idy.fsf@evledraar.gmail.com/

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Acked-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agostring-list.h users: change to use *_{nodup,dup}()
Ævar Arnfjörð Bjarmason [Thu, 1 Jul 2021 10:51:29 +0000 (12:51 +0200)] 
string-list.h users: change to use *_{nodup,dup}()

Change all in-tree users of the string_list_init(LIST, BOOL) API to
use string_list_init_{nodup,dup}(LIST) instead.

As noted in the preceding commit let's leave the now-unused
string_list_init() wrapper in-place for any in-flight users, it can be
removed at some later date.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agostring-list.[ch]: add a string_list_init_{nodup,dup}()
Ævar Arnfjörð Bjarmason [Thu, 1 Jul 2021 10:51:28 +0000 (12:51 +0200)] 
string-list.[ch]: add a string_list_init_{nodup,dup}()

In order to use the new "memcpy() a 'blank' struct on the stack"
pattern for string_list_init(), and to make the macro initialization
consistent with the function initialization introduce two new
string_list_init_{nodup,dup}() functions. These are like the old
string_list_init() when called with a false and true second argument,
respectively.

I think this not only makes things more consistent, but also easier to
read. I often had to lookup what the ", 0)" or ", 1)" in these
invocations meant, now it's right there in the function name, and
corresponds to the macros.

A subsequent commit will convert existing API users to this pattern,
but as this is a very common API let's leave a compatibility function
in place for later removal. This intermediate state also proves that
the compatibility function works.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agodir.[ch]: replace dir_init() with DIR_INIT
Ævar Arnfjörð Bjarmason [Thu, 1 Jul 2021 10:51:27 +0000 (12:51 +0200)] 
dir.[ch]: replace dir_init() with DIR_INIT

Remove the dir_init() function and replace it with a DIR_INIT
macro. In many cases in the codebase we need to initialize things with
a function for good reasons, e.g. needing to call another function on
initialization. The "dir_init()" function was not one such case, and
could trivially be replaced with a more idiomatic macro initialization
pattern.

The only place where we made use of its use of memset() was in
dir_clear() itself, which resets the contents of an an existing struct
pointer. Let's use the new "memcpy() a 'blank' struct on the stack"
idiom to do that reset.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years ago*.c *_init(): define in terms of corresponding *_INIT macro
Ævar Arnfjörð Bjarmason [Thu, 1 Jul 2021 10:51:26 +0000 (12:51 +0200)] 
*.c *_init(): define in terms of corresponding *_INIT macro

Change the common patter in the codebase of duplicating the
initialization logic between an *_INIT macro and a
corresponding *_init() function to use the macro as the canonical
source of truth.

Now we no longer need to keep the function up-to-date with the macro
version. This implements a suggestion by Jeff King who found that
under -O2 [1] modern compilers will init new version in place without
the extra copy[1]. The performance of a single *_init() won't matter
in most cases, but even if it does we're going to be producing
efficient machine code to perform these operations.

1. https://lore.kernel.org/git/YNyrDxUO1PlGJvCn@coredump.intra.peff.net/

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years ago*.h: move some *_INIT to designated initializers
Ævar Arnfjörð Bjarmason [Thu, 1 Jul 2021 10:51:25 +0000 (12:51 +0200)] 
*.h: move some *_INIT to designated initializers

Move *_INIT macros I'll use in a subsequent commits to designated
initializers. This isn't required for those follow-up changes, but
since next commits will change things in this area, let's use the
modern pattern over the old one while we're at it.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agotest-lib: avoid accidental globbing in match_pattern_list()
Jeff King [Wed, 16 Jun 2021 10:23:07 +0000 (06:23 -0400)] 
test-lib: avoid accidental globbing in match_pattern_list()

We have a custom match_pattern_list() function which we use for matching
test names (like "t1234") against glob-like patterns (like "t1???") for
$GIT_SKIP_TESTS, --verbose-only, etc.

Those patterns may have multiple whitespace-separated elements (e.g.,
"t0* t1234 t5?78"). The callers of match_pattern_list thus pass the
strings unquoted, so that the shell does the usual field-splitting into
separate arguments.

But this also means the shell will do the usual globbing for each
argument, which can result in us seeing an expansion based on what's in
the filesystem, rather than the real pattern. For example, if I have the
path "t5000" in the filesystem, and you feed the pattern "t?000", that
_should_ match the string "t0000", but it won't after the shell has
expanded it to "t5000".

This has been a bug ever since that function was introduced. But it
didn't usually trigger since we typically use the function inside the
trash directory, which has a very limited set of files that are unlikely
to match. It became a lot easier to trigger after edc23840b0 (test-lib:
bring $remove_trash out of retirement, 2021-05-10), because now we match
$GIT_SKIP_TESTS before even entering the trash directory. So the t5000
example above can be seen with:

  GIT_SKIP_TESTS=t?000 ./t0000-basic.sh

which should skip all tests but doesn't.

We can fix this by using "set -f" to ask the shell not to glob (which is
in POSIX, so should hopefully be portable enough). We only want to do
this in a subshell (to avoid polluting the rest of the script), which
means we need to get the whole string intact into the match_pattern_list
function by quoting it. Arguably this is a good idea anyway, since it
makes it much more obvious that we intend to split, and it's not simply
sloppy scripting.

Diagnosed-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agofetch: document the --negotiate-only option
Ævar Arnfjörð Bjarmason [Wed, 30 Jun 2021 16:38:11 +0000 (18:38 +0200)] 
fetch: document the --negotiate-only option

There was no documentation for the --negotiate-only option added in
9c1e657a8fd (fetch: teach independent negotiation (no packfile),
2021-05-04), only documentation for the related push.negotiation
option added in the following commit in 477673d6f39 (send-pack:
support push negotiation, 2021-05-04).

Let's document it, and update the cross-linking I'd added between
--negotiation-tip=* and 'fetch.negotiationAlgorithm' in
526608284a7 (fetch doc: cross-link two new negotiation options,
2018-08-01).

I think it would be better to say "in common with the remote" here
than "...the server", but the documentation for --negotiation-tip=*
above this talks about "the server", so let's continue doing that in
this related option. See 3390e42adb3 (fetch-pack: support negotiation
tip whitelist, 2018-07-02) for that documentation.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agosend-pack.c: move "no refs in common" abort earlier
Ævar Arnfjörð Bjarmason [Wed, 30 Jun 2021 16:38:10 +0000 (18:38 +0200)] 
send-pack.c: move "no refs in common" abort earlier

Move the early return if we have no remote refs in send_pack()
earlier.

When this was added in 4c353e890c0 (Warn when send-pack does nothing,
2005-12-04) one of the first things we'd do was to abort, but as of
cfee10a773b (send-pack/receive-pack: allow errors to be reported back
to pusher., 2005-12-25) we've added numerous server_supports()
conditions that are acted on later in the function, that won't be used
if we don't have remote refs.

Then as of 477673d6f39 (send-pack: support push negotiation,
2021-05-04) we started doing even more work on the assumption that we
had some remote refs to feed to --negotiation-tip=* options.

We only hit this condition if we have nothing to push, so we don't
need to consider "push.negotiate" etc. only to do nothing with that
information.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agomerge-recursive: handle rename-to-self case
Elijah Newren [Wed, 30 Jun 2021 17:30:00 +0000 (17:30 +0000)] 
merge-recursive: handle rename-to-self case

Directory rename detection can cause transitive renames, e.g. if the two
different sides of history each do one half of:
    A/file -> B/file
    B/     -> C/
then directory rename detection transitively renames to give us
    A/file -> C/file

However, when C/ == A/, note that this gives us
    A/file -> A/file.

merge-recursive assumed that any rename D -> E would have D != E.  While
that is almost always true, the above is a special case where it is not.
So we cannot do things like delete the rename source, we cannot assume
that a file existing at path E implies a rename/add conflict and we have
to be careful about what stages end up in the output.

This change feels a bit hackish.  It took me surprisingly many hours to
find, and given merge-recursive's design causing it to attempt to
enumerate all combinations of edge and corner cases with special code
for each combination, I'm worried there are other similar fixes needed
elsewhere if we can just come up with the right special testcase.
Perhaps an audit would rule it out, but I have not the energy.
merge-recursive deserves to die, and since it is on its way out anyway,
fixing this particular bug narrowly will have to be good enough.

Reported-by: Anders Kaseorg <andersk@mit.edu>
Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agomerge-ort: ensure we consult df_conflict and path_conflicts
Elijah Newren [Wed, 30 Jun 2021 17:29:59 +0000 (17:29 +0000)] 
merge-ort: ensure we consult df_conflict and path_conflicts

Path conflicts (typically rename path conflicts, e.g.
rename/rename(1to2) or rename/add/delete), and directory/file conflicts
should obviously result in files not being marked as clean in the merge.
We had a codepath where we missed consulting the path_conflict and
df_conflict flags, based on match_mask.  Granted, it requires an unusual
setup to trigger this codepath (directory rename causing rename-to-self
is the only case I can think of), but we still need to handle it.  To
make it clear that we have audited the other codepaths that do not
explicitly mention these flags, add some assertions that the flags are
not set.

Reported-by: Anders Kaseorg <andersk@mit.edu>
Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agot6423: test directory renames causing rename-to-self
Elijah Newren [Wed, 30 Jun 2021 17:29:58 +0000 (17:29 +0000)] 
t6423: test directory renames causing rename-to-self

Directory rename detection can cause transitive renames, e.g. if the two
different sides of history each do one half of:
    A/file -> B/file
    B/     -> C/
then directory rename detection transitively renames to give us C/file.
Since the default for merge.directoryRenames is conflict, this results
in an error message saying it is unclear whether the file should be
placed at B/file or C/file.

What if C/ is A/, though?  In such a case, the transitive rename would
give us A/file, the original name we started with.  Logically, having
an error message with B/file vs. A/file should be fine, as should
leaving the file where it started.  But the logic in both
merge-recursive and merge-ort did not handle a case of a filename being
renamed to itself correctly; merge-recursive had two bugs, and merge-ort
had one.  Add some testcases covering such a scenario.

Based-on-testcase-by: Anders Kaseorg <andersk@mit.edu>
Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agogrep: report missing left operand of --and
René Scharfe [Wed, 30 Jun 2021 16:12:43 +0000 (18:12 +0200)] 
grep: report missing left operand of --and

Git grep allows combining two patterns with --and.  It checks and
reports if the second pattern is missing when compiling the expression.
A missing first pattern, however, is only reported later at match time.
Thus no error is returned if no matching is done, e.g. because no file
matches the also given pathspec.

When that happens we get an expression tree with an GREP_NODE_AND node
and a NULL pointer to the missing left child.  free_pattern_expr()
tries to dereference it during the cleanup at the end, which results
in a segmentation fault.

Fix this by verifying the presence of the left operand at expression
compilation time.

Reported-by: Matthew Hughes <matthewhughes934@gmail.com>
Helped-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoxmmap: inform Linux users of tuning knobs on ENOMEM
Eric Wong [Wed, 30 Jun 2021 00:01:32 +0000 (00:01 +0000)] 
xmmap: inform Linux users of tuning knobs on ENOMEM

Linux users may benefit from additional information on how to
avoid ENOMEM from mmap despite the system having enough RAM to
accomodate them.  We can't reliably unmap pack windows to work
around the issue since malloc and other library routines may
mmap without our knowledge.

Signed-off-by: Eric Wong <e@80x24.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agotest-lib.sh: set COLUMNS=80 for --verbose repeatability
Ævar Arnfjörð Bjarmason [Tue, 29 Jun 2021 11:29:36 +0000 (13:29 +0200)] 
test-lib.sh: set COLUMNS=80 for --verbose repeatability

Some tests will fail under --verbose because while we've unset COLUMNS
since b1d645b58ac (tests: unset COLUMNS inherited from environment,
2012-03-27), we also look for the columns with an ioctl(..,
TIOCGWINSZ, ...) on some platforms. By setting COLUMNS again we
preempt the TIOCGWINSZ lookup in pager.c's term_columns(), it'll take
COLUMNS over TIOCGWINSZ,

This fixes t0500-progress-display.sh., which broke because of a
combination of the this issue and the progress output reacting to the
column width since 545dc345ebd (progress: break too long progress bar
lines, 2019-04-12). The t5324-split-commit-graph.sh fails in a similar
manner due to progress output, see [1] for details.

The issue is not specific to progress.c, the diff code also checks
COLUMNS and some of its tests can be made to fail in a similar
manner[2], anything that invokes a pager is potentially affected.

See ea77e675e56 (Make "git help" react to window size correctly,
2005-12-18) and ad6c3739a33 (pager: find out the terminal width before
spawning the pager, 2012-02-12) for how the TIOCGWINSZ code ended up
in pager.c

1. http://lore.kernel.org/git/20210624051253.GG6312@szeder.dev
2. https://lore.kernel.org/git/20210627074419.GH6312@szeder.dev/

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>