]> git.ipfire.org Git - thirdparty/git.git/log
thirdparty/git.git
4 months agoMerge branch 'js/oss-fuzz-build-in-ci'
Junio C Hamano [Tue, 30 Jan 2024 00:03:00 +0000 (16:03 -0800)] 
Merge branch 'js/oss-fuzz-build-in-ci'

oss-fuzz tests are built and run in CI.

* js/oss-fuzz-build-in-ci:
  ci: build and run minimal fuzzers in GitHub CI
  fuzz: fix fuzz test build rules

4 months agoMerge branch 'jc/majordomo-to-subspace'
Junio C Hamano [Tue, 30 Jan 2024 00:03:00 +0000 (16:03 -0800)] 
Merge branch 'jc/majordomo-to-subspace'

Doc update.

* jc/majordomo-to-subspace:
  Docs: majordomo@vger.kernel.org has been decomissioned

4 months agoMerge branch 'nb/rebase-x-shell-docfix'
Junio C Hamano [Tue, 30 Jan 2024 00:02:59 +0000 (16:02 -0800)] 
Merge branch 'nb/rebase-x-shell-docfix'

Doc update.

* nb/rebase-x-shell-docfix:
  rebase: fix documentation about used shell in -x

4 months agoMerge branch 'tc/show-ref-exists-fix'
Junio C Hamano [Tue, 30 Jan 2024 00:02:59 +0000 (16:02 -0800)] 
Merge branch 'tc/show-ref-exists-fix'

Update to a new feature recently added, "git show-ref --exists".

* tc/show-ref-exists-fix:
  builtin/show-ref: treat directory as non-existing in --exists

4 months agoMerge branch 'ps/reftable-optimize-io'
Junio C Hamano [Tue, 30 Jan 2024 00:02:59 +0000 (16:02 -0800)] 
Merge branch 'ps/reftable-optimize-io'

Low-level I/O optimization for reftable.

* ps/reftable-optimize-io:
  reftable/stack: fix race in up-to-date check
  reftable/stack: unconditionally reload stack after commit
  reftable/blocksource: use mmap to read tables
  reftable/blocksource: refactor code to match our coding style
  reftable/stack: use stat info to avoid re-reading stack list
  reftable/stack: refactor reloading to use file descriptor
  reftable/stack: refactor stack reloading to have common exit path

4 months agoThe tenth batch
Junio C Hamano [Fri, 26 Jan 2024 16:54:31 +0000 (08:54 -0800)] 
The tenth batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 months agoMerge branch 'vd/fsck-submodule-url-test'
Junio C Hamano [Fri, 26 Jan 2024 16:54:47 +0000 (08:54 -0800)] 
Merge branch 'vd/fsck-submodule-url-test'

Tighten URL checks fsck makes in a URL recorded for submodules.

* vd/fsck-submodule-url-test:
  submodule-config.c: strengthen URL fsck check
  t7450: test submodule urls
  test-submodule: remove command line handling for check-name
  submodule-config.h: move check_submodule_url

4 months agoMerge branch 'kh/maintenance-use-xdg-when-it-should'
Junio C Hamano [Fri, 26 Jan 2024 16:54:47 +0000 (08:54 -0800)] 
Merge branch 'kh/maintenance-use-xdg-when-it-should'

When $HOME/.gitignore is missing but XDG config file available, we
should write into the latter, not former.  "git gc" and "git
maintenance" wrote into a wrong "global config" file, which have
been corrected.

* kh/maintenance-use-xdg-when-it-should:
  maintenance: use XDG config if it exists
  config: factor out global config file retrieval
  config: rename global config function
  config: format newlines

4 months agoMerge branch 'gt/test-commit-o-i-options'
Junio C Hamano [Fri, 26 Jan 2024 16:54:47 +0000 (08:54 -0800)] 
Merge branch 'gt/test-commit-o-i-options'

A few tests to "git commit -o <pathspec>" and "git commit -i
<pathspec>" has been added.

* gt/test-commit-o-i-options:
  t7501: add tests for --amend --signoff
  t7501: add tests for --include and --only

4 months agoMerge branch 'ps/gitlab-ci-macos'
Junio C Hamano [Fri, 26 Jan 2024 16:54:47 +0000 (08:54 -0800)] 
Merge branch 'ps/gitlab-ci-macos'

CI for GitLab learned to drive macOS jobs.

* ps/gitlab-ci-macos:
  ci: add macOS jobs to GitLab CI
  ci: make p4 setup on macOS more robust
  ci: handle TEST_OUTPUT_DIRECTORY when printing test failures
  Makefile: detect new Homebrew location for ARM-based Macs
  t7527: decrease likelihood of racing with fsmonitor daemon

4 months agoMerge branch 'ps/completion-with-reftable-fix'
Junio C Hamano [Fri, 26 Jan 2024 16:54:46 +0000 (08:54 -0800)] 
Merge branch 'ps/completion-with-reftable-fix'

Completion update to prepare for reftable

* ps/completion-with-reftable-fix:
  completion: treat dangling symrefs as existing pseudorefs
  completion: silence pseudoref existence check
  completion: improve existence check for pseudo-refs
  t9902: verify that completion does not print anything
  completion: discover repo path in `__git_pseudoref_exists ()`

4 months agoMerge branch 'jt/tests-with-reftable'
Junio C Hamano [Fri, 26 Jan 2024 16:54:46 +0000 (08:54 -0800)] 
Merge branch 'jt/tests-with-reftable'

Tweak a few tests not to manually modify the reference database
(hence easier to work with other backends like reftable).

* jt/tests-with-reftable:
  t5541: remove lockfile creation
  t1401: remove lockfile creation

4 months agoMerge branch 'la/strvec-comment-fix'
Junio C Hamano [Fri, 26 Jan 2024 16:54:46 +0000 (08:54 -0800)] 
Merge branch 'la/strvec-comment-fix'

Comment fix.

* la/strvec-comment-fix:
  strvec: use correct member name in comments

4 months agoMerge branch 'mj/gitweb-unreadable-config-error'
Junio C Hamano [Fri, 26 Jan 2024 16:54:46 +0000 (08:54 -0800)] 
Merge branch 'mj/gitweb-unreadable-config-error'

When given an existing but unreadable file as a configuration file,
gitweb behaved as if the file did not exist at all, but now it
errors out.  This is a change that may break backward compatibility.

* mj/gitweb-unreadable-config-error:
  gitweb: die when a configuration file cannot be read

4 months agoMerge branch 'ps/worktree-refdb-initialization'
Junio C Hamano [Fri, 26 Jan 2024 16:54:46 +0000 (08:54 -0800)] 
Merge branch 'ps/worktree-refdb-initialization'

Instead of manually creating refs/ hierarchy on disk upon a
creation of a secondary worktree, which is only usable via the
files backend, use the refs API to populate it.

* ps/worktree-refdb-initialization:
  builtin/worktree: create refdb via ref backend
  worktree: expose interface to look up worktree by name
  builtin/worktree: move setup of commondir file earlier
  refs/files: skip creation of "refs/{heads,tags}" for worktrees
  setup: move creation of "refs/" into the files backend
  refs: prepare `refs_init_db()` for initializing worktree refs

4 months agoMerge branch 'ps/commit-graph-write-leakfix'
Junio C Hamano [Fri, 26 Jan 2024 16:54:45 +0000 (08:54 -0800)] 
Merge branch 'ps/commit-graph-write-leakfix'

Leakfix.

* ps/commit-graph-write-leakfix:
  commit-graph: fix memory leak when not writing graph

4 months agoMerge branch 'al/unit-test-ctype'
Junio C Hamano [Fri, 26 Jan 2024 16:54:45 +0000 (08:54 -0800)] 
Merge branch 'al/unit-test-ctype'

Move test-ctype helper to the unit-test framework.

* al/unit-test-ctype:
  unit-tests: rewrite t/helper/test-ctype.c as a unit test

4 months agoMerge branch 'ne/doc-filter-blob-limit-fix'
Junio C Hamano [Fri, 26 Jan 2024 16:54:45 +0000 (08:54 -0800)] 
Merge branch 'ne/doc-filter-blob-limit-fix'

Docfix.

* ne/doc-filter-blob-limit-fix:
  rev-list-options: fix off-by-one in '--filter=blob:limit=<n>' explainer

4 months agoMerge branch 'rj/advice-delete-branch-not-fully-merged'
Junio C Hamano [Fri, 26 Jan 2024 16:54:45 +0000 (08:54 -0800)] 
Merge branch 'rj/advice-delete-branch-not-fully-merged'

The error message given when "git branch -d branch" fails due to
commits unique to the branch has been split into an error and a new
conditional advice message.

