]> git.ipfire.org Git - thirdparty/git.git/log
thirdparty/git.git
2 years agoMerge branch 'tb/midx-no-bitmap-for-no-objects'
Junio C Hamano [Fri, 18 Feb 2022 21:53:30 +0000 (13:53 -0800)] 
Merge branch 'tb/midx-no-bitmap-for-no-objects'

When there is no object to write .bitmap file for, "git
multi-pack-index" triggered an error, instead of just skipping,
which has been corrected.

* tb/midx-no-bitmap-for-no-objects:
  midx: prevent writing a .bitmap without any objects

2 years agoMerge branch 'ab/release-transport-ls-refs-options'
Junio C Hamano [Fri, 18 Feb 2022 21:53:29 +0000 (13:53 -0800)] 
Merge branch 'ab/release-transport-ls-refs-options'

* ab/release-transport-ls-refs-options:
  ls-remote & transport API: release "struct transport_ls_refs_options"

2 years agoMerge branch 'ab/hash-object-leakfix'
Junio C Hamano [Fri, 18 Feb 2022 21:53:29 +0000 (13:53 -0800)] 
Merge branch 'ab/hash-object-leakfix'

Trivial leakfix.

* ab/hash-object-leakfix:
  hash-object: fix a trivial leak in --path

2 years agoMerge branch 'gc/branch-recurse-submodules'
Junio C Hamano [Fri, 18 Feb 2022 21:53:29 +0000 (13:53 -0800)] 
Merge branch 'gc/branch-recurse-submodules'

"git branch" learned the "--recurse-submodules" option.

* gc/branch-recurse-submodules:
  branch.c: use 'goto cleanup' in setup_tracking() to fix memory leaks
  branch: add --recurse-submodules option for branch creation
  builtin/branch: consolidate action-picking logic in cmd_branch()
  branch: add a dry_run parameter to create_branch()
  branch: make create_branch() always create a branch
  branch: move --set-upstream-to behavior to dwim_and_setup_tracking()

2 years agoMerge branch 'ab/t0051-skip-on-non-windows'
Junio C Hamano [Fri, 18 Feb 2022 21:53:28 +0000 (13:53 -0800)] 
Merge branch 'ab/t0051-skip-on-non-windows'

Conditional test update.

* ab/t0051-skip-on-non-windows:
  t0051: use "skip_all" under !MINGW in single-test file

2 years agoMerge branch 'ps/avoid-unnecessary-hook-invocation-with-packed-refs'
Junio C Hamano [Fri, 18 Feb 2022 21:53:27 +0000 (13:53 -0800)] 
Merge branch 'ps/avoid-unnecessary-hook-invocation-with-packed-refs'

Because a deletion of ref would need to remove it from both the
loose ref store and the packed ref store, a delete-ref operation
that logically removes one ref may end up invoking ref-transaction
hook twice, which has been corrected.

* ps/avoid-unnecessary-hook-invocation-with-packed-refs:
  refs: skip hooks when deleting uncovered packed refs
  refs: do not execute reference-transaction hook on packing refs
  refs: demonstrate excessive execution of the reference-transaction hook
  refs: allow skipping the reference-transaction hook
  refs: allow passing flags when beginning transactions
  refs: extract packed_refs_delete_refs() to allow control of transaction

2 years agoMerge branch 'pw/use-in-process-checkout-in-rebase'
Junio C Hamano [Fri, 18 Feb 2022 21:53:27 +0000 (13:53 -0800)] 
Merge branch 'pw/use-in-process-checkout-in-rebase'

Use an internal call to reset_head() helper function instead of
spawning "git checkout" in "rebase", and update code paths that are
involved in the change.

* pw/use-in-process-checkout-in-rebase:
  rebase -m: don't fork git checkout
  rebase --apply: set ORIG_HEAD correctly
  rebase --apply: fix reflog
  reset_head(): take struct rebase_head_opts
  rebase: cleanup reset_head() calls
  create_autostash(): remove unneeded parameter
  reset_head(): make default_reflog_action optional
  reset_head(): factor out ref updates
  reset_head(): remove action parameter
  rebase --apply: don't run post-checkout hook if there is an error
  rebase: do not remove untracked files on checkout
  rebase: pass correct arguments to post-checkout hook
  t5403: refactor rebase post-checkout hook tests
  rebase: factor out checkout for up to date branch

2 years agoMerge branch 'cb/clear-quarantine-early-on-all-ref-update-errors'
Junio C Hamano [Fri, 18 Feb 2022 21:53:27 +0000 (13:53 -0800)] 
Merge branch 'cb/clear-quarantine-early-on-all-ref-update-errors'

"receive-pack" checks if it will do any ref updates (various
conditions could reject a push) before received objects are taken
out of the temporary directory used for quarantine purposes, so
that a push that is known-to-fail will not leave crufts that a
future "gc" needs to clean up.

* cb/clear-quarantine-early-on-all-ref-update-errors:
  receive-pack: purge temporary data if no command is ready to run

2 years agoThe fifth batch
Junio C Hamano [Fri, 18 Feb 2022 00:24:23 +0000 (16:24 -0800)] 
The fifth batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agoMerge branch 'ab/complete-show-all-commands'
Junio C Hamano [Fri, 18 Feb 2022 00:25:05 +0000 (16:25 -0800)] 
Merge branch 'ab/complete-show-all-commands'

The command line completion script (in contrib/) learned to
complete all Git subcommands, including the ones that are normally
hidden, when GIT_COMPLETION_SHOW_ALL_COMMANDS is used.

* ab/complete-show-all-commands:
  completion: add a GIT_COMPLETION_SHOW_ALL_COMMANDS
  completion tests: re-source git-completion.bash in a subshell

2 years agoMerge branch 'sy/modernize-t-lib-read-tree-m-3way'
Junio C Hamano [Fri, 18 Feb 2022 00:25:05 +0000 (16:25 -0800)] 
Merge branch 'sy/modernize-t-lib-read-tree-m-3way'

Style updates on a test script helper.

* sy/modernize-t-lib-read-tree-m-3way:
  t/lib-read-tree-m-3way: indent with tabs
  t/lib-read-tree-m-3way: modernize style

2 years agoMerge branch 'po/doc-check-ignore-markup-fix'
Junio C Hamano [Fri, 18 Feb 2022 00:25:05 +0000 (16:25 -0800)] 
Merge branch 'po/doc-check-ignore-markup-fix'

Typofix.

* po/doc-check-ignore-markup-fix:
  doc: check-ignore: code-quote an exclamation mark

2 years agoMerge branch 'js/scalar-global-options'
Junio C Hamano [Fri, 18 Feb 2022 00:25:05 +0000 (16:25 -0800)] 
Merge branch 'js/scalar-global-options'

Scalar update.

* js/scalar-global-options:
  scalar: accept -C and -c options before the subcommand

2 years agoMerge branch 'vd/sparse-clean-etc'
Junio C Hamano [Fri, 18 Feb 2022 00:25:05 +0000 (16:25 -0800)] 
Merge branch 'vd/sparse-clean-etc'

"git update-index", "git checkout-index", and "git clean" are
taught to work better with the sparse checkout feature.

* vd/sparse-clean-etc:
  update-index: reduce scope of index expansion in do_reupdate
  update-index: integrate with sparse index
  update-index: add tests for sparse-checkout compatibility
  checkout-index: integrate with sparse index
  checkout-index: add --ignore-skip-worktree-bits option
  checkout-index: expand sparse checkout compatibility tests
  clean: integrate with sparse index
  reset: reorder wildcard pathspec conditions
  reset: fix validation in sparse index test

2 years agoMerge branch 'jz/rev-list-exclude-first-parent-only'
Junio C Hamano [Fri, 18 Feb 2022 00:25:05 +0000 (16:25 -0800)] 
Merge branch 'jz/rev-list-exclude-first-parent-only'

"git log" and friends learned an option --exclude-first-parent-only
to propagate UNINTERESTING bit down only along the first-parent
chain, just like --first-parent option shows commits that lack the
UNINTERESTING bit only along the first-parent chain.

