]> git.ipfire.org Git - thirdparty/git.git/log
thirdparty/git.git
9 months agobuiltin: add a repository parameter for builtin functions
John Cai [Fri, 13 Sep 2024 21:16:14 +0000 (21:16 +0000)] 
builtin: add a repository parameter for builtin functions

In order to reduce the usage of the global the_repository, add a
parameter to builtin functions that will get passed a repository
variable.

This commit uses UNUSED on most of the builtin functions, as subsequent
commits will modify the actual builtins to pass the repository parameter
down.

Signed-off-by: John Cai <johncai86@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 months agoThe eleventh batch
Junio C Hamano [Thu, 29 Aug 2024 17:38:34 +0000 (10:38 -0700)] 
The eleventh batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 months agoMerge branch 'ds/sparse-diff-index'
Junio C Hamano [Thu, 29 Aug 2024 18:08:17 +0000 (11:08 -0700)] 
Merge branch 'ds/sparse-diff-index'

The underlying machinery for "git diff-index" has long been made to
expand the sparse index as needed, but the command fully expanded
the sparse index upfront, which now has been taught not to do.

* ds/sparse-diff-index:
  diff-index: integrate with the sparse index

9 months agoMerge branch 'cp/unit-test-reftable-block'
Junio C Hamano [Thu, 29 Aug 2024 18:08:16 +0000 (11:08 -0700)] 
Merge branch 'cp/unit-test-reftable-block'

Another test for reftable library ported to the unit test framework.

* cp/unit-test-reftable-block:
  t-reftable-block: mark unused argv/argc
  t-reftable-block: add tests for index blocks
  t-reftable-block: add tests for obj blocks
  t-reftable-block: add tests for log blocks
  t-reftable-block: remove unnecessary variable 'j'
  t-reftable-block: use xstrfmt() instead of xstrdup()
  t-reftable-block: use block_iter_reset() instead of block_iter_close()
  t-reftable-block: use reftable_record_key() instead of strbuf_addstr()
  t-reftable-block: use reftable_record_equal() instead of check_str()
  t-reftable-block: release used block reader
  t: harmonize t-reftable-block.c with coding guidelines
  t: move reftable/block_test.c to the unit testing framework

9 months agoMerge branch 'ps/reftable-drop-generic'
Junio C Hamano [Thu, 29 Aug 2024 18:08:15 +0000 (11:08 -0700)] 
Merge branch 'ps/reftable-drop-generic'

The code in the reftable library has been cleaned up by discarding
unused "generic" interface.

* ps/reftable-drop-generic:
  reftable: mark unused parameters in empty iterator functions
  reftable/generic: drop interface
  t/helper: refactor to not use `struct reftable_table`
  t/helper: use `hash_to_hex_algop()` to print hashes
  t/helper: inline printing of reftable records
  t/helper: inline `reftable_table_print()`
  t/helper: inline `reftable_stack_print_directory()`
  t/helper: inline `reftable_reader_print_file()`
  t/helper: inline `reftable_dump_main()`
  reftable/dump: drop unused `compact_stack()`
  reftable/generic: move generic iterator code into iterator interface
  reftable/iter: drop double-checking logic
  reftable/stack: open-code reading refs
  reftable/merged: stop using generic tables in the merged table
  reftable/merged: rename `reftable_new_merged_table()`
  reftable/merged: expose functions to initialize iterators

9 months agoThe tenth batch
Junio C Hamano [Wed, 28 Aug 2024 17:31:11 +0000 (10:31 -0700)] 
The tenth batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 months agoMerge branch 'ah/git-prompt-portability'
Junio C Hamano [Wed, 28 Aug 2024 17:31:28 +0000 (10:31 -0700)] 
Merge branch 'ah/git-prompt-portability'

The command line prompt support used to be littered with bash-isms,
which has been corrected to work with more shells.

* ah/git-prompt-portability:
  git-prompt: support custom 0-width PS1 markers
  git-prompt: ta-da! document usage in other shells
  git-prompt: don't use shell $'...'
  git-prompt: add some missing quotes
  git-prompt: replace [[...]] with standard code
  git-prompt: don't use shell arrays
  git-prompt: fix uninitialized variable
  git-prompt: use here-doc instead of here-string

9 months agoMerge branch 'gt/unit-test-urlmatch-normalization'
Junio C Hamano [Wed, 28 Aug 2024 17:31:27 +0000 (10:31 -0700)] 
Merge branch 'gt/unit-test-urlmatch-normalization'

Another rewrite of test.

* gt/unit-test-urlmatch-normalization:
  t: migrate t0110-urlmatch-normalization to the new framework

9 months agoMerge branch 'mt/rebase-x-quiet'
Junio C Hamano [Wed, 28 Aug 2024 17:31:26 +0000 (10:31 -0700)] 
Merge branch 'mt/rebase-x-quiet'

"git rebase -x --quiet" was not quiet, which was corrected.

* mt/rebase-x-quiet:
  rebase --exec: respect --quiet

9 months agoreftable: mark unused parameters in empty iterator functions
Jeff King [Wed, 28 Aug 2024 04:09:44 +0000 (00:09 -0400)] 
reftable: mark unused parameters in empty iterator functions

These unused parameters were marked in a68ec8683a (reftable: mark unused
parameters in virtual functions, 2024-08-17), but the functions were
moved to a new file in a parallel branch via f2406c81b9
(reftable/generic: move generic iterator code into iterator interface,
2024-08-22).

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 months agot-reftable-block: mark unused argv/argc
Jeff King [Wed, 28 Aug 2024 04:08:03 +0000 (00:08 -0400)] 
t-reftable-block: mark unused argv/argc

This is conceptually the same as the cases in df9d638c24 (unit-tests:
ignore unused argc/argv, 2024-08-17), but this unit test was migrated
from the reftable tests in a parallel branch.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 months agoSync with 'maint'
Junio C Hamano [Mon, 26 Aug 2024 18:36:13 +0000 (11:36 -0700)] 
Sync with 'maint'

9 months agoThe ninth batch
Junio C Hamano [Mon, 26 Aug 2024 18:02:47 +0000 (11:02 -0700)] 
The ninth batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 months agoMerge branch 'jc/coding-style-c-operator-with-spaces'
Junio C Hamano [Mon, 26 Aug 2024 18:32:24 +0000 (11:32 -0700)] 
Merge branch 'jc/coding-style-c-operator-with-spaces'

Write down whitespacing rules around C opeators.

* jc/coding-style-c-operator-with-spaces:
  CodingGuidelines: spaces around C operators

9 months agoMerge branch 'ds/for-each-ref-is-base'
Junio C Hamano [Mon, 26 Aug 2024 18:32:24 +0000 (11:32 -0700)] 
Merge branch 'ds/for-each-ref-is-base'

'git for-each-ref' learned a new "--format" atom to find the branch
that the history leading to a given commit "%(is-base:<commit>)" is
likely based on.

* ds/for-each-ref-is-base:
  p1500: add is-base performance tests
  for-each-ref: add 'is-base' token
  commit: add gentle reference lookup method
  commit-reach: add get_branch_base_for_tip

9 months agoMerge branch 'jk/send-email-translate-aliases'
Junio C Hamano [Mon, 26 Aug 2024 18:32:23 +0000 (11:32 -0700)] 
Merge branch 'jk/send-email-translate-aliases'

"git send-email" learned "--translate-aliases" option that reads
addresses from the standard input and emits the result of applying
aliases on them to the standard output.

* jk/send-email-translate-aliases:
  send-email: teach git send-email option to translate aliases
  t9001-send-email.sh: update alias list used for pine test
  t9001-send-email.sh: fix quoting for mailrc --dump-aliases test

9 months agoMerge branch 'jk/mark-unused-parameters'
Junio C Hamano [Mon, 26 Aug 2024 18:32:22 +0000 (11:32 -0700)] 
Merge branch 'jk/mark-unused-parameters'

Mark unused parameters as UNUSED to squelch -Wunused warnings.