* rj/advice-delete-branch-not-fully-merged:
  branch: make the advice to force-deleting a conditional one
  advice: fix an unexpected leading space
  advice: sort the advice related lists

4 months agoMerge branch 'es/some-up-to-date-messages-must-stay'
Junio C Hamano [Fri, 26 Jan 2024 16:54:45 +0000 (08:54 -0800)] 
Merge branch 'es/some-up-to-date-messages-must-stay'

Comment updates to help developers not to attempt to modify
messages from plumbing commands that must stay constant.

It might make sense to reassess the plumbing needs every few years,
but that should be done as a separate effort.

* es/some-up-to-date-messages-must-stay:
  messages: mark some strings with "up-to-date" not to touch

4 months agoDocs: majordomo@vger.kernel.org has been decomissioned
Junio C Hamano [Fri, 19 Jan 2024 22:26:45 +0000 (14:26 -0800)] 
Docs: majordomo@vger.kernel.org has been decomissioned

Update the instruction for subscribing to the Git mailing list
we have on a few documentation pages.

Reported-by: Kyle Lippincott <spectral@google.com>
Helped-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 months agoThe ninth batch
Junio C Hamano [Fri, 19 Jan 2024 22:57:34 +0000 (14:57 -0800)] 
The ninth batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 months agoMerge branch 'ps/p4-use-ref-api'
Junio C Hamano [Fri, 19 Jan 2024 23:04:46 +0000 (15:04 -0800)] 
Merge branch 'ps/p4-use-ref-api'

"git p4" update to prepare for reftable

* ps/p4-use-ref-api:
  git-p4: stop reaching into the refdb

4 months agoMerge branch 'cp/t4129-pipefix'
Junio C Hamano [Fri, 19 Jan 2024 23:04:46 +0000 (15:04 -0800)] 
Merge branch 'cp/t4129-pipefix'

Test update.

* cp/t4129-pipefix:
  t4129: prevent loss of exit code due to the use of pipes

4 months agoMerge branch 'sk/mingw-owner-check-error-message-improvement'
Junio C Hamano [Fri, 19 Jan 2024 23:04:46 +0000 (15:04 -0800)] 
Merge branch 'sk/mingw-owner-check-error-message-improvement'

In addition to (rather cryptic) Security Identifiers, show username
and domain in the error message when we barf on mismatch between
the Git directory and the current user on Windows.

* sk/mingw-owner-check-error-message-improvement:
  mingw: give more details about unsafe directory's ownership

4 months agoMerge branch 'bk/bisect-doc-fix'
Junio C Hamano [Fri, 19 Jan 2024 23:04:46 +0000 (15:04 -0800)] 
Merge branch 'bk/bisect-doc-fix'

Synopsis fix.

* bk/bisect-doc-fix:
  doc: refer to pathspec instead of path
  doc: use singular form of repeatable path arg

4 months agoMerge branch 'tb/fetch-all-configuration'
Junio C Hamano [Fri, 19 Jan 2024 23:04:45 +0000 (15:04 -0800)] 
Merge branch 'tb/fetch-all-configuration'

"git fetch" learned to pay attention to "fetch.all" configuration
variable, which pretends as if "--all" was passed from the command
line when no remote parameter was given.

* tb/fetch-all-configuration:
  fetch: add new config option fetch.all

4 months agoMerge branch 'rj/clarify-branch-doc-m'
Junio C Hamano [Fri, 19 Jan 2024 23:04:45 +0000 (15:04 -0800)] 
Merge branch 'rj/clarify-branch-doc-m'

Doc update.

* rj/clarify-branch-doc-m:
  branch: clarify <oldbranch> term

4 months agoMerge branch 'ps/gitlab-ci-static-analysis'
Junio C Hamano [Fri, 19 Jan 2024 23:04:45 +0000 (15:04 -0800)] 
Merge branch 'ps/gitlab-ci-static-analysis'

GitLab CI update.

* ps/gitlab-ci-static-analysis:
  ci: add job performing static analysis on GitLab CI

4 months agoMerge branch 'ps/prompt-parse-HEAD-futureproof'
Junio C Hamano [Fri, 19 Jan 2024 23:04:45 +0000 (15:04 -0800)] 
Merge branch 'ps/prompt-parse-HEAD-futureproof'

Futureproof command line prompt support (in contrib/).

* ps/prompt-parse-HEAD-futureproof:
  git-prompt: stop manually parsing HEAD with unknown ref formats

4 months agoci: build and run minimal fuzzers in GitHub CI
Josh Steadmon [Fri, 19 Jan 2024 21:38:13 +0000 (13:38 -0800)] 
ci: build and run minimal fuzzers in GitHub CI

To prevent bitrot, we would like to regularly exercise the fuzz tests in
order to make sure they still link & run properly. We already compile
the fuzz test objects as part of the default `make` target, but we do
not link the executables due to the fuzz tests needing specific
compilers and compiler features. This has lead to frequent build
breakages for the fuzz tests.

To remedy this, we can add a CI step to actually link the fuzz
executables, and run them (with finite input rather than the default
infinite random input mode) to verify that they execute properly.

Since the main use of the fuzz tests is via OSS-Fuzz [1], and OSS-Fuzz
only runs tests on Linux [2], we only set up a CI test for the fuzzers
on Linux.

[1] https://github.com/google/oss-fuzz
[2] https://google.github.io/oss-fuzz/further-reading/fuzzer-environment/

Signed-off-by: Josh Steadmon <steadmon@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 months agofuzz: fix fuzz test build rules
Josh Steadmon [Fri, 19 Jan 2024 21:38:12 +0000 (13:38 -0800)] 
fuzz: fix fuzz test build rules

When we originally added the fuzz tests in 5e47215080 (fuzz: add basic
fuzz testing target., 2018-10-12), we went to some trouble to create a
Makefile rule that allowed linking the fuzz executables without pulling
in common-main.o. This was necessary to prevent the
fuzzing-engine-provided main() from clashing with Git's main().

However, since 19d75948ef (common-main.c: move non-trace2 exit()
behavior out of trace2.c, 2022-06-02), it has been necessary to link
common-main.o due to moving the common_exit() function to that file.
Ævar suggested a set of compiler flags to allow this in [1], but this
was never reflected in the Makefile.

Since we now must include common-main.o, there's no reason to pick and
choose a subset of object files to link, so simplify the Makefile rule
for the fuzzer executables to just use libgit.a. While we're at it,
include the necessary linker flag to allow multiple definitions
directly in the Makefile rule, rather than requiring it to be passed on
the command-line each time. This means the Makefile rule as written is
now more compiler-specific, but this was already the case for the
fuzzers themselves anyway.

[1] https://lore.kernel.org/git/220607.8635ggupws.gmgdl@evledraar.gmail.com/

Signed-off-by: Josh Steadmon <steadmon@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 months agosubmodule-config.c: strengthen URL fsck check
Victoria Dye [Thu, 18 Jan 2024 01:55:18 +0000 (01:55 +0000)] 
submodule-config.c: strengthen URL fsck check

Update the validation of "curl URL" submodule URLs (i.e. those that specify
an "http[s]" or "ftp[s]" protocol) in 'check_submodule_url()' to catch more
invalid URLs. The existing validation using 'credential_from_url_gently()'
parses certain URLs incorrectly, leading to invalid submodule URLs passing
'git fsck' checks. Conversely, 'url_normalize()' - used to validate remote
URLs in 'remote_get()' - correctly identifies the invalid URLs missed by
'credential_from_url_gently()'.

To catch more invalid cases, replace 'credential_from_url_gently()' with
'url_normalize()' followed by a 'url_decode()' and a check for newlines
(mirroring 'check_url_component()' in the 'credential_from_url_gently()'
validation).

Signed-off-by: Victoria Dye <vdye@github.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 months agot7450: test submodule urls
Victoria Dye [Thu, 18 Jan 2024 01:55:17 +0000 (01:55 +0000)] 
t7450: test submodule urls

Add tests to 't7450-bad-git-dotfiles.sh' to check the validity of different
submodule URLs. To verify this directly (without setting up test
repositories & submodules), add a 'check-url' subcommand to 'test-tool
submodule' that calls 'check_submodule_url' in the same way that
'check-name' calls 'check_submodule_name'.

Add two tests to separately address cases where the URL check correctly
filters out invalid URLs and cases where the check misses invalid URLs. Mark
the latter ("url check misses invalid cases") with 'test_expect_failure' to
indicate that this is currently broken, which will be fixed in the next step.

Signed-off-by: Victoria Dye <vdye@github.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 months agomaintenance: use XDG config if it exists
Kristoffer Haugsbakk [Thu, 18 Jan 2024 16:12:52 +0000 (17:12 +0100)] 
maintenance: use XDG config if it exists

