]> git.ipfire.org Git - thirdparty/git.git/log
thirdparty/git.git
3 years agostatus: fix nested sparse directory diff in sparse index
Victoria Dye [Tue, 1 Mar 2022 20:24:25 +0000 (20:24 +0000)] 
status: fix nested sparse directory diff in sparse index

Enable the 'recursive' diff option for the diff executed as part of 'git
status'. Without the 'recursive' enabled, 'git status' reports index
changes incorrectly when the following conditions were met:

* sparse index is enabled
* there is a difference between the index and HEAD in a file inside a
  *subdirectory* of a sparse directory
* the sparse directory index entry is *not* expanded in-core

Because it is not recursive by default, the diff in 'git status' reports
changes only at the level of files and directories that are immediate
children of a sparse directory, rather than recursing into directories with
changes to identify the modified file(s). As a result, 'git status' reports
the immediate subdirectory itself as "modified".

Example:

$ git init
$ mkdir -p sparse/sub
$ echo test >sparse/sub/foo
$ git add .
$ git commit -m "commit 1"
$ echo somethingelse >sparse/sub/foo
$ git add .
$ git commit -a -m "commit 2"
$ git sparse-checkout set --cone --sparse-index 'sparse'
$ git reset --soft HEAD~1
$ git status
On branch master
You are in a sparse checkout.

Changes to be committed:
  (use "git restore --staged <file>..." to unstage)
        modified:   sparse/sub

Enabling the 'recursive' diff option in 'wt_status_collect_changes_index'
corrects this issue by allowing the diff to recurse into subdirectories of
sparse directories to find modified files. Given the same repository setup
as the example above, the corrected result of `git status` is:

$ git status
On branch master
You are in a sparse checkout.

Changes to be committed:
  (use "git restore --staged <file>..." to unstage)
        modified:   sparse/sub/foo

Signed-off-by: Victoria Dye <vdye@github.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agosparse-index: prevent repo root from becoming sparse
Victoria Dye [Tue, 1 Mar 2022 20:24:24 +0000 (20:24 +0000)] 
sparse-index: prevent repo root from becoming sparse

Prevent the repository root from being collapsed into a sparse directory by
treating an empty path as "inside the sparse-checkout". When collapsing a
sparse index (e.g. in 'git sparse-checkout reapply'), the root directory
typically could not become a sparse directory due to the presence of in-cone
root-level files and directories. However, if no such in-cone files or
directories were present, there was no explicit check signaling that the
"repository root path" (an empty string, in the case of
'convert_to_sparse(...)') was in-cone, and a sparse directory index entry
would be created from the repository root directory.

The documentation in Documentation/git-sparse-checkout.txt explicitly states
that the files in the root directory are expected to be in-cone for a
cone-mode sparse-checkout. Collapsing the root into a sparse directory entry
violates that assumption, as sparse directory entries are expected to be
outside the sparse cone and have SKIP_WORKTREE enabled. This invalid state
in turn causes issues with commands that interact with the index, e.g.
'git status'.

Treating an empty (root) path as in-cone prevents the creation of a root
sparse directory in 'convert_to_sparse(...)'. Because the repository root is
otherwise never compared with sparse patterns (in both cone-mode and
non-cone sparse-checkouts), the new check does not cause additional changes
to how sparse patterns are applied.

Helped-by: Derrick Stolee <derrickstolee@github.com>
Signed-off-by: Victoria Dye <vdye@github.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoThe seventh batch
Junio C Hamano [Thu, 24 Feb 2022 00:58:13 +0000 (16:58 -0800)] 
The seventh batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoMerge branch 'bc/clarify-eol-attr'
Junio C Hamano [Thu, 24 Feb 2022 00:58:04 +0000 (16:58 -0800)] 
Merge branch 'bc/clarify-eol-attr'

Documentation update

* bc/clarify-eol-attr:
  doc: clarify interaction between 'eol' and text=auto

3 years agoMerge branch 'ds/mailmap'
Junio C Hamano [Thu, 24 Feb 2022 00:58:04 +0000 (16:58 -0800)] 
Merge branch 'ds/mailmap'

Update mailmap entries.

* ds/mailmap:
  mailmap: change primary address for Derrick Stolee

3 years agoMerge branch 'ah/log-no-graph'
Junio C Hamano [Thu, 24 Feb 2022 00:58:03 +0000 (16:58 -0800)] 
Merge branch 'ah/log-no-graph'