* jk/mark-unused-parameters:
  t-hashmap: stop calling setup() for t_intern() test
  scalar: mark unused parameters in dummy function
  daemon: mark unused parameters in non-posix fallbacks
  setup: mark unused parameter in config callback
  test-mergesort: mark unused parameters in trivial callback
  t-hashmap: mark unused parameters in callback function
  reftable: mark unused parameters in virtual functions
  reftable: drop obsolete test function declarations
  reftable: ignore unused argc/argv in test functions
  unit-tests: ignore unused argc/argv
  t/helper: mark more unused argv/argc arguments
  oss-fuzz: mark unused argv/argc argument
  refs: mark unused parameters in do_for_each_reflog_helper()
  refs: mark unused parameters in ref_store fsck callbacks
  update-ref: mark more unused parameters in parser callbacks
  imap-send: mark unused parameter in ssl_socket_connect() fallback

9 months agoMerge branch 'jk/drop-unused-parameters'
Junio C Hamano [Mon, 26 Aug 2024 18:32:21 +0000 (11:32 -0700)] 
Merge branch 'jk/drop-unused-parameters'

Drop unused parameters from functions.

* jk/drop-unused-parameters:
  diff-lib: drop unused index argument from get_stat_data()
  ref-filter: drop unused parameters from email_atom_option_parser()
  pack-bitmap: drop unused parameters from select_pseudo_merges()
  pack-bitmap: load writer config from repository parameter
  refs: drop some unused parameters from create_symref_lock()

9 months agoMerge branch 'tb/pseudo-merge-bitmap-fixes'
Junio C Hamano [Mon, 26 Aug 2024 18:32:21 +0000 (11:32 -0700)] 
Merge branch 'tb/pseudo-merge-bitmap-fixes'

We created a useless pseudo-merge reachability bitmap that is about
0 commits, and attempted to include commits that are not in packs,
which made no sense.  These bugs have been corrected.

* tb/pseudo-merge-bitmap-fixes:
  pseudo-merge.c: ensure pseudo-merge groups are closed
  pseudo-merge.c: do not generate empty pseudo-merge commits
  t/t5333-pseudo-merge-bitmaps.sh: demonstrate empty pseudo-merge groups
  pack-bitmap-write.c: select pseudo-merges even for small bitmaps
  pack-bitmap: drop redundant args from `bitmap_writer_finish()`
  pack-bitmap: drop redundant args from `bitmap_writer_build()`
  pack-bitmap: drop redundant args from `bitmap_writer_build_type_index()`
  pack-bitmap: initialize `bitmap_writer_init()` with packing_data

9 months agoMerge branch 'ps/maintenance-detach-fix-more'
Junio C Hamano [Mon, 26 Aug 2024 18:32:20 +0000 (11:32 -0700)] 
Merge branch 'ps/maintenance-detach-fix-more'

A tests for "git maintenance" that were broken on Windows have been
corrected.

* ps/maintenance-detach-fix-more:
  builtin/maintenance: fix loose objects task emitting pack hash
  t7900: exercise detaching via trace2 regions
  t7900: fix flaky test due to leaking background job

9 months agoMerge branch 'ps/maintenance-detach-fix'
Junio C Hamano [Mon, 26 Aug 2024 18:32:20 +0000 (11:32 -0700)] 
Merge branch 'ps/maintenance-detach-fix'

Maintenance tasks other than "gc" now properly go background when
"git maintenance" runs them.

* ps/maintenance-detach-fix:
  run-command: fix detaching when running auto maintenance
  builtin/maintenance: add a `--detach` flag
  builtin/gc: add a `--detach` flag
  builtin/gc: stop processing log file on signal
  builtin/gc: fix leaking config values
  builtin/gc: refactor to read config into structure
  config: fix constness of out parameter for `git_config_get_expiry()`

9 months agoA bit more topics for 2.46.x maintenance track
Junio C Hamano [Mon, 26 Aug 2024 18:13:19 +0000 (11:13 -0700)] 
A bit more topics for 2.46.x maintenance track

Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 months agoMerge branch 'xx/diff-tree-remerge-diff-fix' into maint-2.46
Junio C Hamano [Mon, 26 Aug 2024 18:10:24 +0000 (11:10 -0700)] 
Merge branch 'xx/diff-tree-remerge-diff-fix' into maint-2.46

"git rev-list ... | git diff-tree -p --remerge-diff --stdin" should
behave more or less like "git log -p --remerge-diff" but instead it
crashed, forgetting to prepare a temporary object store needed.

* xx/diff-tree-remerge-diff-fix:
  diff-tree: fix crash when used with --remerge-diff

9 months agoMerge branch 'rs/t-example-simplify' into maint-2.46
Junio C Hamano [Mon, 26 Aug 2024 18:10:24 +0000 (11:10 -0700)] 
Merge branch 'rs/t-example-simplify' into maint-2.46

Unit test simplification.

* rs/t-example-simplify:
  t-example-decorate: remove test messages

9 months agoMerge branch 'jc/safe-directory' into maint-2.46
Junio C Hamano [Mon, 26 Aug 2024 18:10:23 +0000 (11:10 -0700)] 
Merge branch 'jc/safe-directory' into maint-2.46

Follow-up on 2.45.1 regression fix.

* jc/safe-directory:
  safe.directory: setting safe.directory="." allows the "current" directory
  safe.directory: normalize the configured path
  safe.directory: normalize the checked path
  safe.directory: preliminary clean-up

9 months agoMerge branch 'jc/document-use-of-local' into maint-2.46
Junio C Hamano [Mon, 26 Aug 2024 18:10:23 +0000 (11:10 -0700)] 
Merge branch 'jc/document-use-of-local' into maint-2.46

Doc update.

* jc/document-use-of-local:
  doc: note that AT&T ksh does not work with our test suite

9 months agoMerge branch 'rs/use-decimal-width' into maint-2.46
Junio C Hamano [Mon, 26 Aug 2024 18:10:22 +0000 (11:10 -0700)] 
Merge branch 'rs/use-decimal-width' into maint-2.46

Code clean-up.

* rs/use-decimal-width:
  log-tree: use decimal_width()

9 months agoMerge branch 'ss/packed-ref-store-leakfix' into maint-2.46
Junio C Hamano [Mon, 26 Aug 2024 18:10:22 +0000 (11:10 -0700)] 
Merge branch 'ss/packed-ref-store-leakfix' into maint-2.46

Leakfix.

* ss/packed-ref-store-leakfix:
  refs/files: prevent memory leak by freeing packed_ref_store

9 months agoMerge branch 'kl/test-fixes' into maint-2.46
Junio C Hamano [Mon, 26 Aug 2024 18:10:21 +0000 (11:10 -0700)] 
Merge branch 'kl/test-fixes' into maint-2.46

A flakey test and incorrect calls to strtoX() functions have been
fixed.

* kl/test-fixes:
  t6421: fix test to work when repo dir contains d0
  set errno=0 before strtoX calls

9 months agoMerge branch 'jc/reflog-expire-lookup-commit-fix' into maint-2.46
Junio C Hamano [Mon, 26 Aug 2024 18:10:21 +0000 (11:10 -0700)] 
Merge branch 'jc/reflog-expire-lookup-commit-fix' into maint-2.46

"git reflog expire" failed to honor annotated tags when computing
reachable commits.

* jc/reflog-expire-lookup-commit-fix:
  Revert "reflog expire: don't use lookup_commit_reference_gently()"

9 months agoMerge branch 'jr/ls-files-expand-literal-doc' into maint-2.46
Junio C Hamano [Mon, 26 Aug 2024 18:10:20 +0000 (11:10 -0700)] 
Merge branch 'jr/ls-files-expand-literal-doc' into maint-2.46

Docfix.

* jr/ls-files-expand-literal-doc:
  doc: fix hex code escapes in git-ls-files

9 months agoMerge branch 'jc/leakfix-mailmap' into maint-2.46
Junio C Hamano [Mon, 26 Aug 2024 18:10:20 +0000 (11:10 -0700)] 
Merge branch 'jc/leakfix-mailmap' into maint-2.46

Leakfix.

* jc/leakfix-mailmap:
  mailmap: plug memory leak in read_mailmap_blob()