`git maintenance register` registers the repository in the user's global
config. `$XDG_CONFIG_HOME/git/config` is supposed to be used if
`~/.gitconfig` does not exist. However, this command creates a
`~/.gitconfig` file and writes to that one even though the XDG variant
exists.

This used to work correctly until 50a044f1e4 (gc: replace config
subprocesses with API calls, 2022-09-27), when the command started calling
the config API instead of git-config(1).

Also change `unregister` accordingly.

Signed-off-by: Kristoffer Haugsbakk <code@khaugsbakk.name>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 months agoconfig: factor out global config file retrieval
Kristoffer Haugsbakk [Thu, 18 Jan 2024 16:12:51 +0000 (17:12 +0100)] 
config: factor out global config file retrieval

Factor out code that retrieves the global config file so that we can use
it in `gc.c` as well.

Use the old name from the previous commit since this function acts
functionally the same as `git_system_config` but for “global”.

Signed-off-by: Kristoffer Haugsbakk <code@khaugsbakk.name>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 months agoconfig: rename global config function
Kristoffer Haugsbakk [Thu, 18 Jan 2024 16:12:50 +0000 (17:12 +0100)] 
config: rename global config function

Rename this function to a more descriptive name since we want to use the
existing name for a new function.

Signed-off-by: Kristoffer Haugsbakk <code@khaugsbakk.name>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 months agoconfig: format newlines
Kristoffer Haugsbakk [Thu, 18 Jan 2024 16:12:49 +0000 (17:12 +0100)] 
config: format newlines

Remove unneeded newlines according to `clang-format`.

Signed-off-by: Kristoffer Haugsbakk <code@khaugsbakk.name>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 months agoreftable/stack: fix race in up-to-date check
Patrick Steinhardt [Thu, 18 Jan 2024 13:41:56 +0000 (14:41 +0100)] 
reftable/stack: fix race in up-to-date check

In 6fdfaf15a0 (reftable/stack: use stat info to avoid re-reading stack
list, 2024-01-11) we have introduced a new mechanism to avoid re-reading
the table list in case stat(3P) figures out that the stack didn't change
since the last time we read it.

While this change significantly improved performance when writing many
refs, it can unfortunately lead to false negatives in very specific
scenarios. Given two processes A and B, there is a feasible sequence of
events that cause us to accidentally treat the table list as up-to-date
even though it changed:

  1. A reads the reftable stack and caches its stat info.

  2. B updates the stack, appending a new table to "tables.list". This
     will both use a new inode and result in a different file size, thus
     invalidating A's cache in theory.

  3. B decides to auto-compact the stack and merges two tables. The file
     size now matches what A has cached again. Furthermore, the
     filesystem may decide to recycle the inode number of the file we
     have replaced in (2) because it is not in use anymore.

  4. A reloads the reftable stack. Neither the inode number nor the
     file size changed. If the timestamps did not change either then we
     think the cached copy of our stack is up-to-date.

In fact, the commit introduced three related issues:

  - Non-POSIX compliant systems may not report proper `st_dev` and
    `st_ino` values in stat(3P), which made us rely solely on the
    file's potentially coarse-grained mtime and ctime.

  - `stat_validity_check()` and friends may end up not comparing
    `st_dev` and `st_ino` depending on the "core.checkstat" config,
    again reducing the signal to the mtime and ctime.

  - `st_ino` can be recycled, rendering the check moot even on
    POSIX-compliant systems.

Given that POSIX defines that "The st_ino and st_dev fields taken
together uniquely identify the file within the system", these issues led
to the most important signal to establish file identity to be ignored or
become useless in some cases.

Refactor the code to stop using `stat_validity_check()`. Instead, we
manually stat(3P) the file descriptors to make relevant information
available. On Windows and MSYS2 the result will have both `st_dev` and
`st_ino` set to 0, which allows us to address the first issue by not
using the stat-based cache in that case. It also allows us to make sure
that we always compare `st_dev` and `st_ino`, addressing the second
issue.

The third issue of inode recycling can be addressed by keeping the file
descriptor of "files.list" open during the lifetime of the reftable
stack. As the file will still exist on disk even though it has been
unlinked it is impossible for its inode to be recycled as long as the
file descriptor is still open.

This should address the race in a POSIX-compliant way. The only real
downside is that this mechanism cannot be used on non-POSIX-compliant
systems like Windows. But we at least have the second-level caching
mechanism in place that compares contents of "files.list" with the
currently loaded list of tables.

This new mechanism performs roughly the same as the previous one that
relied on `stat_validity_check()`:

  Benchmark 1: update-ref: create many refs (HEAD~)
    Time (mean ± σ):      4.754 s ±  0.026 s    [User: 2.204 s, System: 2.549 s]
    Range (min … max):    4.694 s …  4.802 s    20 runs

  Benchmark 2: update-ref: create many refs (HEAD)
    Time (mean ± σ):      4.721 s ±  0.020 s    [User: 2.194 s, System: 2.527 s]
    Range (min … max):    4.691 s …  4.753 s    20 runs

  Summary
    update-ref: create many refs (HEAD~) ran
      1.01 ± 0.01 times faster than update-ref: create many refs (HEAD)

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 months agoreftable/stack: unconditionally reload stack after commit
Patrick Steinhardt [Thu, 18 Jan 2024 13:41:51 +0000 (14:41 +0100)] 
reftable/stack: unconditionally reload stack after commit

After we have committed an addition to the reftable stack we call
`reftable_stack_reload()` to reload the stack and thus reflect the
changes that were just added. This function will only conditionally
reload the stack in case `stack_uptodate()` tells us that the stack
needs reloading. This check is wasteful though because we already know
that the stack needs reloading.

Call `reftable_stack_reload_maybe_reuse()` instead, which will
unconditionally reload the stack. This is merely a conceptual fix, the
code in question was not found to cause any problems in practice.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 months agoci: add macOS jobs to GitLab CI
Patrick Steinhardt [Thu, 18 Jan 2024 10:23:02 +0000 (11:23 +0100)] 
ci: add macOS jobs to GitLab CI

Add a job to GitLab CI which runs tests on macOS, which matches the
equivalent "osx-clang" job that we have for GitHub Workflows. One
significant difference though is that this new job runs on Apple M1
machines and thus uses the "arm64" architecture. As GCC does not yet
support this comparatively new architecture we cannot easily include an
equivalent for the "osx-gcc" job that exists in GitHub Workflows.

Note that one test marked as `test_must_fail` is surprisingly passing:

  t7815-grep-binary.sh                             (Wstat: 0 Tests: 22 Failed: 0)
    TODO passed:   12

This seems to boil down to an unexpected difference in how regcomp(3P)
works when matching NUL bytes. Cross-checking with the respective GitHub
job shows that this is not an issue unique to the GitLab CI job as it
passes in the same way there.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 months agoci: make p4 setup on macOS more robust
Patrick Steinhardt [Thu, 18 Jan 2024 10:22:58 +0000 (11:22 +0100)] 
ci: make p4 setup on macOS more robust

When setting up Perforce on macOS we put both `p4` and `p4d` into
"$HOME/bin". On GitHub CI this directory is indeed contained in the PATH
environment variable and thus there is no need for additional setup than
to put the binaries there. But GitLab CI does not do this, and thus our
Perforce-based tests would be skipped there even though we download the
binaries.

Refactor the setup code to become more robust by downloading binaries
into a separate directory which we then manually append to our PATH.
This matches what we do on Linux-based jobs.

Note that it may seem like we already did append "$HOME/bin" to PATH
because we're actually removing the lines that adapt PATH. But we only
ever adapted the PATH variable in "ci/install-dependencies.sh", and
didn't adapt it when running "ci/run-build-and-test.sh". Consequently,
the required binaries wouldn't be found during the test run unless the
CI platform already had the "$HOME/bin" in PATH right from the start.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 months agoci: handle TEST_OUTPUT_DIRECTORY when printing test failures
Patrick Steinhardt [Thu, 18 Jan 2024 10:22:53 +0000 (11:22 +0100)] 
ci: handle TEST_OUTPUT_DIRECTORY when printing test failures

The TEST_OUTPUT_DIRECTORY environment variable can be used to instruct
the test suite to write test data and test results into a different
location than into "t/". The "ci/print-test-failures.sh" script does not
know to handle this environment variable though, which means that it
will search for test results in the wrong location if it was set.

Update the script to handle TEST_OUTPUT_DIRECTORY so that we can start
to set it in our CI.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 months agoMakefile: detect new Homebrew location for ARM-based Macs
Patrick Steinhardt [Thu, 18 Jan 2024 10:22:49 +0000 (11:22 +0100)] 
Makefile: detect new Homebrew location for ARM-based Macs