* jz/rev-list-exclude-first-parent-only:
  git-rev-list: add --exclude-first-parent-only flag

2 years agoMerge branch 'jz/patch-id-hunk-header-parsing-fix'
Junio C Hamano [Fri, 18 Feb 2022 00:25:04 +0000 (16:25 -0800)] 
Merge branch 'jz/patch-id-hunk-header-parsing-fix'

Unlike "git apply", "git patch-id" did not handle patches with
hunks that has only 1 line in either preimage or postimage, which
has been corrected.

* jz/patch-id-hunk-header-parsing-fix:
  patch-id: fix scan_hunk_header on diffs with 1 line of before/after
  patch-id: fix antipatterns in tests

2 years agoMerge branch 'hn/reftable-tests'
Junio C Hamano [Fri, 18 Feb 2022 00:25:04 +0000 (16:25 -0800)] 
Merge branch 'hn/reftable-tests'

Prepare more test scripts for the introduction of reftable.

* hn/reftable-tests:
  t5312: prepare for reftable
  t1405: mark test that checks existence as REFFILES
  t1405: explictly delete reflogs for reftable

2 years agoMerge branch 'tk/subtree-merge-not-ff-only'
Junio C Hamano [Fri, 18 Feb 2022 00:25:04 +0000 (16:25 -0800)] 
Merge branch 'tk/subtree-merge-not-ff-only'

When "git subtree" wants to create a merge, it used "git merge" and
let it be affected by end-user's "merge.ff" configuration, which
has been corrected.

* tk/subtree-merge-not-ff-only:
  subtree: force merge commit

2 years agoThe fourth batch
Junio C Hamano [Wed, 16 Feb 2022 23:12:19 +0000 (15:12 -0800)] 
The fourth batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agoMerge branch 'ab/do-not-hide-failures-in-git-dot-pm'
Junio C Hamano [Wed, 16 Feb 2022 23:14:30 +0000 (15:14 -0800)] 
Merge branch 'ab/do-not-hide-failures-in-git-dot-pm'

Git.pm update.

* ab/do-not-hide-failures-in-git-dot-pm:
  perl Git.pm: don't ignore signalled failure in _cmd_close()

2 years agoMerge branch 'js/no-more-legacy-stash'
Junio C Hamano [Wed, 16 Feb 2022 23:14:30 +0000 (15:14 -0800)] 
Merge branch 'js/no-more-legacy-stash'

Removal of unused code and doc.

* js/no-more-legacy-stash:
  stash: stop warning about the obsolete `stash.useBuiltin` config setting
  stash: remove documentation for `stash.useBuiltin`
  add: remove support for `git-legacy-stash`
  git-sh-setup: remove remnant bits referring to `git-legacy-stash`

2 years agoMerge branch 'js/diff-filter-negation-fix'
Junio C Hamano [Wed, 16 Feb 2022 23:14:30 +0000 (15:14 -0800)] 
Merge branch 'js/diff-filter-negation-fix'

"git diff --diff-filter=aR" is now parsed correctly.

* js/diff-filter-negation-fix:
  diff-filter: be more careful when looking for negative bits
  diff.c: move the diff filter bits definitions up a bit
  docs(diff): lose incorrect claim about `diff-files --diff-filter=A`

2 years agoMerge branch 'en/fetch-negotiation-default-fix'
Junio C Hamano [Wed, 16 Feb 2022 23:14:30 +0000 (15:14 -0800)] 
Merge branch 'en/fetch-negotiation-default-fix'

Interaction between fetch.negotiationAlgorithm and
feature.experimental configuration variables has been corrected.

* en/fetch-negotiation-default-fix:
  repo-settings: rename the traditional default fetch.negotiationAlgorithm
  repo-settings: fix error handling for unknown values
  repo-settings: fix checking for fetch.negotiationAlgorithm=default

2 years agoMerge branch 'ab/auto-detect-zlib-compress2'
Junio C Hamano [Wed, 16 Feb 2022 23:14:29 +0000 (15:14 -0800)] 
Merge branch 'ab/auto-detect-zlib-compress2'

The build procedure has been taught to notice older version of zlib
and enable our replacement uncompress2() automatically.

* ab/auto-detect-zlib-compress2:
  compat: auto-detect if zlib has uncompress2()

2 years agoMerge branch 'tb/midx-bitmap-corruption-fix'
Junio C Hamano [Wed, 16 Feb 2022 23:14:29 +0000 (15:14 -0800)] 
Merge branch 'tb/midx-bitmap-corruption-fix'

A bug that made multi-pack bitmap and the object order out-of-sync,
making the .midx data corrupt, has been fixed.

* tb/midx-bitmap-corruption-fix:
  pack-bitmap.c: gracefully fallback after opening pack/MIDX
  midx: read `RIDX` chunk when present
  t/lib-bitmap.sh: parameterize tests over reverse index source
  t5326: move tests to t/lib-bitmap.sh
  t5326: extract `test_rev_exists`
  t5326: drop unnecessary setup
  pack-revindex.c: instrument loading on-disk reverse index
  midx.c: make changing the preferred pack safe
  t5326: demonstrate bitmap corruption after permutation

2 years agoMerge branch 'en/remerge-diff'
Junio C Hamano [Wed, 16 Feb 2022 23:14:29 +0000 (15:14 -0800)] 
Merge branch 'en/remerge-diff'

"git log --remerge-diff" shows the difference from mechanical merge
result and the result that is actually recorded in a merge commit.

* en/remerge-diff:
  diff-merges: avoid history simplifications when diffing merges
  merge-ort: mark conflict/warning messages from inner merges as omittable
  show, log: include conflict/warning messages in --remerge-diff headers
  diff: add ability to insert additional headers for paths
  merge-ort: format messages slightly different for use in headers
  merge-ort: mark a few more conflict messages as omittable
  merge-ort: capture and print ll-merge warnings in our preferred fashion
  ll-merge: make callers responsible for showing warnings
  log: clean unneeded objects during `log --remerge-diff`
  show, log: provide a --remerge-diff capability

2 years agoMerge branch 'hn/reftable-coverity-fixes'
Junio C Hamano [Wed, 16 Feb 2022 23:14:27 +0000 (15:14 -0800)] 
Merge branch 'hn/reftable-coverity-fixes'

Problems identified by Coverity in the reftable code have been
corrected.

* hn/reftable-coverity-fixes:
  reftable: add print functions to the record types
  reftable: make reftable_record a tagged union
  reftable: remove outdated file reftable.c
  reftable: implement record equality generically
  reftable: make reftable-record.h function signatures const correct
  reftable: handle null refnames in reftable_ref_record_equal
  reftable: drop stray printf in readwrite_test
  reftable: order unittests by complexity
  reftable: all xxx_free() functions accept NULL arguments
  reftable: fix resource warning
  reftable: ignore remove() return value in stack_test.c
  reftable: check reftable_stack_auto_compact() return value
  reftable: fix resource leak blocksource.c
  reftable: fix resource leak in block.c error path
  reftable: fix OOB stack write in print functions

2 years agoMerge branch 'll/doc-mktree-typofix'
Junio C Hamano [Wed, 16 Feb 2022 23:14:26 +0000 (15:14 -0800)] 
Merge branch 'll/doc-mktree-typofix'

Typofix.

* ll/doc-mktree-typofix:
  fix typo in git-mktree.txt

2 years agoMerge branch 'ld/sparse-index-bash-completion'
Junio C Hamano [Wed, 16 Feb 2022 23:14:26 +0000 (15:14 -0800)] 
Merge branch 'ld/sparse-index-bash-completion'

The command line completion (in contrib/) learns to complete
arguments to give to "git sparse-checkout" command.

* ld/sparse-index-bash-completion:
  completion: handle unusual characters for sparse-checkout
  completion: improve sparse-checkout cone mode directory completion
  completion: address sparse-checkout issues