9 months agoMerge branch 'jc/leakfix-hashfile' into maint-2.46
Junio C Hamano [Mon, 26 Aug 2024 18:10:19 +0000 (11:10 -0700)] 
Merge branch 'jc/leakfix-hashfile' into maint-2.46

Leakfix.

* jc/leakfix-hashfile:
  csum-file: introduce discard_hashfile()

9 months agoMerge branch 'jc/jl-git-no-advice-fix' into maint-2.46
Junio C Hamano [Mon, 26 Aug 2024 18:10:19 +0000 (11:10 -0700)] 
Merge branch 'jc/jl-git-no-advice-fix' into maint-2.46

Remove leftover debugging cruft from a test script.

* jc/jl-git-no-advice-fix:
  t0018: remove leftover debugging cruft

9 months agoMerge branch 'tb/config-fixed-value-with-valueless-true' into maint-2.46
Junio C Hamano [Mon, 26 Aug 2024 18:10:18 +0000 (11:10 -0700)] 
Merge branch 'tb/config-fixed-value-with-valueless-true' into maint-2.46

"git config --value=foo --fixed-value section.key newvalue" barfed
when the existing value in the configuration file used the
valueless true syntax, which has been corrected.

* tb/config-fixed-value-with-valueless-true:
  config.c: avoid segfault with --fixed-value and valueless config

9 months agoMerge branch 'ps/ls-remote-out-of-repo-fix' into maint-2.46
Junio C Hamano [Mon, 26 Aug 2024 18:10:18 +0000 (11:10 -0700)] 
Merge branch 'ps/ls-remote-out-of-repo-fix' into maint-2.46

A recent update broke "git ls-remote" used outside a repository,
which has been corrected.

* ps/ls-remote-out-of-repo-fix:
  builtin/ls-remote: fall back to SHA1 outside of a repo

9 months agoMerge branch 'jk/osxkeychain-username-is-nul-terminated' into maint-2.46
Junio C Hamano [Mon, 26 Aug 2024 18:10:17 +0000 (11:10 -0700)] 
Merge branch 'jk/osxkeychain-username-is-nul-terminated' into maint-2.46

The credential helper to talk to OSX keychain sometimes sent
garbage bytes after the username, which has been corrected.

* jk/osxkeychain-username-is-nul-terminated:
  credential/osxkeychain: respect NUL terminator in username

10 months agoThe eighth batch
Junio C Hamano [Fri, 23 Aug 2024 15:57:03 +0000 (08:57 -0700)] 
The eighth batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 months agoMerge branch 'ps/stash-keep-untrack-empty-fix'
Junio C Hamano [Fri, 23 Aug 2024 16:02:36 +0000 (09:02 -0700)] 
Merge branch 'ps/stash-keep-untrack-empty-fix'

A corner case bug in "git stash" was fixed.

* ps/stash-keep-untrack-empty-fix:
  builtin/stash: fix `--keep-index --include-untracked` with empty HEAD

10 months agoMerge branch 'ps/hash-and-ref-format-from-config'
Junio C Hamano [Fri, 23 Aug 2024 16:02:35 +0000 (09:02 -0700)] 
Merge branch 'ps/hash-and-ref-format-from-config'

The default object hash and ref backend format used to be settable
only with explicit command line option to "git init" and
environment variables, but now they can be configured in the user's
global and system wide configuration.

* ps/hash-and-ref-format-from-config:
  setup: make ref storage format configurable via config
  setup: make object format configurable via config
  setup: merge configuration of repository formats
  t0001: delete repositories when object format tests finish
  t0001: exercise initialization with ref formats more thoroughly

10 months agoMerge branch 'cp/unit-test-reftable-readwrite'
Junio C Hamano [Fri, 23 Aug 2024 16:02:35 +0000 (09:02 -0700)] 
Merge branch 'cp/unit-test-reftable-readwrite'

* cp/unit-test-reftable-readwrite:
  t-reftable-readwrite: add test for known error
  t-reftable-readwrite: use 'for' in place of infinite 'while' loops
  t-reftable-readwrite: use free_names() instead of a for loop
  t: move reftable/readwrite_test.c to the unit testing framework

10 months agoMerge branch 'ps/config-wo-the-repository'
Junio C Hamano [Fri, 23 Aug 2024 16:02:34 +0000 (09:02 -0700)] 
Merge branch 'ps/config-wo-the-repository'

Use of API functions that implicitly depend on the_repository
object in the config subsystem has been rewritten to pass a
repository object through the callchain.

* ps/config-wo-the-repository:
  config: hide functions using `the_repository` by default
  global: prepare for hiding away repo-less config functions
  config: don't depend on `the_repository` with branch conditions
  config: don't have setters depend on `the_repository`
  config: pass repo to functions that rename or copy sections
  config: pass repo to `git_die_config()`
  config: pass repo to `git_config_get_expiry_in_days()`
  config: pass repo to `git_config_get_expiry()`
  config: pass repo to `git_config_get_max_percent_split_change()`
  config: pass repo to `git_config_get_split_index()`
  config: pass repo to `git_config_get_index_threads()`
  config: expose `repo_config_clear()`
  config: introduce missing setters that take repo as parameter
  path: hide functions using `the_repository` by default
  path: stop relying on `the_repository` in `worktree_git_path()`
  path: stop relying on `the_repository` when reporting garbage
  hooks: remove implicit dependency on `the_repository`
  editor: do not rely on `the_repository` for interactive edits
  path: expose `do_git_common_path()` as `repo_common_pathv()`
  path: expose `do_git_path()` as `repo_git_pathv()`

10 months agoMerge branch 'ps/leakfixes-part-4'
Junio C Hamano [Fri, 23 Aug 2024 16:02:33 +0000 (09:02 -0700)] 
Merge branch 'ps/leakfixes-part-4'

More leak fixes.

* ps/leakfixes-part-4: (22 commits)
  builtin/diff: free symmetric diff members
  diff: free state populated via options
  builtin/log: fix leak when showing converted blob contents
  userdiff: fix leaking memory for configured diff drivers
  builtin/format-patch: fix various trivial memory leaks
  diff: fix leak when parsing invalid ignore regex option
  unpack-trees: clear index when not propagating it
  sequencer: release todo list on error paths
  merge-ort: unconditionally release attributes index
  builtin/fast-export: plug leaking tag names
  builtin/fast-export: fix leaking diff options
  builtin/fast-import: plug trivial memory leaks
  builtin/notes: fix leaking `struct notes_tree` when merging notes
  builtin/rebase: fix leaking `commit.gpgsign` value
  config: fix leaking comment character config
  submodule-config: fix leaking name entry when traversing submodules
  read-cache: fix leaking hashfile when writing index fails
  bulk-checkin: fix leaking state TODO
  object-name: fix leaking symlink paths in object context
  object-file: fix memory leak when reading corrupted headers
  ...

10 months agodiff-index: integrate with the sparse index
Derrick Stolee [Thu, 22 Aug 2024 16:03:27 +0000 (16:03 +0000)] 
diff-index: integrate with the sparse index

The sparse index allows focusing the index data structure on the files
present in the sparse-checkout, leaving only tree entries for
directories not within the sparse-checkout. Each builtin needs a
repository setting to indicate that it has been tested with the sparse
index before Git will allow the index to be loaded into memory in its
sparse form. This is a safety precaution.

There are still some builtins that haven't been integrated due to the
complexity of the integration and the lack of significant use. However,
'git diff-index' was neglected only because of initial data showing low
usage. The diff machinery was already integrated and there is no more
work to be done there but add some tests to be sure 'git diff-index'
behaves as expected.

For this purpose, we can follow the testing pattern used in 51ba65b5c35
(diff: enable and test the sparse index, 2021-12-06). One difference
here is that we only verify that the sparse index case agrees with the
full index case, but do not generate the expected output. The 'git diff'
tests use the '--name-status' option to ease the creation of the
expected output, but that's not an option for 'diff-index'. Since the
underlying diff machinery is the same, a simple comparison is sufficient
to give some coverage.

Signed-off-by: Derrick Stolee <stolee@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 months agoreftable/generic: drop interface
Patrick Steinhardt [Thu, 22 Aug 2024 06:35:29 +0000 (08:35 +0200)] 
reftable/generic: drop interface