"git log --graph --graph" used to leak a graph structure, and there
was no way to countermand "--graph" that appear earlier on the
command line.  A "--no-graph" option has been added and resource
leakage has been plugged.

* ah/log-no-graph:
  log: add a --no-graph option
  log: fix memory leak if --graph is passed multiple times

3 years agoMerge branch 'hw/t1410-adjust-test-for-reftable'
Junio C Hamano [Thu, 24 Feb 2022 00:58:03 +0000 (16:58 -0800)] 
Merge branch 'hw/t1410-adjust-test-for-reftable'

Fix tests that are unnecessarily specific to ref-files backend.

* hw/t1410-adjust-test-for-reftable:
  t1410: mark bufsize boundary test as REFFILES
  t1410: use test-tool ref-store to inspect reflogs

3 years agoMerge branch 'ps/fetch-optim-with-commit-graph'
Junio C Hamano [Thu, 24 Feb 2022 00:58:03 +0000 (16:58 -0800)] 
Merge branch 'ps/fetch-optim-with-commit-graph'

A couple of optimization to "git fetch".

* ps/fetch-optim-with-commit-graph:
  fetch: skip computing output width when not printing anything
  fetch-pack: use commit-graph when computing cutoff

3 years agoMerge branch 'sy/t0001-use-path-is-helper'
Junio C Hamano [Thu, 24 Feb 2022 00:58:03 +0000 (16:58 -0800)] 
Merge branch 'sy/t0001-use-path-is-helper'

Test modernization.

* sy/t0001-use-path-is-helper:
  t0001: replace "test [-d|-f]" with test_path_is_* functions

3 years agoMerge branch 'bs/forbid-i18n-of-protocol-token-in-fetch-pack'
Junio C Hamano [Thu, 24 Feb 2022 00:58:03 +0000 (16:58 -0800)] 
Merge branch 'bs/forbid-i18n-of-protocol-token-in-fetch-pack'

L10n support for a few error messages.

* bs/forbid-i18n-of-protocol-token-in-fetch-pack:
  fetch-pack: parameterize message containing 'ready' keyword

3 years agoThe sixth batch
Junio C Hamano [Fri, 18 Feb 2022 17:53:31 +0000 (09:53 -0800)] 
The sixth batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoMerge branch 'jc/glossary-worktree'
Junio C Hamano [Fri, 18 Feb 2022 21:53:30 +0000 (13:53 -0800)] 
Merge branch 'jc/glossary-worktree'

"working tree" and "per-worktree ref" were in glossary, but
"worktree" itself wasn't, which has been corrected.

* jc/glossary-worktree:
  glossary: describe "worktree"

3 years agoMerge branch 'jd/t0015-modernize'
Junio C Hamano [Fri, 18 Feb 2022 21:53:30 +0000 (13:53 -0800)] 
Merge branch 'jd/t0015-modernize'

Test modernization.

* jd/t0015-modernize:
  t/t0015-hash.sh: remove unnecessary '\' at line end

3 years agoMerge branch 'js/short-help-outside-repo-fix'
Junio C Hamano [Fri, 18 Feb 2022 21:53:30 +0000 (13:53 -0800)] 
Merge branch 'js/short-help-outside-repo-fix'

"git cmd -h" outside a repository should error out cleanly for many
commands, but instead it hit a BUG(), which has been corrected.

* js/short-help-outside-repo-fix:
  t0012: verify that built-ins handle `-h` even without gitdir
  checkout/fetch/pull/pack-objects: allow `-h` outside a repository

3 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

3 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"

3 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

3 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()

3 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

3 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

3 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

3 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

3 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>
3 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

3 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

3 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

3 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

3 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

3 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

3 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

3 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

3 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

3 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>
3 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()

3 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`

3 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`

3 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

3 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()

3 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

3 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

3 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

3 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

3 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

3 years agomailmap: change primary address for Derrick Stolee
Derrick Stolee [Mon, 14 Feb 2022 16:45:53 +0000 (16:45 +0000)] 
mailmap: change primary address for Derrick Stolee

Stolee transitioned from Microsoft to GitHub in July 2020, but continued
to use <dstolee@microsoft.com> because it was a valid address. He also
used <stolee@gmail.com> to communicate with the mailing list since
writing plaintext emails is difficult in Outlook. However, recent issues
with GMail delaying mailing list messages created a need to change his
primary email address.