With the introduction of the ARM-based Macs the default location for
Homebrew has changed from "/usr/local" to "/opt/homebrew". We only
handle the former location though, which means that unless the user has
manually configured required search paths we won't be able to locate it.

Improve upon this by adding relevant paths to our CFLAGS and LDFLAGS as
well as detecting the location of msgfmt(1).

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 months agot7527: decrease likelihood of racing with fsmonitor daemon
Patrick Steinhardt [Thu, 18 Jan 2024 10:22:45 +0000 (11:22 +0100)] 
t7527: decrease likelihood of racing with fsmonitor daemon

In t7527, we test that the builtin fsmonitor daemon works well in
various edge cases. One of these tests is frequently failing because
events reported by the fsmonitor--daemon are missing an expected event.
This failure is essentially a race condition: we do not wait for the
daemon to flush out all events before we ask it to quit. Consequently,
it can happen that we miss some expected events.

In other testcases we counteract this race by sending a simple query to
the daemon. Quoting a comment:

  We run a simple query after modifying the filesystem just to introduce
  a bit of a delay so that the trace logging from the daemon has time to
  get flushed to disk.

Now this workaround is not a "proper" fix as we do not wait for all
events to have been synchronized in a deterministic way. But this fix
seems to be sufficient for all the other tests to pass, so it must not
be all that bad.

Convert the failing test to do the same. While the test was previously
failing in about 50% of the test runs, I couldn't reproduce the failure
after the change anymore.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 months agobuiltin/show-ref: treat directory as non-existing in --exists
Toon Claes [Wed, 10 Jan 2024 14:15:59 +0000 (15:15 +0100)] 
builtin/show-ref: treat directory as non-existing in --exists

9080a7f178 (builtin/show-ref: add new mode to check for reference
existence, 2023-10-31) added the option --exists to git-show-ref(1).

When you use this option against a ref that doesn't exist, but it is
a parent directory of an existing ref, you get the following error:

    $ git show-ref --exists refs/heads
    error: failed to look up reference: Is a directory

when the ref-files backend is in use.  To be more clear to user,
hide the error about having found a directory.  What matters to the
user is that the named ref does not exist.  Instead, print the same
error as when the ref was not found:

    error: reference does not exist

Signed-off-by: Toon Claes <toon@iotcl.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 months agotest-submodule: remove command line handling for check-name
Victoria Dye [Thu, 18 Jan 2024 01:55:16 +0000 (01:55 +0000)] 
test-submodule: remove command line handling for check-name

The 'check-name' subcommand to 'test-tool submodule' is documented as being
able to take a command line argument '<name>'. However, this does not work -
and has never worked - because 'argc > 0' triggers the usage message in
'cmd__submodule_check_name()'. To simplify the helper and avoid future
confusion around proper use of the subcommand, remove any references to
command line arguments for 'check-name' in usage strings and handling in
'check_name()'.

Helped-by: Jeff King <peff@peff.net>
Signed-off-by: Victoria Dye <vdye@github.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 months agosubmodule-config.h: move check_submodule_url
Victoria Dye [Thu, 18 Jan 2024 01:55:15 +0000 (01:55 +0000)] 
submodule-config.h: move check_submodule_url

Move 'check_submodule_url' out of 'fsck.c' and into 'submodule-config.h' as
a public method, similar to 'check_submodule_name'. With the function now
accessible outside of 'fsck', it can be used in a later commit to extend
'test-tool submodule' to check the validity of submodule URLs as it does
with names in the 'check-name' subcommand.

Other than its location, no changes are made to 'check_submodule_url' in
this patch.

Signed-off-by: Victoria Dye <vdye@github.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 months agorebase: fix documentation about used shell in -x
Nikolay Borisov [Wed, 17 Jan 2024 08:53:47 +0000 (10:53 +0200)] 
rebase: fix documentation about used shell in -x

The shell used when using the -x option is erroneously documented to be
the one pointed to by the $SHELL environmental variable. This was true
when rebase was implemented as a shell script but this is no longer
true.

Signed-off-by: Nikolay Borisov <nik.borisov@suse.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 months agot7501: add tests for --amend --signoff
Ghanshyam Thakkar [Wed, 17 Jan 2024 16:13:55 +0000 (21:43 +0530)] 
t7501: add tests for --amend --signoff

Add tests for amending the commit to add Signed-off-by trailer. And
also to check if it does not add another trailer if one already exists.

Currently, there are tests for --signoff separately in t7501, however,
they are not tested with --amend.

Therefore, these tests belong with other similar tests of --amend in
t7501-commit-basic-functionality.

Helped-by: Phillip Wood <phillip.wood123@gmail.com>
Signed-off-by: Ghanshyam Thakkar <shyamthakkar001@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 months agot7501: add tests for --include and --only
Ghanshyam Thakkar [Wed, 17 Jan 2024 16:13:54 +0000 (21:43 +0530)] 
t7501: add tests for --include and --only

Add tests for --only (-o) and --include (-i). This include testing
with or without staged changes for both -i and -o. Also to test
for committing untracked files with -i, -o and without -i/-o.

Some tests already exist in t7501 for testing --only, however,
it is only tested in combination with --amend and --allow-empty
and on to-be-born branch. The addition of these tests check, when
the pathspec is provided without using -only, that only the files
matching the pathspec get committed. This behavior is same when
we provide --only and it is checked by the tests.
(as --only is the default mode of operation when pathspec is
provided.)

As for --include, there is no prior test for checking if --include
also commits staged changes, thus add test for that. Along with
the tests also document a potential bug, in which, when provided
with -i and a pathspec that does not match any tracked path,
commit does not fail if there are staged changes. And when there
are no staged changes commit fails. However, no error is returned
to stderr in either of the cases. This is described in the TODO
comment before the relevent testcase.

And also add a test for checking incompatibilty when using -o and
-i together.

Thus, these tests belong in t7501 with other similar existing tests,
as described in the case of --only.

Helped-by: Junio C Hamano <gitster@pobox.com>
Helped-by: Christian Couder <christian.couder@gmail.com>
Signed-off-by: Ghanshyam Thakkar <shyamthakkar001@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 months agoMerge branch 'ps/gitlab-ci-static-analysis' into ps/gitlab-ci-macos
Junio C Hamano [Tue, 16 Jan 2024 21:13:15 +0000 (13:13 -0800)] 
Merge branch 'ps/gitlab-ci-static-analysis' into ps/gitlab-ci-macos

* ps/gitlab-ci-static-analysis:
  ci: add job performing static analysis on GitLab CI

4 months agoThe eighth batch
Junio C Hamano [Tue, 16 Jan 2024 18:11:37 +0000 (10:11 -0800)] 
The eighth batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 months agoMerge branch 'ib/rebase-reschedule-doc'
Junio C Hamano [Tue, 16 Jan 2024 18:11:58 +0000 (10:11 -0800)] 
Merge branch 'ib/rebase-reschedule-doc'

Doc update.

* ib/rebase-reschedule-doc:
  rebase: clarify --reschedule-failed-exec default

4 months agoMerge branch 'jk/commit-graph-slab-clear-fix'
Junio C Hamano [Tue, 16 Jan 2024 18:11:58 +0000 (10:11 -0800)] 
Merge branch 'jk/commit-graph-slab-clear-fix'