The `reftable_table` interface provides a generic infrastructure that
can abstract away whether the underlying table is a single table, or a
merged table. This abstraction can make it rather hard to reason about
the code. We didn't ever use it to implement the reftable backend, and
with the preceding patches in this patch series we in fact don't use it
at all anymore. Furthermore, it became somewhat useless with the recent
refactorings that made it possible to seek reftable iterators multiple
times, as these now provide generic access to tables for us. The
interface is thus redundant and only brings unnecessary complexity with
it.

Remove the `struct reftable_table` interface and its associated
functions.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 months agot/helper: refactor to not use `struct reftable_table`
Patrick Steinhardt [Thu, 22 Aug 2024 06:35:24 +0000 (08:35 +0200)] 
t/helper: refactor to not use `struct reftable_table`

The `struct reftable_table` interface in our "reftable" test helper gets
used such that we can easily print either a single table, or a merged
stack. This generic interface is about to go away.

Prepare the code for this change by using merged tables instead. When
printing the stack we've already got one. When using a single table, we
can create a merged table from it to adapt.

This removes the last user of the generic interface.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 months agot/helper: use `hash_to_hex_algop()` to print hashes
Patrick Steinhardt [Thu, 22 Aug 2024 06:35:21 +0000 (08:35 +0200)] 
t/helper: use `hash_to_hex_algop()` to print hashes

The "reftable" test helper uses a hand-crafted version to convert from a
raw hash to its hex variant. This was done because this code used to be
part of the reftable library, where we do not use most functions from
the Git core.

Now that the code is integrated into the "dump-reftable" helper though,
that limitation went away. Let's thus use `hash_to_hex_algop()` instead.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 months agot/helper: inline printing of reftable records
Patrick Steinhardt [Thu, 22 Aug 2024 06:35:18 +0000 (08:35 +0200)] 
t/helper: inline printing of reftable records

Move printing of reftable records into the "dump-reftable" helper. This
follows the same reasoning as the preceding commit.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 months agot/helper: inline `reftable_table_print()`
Patrick Steinhardt [Thu, 22 Aug 2024 06:35:15 +0000 (08:35 +0200)] 
t/helper: inline `reftable_table_print()`

Move `reftable_table_print()` into the "dump-reftable" helper. This
follows the same reasoning as the preceding commit.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 months agot/helper: inline `reftable_stack_print_directory()`
Patrick Steinhardt [Thu, 22 Aug 2024 06:35:12 +0000 (08:35 +0200)] 
t/helper: inline `reftable_stack_print_directory()`

Move `reftable_stack_print_directory()` into the "dump-reftable" helper.
This follows the same reasoning as the preceding commit.

Note that this requires us to remove the tests for this functionality in
`reftable/stack_test.c`. The test does not really add much anyway,
because all it verifies is that we do not crash or run into an error,
and it specifically doesn't check the outputted data. Also, as the code
is now part of the test helper, it doesn't make much sense to have a
unit test for it in the first place.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 months agot/helper: inline `reftable_reader_print_file()`
Patrick Steinhardt [Thu, 22 Aug 2024 06:35:05 +0000 (08:35 +0200)] 
t/helper: inline `reftable_reader_print_file()`

Move `reftable_reader_print_file()` into the "dump-reftable" helper.
This follows the same reasoning as the preceding commit.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 months agot/helper: inline `reftable_dump_main()`
Patrick Steinhardt [Thu, 22 Aug 2024 06:35:02 +0000 (08:35 +0200)] 
t/helper: inline `reftable_dump_main()`

The printing functionality part of `reftable/dump.c` is really only used
by our "dump-reftable" test helper. It is certainly not generic logic
that is useful to anybody outside of Git, and the format it generates is
quite specific. Still, parts of it are used in our test suite and the
output may be useful to take a peek into reftable stacks, tables and
blocks. So while it does not make sense to expose this as part of the
reftable library, it does make sense to keep it around.

Inline the `reftable_dump_main()` function into the "dump-reftable" test
helper. This clarifies that its format is subject to change and not part
of our public interface. Furthermore, this allows us to iterate on the
implementation in subsequent patches.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 months agoreftable/dump: drop unused `compact_stack()`
Patrick Steinhardt [Thu, 22 Aug 2024 06:35:00 +0000 (08:35 +0200)] 
reftable/dump: drop unused `compact_stack()`

The `compact_stack()` function is exposed via `reftable_dump_main()`,
which ultimately ends up being wired into "test-tool reftable". It is
never used by our tests though, and nowadays we have wired up support
for stack compaction into git-pack-refs(1).

Remove the code.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 months agoreftable/generic: move generic iterator code into iterator interface
Patrick Steinhardt [Thu, 22 Aug 2024 06:34:57 +0000 (08:34 +0200)] 
reftable/generic: move generic iterator code into iterator interface

Move functions relating to the reftable iterator from "generic.c" into
"iter.c". This prepares for the removal of the former subsystem.

While at it, remove some unneeded braces to conform to our coding style.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 months agoreftable/iter: drop double-checking logic
Patrick Steinhardt [Thu, 22 Aug 2024 06:34:54 +0000 (08:34 +0200)] 
reftable/iter: drop double-checking logic

The filtering ref iterator can be used to only yield refs which are not
in a specific skip list. This iterator has an option to double-check the
results it returns, which causes us to seek the reference we are about
to yield via a separate table such that we detect whether the reference
that the first iterator has yielded actually exists.

The value of this is somewhat dubious, and I cannot think of any usecase
where this functionality should be required. Furthermore, this option is
never set in our codebase, which means that it is essentially untested.
And last but not least, the `struct reftable_table` that is used to
implement it is about to go away.

So while we could refactor the code to not use a `reftable_table`, it
very much feels like a wasted effort. Let's just drop this code.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 months agoreftable/stack: open-code reading refs
Patrick Steinhardt [Thu, 22 Aug 2024 06:34:48 +0000 (08:34 +0200)] 
reftable/stack: open-code reading refs

To read a reference for the reftable stack, we first create a generic
`reftable_table` from the merged table and then read the reference via a
convenience function. We are about to remove these generic interfaces,
so let's instead open-code the logic to prepare for this removal.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 months agoreftable/merged: stop using generic tables in the merged table
Patrick Steinhardt [Thu, 22 Aug 2024 06:34:44 +0000 (08:34 +0200)] 
reftable/merged: stop using generic tables in the merged table

The merged table provides access to a reftable stack by merging the
contents of those tables into a virtual table. These subtables are being
tracked via `struct reftable_table`, which is a generic interface for
accessing either a single reftable or a merged reftable. So in theory,
it would be possible for the merged table to merge together other merged
tables.

This is somewhat nonsensical though: we only ever set up a merged table
over normal reftables, and there is no reason to do otherwise. This
generic interface thus makes the code way harder to follow and reason
about than really necessary. The abstraction layer may also have an
impact on performance, even though the extra set of vtable function
calls probably doesn't really matter.

Refactor the merged tables to use a `struct reftable_reader` for each of
the subtables instead, which gives us direct access to the underlying
tables. Adjust names accordingly.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 months agoreftable/merged: rename `reftable_new_merged_table()`
Patrick Steinhardt [Thu, 22 Aug 2024 06:34:41 +0000 (08:34 +0200)] 
reftable/merged: rename `reftable_new_merged_table()`

Rename `reftable_new_merged_table()` to `reftable_merged_table_new()`
such that the name matches our coding style.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 months agoreftable/merged: expose functions to initialize iterators
Patrick Steinhardt [Thu, 22 Aug 2024 06:34:38 +0000 (08:34 +0200)] 
reftable/merged: expose functions to initialize iterators

We do not expose any functions via our public headers that would allow a
caller to initialize a reftable iterator from a merged table. Instead,
they are expected to go via the generic `reftable_table` interface,
which is somewhat roundabout.