2 years agoThe third batch
Junio C Hamano [Sat, 12 Feb 2022 00:49:31 +0000 (16:49 -0800)] 
The third batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agoMerge branch 'sy/diff-usage-typofix'
Junio C Hamano [Sat, 12 Feb 2022 00:56:01 +0000 (16:56 -0800)] 
Merge branch 'sy/diff-usage-typofix'

Typofix.

* sy/diff-usage-typofix:
  builtin/diff.c: fix "git-diff" usage string typo

2 years agoMerge branch 'tg/fetch-prune-exit-code-fix'
Junio C Hamano [Sat, 12 Feb 2022 00:56:01 +0000 (16:56 -0800)] 
Merge branch 'tg/fetch-prune-exit-code-fix'

When "git fetch --prune" failed to prune the refs it wanted to
prune, the command issued error messages but exited with exit
status 0, which has been corrected.

* tg/fetch-prune-exit-code-fix:
  fetch --prune: exit with error if pruning fails

2 years agoMerge branch 'en/sparse-checkout-leakfix'
Junio C Hamano [Sat, 12 Feb 2022 00:56:01 +0000 (16:56 -0800)] 
Merge branch 'en/sparse-checkout-leakfix'

Leakfix.

* en/sparse-checkout-leakfix:
  sparse-checkout: fix a couple minor memory leaks

2 years agoMerge branch 'rc/negotiate-only-typofix'
Junio C Hamano [Sat, 12 Feb 2022 00:55:59 +0000 (16:55 -0800)] 
Merge branch 'rc/negotiate-only-typofix'

Typofix.

* rc/negotiate-only-typofix:
  fetch: fix negotiate-only error message

2 years agoMerge branch 'jc/doc-log-messages'
Junio C Hamano [Sat, 12 Feb 2022 00:55:58 +0000 (16:55 -0800)] 
Merge branch 'jc/doc-log-messages'

Update the contributor-facing documents on proposed log messages.

* jc/doc-log-messages:
  SubmittingPatches: explain why we care about log messages
  CodingGuidelines: hint why we value clearly written log messages
  SubmittingPatches: write problem statement in the log in the present tense

2 years agoMerge branch 'ab/no-errno-from-resolve-ref-unsafe'
Junio C Hamano [Sat, 12 Feb 2022 00:55:58 +0000 (16:55 -0800)] 
Merge branch 'ab/no-errno-from-resolve-ref-unsafe'

Remaining code-clean-up.

* ab/no-errno-from-resolve-ref-unsafe:
  refs API: remove "failure_errno" from refs_resolve_ref_unsafe()
  sequencer: don't use die_errno() on refs_resolve_ref_unsafe() failure

2 years agoMerge branch 'gh/doc-typos'
Junio C Hamano [Sat, 12 Feb 2022 00:55:58 +0000 (16:55 -0800)] 
Merge branch 'gh/doc-typos'

Typofix.

* gh/doc-typos:
  Documentation/config/pgp.txt: add missing apostrophe
  Documentation/config/pgp.txt: replace stray <TAB> character with <SPC>

2 years agoMerge branch 'rs/parse-options-lithelp-help'
Junio C Hamano [Sat, 12 Feb 2022 00:55:58 +0000 (16:55 -0800)] 
Merge branch 'rs/parse-options-lithelp-help'

Comment update.

* rs/parse-options-lithelp-help:
  parse-options: document bracketing of argh

2 years agoMerge branch 'bc/csprng-mktemps'
Junio C Hamano [Sat, 12 Feb 2022 00:55:57 +0000 (16:55 -0800)] 
Merge branch 'bc/csprng-mktemps'

Pick a better random number generator and use it when we prepare
temporary filenames.

* bc/csprng-mktemps:
  wrapper: use a CSPRNG to generate random file names
  wrapper: add a helper to generate numbers from a CSPRNG

2 years agoMerge branch 'bc/clarify-eol-attr'
Junio C Hamano [Sat, 12 Feb 2022 00:55:57 +0000 (16:55 -0800)] 
Merge branch 'bc/clarify-eol-attr'

Doc and test update around the eol attribute.

* bc/clarify-eol-attr:
  docs: correct documentation about eol attribute
  t0027: add tests for eol without text in .gitattributes

2 years agoThe second batch for 2.36
Junio C Hamano [Wed, 9 Feb 2022 22:21:18 +0000 (14:21 -0800)] 
The second batch for 2.36

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agoMerge branch 'jc/mem-pool-alignment'
Junio C Hamano [Wed, 9 Feb 2022 22:21:01 +0000 (14:21 -0800)] 
Merge branch 'jc/mem-pool-alignment'

Update the logic to compute alignment requirement for our mem-pool.

* jc/mem-pool-alignment:
  mem-pool: don't assume uintmax_t is aligned enough for all types

2 years agoMerge branch 'js/sparse-vs-split-index'
Junio C Hamano [Wed, 9 Feb 2022 22:21:01 +0000 (14:21 -0800)] 
Merge branch 'js/sparse-vs-split-index'

Mark in various places in the code that the sparse index and the
split index features are mutually incompatible.

* js/sparse-vs-split-index:
  split-index: it really is incompatible with the sparse index
  t1091: disable split index
  sparse-index: sparse index is disallowed when split index is active

2 years agoMerge branch 'jt/clone-not-quite-empty'
Junio C Hamano [Wed, 9 Feb 2022 22:21:01 +0000 (14:21 -0800)] 
Merge branch 'jt/clone-not-quite-empty'

Cloning from a repository that does not yet have any branches or
tags but has other refs resulted in a "remote transport reported
error", which has been corrected.

* jt/clone-not-quite-empty:
  clone: support unusual remote ref configurations

2 years agoMerge branch 'jt/sparse-checkout-leading-dir-fix'
Junio C Hamano [Wed, 9 Feb 2022 22:21:00 +0000 (14:21 -0800)] 
Merge branch 'jt/sparse-checkout-leading-dir-fix'

"git sparse-checkout init" failed to write into $GIT_DIR/info
directory when the repository was created without one, which has
been corrected to auto-create it.

* jt/sparse-checkout-leading-dir-fix:
  sparse-checkout: create leading directory

2 years agoMerge branch 'en/plug-leaks-in-merge'
Junio C Hamano [Wed, 9 Feb 2022 22:21:00 +0000 (14:21 -0800)] 
Merge branch 'en/plug-leaks-in-merge'

Leakfix.

* en/plug-leaks-in-merge:
  merge: fix memory leaks in cmd_merge()
  merge-ort: fix memory leak in merge_ort_internal()

2 years agoMerge branch 'ab/config-based-hooks-2'
Junio C Hamano [Wed, 9 Feb 2022 22:21:00 +0000 (14:21 -0800)] 
Merge branch 'ab/config-based-hooks-2'

More "config-based hooks".

* ab/config-based-hooks-2:
  run-command: remove old run_hook_{le,ve}() hook API
  receive-pack: convert push-to-checkout hook to hook.h
  read-cache: convert post-index-change to use hook.h
  commit: convert {pre-commit,prepare-commit-msg} hook to hook.h
  git-p4: use 'git hook' to run hooks
  send-email: use 'git hook run' for 'sendemail-validate'
  git hook run: add an --ignore-missing flag
  hooks: convert worktree 'post-checkout' hook to hook library
  hooks: convert non-worktree 'post-checkout' hook to hook library
  merge: convert post-merge to use hook.h
  am: convert applypatch-msg to use hook.h
  rebase: convert pre-rebase to use hook.h
  hook API: add a run_hooks_l() wrapper
  am: convert {pre,post}-applypatch to use hook.h
  gc: use hook library for pre-auto-gc hook
  hook API: add a run_hooks() wrapper
  hook: add 'run' subcommand

2 years agoMerge branch 'fs/ssh-signing-crlf'
Junio C Hamano [Wed, 9 Feb 2022 22:21:00 +0000 (14:21 -0800)] 
Merge branch 'fs/ssh-signing-crlf'

The code path that verifies signatures made with ssh were made to
work better on a system with CRLF line endings.

* fs/ssh-signing-crlf:
  gpg-interface: trim CR from ssh-keygen