Clearing in-core repository (happens during e.g., "git fetch
--recurse-submodules" with commit graph enabled) made in-core
commit object in an inconsistent state by discarding the necessary
data from commit-graph too early, which has been corrected.

* jk/commit-graph-slab-clear-fix:
  commit-graph: retain commit slab when closing NULL commit_graph

4 months agoMerge branch 'jk/index-pack-lsan-false-positive-fix'
Junio C Hamano [Tue, 16 Jan 2024 18:11:58 +0000 (10:11 -0800)] 
Merge branch 'jk/index-pack-lsan-false-positive-fix'

Fix false positive reported by leak sanitizer.

* jk/index-pack-lsan-false-positive-fix:
  index-pack: spawn threads atomically

4 months agoMerge branch 'cp/sideband-array-index-comment-fix'
Junio C Hamano [Tue, 16 Jan 2024 18:11:57 +0000 (10:11 -0800)] 
Merge branch 'cp/sideband-array-index-comment-fix'

In-code comment fix.

* cp/sideband-array-index-comment-fix:
  sideband.c: remove redundant 'NEEDSWORK' tag

4 months agoMerge branch 'ps/refstorage-extension'
Junio C Hamano [Tue, 16 Jan 2024 18:11:57 +0000 (10:11 -0800)] 
Merge branch 'ps/refstorage-extension'

Introduce a new extension "refstorage" so that we can mark a
repository that uses a non-default ref backend, like reftable.

* ps/refstorage-extension:
  t9500: write "extensions.refstorage" into config
  builtin/clone: introduce `--ref-format=` value flag
  builtin/init: introduce `--ref-format=` value flag
  builtin/rev-parse: introduce `--show-ref-format` flag
  t: introduce GIT_TEST_DEFAULT_REF_FORMAT envvar
  setup: introduce GIT_DEFAULT_REF_FORMAT envvar
  setup: introduce "extensions.refStorage" extension
  setup: set repository's formats on init
  setup: start tracking ref storage format
  refs: refactor logic to look up storage backends
  worktree: skip reading HEAD when repairing worktrees
  t: introduce DEFAULT_REPO_FORMAT prereq

4 months agoMerge branch 'ps/reftable-fixes-and-optims'
Junio C Hamano [Tue, 16 Jan 2024 18:11:56 +0000 (10:11 -0800)] 
Merge branch 'ps/reftable-fixes-and-optims'

More fixes and optimizations to the reftable backend.

* ps/reftable-fixes-and-optims:
  reftable/merged: transfer ownership of records when iterating
  reftable/merged: really reuse buffers to compute record keys
  reftable/record: store "val2" hashes as static arrays
  reftable/record: store "val1" hashes as static arrays
  reftable/record: constify some parts of the interface
  reftable/writer: fix index corruption when writing multiple indices
  reftable/stack: do not auto-compact twice in `reftable_stack_add()`
  reftable/stack: do not overwrite errors when compacting

4 months agocompletion: treat dangling symrefs as existing pseudorefs
Patrick Steinhardt [Mon, 15 Jan 2024 10:36:15 +0000 (11:36 +0100)] 
completion: treat dangling symrefs as existing pseudorefs

The `__git_pseudoref_exists ()` helper function back to git-rev-parse(1)
in case the reftable backend is in use. This is not in the same spirit
as the simple existence check that the "files" backend does though,
because there we only check for the pseudo-ref to exist with `test -f`.
With git-rev-parse(1) we not only check for existence, but also verify
that the pseudo-ref resolves to an object, which may not be the case
when the pseudo-ref points to an unborn branch.

Fix this issue by using `git show-ref --exists` instead. Note that we do
not have to silence stdout anymore as git-show-ref(1) will not print
anything.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 months agocompletion: silence pseudoref existence check
Patrick Steinhardt [Mon, 15 Jan 2024 10:36:11 +0000 (11:36 +0100)] 
completion: silence pseudoref existence check

In 44dbb3bf29 (completion: support pseudoref existence checks for
reftables, 2023-12-19), we have extended the Bash completion script to
support future ref backends better by using git-rev-parse(1) to check
for pseudo-ref existence. This conversion has introduced a bug, because
even though we pass `--quiet` to git-rev-parse(1) it would still output
the resolved object ID of the ref in question if it exists.

Fix this by redirecting its stdout to `/dev/null` and add a test that
catches this behaviour. Note that the test passes even without the fix
for the "files" backend because we parse pseudo refs via the filesystem
directly in that case. But the test will fail with the "reftable"
backend.

Helped-by: Jeff King <peff@peff.net>
Helped-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 months agocompletion: improve existence check for pseudo-refs
Patrick Steinhardt [Mon, 15 Jan 2024 10:36:06 +0000 (11:36 +0100)] 
completion: improve existence check for pseudo-refs

Improve the existence check along the following lines:

  - Stop stripping the "ref :" prefix and compare to the expected value
    directly. This allows us to drop a now-unused variable that was
    previously leaking into the user's shell.

  - Mark the "head" variable as local so that we don't leak its value
    into the user's shell.

  - Stop manually handling the `-C $__git_repo_path` option, which the
    `__git ()` wrapper aleady does for us.

  - In simlar spirit, stop redirecting stderr, which is also handled by
    the wrapper already.

Suggested-by: SZEDER Gábor <szeder.dev@gmail.com>
Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 months agot9902: verify that completion does not print anything
Patrick Steinhardt [Mon, 15 Jan 2024 10:36:02 +0000 (11:36 +0100)] 
t9902: verify that completion does not print anything

The Bash completion script must not print anything to either stdout or
stderr. Instead, it is only expected to populate certain variables.
Tighten our `test_completion ()` test helper to verify this requirement.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 months agocompletion: discover repo path in `__git_pseudoref_exists ()`
Patrick Steinhardt [Mon, 15 Jan 2024 10:35:57 +0000 (11:35 +0100)] 
completion: discover repo path in `__git_pseudoref_exists ()`

The helper function `__git_pseudoref_exists ()` expects that the repo
path has already been discovered by its callers, which makes for a
rather fragile calling convention. Refactor the function to discover the
repo path itself to make it more self-contained, which also removes the
need to discover the path in some of its callers.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 months agorev-list-options: fix off-by-one in '--filter=blob:limit=<n>' explainer
Nikolay Edigaryev [Sun, 14 Jan 2024 19:50:50 +0000 (19:50 +0000)] 
rev-list-options: fix off-by-one in '--filter=blob:limit=<n>' explainer

'--filter=blob:limit=<n>' was introduced in 25ec7bcac0 (list-objects:
filter objects in traverse_commit_list, 2017-11-21) and later expanded
to bitmaps in 84243da129 (pack-bitmap: implement BLOB_LIMIT filtering,
2020-02-14)

The logic that was introduced in these commits (and that still persists
to this day) omits blobs larger than _or equal_ to n bytes or units.

However, the documentation (Documentation/rev-list-options.txt) states:

>The form '--filter=blob:limit=<n>[kmg]' omits blobs larger than n
bytes or units. n may be zero.

Moreover, the t6113-rev-list-bitmap-filters.sh tests for exactly this
logic, so it seems it is the documentation that needs fixing, not the
code.

This changes the explanation to be similar to
Documentation/git-clone.txt, which is correct.

Signed-off-by: Nikolay Edigaryev <edigaryev@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 months agounit-tests: rewrite t/helper/test-ctype.c as a unit test
Achu Luma [Fri, 12 Jan 2024 10:27:43 +0000 (11:27 +0100)] 
unit-tests: rewrite t/helper/test-ctype.c as a unit test

In the recent codebase update (8bf6fbd00d (Merge branch
'js/doc-unit-tests', 2023-12-09)), a new unit testing framework was
merged, providing a standardized approach for testing C code. Prior to
this update, some unit tests relied on the test helper mechanism,
lacking a dedicated unit testing framework. It's more natural to perform
these unit tests using the new unit test framework.

This commit migrates the unit tests for C character classification
functions (isdigit(), isspace(), etc) from the legacy approach
using the test-tool command `test-tool ctype` in t/helper/test-ctype.c
to the new unit testing framework (t/unit-tests/test-lib.h).

The migration involves refactoring the tests to utilize the testing
macros provided by the framework (TEST() and check_*()).

Mentored-by: Christian Couder <chriscool@tuxfamily.org>
Helped-by: René Scharfe <l.s.r@web.de>
Helped-by: Phillip Wood <phillip.wood123@gmail.com>
Helped-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Achu Luma <ach.lumap@gmail.com>
Acked-by: Phillip Wood <phillip.wood123@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 months agocommit-graph: fix memory leak when not writing graph
Patrick Steinhardt [Mon, 18 Dec 2023 10:02:28 +0000 (11:02 +0100)] 
commit-graph: fix memory leak when not writing graph

When `write_commit_graph()` bails out writing a split commit-graph early
then it may happen that we have already gathered the set of existing
commit-graph file names without yet determining the new merged set of
files. This can result in a memory leak though because we only clear the
preimage of files when we have collected the postimage.

Fix this issue by dropping the condition altogether so that we always
try to free both preimage and postimage filenames. As the context
structure is zero-initialized this simplification is safe to do.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Acked-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 months agoThe seventh batch
Junio C Hamano [Fri, 12 Jan 2024 23:58:36 +0000 (15:58 -0800)] 
The seventh batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 months agoMerge branch 'cp/git-flush-is-an-env-bool'
Junio C Hamano [Sat, 13 Jan 2024 00:09:57 +0000 (16:09 -0800)] 
Merge branch 'cp/git-flush-is-an-env-bool'

Unlike other environment variables that took the usual
true/false/yes/no as well as 0/1, GIT_FLUSH only understood 0/1,
which has been corrected.

* cp/git-flush-is-an-env-bool:
  write-or-die: make GIT_FLUSH a Boolean environment variable

4 months agoMerge branch 'ms/rebase-insnformat-doc-fix'
Junio C Hamano [Sat, 13 Jan 2024 00:09:56 +0000 (16:09 -0800)] 
Merge branch 'ms/rebase-insnformat-doc-fix'

Docfix.

* ms/rebase-insnformat-doc-fix:
  Documentation: fix statement about rebase.instructionFormat

4 months agoMerge branch 'jx/sideband-chomp-newline-fix'
Junio C Hamano [Sat, 13 Jan 2024 00:09:56 +0000 (16:09 -0800)] 
Merge branch 'jx/sideband-chomp-newline-fix'

Sideband demultiplexer fixes.

* jx/sideband-chomp-newline-fix:
  pkt-line: do not chomp newlines for sideband messages
  pkt-line: memorize sideband fragment in reader
  test-pkt-line: add option parser for unpack-sideband

4 months agoMerge branch 'tb/multi-pack-verbatim-reuse'
Junio C Hamano [Sat, 13 Jan 2024 00:09:56 +0000 (16:09 -0800)] 
Merge branch 'tb/multi-pack-verbatim-reuse'

Streaming spans of packfile data used to be done only from a
single, primary, pack in a repository with multiple packfiles.  It
has been extended to allow reuse from other packfiles, too.

* tb/multi-pack-verbatim-reuse: (26 commits)
  t/perf: add performance tests for multi-pack reuse
  pack-bitmap: enable reuse from all bitmapped packs
  pack-objects: allow setting `pack.allowPackReuse` to "single"
  t/test-lib-functions.sh: implement `test_trace2_data` helper
  pack-objects: add tracing for various packfile metrics
  pack-bitmap: prepare to mark objects from multiple packs for reuse
  pack-revindex: implement `midx_pair_to_pack_pos()`
  pack-revindex: factor out `midx_key_to_pack_pos()` helper
  midx: implement `midx_preferred_pack()`
  git-compat-util.h: implement checked size_t to uint32_t conversion
  pack-objects: include number of packs reused in output
  pack-objects: prepare `write_reused_pack_verbatim()` for multi-pack reuse
  pack-objects: prepare `write_reused_pack()` for multi-pack reuse
  pack-objects: pass `bitmapped_pack`'s to pack-reuse functions
  pack-objects: keep track of `pack_start` for each reuse pack
  pack-objects: parameterize pack-reuse routines over a single pack
  pack-bitmap: return multiple packs via `reuse_partial_packfile_from_bitmap()`
  pack-bitmap: simplify `reuse_partial_packfile_from_bitmap()` signature
  ewah: implement `bitmap_is_empty()`
  pack-bitmap: pass `bitmapped_pack` struct to pack-reuse functions
  ...

4 months agoMerge branch 'jk/t1006-cat-file-objectsize-disk'
Junio C Hamano [Sat, 13 Jan 2024 00:09:56 +0000 (16:09 -0800)] 
Merge branch 'jk/t1006-cat-file-objectsize-disk'

Test update.

* jk/t1006-cat-file-objectsize-disk:
  t1006: prefer shell loop to awk for packed object sizes
  t1006: add tests for %(objectsize:disk)

4 months agoMerge branch 'jw/builtin-objectmode-attr'
Junio C Hamano [Sat, 13 Jan 2024 00:09:55 +0000 (16:09 -0800)] 
Merge branch 'jw/builtin-objectmode-attr'

The builtin_objectmode attribute is populated for each path
without adding anything in .gitattributes files, which would be
useful in magic pathspec, e.g., ":(attr:builtin_objectmode=100755)"
to limit to executables.

* jw/builtin-objectmode-attr:
  attr: add builtin objectmode values support

4 months agoMerge branch 'js/contributor-docs-updates'
Junio C Hamano [Sat, 13 Jan 2024 00:09:55 +0000 (16:09 -0800)] 
Merge branch 'js/contributor-docs-updates'

Doc update.

* js/contributor-docs-updates:
  SubmittingPatches: hyphenate non-ASCII
  SubmittingPatches: clarify GitHub artifact format
  SubmittingPatches: clarify GitHub visual
  SubmittingPatches: provide tag naming advice
  SubmittingPatches: update extra tags list
  SubmittingPatches: discourage new trailers
  SubmittingPatches: drop ref to "What's in git.git"
  CodingGuidelines: write punctuation marks
  CodingGuidelines: move period inside parentheses

4 months agostrvec: use correct member name in comments
Linus Arver [Fri, 12 Jan 2024 07:06:35 +0000 (07:06 +0000)] 
strvec: use correct member name in comments

In d70a9eb611 (strvec: rename struct fields, 2020-07-28), we renamed the
"argv" member to "v". In the same patch we also did the following rename
in strvec.c:

    -void strvec_pushv(struct strvec *array, const char **argv)
    +void strvec_pushv(struct strvec *array, const char **items)

and it appears that this s/argv/items operation was erroneously applied
to strvec.h.

Rename "items" to "v".

Signed-off-by: Linus Arver <linusa@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 months agomessages: mark some strings with "up-to-date" not to touch
Junio C Hamano [Fri, 12 Jan 2024 17:19:10 +0000 (12:19 -0500)] 
messages: mark some strings with "up-to-date" not to touch

The treewide clean-up of "up-to-date" strings done in 7560f547
(treewide: correct several "up-to-date" to "up to date", 2017-08-23)
deliberately left some out, but unlike the lines that were changed
by the commit, the lines that were deliberately left untouched by
the commit is impossible to ask "git blame" to link back to the
commit that did not touch them.

Let's do the second best thing, leave a short comment near them
explaining why those strings should not be modified or localized.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
[es: make in-code comment more developer-friendly]
Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 months agot5541: remove lockfile creation
Justin Tobler [Thu, 11 Jan 2024 20:24:30 +0000 (20:24 +0000)] 
t5541: remove lockfile creation

To create error conditions, some tests set up reference locks by
directly creating its lockfile. While this works for the files reference
backend, this approach is incompatible with the reftable backend.
Refactor the test to create a d/f conflict via git-update-ref(1) instead
so that the test is reference backend agnostic.

Signed-off-by: Justin Tobler <jltobler@gmail.com>
Acked-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 months agot1401: remove lockfile creation
Justin Tobler [Thu, 11 Jan 2024 20:24:29 +0000 (20:24 +0000)] 
t1401: remove lockfile creation

To create error conditions, some tests set up reference locks by
directly creating its lockfile. While this works for the files reference
backend, this approach is incompatible with the reftable backend.
Refactor the test to create a d/f conflict via git-symbolic-ref(1)
instead so that the test is reference backend agnostic.

Signed-off-by: Justin Tobler <jltobler@gmail.com>
Acked-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 months agobranch: make the advice to force-deleting a conditional one
Rubén Justo [Thu, 11 Jan 2024 12:40:34 +0000 (13:40 +0100)] 
branch: make the advice to force-deleting a conditional one

The error message we show when the user tries to delete a not fully
merged branch describes the error and gives a hint to the user:

error: the branch 'foo' is not fully merged.
If you are sure you want to delete it, run 'git branch -D foo'.

Let's move the hint part so that it is displayed using the advice
machinery:

error: the branch 'foo' is not fully merged
hint: If you are sure you want to delete it, run 'git branch -D foo'
hint: Disable this message with "git config advice.forceDeleteBranch false"

Signed-off-by: Rubén Justo <rjusto@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 months agoadvice: fix an unexpected leading space
Rubén Justo [Thu, 11 Jan 2024 12:40:17 +0000 (13:40 +0100)] 
advice: fix an unexpected leading space

This space was introduced, presumably unintentionally, in b3b18d1621
(advice: revamp advise API, 2020-03-02)

I notice this space due to confuse diff outputs while doing some
changes to enum advice_type.

As a reference, a recent change we have to that enum is:

    $ git show 35f0383

    ...
    diff --git a/advice.h b/advice.h
    index 0f584163f5..2affbe1426 100644
    --- a/advice.h
    +++ b/advice.h
    @@ -49,6 +49,7 @@ struct string_list;
    ADVICE_UPDATE_SPARSE_PATH,
    ADVICE_WAITING_FOR_EDITOR,
    ADVICE_SKIPPED_CHERRY_PICKS,
    +       ADVICE_WORKTREE_ADD_ORPHAN,
     };