Implement two new functions to initialize iterators for ref and log
records to plug this gap.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 months agoThe seventh batch
Junio C Hamano [Wed, 21 Aug 2024 18:41:52 +0000 (11:41 -0700)] 
The seventh batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 months agoMerge branch 'jc/how-to-maintain-updates'
Junio C Hamano [Wed, 21 Aug 2024 19:02:25 +0000 (12:02 -0700)] 
Merge branch 'jc/how-to-maintain-updates'

Doc updates.

* jc/how-to-maintain-updates:
  howto-maintain: mention preformatted docs

10 months agoMerge branch 'jk/apply-patch-mode-check-fix'
Junio C Hamano [Wed, 21 Aug 2024 19:02:25 +0000 (12:02 -0700)] 
Merge branch 'jk/apply-patch-mode-check-fix'

Test fix.

* jk/apply-patch-mode-check-fix:
  t4129: fix racy index when calling chmod after git-add

10 months agoMerge branch 'ps/bundle-outside-repo-fix'
Junio C Hamano [Wed, 21 Aug 2024 19:02:24 +0000 (12:02 -0700)] 
Merge branch 'ps/bundle-outside-repo-fix'

"git bundle unbundle" outside a repository triggered a BUG()
unnecessarily, which has been corrected.

* ps/bundle-outside-repo-fix:
  bundle: default to SHA1 when reading bundle headers
  builtin/bundle: have unbundle check for repo before opening its bundle

10 months agoMerge branch 'jc/grammo-fixes'
Junio C Hamano [Wed, 21 Aug 2024 19:02:23 +0000 (12:02 -0700)] 
Merge branch 'jc/grammo-fixes'

Doc updates.

* jc/grammo-fixes:
  doc: grammofix in git-diff-tree
  tutorial: grammofix

10 months agoMerge branch 'ag/git-svn-global-ignores'
Junio C Hamano [Wed, 21 Aug 2024 19:02:23 +0000 (12:02 -0700)] 
Merge branch 'ag/git-svn-global-ignores'

"git svn" has been taught about svn:global-ignores property
recent versions of Subversion has.

* ag/git-svn-global-ignores:
  git-svn: mention `svn:global-ignores` in help+docs
  git-svn: use `svn:global-ignores` to create .gitignore
  git-svn: add public property `svn:global-ignores`

10 months agobuiltin/maintenance: fix loose objects task emitting pack hash
Patrick Steinhardt [Mon, 19 Aug 2024 07:48:05 +0000 (09:48 +0200)] 
builtin/maintenance: fix loose objects task emitting pack hash

The "loose-objects" maintenance tasks executes git-pack-objects(1) to
pack all loose objects into a new packfile. This command ends up
printing the hash of the packfile to stdout though, which clutters the
output of `git maintenance run`.

Fix this issue by disabling stdout of the child process.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 months agot7900: exercise detaching via trace2 regions
Patrick Steinhardt [Mon, 19 Aug 2024 07:48:02 +0000 (09:48 +0200)] 
t7900: exercise detaching via trace2 regions

In t7900, we exercise the `--detach` logic by checking whether the
command ended up writing anything to its output or not. This supposedly
works because we close stdin, stdout and stderr when daemonizing. But
one, it breaks on platforms where daemonize is a no-op, like Windows.
And second, that git-maintenance(1) outputs anything at all in these
tests is a bug in the first place that we'll fix in a subsequent commit.

Introduce a new trace2 region around the detach which allows us to more
explicitly check whether the detaching logic was executed. This is a
much more direct way to exercise the logic, provides a potentially
useful signal to tracing logs and also works alright on platforms which
do not have the ability to daemonize.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
[jc: dropped a stale in-code comment from a test]
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 months agot-reftable-block: add tests for index blocks
Chandra Pratap [Wed, 21 Aug 2024 12:31:01 +0000 (18:01 +0530)] 
t-reftable-block: add tests for index blocks

In the current testing setup, block operations are left unexercised
for index blocks. Add a test that exercises these operations for
index blocks.

Mentored-by: Patrick Steinhardt <ps@pks.im>
Mentored-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Chandra Pratap <chandrapratap3519@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 months agot-reftable-block: add tests for obj blocks
Chandra Pratap [Wed, 21 Aug 2024 12:31:00 +0000 (18:01 +0530)] 
t-reftable-block: add tests for obj blocks

In the current testing setup, block operations are left unexercised
for obj blocks. Add a test that exercises these operations for obj
blocks.

Mentored-by: Patrick Steinhardt <ps@pks.im>
Mentored-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Chandra Pratap <chandrapratap3519@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 months agot-reftable-block: add tests for log blocks
Chandra Pratap [Wed, 21 Aug 2024 12:30:59 +0000 (18:00 +0530)] 
t-reftable-block: add tests for log blocks

In the current testing setup, block operations are only exercised
for ref blocks. Add another test that exercises these operations
for log blocks as well.

Mentored-by: Patrick Steinhardt <ps@pks.im>
Mentored-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Chandra Pratap <chandrapratap3519@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 months agot-reftable-block: remove unnecessary variable 'j'
Chandra Pratap [Wed, 21 Aug 2024 12:30:58 +0000 (18:00 +0530)] 
t-reftable-block: remove unnecessary variable 'j'

Currently, there are two variables for array indices, 'i' and 'j'.
The variable 'j' is used only once and can be easily replaced with
'i'. Get rid of 'j' and replace its occurence with 'i'.

Mentored-by: Patrick Steinhardt <ps@pks.im>
Mentored-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Chandra Pratap <chandrapratap3519@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 months agot-reftable-block: use xstrfmt() instead of xstrdup()
Chandra Pratap [Wed, 21 Aug 2024 12:30:57 +0000 (18:00 +0530)] 
t-reftable-block: use xstrfmt() instead of xstrdup()

Use xstrfmt() to assign a formatted string to a ref record's
refname instead of xstrdup(). This helps save the overhead of
a local 'char' buffer as well as makes the test more compact.

Mentored-by: Patrick Steinhardt <ps@pks.im>
Mentored-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Chandra Pratap <chandrapratap3519@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 months agot-reftable-block: use block_iter_reset() instead of block_iter_close()
Chandra Pratap [Wed, 21 Aug 2024 12:30:56 +0000 (18:00 +0530)] 
t-reftable-block: use block_iter_reset() instead of block_iter_close()

block_iter_reset() restores a block iterator to its state at the time
of initialization without freeing any memory while block_iter_close()
deallocates the memory for the iterator.

In the current testing setup, a block iterator is allocated and
deallocated for every iteration of a loop, which hurts performance.
Improve upon this by using block_iter_reset() at the start of each
iteration instead. This has the added benifit of testing
block_iter_reset(), which currently remains untested.

Similarly, remove reftable_record_release() for a reftable record
that is still in use.

Mentored-by: Patrick Steinhardt <ps@pks.im>
Mentored-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Chandra Pratap <chandrapratap3519@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 months agot-reftable-block: use reftable_record_key() instead of strbuf_addstr()
Chandra Pratap [Wed, 21 Aug 2024 12:30:55 +0000 (18:00 +0530)] 
t-reftable-block: use reftable_record_key() instead of strbuf_addstr()

In the current testing setup, the record key required for many block
iterator functions is manually stored in a strbuf struct and then
passed to these functions. This is not ideal when there exists a
dedicated function to encode a record's key into a strbuf, namely
reftable_record_key(). Use this function instead of manual encoding.

Mentored-by: Patrick Steinhardt <ps@pks.im>
Mentored-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Chandra Pratap <chandrapratap3519@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 months agot-reftable-block: use reftable_record_equal() instead of check_str()
Chandra Pratap [Wed, 21 Aug 2024 12:30:54 +0000 (18:00 +0530)] 
t-reftable-block: use reftable_record_equal() instead of check_str()

In the current testing setup, operations like read and write for
reftable blocks as defined by reftable/block.{c, h} are verified by
comparing only the keys of input and output reftable records. This is
not ideal because there can exist inequal reftable records with the
same key. Use the dedicated function for record comparison,
reftable_record_equal(), instead of key-based comparison.

Mentored-by: Patrick Steinhardt <ps@pks.im>
Mentored-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Chandra Pratap <chandrapratap3519@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 months agot-reftable-block: release used block reader
Chandra Pratap [Wed, 21 Aug 2024 12:30:53 +0000 (18:00 +0530)] 
t-reftable-block: release used block reader