2 years agoMerge branch 'jc/name-rev-stdin'
Junio C Hamano [Wed, 9 Feb 2022 22:21:00 +0000 (14:21 -0800)] 
Merge branch 'jc/name-rev-stdin'

"git name-rev --stdin" does not behave like usual "--stdin" at
all.  Start the process of renaming it to "--annotate-stdin".

* jc/name-rev-stdin:
  name-rev.c: use strbuf_getline instead of limited size buffer
  name-rev: deprecate --stdin in favor of --annotate-stdin

2 years agoMerge branch 'gc/fetch-negotiate-only-early-return'
Junio C Hamano [Wed, 9 Feb 2022 22:20:59 +0000 (14:20 -0800)] 
Merge branch 'gc/fetch-negotiate-only-early-return'

"git fetch --negotiate-only" is an internal command used by "git
push" to figure out which part of our history is missing from the
other side.  It should never recurse into submodules even when
fetch.recursesubmodules configuration variable is set, nor it
should trigger "gc".  The code has been tightened up to ensure it
only does common ancestry discovery and nothing else.

* gc/fetch-negotiate-only-early-return:
  fetch: help translators by reusing the same message template
  fetch --negotiate-only: do not update submodules
  fetch: skip tasks related to fetching objects
  fetch: use goto cleanup in cmd_fetch()

2 years agoMerge branch 'pw/add-p-hunk-split-fix'
Junio C Hamano [Wed, 9 Feb 2022 22:20:59 +0000 (14:20 -0800)] 
Merge branch 'pw/add-p-hunk-split-fix'

"git add -p" rewritten in C regressed hunk splitting in some cases,
which has been corrected.

* pw/add-p-hunk-split-fix:
  builtin add -p: fix hunk splitting
  t3701: clean up hunk splitting tests

2 years agoMerge branch 'tl/doc-cli-options-first'
Junio C Hamano [Wed, 9 Feb 2022 22:20:59 +0000 (14:20 -0800)] 
Merge branch 'tl/doc-cli-options-first'

We explain that revs come first before the pathspec among command
line arguments, but did not spell out that dashed options come
before other args, which has been corrected.

* tl/doc-cli-options-first:
  git-cli.txt: clarify "options first and then args"

2 years agoMerge branch 'po/readme-mention-contributor-hints'
Junio C Hamano [Wed, 9 Feb 2022 22:20:59 +0000 (14:20 -0800)] 
Merge branch 'po/readme-mention-contributor-hints'

Doc update.

* po/readme-mention-contributor-hints:
  README.md: add CodingGuidelines and a link for Translators

2 years agoMerge branch 'jt/conditional-config-on-remote-url'
Junio C Hamano [Wed, 9 Feb 2022 22:20:58 +0000 (14:20 -0800)] 
Merge branch 'jt/conditional-config-on-remote-url'

The conditional inclusion mechanism of configuration files using
"[includeIf <condition>]" learns to base its decision on the
URL of the remote repository the repository interacts with.

* jt/conditional-config-on-remote-url:
  config: include file if remote URL matches a glob
  config: make git_config_include() static

2 years agoMerge branch 'en/merge-ort-restart-optim-fix'
Junio C Hamano [Wed, 9 Feb 2022 22:20:58 +0000 (14:20 -0800)] 
Merge branch 'en/merge-ort-restart-optim-fix'

The merge-ort misbehaved when merge.renameLimit configuration is
set too low and failed to find all renames.

* en/merge-ort-restart-optim-fix:
  merge-ort: avoid assuming all renames detected

2 years agoMerge branch 'js/test-unset-trace2-parents'
Junio C Hamano [Wed, 9 Feb 2022 22:20:58 +0000 (14:20 -0800)] 
Merge branch 'js/test-unset-trace2-parents'

Avoid tests that are run under GIT_TRACE2 set from failing
unnecessarily.

* js/test-unset-trace2-parents:
  test-lib: unset trace2 parent envvars

2 years agomidx: prevent writing a .bitmap without any objects
Taylor Blau [Wed, 9 Feb 2022 19:26:47 +0000 (14:26 -0500)] 
midx: prevent writing a .bitmap without any objects

When trying to write a MIDX, we already prevent the case where there
weren't any packs present, and thus we would have written an empty MIDX.

But there is another "empty" case, which is more interesting, and we
don't yet handle. If we try to write a MIDX which has at least one pack,
but those packs together don't contain any objects, we will encounter a
BUG() when trying to use the bitmap corresponding to that MIDX, like so:

    $ git rev-parse HEAD | git pack-objects --revs --use-bitmap-index --stdout >/dev/null
    BUG: pack-revindex.c:394: pack_pos_to_midx: out-of-bounds object at 0

(note that in the above reproduction, both `--use-bitmap-index` and
`--stdout` are important, since without the former we won't even both to
load the .bitmap, and without the latter we wont attempt pack reuse).

The problem occurs when we try to discover the identity of the
preferred pack to determine which range if any of existing packs we can
reuse verbatim. This path is: `reuse_packfile_objects()` ->
`reuse_partial_packfile_from_bitmap()` -> `midx_preferred_pack()`.

    #4  0x000055555575401f in pack_pos_to_midx (m=0x555555997160, pos=0) at pack-revindex.c:394
    #5  0x00005555557502c8 in midx_preferred_pack (bitmap_git=0x55555599c280) at pack-bitmap.c:1431
    #6  0x000055555575036c in reuse_partial_packfile_from_bitmap (bitmap_git=0x55555599c280, packfile_out=0x5555559666b0 <reuse_packfile>,
        entries=0x5555559666b8 <reuse_packfile_objects>, reuse_out=0x5555559666c0 <reuse_packfile_bitmap>) at pack-bitmap.c:1452
    #7  0x00005555556041f6 in get_object_list_from_bitmap (revs=0x7fffffffcbf0) at builtin/pack-objects.c:3658
    #8  0x000055555560465c in get_object_list (ac=2, av=0x555555997050) at builtin/pack-objects.c:3765
    #9  0x0000555555605e4e in cmd_pack_objects (argc=0, argv=0x7fffffffe920, prefix=0x0) at builtin/pack-objects.c:4154

Since neither the .bitmap or MIDX stores the identity of the
preferred pack, we infer it by trying to load the first object in
pseudo-pack order, and then asking the MIDX which pack was chosen to
represent that object.

But this fails our bounds check, since there are zero objects in the
MIDX to begin with, which results in the BUG().

We could catch this more carefully in `midx_preferred_pack()`, but
signaling the absence of a preferred pack out to all of its callers is
somewhat awkward.

Instead, let's avoid writing a MIDX .bitmap without any objects
altogether. We catch this case in `write_midx_internal()`, and emit a
warning if the caller indicated they wanted to write a bitmap before
clearing out the relevant flags. If we somehow got to
write_midx_bitmap(), then we will call BUG(), but this should now be an
unreachable path.

Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agocompletion: handle unusual characters for sparse-checkout
Lessley Dennington [Mon, 7 Feb 2022 17:31:45 +0000 (17:31 +0000)] 
completion: handle unusual characters for sparse-checkout

Update the __gitcomp_directories method to de-quote and handle unusual
characters in directory names. Although this initially involved an attempt
to re-use the logic in __git_index_files, this method removed
subdirectories (e.g. folder1/0/ became folder1/), so instead new custom
logic was placed directly in the __gitcomp_directories method.

Note there are two tests for this new functionality - one for spaces and
accents and one for backslashes and tabs. The backslashes and tabs test
uses FUNNYNAMES to avoid running on Windows. This is because:

1. Backslashes are explicitly not allowed in Windows file paths.
2. Although tabs appear to be allowed when creating a file in a Windows
bash shell, they actually are not renderable (and appear as empty boxes
in the shell).

Co-authored-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Co-authored-by: Lessley Dennington <lessleydennington@gmail.com>
Helped-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Lessley Dennington <lessleydennington@gmail.com>
Reviewed-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agocompletion: improve sparse-checkout cone mode directory completion
Lessley Dennington [Mon, 7 Feb 2022 17:31:44 +0000 (17:31 +0000)] 
completion: improve sparse-checkout cone mode directory completion