Note the hunk header, instead of a much more expected:

    @@ -49,6 +49,7 @@ enum advice_type

Signed-off-by: Rubén Justo <rjusto@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 months agoadvice: sort the advice related lists
Rubén Justo [Thu, 11 Jan 2024 12:40:01 +0000 (13:40 +0100)] 
advice: sort the advice related lists

Let's keep the advice related lists sorted to make them more
digestible.

A multi-line comment has also been changed; that produces the unexpected
'insertion != deletion' in this supposedly 'only sort lines' commit.

Signed-off-by: Rubén Justo <rjusto@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 months agogit-p4: stop reaching into the refdb
Patrick Steinhardt [Thu, 11 Jan 2024 13:47:27 +0000 (14:47 +0100)] 
git-p4: stop reaching into the refdb

The git-p4 tool creates a bunch of temporary branches that share a
common prefix "refs/git-p4-tmp/". These branches get cleaned up via
git-update-ref(1) after the import has finished. Once done, we try to
manually remove the now supposedly-empty ".git/refs/git-p4-tmp/"
directory.

This last step can fail in case there still are any temporary branches
around that we failed to delete because `os.rmdir()` refuses to delete a
non-empty directory. It can thus be seen as kind of a sanity check to
verify that we really did delete all temporary branches. Another failure
mode though is when the directory didn't exist in the first place, which
can be the case when using an alternate ref backend like the upcoming
"reftable" backend.