Used block readers must be released using block_reader_release() to
prevent the occurence of a memory leak. Make test_block_read_write()
conform to this statement.

Mentored-by: Patrick Steinhardt <ps@pks.im>
Mentored-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Chandra Pratap <chandrapratap3519@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 months agot: harmonize t-reftable-block.c with coding guidelines
Chandra Pratap [Wed, 21 Aug 2024 12:30:52 +0000 (18:00 +0530)] 
t: harmonize t-reftable-block.c with coding guidelines

Harmonize the newly ported test unit-tests/t-reftable-block.c
with the following guidelines:
- Single line 'for' statements must omit curly braces.
- Structs must be 0-initialized with '= { 0 }' instead of '= { NULL }'.
- Array sizes and indices should preferably be of type 'size_t'and
  not 'int'.
- Return code variable should preferably be named 'ret', not 'n'.

Mentored-by: Patrick Steinhardt <ps@pks.im>
Mentored-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Chandra Pratap <chandrapratap3519@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 months agot: move reftable/block_test.c to the unit testing framework
Chandra Pratap [Wed, 21 Aug 2024 12:30:51 +0000 (18:00 +0530)] 
t: move reftable/block_test.c to the unit testing framework

reftable/block_test.c exercises the functions defined in
reftable/block.{c, h}. Migrate reftable/block_test.c to the unit
testing framework. Migration involves refactoring the tests
to use the unit testing framework instead of reftable's test
framework and renaming the tests to follow the unit-tests'
naming conventions.

Mentored-by: Patrick Steinhardt <ps@pks.im>
Mentored-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Chandra Pratap <chandrapratap3519@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 months agorebase --exec: respect --quiet
Matheus Tavares [Wed, 21 Aug 2024 01:31:52 +0000 (22:31 -0300)] 
rebase --exec: respect --quiet

rebase --exec doesn't obey --quiet and ends up printing messages about
the command being executed:

  git rebase HEAD~3 --quiet --exec true
  Executing: true
  Executing: true
  Executing: true

Let's fix that by omitting the "Executing" messages when using --quiet.

Furthermore, the sequencer code includes a few calls to
term_clear_line(), which prints a special character sequence to erase
the previous line displayed on stderr (even when nothing was printed
yet). For an user running the command interactively, the net effect of
calling this function with or without --quiet is the same as the
characters are invisible in the terminal. However, when redirecting the
output to a file or piping to another command, the presence of these
invisible characters is noticeable, and it may break user expectation as
--quiet is not being respected.

We could skip the term_clear_line() calls when --quiet is used, like we
are doing with the "Executing" messages, but it makes much more sense to
condition the line cleaning upon stderr being TTY, since these
characters are really only useful for TTY outputs.

The added test checks for both these two changes.

Reported-by: Lincoln Yuji <lincolnyuji@hotmail.com>
Reported-by: Rodrigo Siqueira <siqueirajordao@riseup.net>
Signed-off-by: Matheus Tavares <matheus.tavb@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 months agoSync with 'maint' for Windows+VS build jobs used at CI
Junio C Hamano [Tue, 20 Aug 2024 21:24:05 +0000 (14:24 -0700)] 
Sync with 'maint' for Windows+VS build jobs used at CI

10 months agoMerge branch 'jk/midx-unused-fix'
Junio C Hamano [Tue, 20 Aug 2024 21:23:46 +0000 (14:23 -0700)] 
Merge branch 'jk/midx-unused-fix'

Code clean-up in the base topic.

* jk/midx-unused-fix:
  midx: drop unused parameters from add_midx_to_chain()

10 months agoMerge branch 'js/ci-win-vs-build' into maint-2.46
Junio C Hamano [Tue, 20 Aug 2024 21:23:12 +0000 (14:23 -0700)] 
Merge branch 'js/ci-win-vs-build' into maint-2.46

Sync with Windows+VS build jobs used at CI.

* js/ci-win-vs-build:
  ci(win+VS): download the vcpkg artifacts using a dedicated GitHub Action
  ci: bump microsoft/setup-msbuild from v1 to v2

10 months agoCodingGuidelines: spaces around C operators
Junio C Hamano [Tue, 20 Aug 2024 20:36:11 +0000 (13:36 -0700)] 
CodingGuidelines: spaces around C operators

As we have operated with "write like how your surrounding code is
written" for too long, after a huge code drop from another project,
we'll end up being inconsistent before such an imported code is
cleaned up.  We have many uses of cast operator with a space before
its operand, mostly in the reftable code.

Spell the convention out before it spreads to other places.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 months agot: migrate t0110-urlmatch-normalization to the new framework
Ghanshyam Thakkar [Tue, 20 Aug 2024 15:19:47 +0000 (20:49 +0530)] 
t: migrate t0110-urlmatch-normalization to the new framework

helper/test-urlmatch-normalization along with
t0110-urlmatch-normalization test the `url_normalize()` function from
'urlmatch.h'. Migrate them to the unit testing framework for better
performance. And also add different test_msg()s for better debugging.

In the migration, last two of the checks from `t_url_general_escape()`
were slightly changed compared to the shell script. This involves
changing

'\'' -> '
'\!' -> !

in the urls of those checks. This is because in C strings, we don't
need to escape "'" and "!". Other than these two, all the urls were
pasted verbatim from the shell script.

Another change is the removal of a MINGW prerequisite from one of the
test. It was there because[1] on Windows, the command line is a
Unicode string, it is not possible to pass arbitrary bytes to a
program. But in unit tests we don't have this limitation.

And since we can construct strings with arbitrary bytes in C, let's
also remove the test files which contain URLs with arbitrary bytes in
the 't/t0110' directory and instead embed those URLs in the unit test
code itself.

[1]: https://lore.kernel.org/git/53CAC8EF.6020707@gmail.com/

Mentored-by: Christian Couder <chriscool@tuxfamily.org>
Mentored-by: Kaartic Sivaraam <kaartic.sivaraam@gmail.com>
Signed-off-by: Ghanshyam Thakkar <shyamthakkar001@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 months agot-hashmap: stop calling setup() for t_intern() test
Jeff King [Tue, 20 Aug 2024 05:18:19 +0000 (01:18 -0400)] 
t-hashmap: stop calling setup() for t_intern() test

Commit f24a9b78a9 (t-hashmap: mark unused parameters in callback
function, 2024-08-17) noted that the t_intern() does not need its
hashmap parameter, but we have to keep it to conform to the function
pointer interface of setup().

But since the only thing setup() does is create and tear down the
hashmap, we can just skip calling setup() entirely for this case, and
drop the unused parameters. This simplifies the code a bit.

Helped-by: Ghanshyam Thakkar <shyamthakkar001@gmail.com>
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 months agogit-prompt: support custom 0-width PS1 markers
Avi Halachmi (:avih) [Tue, 20 Aug 2024 01:48:32 +0000 (01:48 +0000)] 
git-prompt: support custom 0-width PS1 markers

When using colors, the shell needs to identify 0-width substrings
in PS1 - such as color escape sequences - when calculating the
on-screen width of the prompt.

Until now, we used the form %F{<color>} in zsh - which it knows is
0-width, or otherwise use standard SGR esc sequences wrapped between
byte values 1 and 2 (SOH, STX) as 0-width start/end markers, which
bash/readline identify as such.

But now that more shells are supported, the standard SGR sequences
typically work, but the SOH/STX markers might not be identified.

This commit adds support for vars GIT_PS1_COLOR_{PRE,POST} which
set custom 0-width markers or disable the markers.

Signed-off-by: Avi Halachmi (:avih) <avihpit@yahoo.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 months agogit-prompt: ta-da! document usage in other shells
Avi Halachmi (:avih) [Tue, 20 Aug 2024 01:48:31 +0000 (01:48 +0000)] 
git-prompt: ta-da! document usage in other shells

With one big exception, git-prompt.sh should now be both almost posix
compliant, and also compatible with most (posix-ish) shells.