Signed-off-by: Derrick Stolee <derrickstolee@github.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agodoc: clarify interaction between 'eol' and text=auto
brian m. carlson [Mon, 14 Feb 2022 18:15:43 +0000 (10:15 -0800)] 
doc: clarify interaction between 'eol' and text=auto

The `eol` takes effect on text files only when the index has the
contents in LF line endings.  Paths with contents in CRLF line
endings in the index may become dirty unless text=auto.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 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>
3 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

3 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

3 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

3 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

3 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

3 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

3 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>

3 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

3 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

3 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

3 years agot0001: replace "test [-d|-f]" with test_path_is_* functions
Shaoxuan Yuan [Fri, 21 Jan 2022 10:21:09 +0000 (18:21 +0800)] 
t0001: replace "test [-d|-f]" with test_path_is_* functions

Signed-off-by: Shaoxuan Yuan <shaoxuan.yuan02@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agofetch-pack: parameterize message containing 'ready' keyword
Bagas Sanjaya [Wed, 22 Dec 2021 07:58:06 +0000 (14:58 +0700)] 
fetch-pack: parameterize message containing 'ready' keyword

The protocol keyword 'ready' isn't meant for translation. Pass it as
parameter instead of spell it in die() message (and potentially confuse
translators).

Signed-off-by: Bagas Sanjaya <bagasdotme@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agolog: add a --no-graph option
Alex Henrie [Fri, 11 Feb 2022 16:36:25 +0000 (09:36 -0700)] 
log: add a --no-graph option

It's useful to be able to countermand a previous --graph option, for
example if `git log --graph` is run via an alias.

Signed-off-by: Alex Henrie <alexhenrie24@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agolog: fix memory leak if --graph is passed multiple times
Alex Henrie [Fri, 11 Feb 2022 16:36:24 +0000 (09:36 -0700)] 
log: fix memory leak if --graph is passed multiple times

Signed-off-by: Alex Henrie <alexhenrie24@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agofetch: skip computing output width when not printing anything
Patrick Steinhardt [Thu, 10 Feb 2022 12:28:16 +0000 (13:28 +0100)] 
fetch: skip computing output width when not printing anything

When updating references via git-fetch(1), then by default we report to
the user which references have been changed. This output is formatted in
a nice table such that the different columns are aligned. Because the
first column contains abbreviated object IDs we thus need to iterate
over all refs which have changed and compute the minimum length for
their respective abbreviated hashes. While this effort makes sense in
most cases, it is wasteful when the user passes the `--quiet` flag: we
don't print the summary, but still compute the length.