Use new __gitcomp_directories method to complete directory names in cone
mode sparse-checkouts. This method addresses the caveat of poor
performance in monorepos from the previous commit (by completing only one
level of directories).

The unusual character caveat from the previous commit will be fixed by the
final commit in this series.

Co-authored-by: Elijah Newren <newren@gmail.com>
Co-authored-by: Lessley Dennington <lessleydennington@gmail.com>
Signed-off-by: Lessley Dennington <lessleydennington@gmail.com>
Reviewed-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agocompletion: address sparse-checkout issues
Lessley Dennington [Mon, 7 Feb 2022 17:31:43 +0000 (17:31 +0000)] 
completion: address sparse-checkout issues

Correct multiple issues with tab completion of the git sparse-checkout
command. These issues were:

1. git sparse-checkout <TAB> previously resulted in an incomplete list of
subcommands (it was missing reapply and add).
2. Subcommand options were not tab-completable.
3. git sparse-checkout set <TAB> and git sparse-checkout add <TAB> showed
both file names and directory names. While this may be a less surprising
behavior for non-cone mode, cone mode sparse checkouts should complete
only directory names.

Note that while the new strategy of just using git ls-tree to complete on
directory names is simple and a step in the right direction, it does have
some caveats. These are:

1. Likelihood of poor performance in large monorepos (as a result of
recursively completing directory names).
2. Inability to handle paths containing unusual characters.

These caveats will be fixed by subsequent commits in this series.

Signed-off-by: Lessley Dennington <lessleydennington@gmail.com>
Reviewed-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agols-remote & transport API: release "struct transport_ls_refs_options"
Ævar Arnfjörð Bjarmason [Sat, 5 Feb 2022 00:08:14 +0000 (01:08 +0100)] 
ls-remote & transport API: release "struct transport_ls_refs_options"

Fix a memory leak in codepaths that use the "struct
transport_ls_refs_options" API. Since the introduction of the struct
in 39835409d10 (connect, transport: encapsulate arg in struct,
2021-02-05) the caller has been responsible for freeing it.