Convert the code to instead use git-for-each-ref(1) to verify that there
are no more temporary branches around. This works alright with alternate
ref backends while retaining the sanity check that we really did prune
all temporary branches.

This is a modification in behaviour for the "files" backend because the
empty directory does not get deleted anymore. But arguably we should not
care about such implementation details of the ref backend anyway, and
this should not cause any user-visible change in behaviour.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 months agoreftable/blocksource: use mmap to read tables
Patrick Steinhardt [Thu, 11 Jan 2024 10:06:56 +0000 (11:06 +0100)] 
reftable/blocksource: use mmap to read tables

The blocksource interface provides an interface to read blocks from a
reftable table. This interface is implemented using read(3P) calls on
the underlying file descriptor. While this works alright, this pattern
is very inefficient when repeatedly querying the reftable stack for one
or more refs. This inefficiency can mostly be attributed to the fact
that we often need to re-read the same blocks over and over again, and
every single time we need to call read(3P) again.

A natural fit in this context is to use mmap(3P) instead of read(3P),
which has a bunch of benefits:

  - We do not need to come up with a caching strategy for some of the
    blocks as this will be handled by the kernel already.

  - We can avoid the overhead of having to call into the read(3P)
    syscall repeatedly.

  - We do not need to allocate returned blocks repeatedly, but can
    instead hand out pointers into the mmapped region directly.

Using mmap comes with a significant drawback on Windows though, because
mmapped files cannot be deleted and neither is it possible to rename
files onto an mmapped file. But for one, the reftable library gracefully
handles the case where auto-compaction cannot delete a still-open stack
already and ignores any such errors. Also, `reftable_stack_clean()` will
prune stale tables which are not referenced by "tables.list" anymore so
that those files can eventually be pruned. And second, we never rewrite
already-written stacks, so it does not matter that we cannot rename a
file over an mmaped file, either.

Another unfortunate property of mmap is that it is not supported by all
systems. But given that the size of reftables should typically be rather
limited (megabytes at most in the vast majority of repositories), we can
use the fallback implementation provided by `git_mmap()` which reads the
whole file into memory instead. This is the same strategy that the
"packed" backend uses.

While this change doesn't significantly improve performance in the case
where we're seeking through stacks once (like e.g. git-for-each-ref(1)
would). But it does speed up usecases where there is lots of random
access to refs, e.g. when writing. The following benchmark demonstrates
these savings with git-update-ref(1) creating N refs in an otherwise
empty repository:

  Benchmark 1: update-ref: create many refs (refcount = 1, revision = HEAD~)
    Time (mean ± σ):       5.1 ms ±   0.2 ms    [User: 2.5 ms, System: 2.5 ms]
    Range (min … max):     4.8 ms …   7.1 ms    111 runs

  Benchmark 2: update-ref: create many refs (refcount = 100, revision = HEAD~)
    Time (mean ± σ):      14.8 ms ±   0.5 ms    [User: 7.1 ms, System: 7.5 ms]
    Range (min … max):    14.1 ms …  18.7 ms    84 runs

  Benchmark 3: update-ref: create many refs (refcount = 10000, revision = HEAD~)
    Time (mean ± σ):     926.4 ms ±   5.6 ms    [User: 448.5 ms, System: 477.7 ms]
    Range (min … max):   920.0 ms … 936.1 ms    10 runs

  Benchmark 4: update-ref: create many refs (refcount = 1, revision = HEAD)
    Time (mean ± σ):       5.0 ms ±   0.2 ms    [User: 2.4 ms, System: 2.5 ms]
    Range (min … max):     4.7 ms …   5.4 ms    111 runs

  Benchmark 5: update-ref: create many refs (refcount = 100, revision = HEAD)
    Time (mean ± σ):      10.5 ms ±   0.2 ms    [User: 5.0 ms, System: 5.3 ms]
    Range (min … max):    10.0 ms …  10.9 ms    93 runs

  Benchmark 6: update-ref: create many refs (refcount = 10000, revision = HEAD)
    Time (mean ± σ):     529.6 ms ±   9.1 ms    [User: 268.0 ms, System: 261.4 ms]
    Range (min … max):   522.4 ms … 547.1 ms    10 runs

  Summary
    update-ref: create many refs (refcount = 1, revision = HEAD) ran
      1.01 ± 0.06 times faster than update-ref: create many refs (refcount = 1, revision = HEAD~)
      2.08 ± 0.07 times faster than update-ref: create many refs (refcount = 100, revision = HEAD)
      2.95 ± 0.14 times faster than update-ref: create many refs (refcount = 100, revision = HEAD~)
    105.33 ± 3.76 times faster than update-ref: create many refs (refcount = 10000, revision = HEAD)
    184.24 ± 5.89 times faster than update-ref: create many refs (refcount = 10000, revision = HEAD~)

Theoretically, we could also replicate the strategy of the "packed"
backend where small tables are read into memory instead of using mmap.
Benchmarks did not confirm that this has a performance benefit though.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 months agoreftable/blocksource: refactor code to match our coding style
Patrick Steinhardt [Thu, 11 Jan 2024 10:06:52 +0000 (11:06 +0100)] 
reftable/blocksource: refactor code to match our coding style

Refactor `reftable_block_source_from_file()` to match our coding style
better.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 months agoreftable/stack: use stat info to avoid re-reading stack list
Patrick Steinhardt [Thu, 11 Jan 2024 10:06:48 +0000 (11:06 +0100)] 
reftable/stack: use stat info to avoid re-reading stack list

Whenever we call into the refs interfaces we potentially have to reload
refs in case they have been concurrently modified, either in-process or
externally. While this happens somewhat automatically for loose refs
because we simply try to re-read the files, the "packed" backend will
reload its snapshot of the packed-refs file in case its stat info has
changed since last reading it.

In the reftable backend we have a similar mechanism that is provided by
`reftable_stack_reload()`. This function will read the list of stacks
from "tables.list" and, if they have changed from the currently stored
list, reload the stacks. This is heavily inefficient though, as we have
to check whether the stack is up-to-date on basically every read and
thus keep on re-reading the file all the time even if it didn't change
at all.

We can do better and use the same stat(3P)-based mechanism that the
"packed" backend uses. Instead of reading the file, we will only open
the file descriptor, fstat(3P) it, and then compare the info against the
cached value from the last time we have updated the stack. This should
always work alright because "tables.list" is updated atomically via a
rename, so even if the ctime or mtime wasn't granular enough to identify
a change, at least the inode number or file size should have changed.