That exception is the use of "local" vars in functions, which happens
extensively in the current code, and is not simple to replace with
posix compliant code (but also not impossible).

Luckily, almost all shells support "local" as used by the current
code, with the notable exception of ksh93[u+m], but also the Schily
minimal posix sh (pbosh), and yash in posix mode.

See assessment below that "local" is likely the only blocker in those.

So except mainly ksh93, git-prompt.sh now works in most shells:
- bash, zsh, dash since at least 0.5.8, free/net bsd sh, busybox-ash,
  mksh, openbsd sh, pdksh(!), Schily extended Bourne sh (bosh), yash.

which is quite nice.

As an anecdote, replacing the 1st line in __git_ps1() (local exit=$?)
with these 2 makes it work in all tested shells, even without "local":

  # handles only 0/1 args for simplicity. needs +5 LOC for any $#
  __git_e=$?; local exit="$__git_e" 2>/dev/null ||
    {(eval 'local() { export "$@"; }'; __git_ps1 "$@"); return "$__git_e"; }

Explanation:

  If the shell doesn't have the command "local", define our own
  function "local" which instead does plain (global) assignents.
  Then use __git_ps1 in a subshell to not clober the caller's vars.

  This happens to work because currently there are no name conflicts
  (shadow) at the code, initial value is not assumed (i.e. always
  doing either 'local x=...'  or 'local x;...  x=...'), and assigned
  initial values are quoted (local x="$y"), preventing word split and
  glob expansion (i.e. assignment context is not assumed).

  The last two (always init, quote values) seem to be enough to use
  "local" portably if supported, and otherwise shells indeed differ.

  Uses "eval", else shells with "local" may reject it during parsing.
  We don't need "export", but it's smaller than writing our own loop.

While cute, this approach is not really sustainable because all the
vars become global, which is hard to maintain without conflicts
(but hey, it currently has no conflicts - without even trying...).

However, regardless of being an anecdote, it provides some support to
the assessment that "local" is the only blocker in those shells.

Signed-off-by: Avi Halachmi (:avih) <avihpit@yahoo.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 months agogit-prompt: don't use shell $'...'
Avi Halachmi (:avih) [Tue, 20 Aug 2024 01:48:30 +0000 (01:48 +0000)] 
git-prompt: don't use shell $'...'

$'...' is new in POSIX (2024), and some shells support it in recent
versions, while others have had it for decades (bash, zsh, ksh93).

However, there are still enough shells which don't support it, and
it's cheap to use an alternative form which works in all shells,
so let's do that instead of dismissing it as "it's compliant".

It was agreed to use one form rather than $'...' where supported and
fallback otherwise.

shells where $'...' works:
- bash, zsh, ksh93, mksh, busybox-ash, dash master, free/net bsd sh.

shells where it doesn't work, but the new fallback works:
- all dash releases (up to 0.5.12), older versions of free/net bsd sh,
  openbsd sh, pdksh, all Schily Bourne sh variants, yash.

Signed-off-by: Avi Halachmi (:avih) <avihpit@yahoo.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 months agogit-prompt: add some missing quotes
Avi Halachmi (:avih) [Tue, 20 Aug 2024 01:48:29 +0000 (01:48 +0000)] 
git-prompt: add some missing quotes

The issues which this commit fixes are unlikely to be broken
in real life, but the fixes improve correctness, and would prevent
bugs in some uncommon cases, such as weird IFS values.

Listing some portability guidelines here for future reference.

I'm leaving it to someone else to decide whether to include
it in the file itself, place it as a new file, or not.

---------

The command "local" is non standard, but is allowed in this file:
- Quote initialization if it can expand (local x="$y"). See below.
- Don't assume initial value after "local x". Either initialize it
  (local x=..), or set before first use (local x;.. x=..; <use $x>).
  (between shells, "local x" can unset x, or inherit it, or do x= )

Other non-standard features beyond "local" are to be avoided.

Use the standard "test" - [...] instead of non-standard [[...]] .

--------

Quotes (some portability things, but mainly general correctness):

Quotes prevent tilde-expansion of some unquoted literal tildes (~).
If the expansion is undesirable, quotes would ensure that.
  Tilds expanded: a=~user:~/ ;  echo ~user ~/dir
  not expanded:   t="~"; a=${t}user  b=\~foo~;  echo "~user" $t/dir

But the main reason for quoting is to prevent IFS field splitting
(which also coalesces IFS chars) and glob expansion in parts which
contain parameter/arithmetic expansion or command substitution.

"Simple command" (POSIX term) is assignment[s] and/or command [args].
Examples:
  foo=bar         # one assignment
  foo=$bar x=y    # two assignments
  foo bar         # command, no assignments
  x=123 foo bar   # one assignment and a command

The assignments part is not IFS-split or glob-expanded.

The command+args part does get IFS field split and glob expanded,
but only at unquoted expanded/substituted parts.

In the command+args part, expanded/substituted values must be quoted.
(the commands here are "[" and "local"):
  Good: [ "$mode" = yes ]; local s="*" x="$y" e="$?" z="$(cmd ...)"
  Bad:  [ $mode = yes ];   local s=*   x=$y   e=$?   z=$(cmd...)

The arguments to "local" do look like assignments, but they're not
the assignment part of a simple command; they're at the command part.

Still at the command part, no need to quote non-expandable values:
  Good:                 local x=   y=yes;   echo OK
  OK, but not required: local x="" y="yes"; echo "OK"
But completely empty (NULL) arguments must be quoted:
  foo ""   is not the same as:   foo