That commit in turn migrated code originally added in
402c47d9391 (clone: send ref-prefixes when using protocol v2,
2018-07-20) and b4be74105fe (ls-remote: pass ref prefixes when
requesting a remote's refs, 2018-03-15). Only some of those codepaths
were releasing the allocated resources of the struct, now all of them
will.

Mark the "t/t5511-refspec.sh" test as passing when git is compiled
with SANITIZE=leak. They'll now be listed as running under the
"GIT_TEST_PASSING_SANITIZE_LEAK=true" test mode (the "linux-leaks" CI
target). Previously 24/47 tests would fail.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agohash-object: fix a trivial leak in --path
Ævar Arnfjörð Bjarmason [Sat, 5 Feb 2022 00:04:29 +0000 (01:04 +0100)] 
hash-object: fix a trivial leak in --path

Fix a memory leak that happened when the --path option was
provided. This leak has been with us ever since the option was added
in 39702431500 (add --path option to git hash-object, 2008-08-03).

We can now mark "t1007-hash-object.sh" as passing when git is compiled
with SANITIZE=leak. It'll now run in the the
"GIT_TEST_PASSING_SANITIZE_LEAK=true" test mode (the "linux-leaks" CI
target).

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agoThe first batch
Junio C Hamano [Sat, 5 Feb 2022 17:43:36 +0000 (09:43 -0800)] 
The first batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agoMerge branch 'ms/update-index-racy'
Junio C Hamano [Sat, 5 Feb 2022 17:42:32 +0000 (09:42 -0800)] 
Merge branch 'ms/update-index-racy'

"git update-index --refresh" has been taught to deal better with
racy timestamps (just like "git status" already does).

* ms/update-index-racy:
  update-index: refresh should rewrite index in case of racy timestamps
  t7508: add tests capturing racy timestamp handling
  t7508: fix bogus mtime verification
  test-lib: introduce API for verifying file mtime

2 years agoMerge branch 'jc/reflog-parse-options'
Junio C Hamano [Sat, 5 Feb 2022 17:42:31 +0000 (09:42 -0800)] 
Merge branch 'jc/reflog-parse-options'

Use the parse-options API in "git reflog" command.

* jc/reflog-parse-options:
  builtin/reflog.c: use parse-options api for expire, delete subcommands

2 years agoMerge branch 'ab/cat-file'
Junio C Hamano [Sat, 5 Feb 2022 17:42:31 +0000 (09:42 -0800)] 
Merge branch 'ab/cat-file'

Assorted updates to "git cat-file", especially "-h".

* ab/cat-file:
  cat-file: s/_/-/ in typo'd usage_msg_optf() message
  cat-file: don't whitespace-pad "(...)" in SYNOPSIS and usage output
  cat-file: use GET_OID_ONLY_TO_DIE in --(textconv|filters)
  object-name.c: don't have GET_OID_ONLY_TO_DIE imply *_QUIETLY
  cat-file: correct and improve usage information
  cat-file: fix remaining usage bugs
  cat-file: make --batch-all-objects a CMDMODE
  cat-file: move "usage" variable to cmd_cat_file()
  cat-file docs: fix SYNOPSIS and "-h" output
  parse-options API: add a usage_msg_optf()
  cat-file tests: test messaging on bad objects/paths
  cat-file tests: test bad usage

2 years agoMerge branch 'jc/qsort-s-alignment-fix'
Junio C Hamano [Sat, 5 Feb 2022 17:42:31 +0000 (09:42 -0800)] 
Merge branch 'jc/qsort-s-alignment-fix'

Fix a hand-rolled alloca() imitation that may have violated
alignment requirement of data being sorted in compatibility
implementation of qsort_s() and stable qsort().

* jc/qsort-s-alignment-fix:
  stable-qsort: avoid using potentially unaligned access
  compat/qsort_s.c: avoid using potentially unaligned access

2 years agoMerge branch 'rs/apply-symlinks-use-strset'
Junio C Hamano [Sat, 5 Feb 2022 17:42:30 +0000 (09:42 -0800)] 
Merge branch 'rs/apply-symlinks-use-strset'

"git apply" (ab)used the util pointer of the string-list to keep
track of how each symbolic link needs to be handled, which has been
simplified by using strset.

* rs/apply-symlinks-use-strset:
  apply: use strsets to track symlinks

2 years agoMerge branch 'rs/grep-expr-cleanup'
Junio C Hamano [Sat, 5 Feb 2022 17:42:30 +0000 (09:42 -0800)] 
Merge branch 'rs/grep-expr-cleanup'

Code clean-up.

* rs/grep-expr-cleanup:
  grep: use grep_and_expr() in compile_pattern_and()
  grep: extract grep_binexp() from grep_or_expr()
  grep: use grep_not_expr() in compile_pattern_not()
  grep: use grep_or_expr() in compile_pattern_or()

2 years agoMerge branch 'jh/p4-spawning-external-commands-cleanup'
Junio C Hamano [Sat, 5 Feb 2022 17:42:29 +0000 (09:42 -0800)] 
Merge branch 'jh/p4-spawning-external-commands-cleanup'

* jh/p4-spawning-external-commands-cleanup:
  git-p4: don't print shell commands as python lists
  git-p4: pass command arguments as lists instead of using shell
  git-p4: don't select shell mode using the type of the command argument

2 years agoMerge branch 'jh/p4-fix-use-of-process-error-exception'
Junio C Hamano [Sat, 5 Feb 2022 17:42:29 +0000 (09:42 -0800)] 
Merge branch 'jh/p4-fix-use-of-process-error-exception'

* jh/p4-fix-use-of-process-error-exception:
  git-p4: fix instantiation of CalledProcessError

2 years agoMerge branch 'jc/find-header'
Junio C Hamano [Sat, 5 Feb 2022 17:42:29 +0000 (09:42 -0800)] 
Merge branch 'jc/find-header'

Code clean-up.

* jc/find-header:
  receive-pack.c: consolidate find header logic

2 years agoMerge branch 'pb/pull-rebase-autostash-fix'
Junio C Hamano [Sat, 5 Feb 2022 17:42:28 +0000 (09:42 -0800)] 
Merge branch 'pb/pull-rebase-autostash-fix'

"git pull --rebase" ignored the rebase.autostash configuration
variable when the remote history is a descendant of our history,
which has been corrected.

* pb/pull-rebase-autostash-fix:
  pull --rebase: honor rebase.autostash when fast-forwarding

2 years agot0051: use "skip_all" under !MINGW in single-test file
Ævar Arnfjörð Bjarmason [Fri, 4 Feb 2022 13:42:14 +0000 (14:42 +0100)] 
t0051: use "skip_all" under !MINGW in single-test file

Have this file added in 06ba9d03e34 (t0051: test GIT_TRACE to a
windows named pipe, 2018-09-11) use the same "skip_all" pattern as an
existing Windows-only test added in 0e218f91c29 (mingw: unset PERL5LIB
by default, 2018-10-30) uses.

This way TAP consumers like "prove" will show a nice summary when the
test is skipped. Instead of:

    $ prove t0051-windows-named-pipe.sh
    [...]
    t0051-windows-named-pipe.sh .. ok
    [...]

We will prominently show a "skipped" notice:

    $ prove t0051-windows-named-pipe.sh
    [...]
    t0051-windows-named-pipe.sh ... skipped: skipping Windows-specific tests
    [...]

This is because we are now making use of the right TAP-y way to
communicate this to the consumer. I.e. skipping the whole test file,
v.s. skipping individual tests (in this case there's only one test).

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agobranch.c: use 'goto cleanup' in setup_tracking() to fix memory leaks
Glen Choo [Sat, 29 Jan 2022 00:04:46 +0000 (16:04 -0800)] 
branch.c: use 'goto cleanup' in setup_tracking() to fix memory leaks

Signed-off-by: Glen Choo <chooglen@google.com>
Reviewed-by: Jonathan Tan <jonathantanmy@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agobranch: add --recurse-submodules option for branch creation
Glen Choo [Sat, 29 Jan 2022 00:04:45 +0000 (16:04 -0800)] 
branch: add --recurse-submodules option for branch creation

To improve the submodules UX, we would like to teach Git to handle
branches in submodules. Start this process by teaching "git branch" the
--recurse-submodules option so that "git branch --recurse-submodules
topic" will create the `topic` branch in the superproject and its
submodules.

Although this commit does not introduce breaking changes, it does not
work well with existing --recurse-submodules commands because "git
branch --recurse-submodules" writes to the submodule ref store, but most
commands only consider the superproject gitlink and ignore the submodule
ref store. For example, "git checkout --recurse-submodules" will check
out the commits in the superproject gitlinks (and put the submodules in
detached HEAD) instead of checking out the submodule branches.

Because of this, this commit introduces a new configuration value,
`submodule.propagateBranches`. The plan is for Git commands to
prioritize submodule ref store information over superproject gitlinks if
this value is true. Because "git branch --recurse-submodules" writes to
submodule ref stores, for the sake of clarity, it will not function
unless this configuration value is set.

This commit also includes changes that support working with submodules
from a superproject commit because "branch --recurse-submodules" (and
future commands) need to read .gitmodules and gitlinks from the
superproject commit, but submodules are typically read from the
filesystem's .gitmodules and the index's gitlinks. These changes are:

* add a submodules_of_tree() helper that gives the relevant
  information of an in-tree submodule (e.g. path and oid) and
  initializes the repository
* add is_tree_submodule_active() by adding a treeish_name parameter to
  is_submodule_active()
* add the "submoduleNotUpdated" advice to advise users to update the
  submodules in their trees

Incidentally, fix an incorrect usage string that combined the 'list'
usage of git branch (-l) with the 'create' usage; this string has been
incorrect since its inception, a8dfd5eac4 (Make builtin-branch.c use
parse_options., 2007-10-07).

Helped-by: Jonathan Tan <jonathantanmy@google.com>
Signed-off-by: Glen Choo <chooglen@google.com>
Reviewed-by: Jonathan Tan <jonathantanmy@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agodoc: check-ignore: code-quote an exclamation mark
Philip Oakley [Thu, 3 Feb 2022 10:16:43 +0000 (10:16 +0000)] 
doc: check-ignore: code-quote an exclamation mark

The plain quoted exclamation mark renders as italics in the
Windows pdf help manual.

Fix this with back-tick quoting and surrounding double quotes
as exemplified by the gitignore.txt guide.

While at it, fix  the surrounding double quotes for the other
special characters usages.

Signed-off-by: Philip Oakley <philipoakley@iee.email>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agofix typo in git-mktree.txt
Liginity Lee [Wed, 2 Feb 2022 09:00:50 +0000 (09:00 +0000)] 
fix typo in git-mktree.txt

fix a typo: change "as" to "a".

Signed-off-by: Liginity Lee <liginity@outlook.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agocompletion: add a GIT_COMPLETION_SHOW_ALL_COMMANDS
Ævar Arnfjörð Bjarmason [Wed, 2 Feb 2022 11:15:10 +0000 (12:15 +0100)] 
completion: add a GIT_COMPLETION_SHOW_ALL_COMMANDS

Add a GIT_COMPLETION_SHOW_ALL_COMMANDS=1 configuration setting to go
with the existing GIT_COMPLETION_SHOW_ALL=1 added in
c099f579b98 (completion: add GIT_COMPLETION_SHOW_ALL env var,
2020-08-19).

This will include plumbing commands such as "cat-file" in "git <TAB>"
and "git c<TAB>" completion. Without/with this I have 134 and 243
completion with git <TAB>, respectively.

It was already possible to do this by tweaking
GIT_TESTING_PORCELAIN_COMMAND_LIST= from the outside, that testing
variable was added in 84a97131065 (completion: let git provide the
completable command list, 2018-05-20). Doing this before loading
git-completion.bash worked:

    export GIT_TESTING_PORCELAIN_COMMAND_LIST="$(git --list-cmds=builtins,main,list-mainporcelain,others,nohelpers,alias,list-complete,config)"

But such testing variables are not meant to be used from the outside,
and we make no guarantees that those internal won't change. So let's
expose this as a dedicated configuration knob.

It would be better to teach --list-cmds=* a new category which would
include all of these groups, but that's a larger change that we can
leave for some other time.

1. https://lore.kernel.org/git/CAGP6POJ9gwp+t-eP3TPkivBLLbNb2+qj=61Mehcj=1BgrVOSLA@mail.gmail.com/

Reported-by: Hongyi Zhao <hongyi.zhao@gmail.com>
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agocompletion tests: re-source git-completion.bash in a subshell
Ævar Arnfjörð Bjarmason [Wed, 2 Feb 2022 11:15:09 +0000 (12:15 +0100)] 
completion tests: re-source git-completion.bash in a subshell

Change tests of git-completion.bash that re-source it to do so inside
a subshell. Re-sourcing it will clobber variables it sets, and in the
case of the "GIT_COMPLETION_SHOW_ALL=1" test added in
ca2d62b7879 (parse-options: don't complete option aliases by default,
2021-07-16) change the behavior of the completion persistently.

Aside from the addition of "(" and ")" on new lines this is an
indentation-only change, only the "(" and ")" lines are changed under
"git diff -w".

So let's change that test, and for good measure do the same for the
three tests that precede it, which were added in
8b0eaa41f23 (completion: clear cached --options when sourcing the
completion script, 2018-03-22). The may not be wrong, but doing this
establishes a more reliable pattern for future tests, which might use
these as a template to copy.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agot/lib-read-tree-m-3way: indent with tabs
Shaoxuan Yuan [Wed, 2 Feb 2022 06:43:00 +0000 (14:43 +0800)] 
t/lib-read-tree-m-3way: indent with tabs

As Documentation/CodingGuidelines says, our shell scripts
(including tests) are to use HT for indentation, but this script
uses 4-column indent with SP. Fix this.

Signed-off-by: Shaoxuan Yuan <shaoxuan.yuan02@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agot/lib-read-tree-m-3way: modernize style
Shaoxuan Yuan [Wed, 2 Feb 2022 06:42:59 +0000 (14:42 +0800)] 
t/lib-read-tree-m-3way: modernize style

Many invocations of the test_expect_success command in this
file are written in old style where the command, an optional
prerequisite, and the test title are written on separate
lines, and the executable script string begins on its own
line, and these lines are pasted together with backslashes
as necessary.

An invocation of the test_expect_success command in modern
test scripts however writes the prerequisite and the title
on the same line as the test_expect_success command itself,
and ends the line with a single quote that begins the
executable script string.

Update the style for uniformity.

Signed-off-by: Shaoxuan Yuan <shaoxuan.yuan02@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agobuiltin/diff.c: fix "git-diff" usage string typo
Shaoxuan Yuan [Wed, 2 Feb 2022 07:28:44 +0000 (15:28 +0800)] 
builtin/diff.c: fix "git-diff" usage string typo

Remove mistaken right square brackets from "git-diff"
usage string. Make the usage string conform to "git-diff"
documentation (Documentation/git-diff.txt).

Signed-off-by: Shaoxuan Yuan <shaoxuan.yuan02@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agopatch-id: fix scan_hunk_header on diffs with 1 line of before/after
Jerry Zhang [Wed, 2 Feb 2022 04:19:45 +0000 (20:19 -0800)] 
patch-id: fix scan_hunk_header on diffs with 1 line of before/after

Normally diffs will contain a hunk header of the format
"@@ -2,2 +2,15 @@ code". However when there is only 1 line of
change, the unified diff format allows for the second comma
separated value to be omitted in either before or after
line counts.

This can produce hunk headers that look like
"@@ -2 +2,18 @@ code" or "@@ -2,2 +2 @@ code".
As a result, scan_hunk_header mistakenly returns the line
number as line count, which then results in unpredictable
parsing errors with the rest of the patch, including giving
multiple lines of output for a single commit.

Fix by explicitly setting line count to 1 when there is
no comma, and add a test.

apply.c contains this same logic except it is correct. A
worthwhile future project might be to unify these two diff
parsers so they both benefit from fixes.

Signed-off-by: Jerry Zhang <jerry@skydio.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agopatch-id: fix antipatterns in tests
Jerry Zhang [Wed, 2 Feb 2022 04:20:15 +0000 (20:20 -0800)] 
patch-id: fix antipatterns in tests

Clean up the tests for patch-id by moving file preparation
tasks inside the test body and redirecting files directly into
stdin instead of using 'cat'.

Signed-off-by: Jerry Zhang <jerry@skydio.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agodiff-merges: avoid history simplifications when diffing merges
Elijah Newren [Wed, 2 Feb 2022 02:37:37 +0000 (02:37 +0000)] 
diff-merges: avoid history simplifications when diffing merges

Doing diffs for merges are special; they should typically avoid history
simplification.  For example, with

    git log --diff-merges=first-parent -- path

the default history simplification would remove merge commits from
consideration if the file "path" matched the second parent.  That is
counter to what the user wants when looking for first-parent diffs.
Similar comments can be made for --diff-merges=separate (which diffs
against both parents) and --diff-merges=remerge (which diffs against a
remerge of the merge commit).

However, history simplification still makes sense if not doing diffing
merges, and it also makes sense for the combined and dense-combined
forms of diffing merges (because both of those are defined to only show
a diff when the merge result at the relevant paths differs from *both*
parents).

So, for separate, first-parent, and remerge styles of diff-merges, turn
off history simplification.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agomerge-ort: mark conflict/warning messages from inner merges as omittable
Elijah Newren [Wed, 2 Feb 2022 02:37:36 +0000 (02:37 +0000)] 
merge-ort: mark conflict/warning messages from inner merges as omittable

A recursive merge involves merging the merge bases of the two branches
being merged.  Such an inner merge can itself generate conflict notices.
While such notices may be useful when initially trying to create a
merge, they seem to just be noise when investigating merges later with
--remerge-diff.  (Especially when both sides of the outer merge resolved
the conflict the same way leading to no overall conflict.)  Remove them.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agoshow, log: include conflict/warning messages in --remerge-diff headers
Elijah Newren [Wed, 2 Feb 2022 02:37:35 +0000 (02:37 +0000)] 
show, log: include conflict/warning messages in --remerge-diff headers

Conflicts such as modify/delete, rename/rename, or file/directory are
not representable via content conflict markers, and the normal output
messages notifying users about these were dropped with --remerge-diff.
While we don't want these messages randomly shown before the commit
and diff headers, we do want them to still be shown; include them as
part of the diff headers instead.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agodiff: add ability to insert additional headers for paths
Elijah Newren [Wed, 2 Feb 2022 02:37:34 +0000 (02:37 +0000)] 
diff: add ability to insert additional headers for paths

When additional headers are provided, we need to
  * add diff_filepairs to diff_queued_diff for each paths in the
    additional headers map which, unless that path is part of
    another diff_filepair already found in diff_queued_diff
  * format the headers (colorization, line_prefix for --graph)
  * make sure the various codepaths that attempt to return early
    if there are "no changes" take into account the headers that
    need to be shown.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agomerge-ort: format messages slightly different for use in headers
Elijah Newren [Wed, 2 Feb 2022 02:37:33 +0000 (02:37 +0000)] 
merge-ort: format messages slightly different for use in headers

When users run
    git show --remerge-diff $MERGE_COMMIT
or
    git log -p --remerge-diff ...
stdout is not an appropriate location to dump conflict messages, but we
do want to provide them to users.  We will include them in the diff
headers instead...but for that to work, we need for any multiline
messages to replace newlines with both a newline and a space.  Add a new
flag to signal when we want these messages modified in such a fashion,
and use it in path_msg() to modify these messages this way.  Also, allow
a special prefix to be specified for these headers.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agomerge-ort: mark a few more conflict messages as omittable
Elijah Newren [Wed, 2 Feb 2022 02:37:32 +0000 (02:37 +0000)] 
merge-ort: mark a few more conflict messages as omittable

path_msg() has the ability to mark messages as omittable, designed for
remerge-diff where we'll instead be showing conflict messages as diff
headers for a subsequent diff.  While all these messages are very useful
when trying to create a merge initially, early use with the
--remerge-diff feature (the only user of this omittable conflict message
capability), suggests that the particular messages marked in this commit
are just noise when trying to see what changes users made to create a
merge commit.  Mark them as omittable.

Note that there were already a few messages marked as omittable in
merge-ort when doing a remerge-diff, because the development of
--remerge-diff preceded the upstreaming of merge-ort and I was trying to
ensure merge-ort could handle all the necessary requirements.  See
commit c5a6f65527 ("merge-ort: add modify/delete handling and delayed
output processing", 2020-12-03) for the initial details.  For some
examples of already-marked-as-omittable messages, see either
"Auto-merging <path>" or some of the submodule update hints.  This
commit just adds two more messages that should also be omittable.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agomerge-ort: capture and print ll-merge warnings in our preferred fashion
Elijah Newren [Wed, 2 Feb 2022 02:37:31 +0000 (02:37 +0000)] 
merge-ort: capture and print ll-merge warnings in our preferred fashion

Instead of immediately printing ll-merge warnings to stderr, we save
them in our output strbuf.  Besides allowing us to move these warnings
to a special file for --remerge-diff, this has two other benefits for
regular merges done by merge-ort:

  * The deferral of messages ensures we can print all messages about
    any given path together (merge-recursive was known to sometimes
    intersperse messages about other paths, particularly when renames
    were involved).

  * The deferral of messages means we can avoid printing spurious
    conflict messages when we just end up aborting due to local user
    modifications in the way.  (In contrast to merge-recursive.c which
    prematurely checks for local modifications in the way via
    unpack_trees() and gets the check wrong both in terms of false
    positives and false negatives relative to renames, merge-ort does
    not perform the local modifications in the way check until the
    checkout() step after the full merge has been computed.)

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agoll-merge: make callers responsible for showing warnings
Elijah Newren [Wed, 2 Feb 2022 02:37:30 +0000 (02:37 +0000)] 
ll-merge: make callers responsible for showing warnings

Since some callers may want to send warning messages to somewhere other
than stdout/stderr, stop printing "warning: Cannot merge binary files"
from ll-merge and instead modify the return status of ll_merge() to
indicate when a merge of binary files has occurred.  Message printing
probably does not belong in a "low-level merge" anyway.

This commit continues printing the message as-is, just from the callers
instead of within ll_merge().  Future changes will start handling the
message differently in the merge-ort codepath.

There was one special case here: the callers in rerere.c do NOT check
for and print such a message; since those code paths explicitly skip
over binary files, there is no reason to check for a return status of
LL_MERGE_BINARY_CONFLICT or print the related message.

Note that my methodology included first modifying ll_merge() to return
a struct, so that the compiler would catch all the callers for me and
ensure I had modified all of them.  After modifying all of them, I then
changed the struct to an enum.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agolog: clean unneeded objects during `log --remerge-diff`
Elijah Newren [Wed, 2 Feb 2022 02:37:29 +0000 (02:37 +0000)] 
log: clean unneeded objects during `log --remerge-diff`

The --remerge-diff option will need to create new blobs and trees
representing the "automatic merge" state.  If one is traversing a
long project history, one can easily get hundreds of thousands of
loose objects generated during `log --remerge-diff`.  However, none of
those loose objects are needed after we have completed our diff
operation; they can be summarily deleted.

Add a new helper function to tmp_objdir to discard all the contained
objects, and call it after each merge is handled.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agoshow, log: provide a --remerge-diff capability
Elijah Newren [Wed, 2 Feb 2022 02:37:28 +0000 (02:37 +0000)] 
show, log: provide a --remerge-diff capability

When this option is specified, we remerge all (two parent) merge commits
and diff the actual merge commit to the automatically created version,
in order to show how users removed conflict markers, resolved the
different conflict versions, and potentially added new changes outside
of conflict regions in order to resolve semantic merge problems (or,
possibly, just to hide other random changes).

This capability works by creating a temporary object directory and
marking it as the primary object store.  This makes it so that any blobs
or trees created during the automatic merge are easily removable
afterwards by just deleting all objects from the temporary object
directory.

There are a few ways that this implementation is suboptimal:
  * `log --remerge-diff` becomes slow, because the temporary object
    directory can fill with many loose objects while running
  * the log output can be muddied with misplaced "warning: cannot merge
    binary files" messages, since ll-merge.c unconditionally writes those
    messages to stderr while running instead of allowing callers to
    manage them.
  * important conflict and warning messages are simply dropped; thus for
    conflicts like modify/delete or rename/rename or file/directory which
    are not representable with content conflict markers, there may be no
    way for a user of --remerge-diff to know that there had been a
    conflict which was resolved (and which possibly motivated other
    changes in the merge commit).
  * when fixing the previous issue, note that some unimportant conflict
    and warning messages might start being included.  We should instead
    make sure these remain dropped.
Subsequent commits will address these issues.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agorepo-settings: rename the traditional default fetch.negotiationAlgorithm
Elijah Newren [Wed, 2 Feb 2022 03:42:40 +0000 (03:42 +0000)] 
repo-settings: rename the traditional default fetch.negotiationAlgorithm

Give the traditional default fetch.negotiationAlgorithm the name
'consecutive'.  Also allow a choice of 'default' to have Git decide
between the choices (currently, picking 'skipping' if
feature.experimental is true and 'consecutive' otherwise).  Update the
documentation accordingly.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agorepo-settings: fix error handling for unknown values
Elijah Newren [Wed, 2 Feb 2022 03:42:39 +0000 (03:42 +0000)] 
repo-settings: fix error handling for unknown values

In commit af3a67de01 ("negotiator: unknown fetch.negotiationAlgorithm
should error out", 2018-08-01), error handling for an unknown
fetch.negotiationAlgorithm was added with the code die()ing.  This was
also added to the documentation for the fetch.negotiationAlgorithm
option, to make it explicit that the code would die on unknown values.

This behavior was lost with commit aaf633c2ad ("repo-settings: create
feature.experimental setting", 2019-08-13).  Restore it so that the
behavior again matches the documentation.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agorepo-settings: fix checking for fetch.negotiationAlgorithm=default
Elijah Newren [Wed, 2 Feb 2022 03:42:38 +0000 (03:42 +0000)] 
repo-settings: fix checking for fetch.negotiationAlgorithm=default

In commit 3050b6dfc75d (repo-settings.c: simplify the setup,
2021-09-21), the branch for handling fetch.negotiationAlgorithm=default
was deleted.  Since this value is documented in
Documentation/config/fetch.txt, restore the check for this value.

Note that this change caused an observable bug: if someone sets
feature.experimental=true in config, and then passes "-c
fetch.negotiationAlgorithm=default" on the command line in an attempt to
override the config, then the override is ignored.  Fix the bug by not
ignoring the value of "default".

Technically, before commit 3050b6dfc75d, repo-settings would treat any
fetch.negotiationAlgorithm value other than "skipping" or "noop" as a
request for "default", but I think it probably makes more sense to
ignore such broken requests and leave fetch.negotiationAlgorithm with
the default value rather than the value of "default".  (If that sounds
confusing, note that "default" is usually the default value, but when
feature.experimental=true, "skipping" is the default value.)

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agoperl Git.pm: don't ignore signalled failure in _cmd_close()
Ævar Arnfjörð Bjarmason [Tue, 1 Feb 2022 20:52:52 +0000 (21:52 +0100)] 
perl Git.pm: don't ignore signalled failure in _cmd_close()

Fix misbehavior in Git.pm that dates back to the very first version of
the library in git.git added in b1edc53d062 (Introduce Git.pm (v4),
2006-06-24). When we fail to execute a command we shouldn't ignore all
signals, those can happen e.g. if abort() is called, or if the command
segfaults.

Because of this we'd consider e.g. a command that died due to LSAN
exiting with abort() successful, as is the case with the tests listed
as running successfully with SANITIZE=leak in 9081a421a6d (checkout:
fix "branch info" memory leaks, 2021-11-16). We did run them
successfully, but only because we ignored these errors.

This was then made worse by the use of "abort_on_error=1" for LSAN
added in 85b81b35ff9 (test-lib: set LSAN_OPTIONS to abort by default,
2017-09-05). Doing that makes sense, but without providing that option
we'd have a "$? >> 8" of "23" on failure, with abort_on_error=1 we'll
get "0".

All of our tests pass even without the SIGPIPE exception being added
here, but as the code appears to have been trying to ignore it let's
keep ignoring it for now.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agoreceive-pack: purge temporary data if no command is ready to run
Chen Bojun [Sat, 29 Jan 2022 06:35:38 +0000 (14:35 +0800)] 
receive-pack: purge temporary data if no command is ready to run

When pushing a hidden ref, e.g.:

    $ git push origin HEAD:refs/hidden/foo

"receive-pack" will reject our request with an error message like this:

    ! [remote rejected] HEAD -> refs/hidden/foo (deny updating a hidden ref)

The remote side ("git-receive-pack") will not create the hidden ref as
expected, but the pack file sent by "git-send-pack" is left inside the
remote repository. I.e. the quarantine directory is not purged as it
should be.

Add a checkpoint before calling "tmp_objdir_migrate()" and after calling
the "pre-receive" hook to purge that temporary data in the quarantine
area when there is no command ready to run.

The reason we do not add the checkpoint before the "pre-receive" hook,
but after it, is that the "pre-receive" hook is called with a switch-off
"skip_broken" flag, and all commands, even broken ones, should be fed
by calling "feed_receive_hook()".

Add a new test case in t5516 as well.

Helped-by: Jiang Xin <zhiyou.jx@alibaba-inc.com>
Helped-by: Teng Long <dyroneteng@gmail.com>
Signed-off-by: Chen Bojun <bojun.cbj@alibaba-inc.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>