This change significantly speeds up operations where many refs are read,
like when using git-update-ref(1). The following benchmark creates N
refs in an otherwise-empty repository via `git update-ref --stdin`:

  Benchmark 1: update-ref: create many refs (refcount = 1, revision = HEAD~)
    Time (mean ± σ):       5.1 ms ±   0.2 ms    [User: 2.4 ms, System: 2.6 ms]
    Range (min … max):     4.8 ms …   7.2 ms    109 runs

  Benchmark 2: update-ref: create many refs (refcount = 100, revision = HEAD~)
    Time (mean ± σ):      19.1 ms ±   0.9 ms    [User: 8.9 ms, System: 9.9 ms]
    Range (min … max):    18.4 ms …  26.7 ms    72 runs

  Benchmark 3: update-ref: create many refs (refcount = 10000, revision = HEAD~)
    Time (mean ± σ):      1.336 s ±  0.018 s    [User: 0.590 s, System: 0.724 s]
    Range (min … max):    1.314 s …  1.373 s    10 runs

  Benchmark 4: update-ref: create many refs (refcount = 1, revision = HEAD)
    Time (mean ± σ):       5.1 ms ±   0.2 ms    [User: 2.4 ms, System: 2.6 ms]
    Range (min … max):     4.8 ms …   7.2 ms    109 runs

  Benchmark 5: update-ref: create many refs (refcount = 100, revision = HEAD)
    Time (mean ± σ):      14.8 ms ±   0.2 ms    [User: 7.1 ms, System: 7.5 ms]
    Range (min … max):    14.2 ms …  15.2 ms    82 runs

  Benchmark 6: update-ref: create many refs (refcount = 10000, revision = HEAD)
    Time (mean ± σ):     927.6 ms ±   5.3 ms    [User: 437.8 ms, System: 489.5 ms]
    Range (min … max):   919.4 ms … 936.4 ms    10 runs

  Summary
    update-ref: create many refs (refcount = 1, revision = HEAD) ran
      1.00 ± 0.07 times faster than update-ref: create many refs (refcount = 1, revision = HEAD~)
      2.89 ± 0.14 times faster than update-ref: create many refs (refcount = 100, revision = HEAD)
      3.74 ± 0.25 times faster than update-ref: create many refs (refcount = 100, revision = HEAD~)
    181.26 ± 8.30 times faster than update-ref: create many refs (refcount = 10000, revision = HEAD)
    261.01 ± 12.35 times faster than update-ref: create many refs (refcount = 10000, revision = HEAD~)

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 months agoreftable/stack: refactor reloading to use file descriptor
Patrick Steinhardt [Thu, 11 Jan 2024 10:06:43 +0000 (11:06 +0100)] 
reftable/stack: refactor reloading to use file descriptor

We're about to introduce a stat(3P)-based caching mechanism to reload
the list of stacks only when it has changed. In order to avoid race
conditions this requires us to have a file descriptor available that we
can use to call fstat(3P) on.

Prepare for this by converting the code to use `fd_read_lines()` so that
we have the file descriptor readily available.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 months agoreftable/stack: refactor stack reloading to have common exit path
Patrick Steinhardt [Thu, 11 Jan 2024 10:06:39 +0000 (11:06 +0100)] 
reftable/stack: refactor stack reloading to have common exit path

The `reftable_stack_reload_maybe_reuse()` function is responsible for
reloading the reftable list from disk. The function is quite hard to
follow though because it has a bunch of different exit paths, many of
which have to free the same set of resources.

Refactor the function to have a common exit path. While at it, touch up
the style of this function a bit to match our usual coding style better.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 months agogitweb: die when a configuration file cannot be read
Marcelo Roberto Jimenez [Wed, 10 Jan 2024 22:57:09 +0000 (19:57 -0300)] 
gitweb: die when a configuration file cannot be read

Fix a possibility of a permission to access error go unnoticed.

Perl uses two different variables to manage errors from a "do
$filename" construct. One is $@, which is set in this case when do
is unable to compile the file. The other is $!, which is set in case
do cannot read the file.  The current code only checks "$@", which
means a configuration file passed to GitWeb that is not readable by
the server process does not cause it to "die".

Make sure we also check and act on "$!" to fix this.

Signed-off-by: Marcelo Roberto Jimenez <marcelo.jimenez@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 months agodoc: refer to pathspec instead of path
Britton Leo Kerin [Wed, 3 Jan 2024 04:02:07 +0000 (19:02 -0900)] 
doc: refer to pathspec instead of path

Signed-off-by: Britton Leo Kerin <britton.kerin@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 months agodoc: use singular form of repeatable path arg
Britton Leo Kerin [Wed, 3 Jan 2024 04:02:06 +0000 (19:02 -0900)] 
doc: use singular form of repeatable path arg

This is more correct because the <path>... doc syntax already indicates
that the arg is "array-type".  It's how other tools do it.  Finally, the
later document text mentions 'path' arguments, while it doesn't mention
'paths'.

Signed-off-by: Britton Leo Kerin <britton.kergin@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 months agot4129: prevent loss of exit code due to the use of pipes
Chandra Pratap [Wed, 10 Jan 2024 12:54:17 +0000 (12:54 +0000)] 
t4129: prevent loss of exit code due to the use of pipes

Piping the output of git commands like git-ls-files to another
command (grep in this case) hides the exit code returned by
these commands. Prevent this by storing the output of git-ls-files
to a temporary file and then "grep-ping" from that file. Replace
grep with test_grep as the latter is more verbose when it fails.

Signed-off-by: Chandra Pratap <chandrapratap3519@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 months agomingw: give more details about unsafe directory's ownership
Sören Krecker [Mon, 8 Jan 2024 17:38:37 +0000 (18:38 +0100)] 
mingw: give more details about unsafe directory's ownership

Add domain/username in error message, if owner sid of repository and
user sid are not equal on windows systems.

Old error message:
'''
fatal: detected dubious ownership in repository at 'C:/Users/test/source/repos/git'
'C:/Users/test/source/repos/git' is owned by:
'S-1-5-21-571067702-4104414259-3379520149-500'
but the current user is:
'S-1-5-21-571067702-4104414259-3379520149-1001'
To add an exception for this directory, call:

git config --global --add safe.directory C:/Users/test/source/repos/git
'''

New error message:
'''
fatal: detected dubious ownership in repository at 'C:/Users/test/source/repos/git'
'C:/Users/test/source/repos/git' is owned by:
        DESKTOP-L78JVA6/Administrator (S-1-5-21-571067702-4104414259-3379520149-500)
but the current user is:
        DESKTOP-L78JVA6/test (S-1-5-21-571067702-4104414259-3379520149-1001)
To add an exception for this directory, call:

        git config --global --add safe.directory C:/Users/test/source/repos/git
'''

Signed-off-by: Sören Krecker <soekkle@freenet.de>
Acked-by: Johannes Sixt <j6t@kdbg.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 months agoThe sixth batch
Junio C Hamano [Mon, 8 Jan 2024 22:05:24 +0000 (14:05 -0800)] 
The sixth batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 months agoMerge branch 'rs/mem-pool-improvements'
Junio C Hamano [Mon, 8 Jan 2024 22:05:16 +0000 (14:05 -0800)] 
Merge branch 'rs/mem-pool-improvements'

MemPool allocator fixes.

* rs/mem-pool-improvements:
  mem-pool: simplify alignment calculation
  mem-pool: fix big allocations

5 months agoMerge branch 'rs/fast-import-simplify-mempool-allocation'
Junio C Hamano [Mon, 8 Jan 2024 22:05:16 +0000 (14:05 -0800)] 
Merge branch 'rs/fast-import-simplify-mempool-allocation'

Code simplification.

* rs/fast-import-simplify-mempool-allocation:
  fast-import: use mem_pool_calloc()

5 months agoMerge branch 'en/sparse-checkout-eoo'
Junio C Hamano [Mon, 8 Jan 2024 22:05:16 +0000 (14:05 -0800)] 
Merge branch 'en/sparse-checkout-eoo'

"git sparse-checkout (add|set) --[no-]cone --end-of-options" did
not handle "--end-of-options" correctly after a recent update.

* en/sparse-checkout-eoo:
  sparse-checkout: be consistent with end of options markers

5 months agoMerge branch 'jc/sparse-checkout-set-default-fix'
Junio C Hamano [Mon, 8 Jan 2024 22:05:16 +0000 (14:05 -0800)] 
Merge branch 'jc/sparse-checkout-set-default-fix'

"git sparse-checkout set" added default patterns even when the
patterns are being fed from the standard input, which has been
corrected.

* jc/sparse-checkout-set-default-fix:
  sparse-checkout: use default patterns for 'set' only !stdin

5 months agoMerge branch 'en/header-cleanup'
Junio C Hamano [Mon, 8 Jan 2024 22:05:15 +0000 (14:05 -0800)] 
Merge branch 'en/header-cleanup'

Remove unused header "#include".

* en/header-cleanup:
  treewide: remove unnecessary includes in source files
  treewide: add direct includes currently only pulled in transitively
  trace2/tr2_tls.h: remove unnecessary include
  submodule-config.h: remove unnecessary include
  pkt-line.h: remove unnecessary include
  line-log.h: remove unnecessary include
  http.h: remove unnecessary include
  fsmonitor--daemon.h: remove unnecessary includes
  blame.h: remove unnecessary includes
  archive.h: remove unnecessary include
  treewide: remove unnecessary includes in source files
  treewide: remove unnecessary includes from header files

5 months agoMerge branch 'ml/doc-merge-updates'
Junio C Hamano [Mon, 8 Jan 2024 22:05:15 +0000 (14:05 -0800)] 
Merge branch 'ml/doc-merge-updates'

Doc update.

* ml/doc-merge-updates:
  Documentation/git-merge.txt: use backticks for command wrapping
  Documentation/git-merge.txt: fix reference to synopsis