Skip computing the summary width when the user asked for us to be quiet.
This gives us a speedup of nearly 10% when doing a mirror-fetch in a
repository with thousands of references being updated:

    Benchmark 1: git fetch --quiet +refs/*:refs/* (HEAD~)
      Time (mean ± σ):     96.078 s ±  0.508 s    [User: 91.378 s, System: 10.870 s]
      Range (min … max):   95.449 s … 96.760 s    5 runs

    Benchmark 2: git fetch --quiet +refs/*:refs/* (HEAD)
      Time (mean ± σ):     88.214 s ±  0.192 s    [User: 83.274 s, System: 10.978 s]
      Range (min … max):   87.998 s … 88.446 s    5 runs

    Summary
      'git fetch --quiet +refs/*:refs/* (HEAD)' ran
        1.09 ± 0.01 times faster than 'git fetch --quiet +refs/*:refs/* (HEAD~)'

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agofetch-pack: use commit-graph when computing cutoff
Patrick Steinhardt [Thu, 10 Feb 2022 12:28:09 +0000 (13:28 +0100)] 
fetch-pack: use commit-graph when computing cutoff

During packfile negotiation we iterate over all refs announced by the
remote side to check whether their IDs refer to commits already known to
us. If a commit is known to us already, then its date is a potential
cutoff point for commits we have in common with the remote side.

There is potentially a lot of commits announced by the remote depending
on how many refs there are in the remote repository, and for every one
of them we need to search for it in our object database and, if found,
parse the corresponding object to find out whether it is a candidate for
the cutoff date. This can be sped up by trying to look up commits via
the commit-graph first, which is a lot more efficient.

Benchmarks in a repository with about 2,1 million refs and an up-to-date
commit-graph show an almost 20% speedup when mirror-fetching:

    Benchmark 1: git fetch +refs/*:refs/* (v2.35.0)
      Time (mean ± σ):     115.587 s ±  2.009 s    [User: 109.874 s, System: 11.305 s]
      Range (min … max):   113.584 s … 118.820 s    5 runs

    Benchmark 2: git fetch +refs/*:refs/* (HEAD)
      Time (mean ± σ):     96.859 s ±  0.624 s    [User: 91.948 s, System: 10.980 s]
      Range (min … max):   96.180 s … 97.875 s    5 runs

    Summary
      'git fetch +refs/*:refs/* (HEAD)' ran
        1.19 ± 0.02 times faster than 'git fetch +refs/*:refs/* (v2.35.0)'

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agot1410: mark bufsize boundary test as REFFILES
Han-Wen Nienhuys [Wed, 9 Feb 2022 11:29:40 +0000 (11:29 +0000)] 
t1410: mark bufsize boundary test as REFFILES

This test fiddles with files under .git/logs to recreate a condition
that is unlikely to warrant special attention under reftable, as
reflog blocks are zlib compressed.

Signed-off-by: Han-Wen Nienhuys <hanwen@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agot1410: use test-tool ref-store to inspect reflogs
Han-Wen Nienhuys [Wed, 9 Feb 2022 11:29:39 +0000 (11:29 +0000)] 
t1410: use test-tool ref-store to inspect reflogs

This makes the test compatible with reftable (it doesn't pass yet for
other reasons, unfortunately)

Signed-off-by: Han-Wen Nienhuys <hanwen@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoglossary: describe "worktree"
Junio C Hamano [Thu, 10 Feb 2022 02:19:07 +0000 (18:19 -0800)] 
glossary: describe "worktree"

We have description on "per worktree ref", but "worktree" is not
described in the glossary.  We do have "working tree", though.

Casually put, a "working tree" is what your editor and compiler
interacts with.  "worktree" is a mechanism to allow one or more
"working tree"s to be attached to a repository and used to check out
different commits and branches independently, which includes not
just a "working tree" but also repository metadata like HEAD, the
index to support simultaneous use of them.  Historically, we used
these terms interchangeably but we have been trying to use "working
tree" when we mean it, instead of "worktree".

Most of the existing references to "working tree" in the glossary do
refer primarily to the working tree portion, except for one that
said refs like HEAD and refs/bisect/* are per "working tree", but it
is more precise to say they are per "worktree".

Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agot/t0015-hash.sh: remove unnecessary '\' at line end
Jaydeep Das [Tue, 8 Feb 2022 09:23:39 +0000 (14:53 +0530)] 
t/t0015-hash.sh: remove unnecessary '\' at line end

The `|` at line end already imples that the statement is not over.
So a `\` after that is redundant.

Signed-off-by: Jaydeep P Das <jaydeepjd.8914@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 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>
3 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

3 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

3 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

3 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

3 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()

3 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

3 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

3 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

3 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()

3 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

3 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"

3 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

3 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

3 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

3 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

3 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>
3 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>
3 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>
3 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>
3 years agot0012: verify that built-ins handle `-h` even without gitdir
Johannes Schindelin [Tue, 8 Feb 2022 11:21:54 +0000 (11:21 +0000)] 
t0012: verify that built-ins handle `-h` even without gitdir

We just fixed a class of recently introduced bugs where calling, say,
`git fetch -h` outside a repository would not show the usage but instead
show an ugly `BUG` message.

Let's verify that this does not regress anymore.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agocheckout/fetch/pull/pack-objects: allow `-h` outside a repository
Johannes Schindelin [Tue, 8 Feb 2022 11:21:53 +0000 (11:21 +0000)] 
checkout/fetch/pull/pack-objects: allow `-h` outside a repository

When we taught these commands about the sparse index, we did not account
for the fact that the `cmd_*()` functions _can_ be called without a
gitdir, namely when `-h` is passed to show the usage.

A plausible approach to address this is to move the
`prepare_repo_settings()` calls right after the `parse_options()` calls:
The latter will never return when it handles `-h`, and therefore it is
safe to assume that we have a `gitdir` at that point, as long as the
built-in is marked with the `RUN_SETUP` flag.

However, it is unfortunately not that simple. In `cmd_pack_objects()`,
for example, the repo settings need to be fully populated so that the
command-line options `--sparse`/`--no-sparse` can override them, not the
other way round.

Therefore, we choose to imitate the strategy taken in `cmd_diff()`,
where we simply do not bother to prepare and initialize the repo
settings unless we have a `gitdir`.

This fixes https://github.com/git-for-windows/git/issues/3688

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 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>
3 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>
3 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>
3 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

3 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

3 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

3 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

3 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

3 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()

3 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

3 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

3 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