Assignments in simple commands - with or without an actual command,
don't need quoting becase there's no IFS split or glob expansion:
  Good:   s=* a=$b c=$(cmd...)${x# foo }${y-   } [cmd ...]
  It's also OK to use double quotes, but not required.

This behavior (no IFS/glob) is called "assignment context", and
"local" does not behave with assignment context in some shells,
hence we require quotes when using "local" - for compatibility.

The value between 'case' and 'in' doesn't IFS-split/glob-expand:
  Good:       case  * $foo $(cmd...)  in ... ; esac
  identical:  case "* $foo $(cmd...)" in ... ; esac

Nested quotes in command substitution are fine, often necessary:
  Good: echo "$(foo... "$x" "$(bar ...)")"

Nested quotes in substring ops are legal, and sometimes needed
to prevent interpretation as a pattern, but not the most readable:
  Legal:  foo "${x#*"$y" }"

Nested quotes in "maybe other value" subst are invalid, unnecessary:
  Good:  local x="${y- }";   foo "${z:+ $a }"
  Bad:   local x="${y-" "}"; foo "${z:+" $a "}"
Outer/inner quotes in "maybe other value" have different use cases:
  "${x-$y}"  always one quoted arg: "$x" if x is set, else "$y".
  ${x+"$x"}  one quoted arg "$x" if x is set, else no arg at all.
  Unquoted $x is similar to the second case, but it would get split
  into few arguments if it includes any of the IFS chars.

Assignments don't need the outer quotes, and the braces delimit the
value, so nested quotes can be avoided, for readability:
  a=$(foo "$x")  a=${x#*"$y" }  c=${y- };  bar "$a" "$b" "$c"

Signed-off-by: Avi Halachmi (:avih) <avihpit@yahoo.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 months agogit-prompt: replace [[...]] with standard code
Avi Halachmi (:avih) [Tue, 20 Aug 2024 01:48:28 +0000 (01:48 +0000)] 
git-prompt: replace [[...]] with standard code

The existing [[...]] tests were either already valid as standard [...]
tests, or only required minimal retouch:

Notes:

- [[...]] doesn't do field splitting and glob expansion, so $var
  or $(cmd...) don't need quoting, but [... does need quotes.

- [[ X == Y ]] when Y is a string is same as [ X = Y ], but if Y is
  a pattern, then we need:  case X in Y)... ; esac  .

- [[ ... && ... ]] was replaced with [ ... ] && [ ... ] .

- [[ -o <zsh-option> ]] requires [[...]], so put it in "eval" and only
  eval it in zsh, so other shells would not abort on syntax error
  (posix says [[ has unspecified results, shells allowed to reject it)

- ((x++)) was changed into x=$((x+1))  (yeah, not [[...]] ...)

Shells which accepted the previous forms:
- bash, zsh, ksh93, mksh, openbsd sh, pdksh.

Shells which didn't, and now can process it:
- dash, free/net bsd sh, busybox-ash, Schily Bourne sh, yash.

Signed-off-by: Avi Halachmi (:avih) <avihpit@yahoo.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 months agogit-prompt: don't use shell arrays
Avi Halachmi (:avih) [Tue, 20 Aug 2024 01:48:27 +0000 (01:48 +0000)] 
git-prompt: don't use shell arrays

Arrays only existed in the svn-upstream code, used to:
- Keep a list of svn remotes.
- Convert commit msg to array of words, extract the 2nd-to-last word.

Except bash/zsh, nearly all shells failed load on syntax errors here.

Now:
- The svn remotes are a list of newline-terminated values.
- The 2nd-to-last word is extracted using standard shell substrings.
- All shells can digest the svn-upstream code.

While using shell field splitting to extract the word is simple, and
doesn't even need non-standard code, e.g. set -- $(git log -1 ...),
it would have the same issues as the old array code: it depends on IFS
which we don't control, and it's subject to glob-expansion, e.g. if
the message happens to include * or **/* (as this commit message just
did), then the array could get huge. This was not great.

Now it uses standard shell substrings, and we know the exact delimiter
to expect, because it's the match from our grep just one line earlier.

The new word extraction code also fixes svn-upstream in zsh, because
previously it used arr[len-2], but because in zsh, unlike bash, array
subscripts are 1-based, it incorrectly extracted the 3rd-to-last word.
symptom: missing upstream status in a git-svn repo: u=, u+N-M, etc.

The breakage in zsh is surprising, because it was last touched by
  commit d0583da838 (prompt: fix show upstream with svn and zsh),
claiming to fix exactly that. However, it only mentions syntax fixes.
It's unclear if behavior was fixed too. But it was broken, now fixed.

Note LF=$'\n' and then using $LF instead of $'\n' few times.
A future commit will add fallback for shells without $'...', so this
would be the only line to touch instead of replacing every $'\n' .

Shells which could run the previous array code:
- bash

Shells which have arrays but were broken anyway:
- zsh: 1-based subscript
- ksh93: no "local" (the new code can't fix this part...)
- mksh, openbsd sh, pdksh: failed load on syntax error: "for ((...))".

More shells which Failed to load due to syntax error:
- dash, free/net bsd sh, busybox-ash, Schily Bourne shell, yash.

Signed-off-by: Avi Halachmi (:avih) <avihpit@yahoo.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 months agogit-prompt: fix uninitialized variable
Avi Halachmi (:avih) [Tue, 20 Aug 2024 01:48:26 +0000 (01:48 +0000)] 
git-prompt: fix uninitialized variable

First use is in the form:  local var; ...; var=$var$whatever...

If the variable was unset (as bash and others do after "local x"),
then it would error if set -u is in effect.

Also, many shells inherit the existing value after "local var"
without init, but in this case it's unlikely to have a prior value.

Now we initialize it.

(local var= is enough, but local var="" is the custom in this file)

Signed-off-by: Avi Halachmi (:avih) <avihpit@yahoo.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 months agogit-prompt: use here-doc instead of here-string
Avi Halachmi (:avih) [Tue, 20 Aug 2024 01:48:25 +0000 (01:48 +0000)] 
git-prompt: use here-doc instead of here-string

Here-documend is standard, and works in all shells.

Both here-string and here-doc add final newline, which is important
in this case, because $output is without final newline, but we do
want "read" to succeed on the last line as well.

Shells which support here-string:
- bash, zsh, mksh, ksh93, yash (non-posix-mode).

shells which don't, and got fixed:
- ash-derivatives (dash, free/net bsd sh, busybox-ash).
- pdksh, openbsd sh.
- All Schily Bourne shell variants.

Signed-off-by: Avi Halachmi (:avih) <avihpit@yahoo.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 months agoci(win+VS): download the vcpkg artifacts using a dedicated GitHub Action
Johannes Schindelin [Tue, 20 Aug 2024 14:31:10 +0000 (14:31 +0000)] 
ci(win+VS): download the vcpkg artifacts using a dedicated GitHub Action

The Git for Windows project provides a GitHub Action to download and
cache Azure Pipelines artifacts (such as the `vcpkg` artifacts), hiding
gnarly internals, and also providing some robustness against network
glitches. Let's use it.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 months agoci: bump microsoft/setup-msbuild from v1 to v2
Johannes Schindelin [Tue, 20 Aug 2024 14:31:09 +0000 (14:31 +0000)] 
ci: bump microsoft/setup-msbuild from v1 to v2

The main benefit: The new version uses a node.js version that is not yet
deprecated.

Links:
- [Release notes](https://github.com/microsoft/setup-msbuild/releases)
- [Changelog](https://github.com/microsoft/setup-msbuild/blob/main/building-release.md)
- [Commits](https://github.com/microsoft/setup-msbuild/compare/v1...v2)

This patch was originally by GitHub's Dependabot, but I cannot attribute
that bot properly because it has no dedicated email address. Probably
because it hasn't reached legal age yet, or something.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 months agoThe sixth batch
Junio C Hamano [Mon, 19 Aug 2024 17:44:04 +0000 (10:44 -0700)] 
The sixth batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 months agoMerge branch 'ps/transport-leakfix-test-updates'
Junio C Hamano [Mon, 19 Aug 2024 18:07:38 +0000 (11:07 -0700)] 
Merge branch 'ps/transport-leakfix-test-updates'

Test updates.

* ps/transport-leakfix-test-updates:
  transport: mark more tests leak-free

10 months agoMerge branch 'tb/incremental-midx-part-1'
Junio C Hamano [Mon, 19 Aug 2024 18:07:37 +0000 (11:07 -0700)] 
Merge branch 'tb/incremental-midx-part-1'

Incremental updates of multi-pack index files.

* tb/incremental-midx-part-1:
  midx: implement support for writing incremental MIDX chains
  t/t5313-pack-bounds-checks.sh: prepare for sub-directories
  t: retire 'GIT_TEST_MULTI_PACK_INDEX_WRITE_BITMAP'
  midx: implement verification support for incremental MIDXs
  midx: support reading incremental MIDX chains
  midx: teach `midx_fanout_add_midx_fanout()` about incremental MIDXs
  midx: teach `midx_preferred_pack()` about incremental MIDXs
  midx: teach `midx_contains_pack()` about incremental MIDXs
  midx: remove unused `midx_locate_pack()`
  midx: teach `fill_midx_entry()` about incremental MIDXs
  midx: teach `nth_midxed_offset()` about incremental MIDXs
  midx: teach `bsearch_midx()` about incremental MIDXs
  midx: introduce `bsearch_one_midx()`
  midx: teach `nth_bitmapped_pack()` about incremental MIDXs
  midx: teach `nth_midxed_object_oid()` about incremental MIDXs
  midx: teach `prepare_midx_pack()` about incremental MIDXs
  midx: teach `nth_midxed_pack_int_id()` about incremental MIDXs
  midx: add new fields for incremental MIDX chains
  Documentation: describe incremental MIDX format

10 months agoMerge branch 'jc/tests-no-useless-tee'
Junio C Hamano [Mon, 19 Aug 2024 18:07:37 +0000 (11:07 -0700)] 
Merge branch 'jc/tests-no-useless-tee'

Test fixes.

* jc/tests-no-useless-tee:
  tests: drop use of 'tee' that hides exit status

10 months agoMerge branch 'rs/unit-tests-test-run'
Junio C Hamano [Mon, 19 Aug 2024 18:07:36 +0000 (11:07 -0700)] 
Merge branch 'rs/unit-tests-test-run'

Unit-test framework has learned a simple control structure to allow
embedding test statements in-line instead of having to create a new
function to contain them.

* rs/unit-tests-test-run:
  t-strvec: use if_test
  t-reftable-basics: use if_test
  t-ctype: use if_test
  unit-tests: add if_test
  unit-tests: show location of checks outside of tests
  t0080: use here-doc test body