]> git.ipfire.org Git - thirdparty/git.git/log
thirdparty/git.git
6 months agofetch: set remote/HEAD if it does not exist
Bence Ferdinandy [Fri, 22 Nov 2024 12:28:50 +0000 (13:28 +0100)] 
fetch: set remote/HEAD if it does not exist

When cloning a repository remote/HEAD is created, but when the user
creates a repository with git init, and later adds a remote, remote/HEAD
is only created if the user explicitly runs a variant of "remote
set-head". Attempt to set remote/HEAD during fetch, if the user does not
have it already set. Silently ignore any errors.

Signed-off-by: Bence Ferdinandy <bence@ferdinandy.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 months agorefs: add create_only option to refs_update_symref_extended
Bence Ferdinandy [Fri, 22 Nov 2024 12:28:49 +0000 (13:28 +0100)] 
refs: add create_only option to refs_update_symref_extended

Allow the caller to specify that it only wants to update the symref if
it does not already exist. Silently ignore the error from the
transaction API if the symref already exists.

Signed-off-by: Bence Ferdinandy <bence@ferdinandy.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 months agorefs: add TRANSACTION_CREATE_EXISTS error
Bence Ferdinandy [Fri, 22 Nov 2024 12:28:48 +0000 (13:28 +0100)] 
refs: add TRANSACTION_CREATE_EXISTS error

Currently there is only one special error for transaction, for when
there is a naming conflict, all other errors are dumped under a generic
error. Add a new special error case for when the caller requests the
reference to be updated only when it does not yet exist and the
reference actually does exist.

Signed-off-by: Bence Ferdinandy <bence@ferdinandy.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 months agoremote set-head: better output for --auto
Bence Ferdinandy [Fri, 22 Nov 2024 12:28:47 +0000 (13:28 +0100)] 
remote set-head: better output for --auto

Currently, set-head --auto will print a message saying "remote/HEAD set
to branch", which implies something was changed.

Change the output of --auto, so the output actually reflects what was
done: a) set a previously unset HEAD, b) change HEAD because remote
changed or c) no updates. As edge cases, if HEAD is changed from
a previous symbolic reference that was not a remote branch, explicitly
call attention to this fact, and also notify the user if the previous
reference was not a symbolic reference.

Signed-off-by: Bence Ferdinandy <bence@ferdinandy.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 months agoremote set-head: refactor for readability
Bence Ferdinandy [Fri, 22 Nov 2024 12:28:46 +0000 (13:28 +0100)] 
remote set-head: refactor for readability

Make two different readability refactors:

Rename strbufs "buf" and "buf2" to something more explanatory.

Instead of calling get_main_ref_store(the_repository) multiple times,
call it once and store the result in a new refs variable. Although this
change probably offers some performance benefits, the main purpose is to
shorten the line lengths of function calls using this variable.

Signed-off-by: Bence Ferdinandy <bence@ferdinandy.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 months agorefs: atomically record overwritten ref in update_symref
Bence Ferdinandy [Fri, 22 Nov 2024 12:28:45 +0000 (13:28 +0100)] 
refs: atomically record overwritten ref in update_symref

When updating a symref with update_symref it's currently not possible to
know for sure what was the previous value that was overwritten. Extend
refs_update_symref under a new function name, to record the value after
the ref has been locked if the caller of refs_update_symref_extended
requests it via a new variable in the function call. Make the return
value of the function notify the caller, if the previous value was
actually not a symbolic reference. Keep the original refs_update_symref
function with the same signature, but now as a wrapper around
refs_update_symref_extended.

Signed-off-by: Bence Ferdinandy <bence@ferdinandy.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 months agorefs: standardize output of refs_read_symbolic_ref
Bence Ferdinandy [Fri, 22 Nov 2024 12:28:44 +0000 (13:28 +0100)] 
refs: standardize output of refs_read_symbolic_ref

When the symbolic reference we want to read with refs_read_symbolic_ref
is actually not a symbolic reference, the files and the reftable
backends return different values (1 and -1 respectively). Standardize
the returned values so that 0 is success, -1 is a generic error and -2
is that the reference was actually non-symbolic.

Signed-off-by: Bence Ferdinandy <bence@ferdinandy.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 months agot/t5505-remote: test failure of set-head
Bence Ferdinandy [Fri, 22 Nov 2024 12:28:43 +0000 (13:28 +0100)] 
t/t5505-remote: test failure of set-head

The test coverage was missing a test for the failure branch of remote
set-head auto's output. Add the missing text and while we are at it,
correct a small grammatical mistake in the error's output ("setup" is
the noun, "set up" is the verb).

Signed-off-by: Bence Ferdinandy <bence@ferdinandy.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 months agot/t5505-remote: set default branch to main
Bence Ferdinandy [Fri, 22 Nov 2024 12:28:42 +0000 (13:28 +0100)] 
t/t5505-remote: set default branch to main

Consider the bare repository called "mirror" in the test. Running `git
remote add --mirror -f origin ../one` will not change HEAD, consequently
if init.defaultBranch is not the same as what HEAD in the remote
("one"), HEAD in "mirror" will be pointing to a non-existent reference.
Hence if "mirror" is used as a remote by yet another repository,
ls-remote will not show HEAD. On the other hand, if init.defaultBranch
happens to match HEAD in "one", then ls-remote will show HEAD.

Since the "ci/run-build-and-tests.sh" script globally exports
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main for some (but not all) jobs,
there may be a drift in some tests between how the test repositories are
set up in the CI and during local testing, if the test itself uses
"master" as default instead of "main". In particular, this happens in
t5505-remote.sh. This issue does not manifest currently, as the test
does not do any remote HEAD manipulation where this would come up, but
should such things be added, a locally passing test would break the CI
and vice-versa.

Set GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main in t5505-remote to be
consistent with the CI.

Signed-off-by: Bence Ferdinandy <bence@ferdinandy.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 months agoanother batch after 2.47-rc0
Junio C Hamano [Mon, 30 Sep 2024 23:15:33 +0000 (16:15 -0700)] 
another batch after 2.47-rc0

Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 months agoMerge branch 'ps/includeif-onbranch-cornercase-fix'
Junio C Hamano [Mon, 30 Sep 2024 23:16:17 +0000 (16:16 -0700)] 
Merge branch 'ps/includeif-onbranch-cornercase-fix'

"git --git-dir=nowhere cmd" failed to properly notice that it
wasn't in any repository while processing includeIf.onbranch
configuration and instead crashed.

* ps/includeif-onbranch-cornercase-fix:
  config: fix evaluating "onbranch" with nonexistent git dir
  t1305: exercise edge cases of "onbranch" includes

8 months agoMerge branch 'ds/background-maintenance-with-credential'
Junio C Hamano [Mon, 30 Sep 2024 23:16:16 +0000 (16:16 -0700)] 
Merge branch 'ds/background-maintenance-with-credential'

Background tasks "git maintenance" runs may need to use credential
information when going over the network, but a credential helper
may work only in an interactive environment, and end up blocking a
scheduled task waiting for UI.  Credential helpers can now behave
differently when they are not running interactively.

* ds/background-maintenance-with-credential:
  scalar: configure maintenance during 'reconfigure'
  maintenance: add custom config to background jobs
  credential: add new interactive config option

8 months agoMerge branch 'rs/archive-with-attr-pathspec-fix'
Junio C Hamano [Mon, 30 Sep 2024 23:16:15 +0000 (16:16 -0700)] 
Merge branch 'rs/archive-with-attr-pathspec-fix'

"git archive" with pathspec magic that uses the attribute
information did not work well, which has been corrected.

* rs/archive-with-attr-pathspec-fix:
  archive: load index before pathspec checks

8 months agoMerge branch 'rs/commit-graph-ununleak'
Junio C Hamano [Mon, 30 Sep 2024 23:16:15 +0000 (16:16 -0700)] 
Merge branch 'rs/commit-graph-ununleak'

Code clean-up.

* rs/commit-graph-ununleak:
  commit-graph: remove unnecessary UNLEAK

8 months agoMerge branch 'pw/submodule-process-sigpipe'
Junio C Hamano [Mon, 30 Sep 2024 23:16:14 +0000 (16:16 -0700)] 
Merge branch 'pw/submodule-process-sigpipe'

When a subprocess to work in a submodule spawned by "git submodule"
fails with SIGPIPE, the parent Git process caught the death of it,
but gave a generic "failed to work in that submodule", which was
misleading.  We now behave as if the parent got SIGPIPE and die.

* pw/submodule-process-sigpipe:
  submodule status: propagate SIGPIPE

8 months agoMerge branch 'ps/reftable-concurrent-writes'
Junio C Hamano [Mon, 30 Sep 2024 23:16:14 +0000 (16:16 -0700)] 
Merge branch 'ps/reftable-concurrent-writes'

Give timeout to the locking code to write to reftable.

* ps/reftable-concurrent-writes:
  refs/reftable: reload locked stack when preparing transaction
  reftable/stack: allow locking of outdated stacks
  refs/reftable: introduce "reftable.lockTimeout"

8 months agoGit 2.47-rc0 v2.47.0-rc0
Junio C Hamano [Thu, 26 Sep 2024 01:23:49 +0000 (18:23 -0700)] 
Git 2.47-rc0

Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 months agoMerge branch 'jk/sendemail-mailmap-doc'
Junio C Hamano [Thu, 26 Sep 2024 01:24:52 +0000 (18:24 -0700)] 
Merge branch 'jk/sendemail-mailmap-doc'

Docfix.

* jk/sendemail-mailmap-doc:
  send-email: document --mailmap and associated configuration

8 months agoMerge branch 'rs/diff-exit-code-binary'
Junio C Hamano [Thu, 26 Sep 2024 01:24:51 +0000 (18:24 -0700)] 
Merge branch 'rs/diff-exit-code-binary'

"git diff --exit-code" ignored modified binary files, which has
been corrected.

* rs/diff-exit-code-binary:
  diff: report modified binary files as changes in builtin_diff()

8 months agoMerge branch 'cb/ci-freebsd-13-4'
Junio C Hamano [Thu, 26 Sep 2024 01:24:51 +0000 (18:24 -0700)] 
Merge branch 'cb/ci-freebsd-13-4'

CI updates.

* cb/ci-freebsd-13-4:
  ci: update FreeBSD image to 13.4

8 months agoMerge branch 'ak/doc-sparse-co-typofix'
Junio C Hamano [Thu, 26 Sep 2024 01:24:50 +0000 (18:24 -0700)] 
Merge branch 'ak/doc-sparse-co-typofix'

Docfix.

* ak/doc-sparse-co-typofix:
  Documentation/technical: fix a typo

8 months agoMerge branch 'ak/typofix-builtins'
Junio C Hamano [Thu, 26 Sep 2024 01:24:50 +0000 (18:24 -0700)] 
Merge branch 'ak/typofix-builtins'

Typofix.

* ak/typofix-builtins:
  builtin: fix typos

8 months agoThe 21st batch
Junio C Hamano [Wed, 25 Sep 2024 17:33:15 +0000 (10:33 -0700)] 
The 21st batch

This pretty much should match what we would have in the upcoming
preview of 2.47.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 months agoMerge branch 'jc/cmake-unit-test-updates'
Junio C Hamano [Wed, 25 Sep 2024 17:37:13 +0000 (10:37 -0700)] 
Merge branch 'jc/cmake-unit-test-updates'

CMake adjustments for recent changes around unit tests.

* jc/cmake-unit-test-updates:
  cmake: generalize the handling of the `UNIT_TEST_OBJS` list
  cmake: stop looking for `REFTABLE_TEST_OBJS` in the Makefile
  cmake: rename clar-related variables to avoid confusion

8 months agoMerge branch 'ps/ci-gitlab-upgrade'
Junio C Hamano [Wed, 25 Sep 2024 17:37:12 +0000 (10:37 -0700)] 
Merge branch 'ps/ci-gitlab-upgrade'

CI updates.

* ps/ci-gitlab-upgrade:
  gitlab-ci: upgrade machine type of Linux runners

8 months agoMerge branch 'ak/refs-symref-referent-typofix'
Junio C Hamano [Wed, 25 Sep 2024 17:37:12 +0000 (10:37 -0700)] 
Merge branch 'ak/refs-symref-referent-typofix'

Typofix.

* ak/refs-symref-referent-typofix:
  ref-filter: fix a typo

8 months agoMerge branch 'ak/typofix-2.46-maint'
Junio C Hamano [Wed, 25 Sep 2024 17:37:11 +0000 (10:37 -0700)] 
Merge branch 'ak/typofix-2.46-maint'

Typofix.

* ak/typofix-2.46-maint:
  upload-pack: fix a typo
  sideband: fix a typo
  setup: fix a typo
  run-command: fix a typo
  revision: fix a typo
  refs: fix typos
  rebase: fix a typo
  read-cache-ll: fix a typo
  pretty: fix a typo
  object-file: fix a typo
  merge-ort: fix typos
  merge-ll: fix a typo
  http: fix a typo
  gpg-interface: fix a typo
  git-p4: fix typos
  git-instaweb: fix a typo
  fsmonitor-settings: fix a typo
  diffcore-rename: fix typos
  config.mak.dev: fix a typo

8 months agoMerge branch 'ps/reftable-exclude'
Junio C Hamano [Wed, 25 Sep 2024 17:37:11 +0000 (10:37 -0700)] 
Merge branch 'ps/reftable-exclude'

The reftable backend learned to more efficiently handle exclude
patterns while enumerating the refs.

* ps/reftable-exclude:
  refs/reftable: wire up support for exclude patterns
  reftable/reader: make table iterator reseekable
  t/unit-tests: introduce reftable library
  Makefile: stop listing test library objects twice
  builtin/receive-pack: fix exclude patterns when announcing refs
  refs: properly apply exclude patterns to namespaced refs

8 months agoMerge branch 'ps/apply-leakfix'
Junio C Hamano [Wed, 25 Sep 2024 17:37:10 +0000 (10:37 -0700)] 
Merge branch 'ps/apply-leakfix'

"git apply" had custom buffer management code that predated before
use of strbuf got widespread, which has been updated to use strbuf,
which also plugged some memory leaks.

* ps/apply-leakfix:
  apply: refactor `struct image` to use a `struct strbuf`
  apply: rename members that track line count and allocation length
  apply: refactor code to drop `line_allocated`
  apply: introduce macro and function to init images
  apply: rename functions operating on `struct image`
  apply: reorder functions to move image-related things together

8 months agosend-email: document --mailmap and associated configuration
Jacob Keller [Mon, 23 Sep 2024 22:24:28 +0000 (15:24 -0700)] 
send-email: document --mailmap and associated configuration

241499aba007 ("send-email: add mailmap support via sendemail.mailmap and
--mailmap", 2024-08-27) added support for --mailmap, and the associated
sendemail.mailmap.* configuration variables. Add documentation to
reflect this feature.

Fixes: 241499aba007 ("send-email: add mailmap support via sendemail.mailmap and --mailmap")
Signed-off-by: Jacob Keller <jacob.keller@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 months agobuiltin: fix typos
Andrew Kreimer [Tue, 24 Sep 2024 13:09:06 +0000 (16:09 +0300)] 
builtin: fix typos

Fix typos in comments.

Signed-off-by: Andrew Kreimer <algonell@gmail.com>
Reviewed-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 months agorefs/reftable: reload locked stack when preparing transaction
Patrick Steinhardt [Tue, 24 Sep 2024 05:33:08 +0000 (07:33 +0200)] 
refs/reftable: reload locked stack when preparing transaction

When starting a reftable transaction we lock all stacks we are about to
modify. While it may happen that the stack is out-of-date at this point
in time we don't really care: transactional updates encode the expected
state of a certain reference, so all that we really want to verify is
that the _current_ value matches that expected state.

Pass `REFTABLE_STACK_NEW_ADDITION_RELOAD` when locking the stack such
that an out-of-date stack will be reloaded after having been locked.
This change is safe because all verifications of the expected state
happen after this step anyway.

Add a testcase that verifies that many writers are now able to write to
the stack concurrently without failures and with a deterministic end
result.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 months agoreftable/stack: allow locking of outdated stacks
Patrick Steinhardt [Tue, 24 Sep 2024 05:33:05 +0000 (07:33 +0200)] 
reftable/stack: allow locking of outdated stacks

In `reftable_stack_new_addition()` we first lock the stack and then
check whether it is still up-to-date. If it is not we return an error to
the caller indicating that the stack is outdated.

This is overly restrictive in our ref transaction interface though: we
lock the stack right before we start to verify the transaction, so we do
not really care whether it is outdated or not. What we really want is
that the stack is up-to-date after it has been locked so that we can
verify queued updates against its current state while we know that it is
locked for concurrent modification.

Introduce a new flag `REFTABLE_STACK_NEW_ADDITION_RELOAD` that alters
the behaviour of `reftable_stack_init_addition()` in this case: when we
notice that it is out-of-date we reload it instead of returning an error
to the caller.

This logic will be wired up in the reftable backend in the next commit.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 months agorefs/reftable: introduce "reftable.lockTimeout"
Patrick Steinhardt [Tue, 24 Sep 2024 05:33:02 +0000 (07:33 +0200)] 
refs/reftable: introduce "reftable.lockTimeout"

When multiple concurrent processes try to update references in a
repository they may try to lock the same lockfiles. This can happen even
when the updates are non-conflicting and can both be applied, so it
doesn't always make sense to abort the transaction immediately. Both the
"loose" and "packed" backends thus have a grace period that they wait
for the lock to be released that can be controlled via the config values
"core.filesRefLockTimeout" and "core.packedRefsTimeout", respectively.

The reftable backend doesn't have such a setting yet and instead fails
immediately when it sees such a lock. But the exact same concepts apply
here as they do apply to the other backends.

Introduce a new "reftable.lockTimeout" config that controls how long we
may wait for a "tables.list" lock to be released. The default value of
this config is 100ms, which is the same default as we have it for the
"loose" backend.

Note that even though we also lock individual tables, this config really
only applies to the "tables.list" file. This is because individual
tables are only ever locked when we already hold the "tables.list" lock
during compaction. When we observe such a lock we in fact do not want to
compact the table at all because it is already in the process of being
compacted by a concurrent process. So applying the same timeout here
would not make any sense and only delay progress.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 months agoconfig: fix evaluating "onbranch" with nonexistent git dir
Patrick Steinhardt [Tue, 24 Sep 2024 10:05:46 +0000 (12:05 +0200)] 
config: fix evaluating "onbranch" with nonexistent git dir

The `include_by_branch()` function is responsible for evaluating whether
or not a specific include should be pulled in based on the currently
checked out branch. Naturally, his condition can only be evaluated when
we have a properly initialized repository with a ref store in the first
place. This is why the function guards against the case when either
`data->repo` or `data->repo->gitdir` are `NULL` pointers.

But the second check is insufficient: the `gitdir` may be set even
though the repository has not been initialized. Quoting "setup.c":

  NEEDSWORK: currently we allow bogus GIT_DIR values to be set in some
  code paths so we also need to explicitly setup the environment if the
  user has set GIT_DIR.  It may be beneficial to disallow bogus GIT_DIR
  values at some point in the future.

So when either the GIT_DIR environment variable or the `--git-dir`
global option are set by the user then `the_repository` may end up with
an initialized `gitdir` variable. And this happens even when the dir is
invalid, like for example when it doesn't exist. It follows that only
checking for whether or not `gitdir` is `NULL` is not sufficient for us
to determine whether the repository has been properly initialized.

This issue can lead to us triggering a BUG: when using a config with an
"includeIf.onbranch:" condition outside of a repository while using the
`--git-dir` option pointing to an invalid Git directory we may end up
trying to evaluate the condition even though the ref storage format has
not been set up.

This bisects to 173761e21b (setup: start tracking ref storage format,
2023-12-29), but that commit really only starts to surface the issue
that has already existed beforehand. The code to check for `gitdir` was
introduced via 85fe0e800c (config: work around bug with
includeif:onbranch and early config, 2019-07-31), which tried to fix
similar issues when we didn't yet have a repository set up. But the fix
was incomplete as it missed the described scenario.

As the quoted comment mentions, we'd ideally refactor the code to not
set up `gitdir` with an invalid value in the first place, but that may
be a bigger undertaking. Instead, refactor the code to use the ref
storage format as an indicator of whether or not the ref store has been
set up to fix the bug.

Reported-by: Ronan Pigott <ronan@rjp.ie>
Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 months agot1305: exercise edge cases of "onbranch" includes
Patrick Steinhardt [Tue, 24 Sep 2024 10:05:42 +0000 (12:05 +0200)] 
t1305: exercise edge cases of "onbranch" includes

Add a couple more tests for "onbranch" includes for several edge cases.
All tests except for the last one pass, so for the most part this change
really only aims to nail down behaviour of include conditionals further.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 months agoDocumentation/technical: fix a typo
Andrew Kreimer [Fri, 20 Sep 2024 08:28:13 +0000 (11:28 +0300)] 
Documentation/technical: fix a typo

Fix a typo in documentation.

Signed-off-by: Andrew Kreimer <algonell@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 months agoThe 20th batch
Junio C Hamano [Mon, 23 Sep 2024 17:31:05 +0000 (10:31 -0700)] 
The 20th batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 months agoMerge branch 'jc/pass-repo-to-builtins'
Junio C Hamano [Mon, 23 Sep 2024 17:35:09 +0000 (10:35 -0700)] 
Merge branch 'jc/pass-repo-to-builtins'

The convention to calling into built-in command implementation has
been updated to pass the repository, if known, together with the
prefix value.

* jc/pass-repo-to-builtins:
  add: pass in repo variable instead of global the_repository
  builtin: remove USE_THE_REPOSITORY for those without the_repository
  builtin: remove USE_THE_REPOSITORY_VARIABLE from builtin.h
  builtin: add a repository parameter for builtin functions

9 months agoMerge branch 'jk/t9001-deflake'
Junio C Hamano [Mon, 23 Sep 2024 17:35:08 +0000 (10:35 -0700)] 
Merge branch 'jk/t9001-deflake'

Test fix.

* jk/t9001-deflake:
  t9001: use a more distinct fake BugID

9 months agoMerge branch 'jk/jump-quickfix-fixes'
Junio C Hamano [Mon, 23 Sep 2024 17:35:08 +0000 (10:35 -0700)] 
Merge branch 'jk/jump-quickfix-fixes'

A few usability fixes to "git jump" (in contrib/).

* jk/jump-quickfix-fixes:
  git-jump: ignore deleted files in diff mode
  git-jump: always specify column 1 for diff entries

9 months agoMerge branch 'ak/typofixes'
Junio C Hamano [Mon, 23 Sep 2024 17:35:07 +0000 (10:35 -0700)] 
Merge branch 'ak/typofixes'

Trivial typofixes.

* ak/typofixes:
  cbtree: fix a typo
  bloom: fix a typo
  attr: fix a typo

9 months agoMerge branch 'jk/diag-unexpected-remote-helper-death'
Junio C Hamano [Mon, 23 Sep 2024 17:35:06 +0000 (10:35 -0700)] 
Merge branch 'jk/diag-unexpected-remote-helper-death'

When a remote-helper dies before Git writes to it, SIGPIPE killed
Git silently.  We now explain the situation a bit better to the end
user in our error message.

* jk/diag-unexpected-remote-helper-death:
  print an error when remote helpers die during capabilities

9 months agoMerge branch 'jc/t5512-sigpipe-fix'
Junio C Hamano [Mon, 23 Sep 2024 17:35:05 +0000 (10:35 -0700)] 
Merge branch 'jc/t5512-sigpipe-fix'

Test fix.

* jc/t5512-sigpipe-fix:
  t5512.40 sometimes dies by SIGPIPE

9 months agoMerge branch 'ps/environ-wo-the-repository'
Junio C Hamano [Mon, 23 Sep 2024 17:35:04 +0000 (10:35 -0700)] 
Merge branch 'ps/environ-wo-the-repository'

Code clean-up.

* ps/environ-wo-the-repository: (21 commits)
  environment: stop storing "core.notesRef" globally
  environment: stop storing "core.warnAmbiguousRefs" globally
  environment: stop storing "core.preferSymlinkRefs" globally
  environment: stop storing "core.logAllRefUpdates" globally
  refs: stop modifying global `log_all_ref_updates` variable
  branch: stop modifying `log_all_ref_updates` variable
  repo-settings: track defaults close to `struct repo_settings`
  repo-settings: split out declarations into a standalone header
  environment: guard state depending on a repository
  environment: reorder header to split out `the_repository`-free section
  environment: move `set_git_dir()` and related into setup layer
  environment: make `get_git_namespace()` self-contained
  environment: move object database functions into object layer
  config: make dependency on repo in `read_early_config()` explicit
  config: document `read_early_config()` and `read_very_early_config()`
  environment: make `get_git_work_tree()` accept a repository
  environment: make `get_graft_file()` accept a repository
  environment: make `get_index_file()` accept a repository
  environment: make `get_object_directory()` accept a repository
  environment: make `get_git_common_dir()` accept a repository
  ...

9 months agoSync with Git 2.46.2
Junio C Hamano [Mon, 23 Sep 2024 17:34:39 +0000 (10:34 -0700)] 
Sync with Git 2.46.2

9 months agoGit 2.46.2 v2.46.2
Junio C Hamano [Fri, 20 Sep 2024 16:10:24 +0000 (09:10 -0700)] 
Git 2.46.2

Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 months agoMerge branch 'ma/test-libcurl-prereq' into maint-2.46
Junio C Hamano [Mon, 23 Sep 2024 17:33:00 +0000 (10:33 -0700)] 
Merge branch 'ma/test-libcurl-prereq' into maint-2.46

Test portability fix.

* ma/test-libcurl-prereq:
  t0211: add missing LIBCURL prereq
  t1517: add missing LIBCURL prereq

9 months agoMerge branch 'jc/doc-skip-fetch-all-and-prefetch' into maint-2.46
Junio C Hamano [Mon, 23 Sep 2024 17:33:00 +0000 (10:33 -0700)] 
Merge branch 'jc/doc-skip-fetch-all-and-prefetch' into maint-2.46

Doc updates.

* jc/doc-skip-fetch-all-and-prefetch:
  doc: remote.*.skip{DefaultUpdate,FetchAll} stops prefetch

9 months agoMerge branch 'bl/trailers-and-incomplete-last-line-fix' into maint-2.46
Junio C Hamano [Mon, 23 Sep 2024 17:32:59 +0000 (10:32 -0700)] 
Merge branch 'bl/trailers-and-incomplete-last-line-fix' into maint-2.46

The interpret-trailers command failed to recognise the end of the
message when the commit log ends in an incomplete line.

* bl/trailers-and-incomplete-last-line-fix:
  interpret-trailers: handle message without trailing newline

9 months agoMerge branch 'rj/cygwin-has-dev-tty' into maint-2.46
Junio C Hamano [Mon, 23 Sep 2024 17:32:59 +0000 (10:32 -0700)] 
Merge branch 'rj/cygwin-has-dev-tty' into maint-2.46

Cygwin does have /dev/tty support that is needed by things like
single-key input mode.

* rj/cygwin-has-dev-tty:
  config.mak.uname: add HAVE_DEV_TTY to cygwin config section

9 months agoMerge branch 'rs/diff-exit-code-fix' into maint-2.46
Junio C Hamano [Mon, 23 Sep 2024 17:32:58 +0000 (10:32 -0700)] 
Merge branch 'rs/diff-exit-code-fix' into maint-2.46

In a few corner cases "git diff --exit-code" failed to report
"changes" (e.g., renamed without any content change), which has
been corrected.

* rs/diff-exit-code-fix:
  diff: report dirty submodules as changes in builtin_diff()
  diff: report copies and renames as changes in run_diff_cmd()

9 months agocommit-graph: remove unnecessary UNLEAK
René Scharfe [Sun, 22 Sep 2024 13:40:42 +0000 (15:40 +0200)] 
commit-graph: remove unnecessary UNLEAK

When f4dbdfc4d5 (commit-graph: clean up leaked memory during write,
2018-10-03) added the UNLEAK, it was right before a call to die_errno().
e103f7276f (commit-graph: return with errors during write, 2019-06-12)
made it unnecessary, as it was then followed by a free() call for the
allocated string.

The code moved to write_commit_graph_file() in the meantime and the
string pointer is now part of a struct, but the function's only caller
still cleans up the allocation.  Drop the superfluous UNLEAK.

Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 months agoarchive: load index before pathspec checks
René Scharfe [Sat, 21 Sep 2024 20:23:39 +0000 (22:23 +0200)] 
archive: load index before pathspec checks

git archive checks whether pathspec arguments match anything to avoid
surprises due to typos and later loads the index to get attributes.

This order was OK when these features were introduced by ba053ea96c
(archive: do not read .gitattributes in working directory, 2009-04-18)
and d5f53d6d6f (archive: complain about path specs that don't match
anything, 2009-12-12).

But when attribute matching was added to pathspec in b0db704652
(pathspec: allow querying for attributes, 2017-03-13), the pathspec
checker in git archive did not support it fully, because it lacks the
attributes from the index.

Load the index earlier, before the pathspec check, to support attr
pathspecs.

Reported-by: Ronan Pigott <ronan@rjp.ie>
Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 months agodiff: report modified binary files as changes in builtin_diff()
René Scharfe [Sat, 21 Sep 2024 15:09:54 +0000 (17:09 +0200)] 
diff: report modified binary files as changes in builtin_diff()

The diff machinery has two ways to detect changes to set the exit code:
Just comparing hashes and comparing blob contents.  The latter is needed
if certain changes have to be ignored, e.g. with --ignore-space-change
or --ignore-matching-lines.  It's enabled by the diff_options flag
diff_from_contents.

The code for handling binary files added by 1aaf69e669 (diff: shortcut
for diff'ing two binary SHA-1 objects, 2014-08-16) always uses a quick
hash-only comparison, even if the slow way is taken.  We need it to
report a hash difference as a change for the purpose of setting the
exit code, though, but it never did.  Fix that.

d7b97b7185 (diff: let external diffs report that changes are
uninteresting, 2024-06-09) set diff_from_contents if external diff
programs are allowed.  This is the default e.g. for git diff, and so
that change exposed the inconsistency much more widely.

Reported-by: Kohei Shibata <shiba200712@gmail.com>
Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 months agoscalar: configure maintenance during 'reconfigure'
Derrick Stolee [Fri, 20 Sep 2024 00:00:23 +0000 (00:00 +0000)] 
scalar: configure maintenance during 'reconfigure'

The 'scalar reconfigure' command is intended to update registered repos
with the latest settings available. However, up to now we were not
reregistering the repos with background maintenance.

In particular, this meant that the background maintenance schedule would
not be updated if there are improvements between versions.

Be sure to register repos for maintenance during the reconfigure step.

Signed-off-by: Derrick Stolee <stolee@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 months agomaintenance: add custom config to background jobs
Derrick Stolee [Fri, 20 Sep 2024 00:00:22 +0000 (00:00 +0000)] 
maintenance: add custom config to background jobs

At the moment, some background jobs are getting blocked on credentials
during the 'prefetch' task. This leads to other tasks, such as
incremental repacks, getting blocked. Further, if a user manages to fix
their credentials, then they still need to cancel the background process
before their background maintenance can continue working.

Update the background schedules for our four scheduler integrations to
include these config options via '-c' options:

 * 'credential.interactive=false' will stop Git and some credential
   helpers from prompting in the UI (assuming the '-c' parameters are
   carried through and respected by GCM).

 * 'core.askPass=true' will replace the text fallback for a username
   and password into the 'true' command, which will return a success in
   its exit code, but Git will treat the empty string returned as an
   invalid password and move on.

We can do some testing that the credentials are passed, at least in the
systemd case due to writing the service files.

Signed-off-by: Derrick Stolee <stolee@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 months agocredential: add new interactive config option
Derrick Stolee [Fri, 20 Sep 2024 00:00:21 +0000 (00:00 +0000)] 
credential: add new interactive config option

When scripts or background maintenance wish to perform HTTP(S) requests,
there is a risk that our stored credentials might be invalid. At the
moment, this causes the credential helper to ping the user and block the
process. Even if the credential helper does not ping the user, Git falls
back to the 'askpass' method, which includes a direct ping to the user
via the terminal.

Even setting the 'core.askPass' config as something like 'echo' will
causes Git to fallback to a terminal prompt. It uses
git_terminal_prompt(), which finds the terminal from the environment and
ignores whether stdin has been redirected. This can also block the
process awaiting input.

Create a new config option to prevent user interaction, favoring a
failure to a blocked process.

The chosen name, 'credential.interactive', is taken from the config
option used by Git Credential Manager to already avoid user
interactivity, so there is already one credential helper that integrates
with this option. However, older versions of Git Credential Manager also
accepted other string values, including 'auto', 'never', and 'always'.
The modern use is to use a boolean value, but we should still be
careful that some users could have these non-booleans. Further, we
should respect 'never' the same as 'false'. This is respected by the
implementation and test, but not mentioned in the documentation.

The implementation for the Git interactions takes place within
credential_getpass(). The method prototype is modified to return an
'int' instead of 'void'. This allows us to detect that no attempt was
made to fill the given credential, changing the single caller slightly.

Also, a new trace2 region is added around the interactive portion of the
credential request. This provides a way to measure the amount of time
spent in that region for commands that _are_ interactive. It also makes
a conventient way to test that the config option works with
'test_region'.

Signed-off-by: Derrick Stolee <stolee@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 months agoci: update FreeBSD image to 13.4
Carlo Marcelo Arenas Belón [Fri, 20 Sep 2024 20:14:09 +0000 (13:14 -0700)] 
ci: update FreeBSD image to 13.4

FreeBSD 13.4 was recently released, and that means the version
of the image used by this job (13.2) will be out of support soon.

Update it before the job starts failing because packages are no
longer compatible or the image gets retired by the provider since
it is now EOL.

Signed-off-by: Carlo Marcelo Arenas Belón <carenas@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 months agosubmodule status: propagate SIGPIPE
Phillip Wood [Fri, 20 Sep 2024 13:07:22 +0000 (13:07 +0000)] 
submodule status: propagate SIGPIPE

It has been reported than running

     git submodule status --recurse | grep -q ^+

results in an unexpected error message

    fatal: failed to recurse into submodule $submodule

When "git submodule--helper" recurses into a submodule it creates a
child process. If that process fails then the error message above is
displayed by the parent. In the case above the child is killed by
SIGPIPE as "grep -q" exits as soon as it sees the first match. Fix this
by propagating SIGPIPE so that it is visible to the process running
git. We could propagate other signals but I'm not sure there is much
value in doing that. In the common case of the user pressing Ctrl-C or
Ctrl-\ then SIGINT or SIGQUIT will be sent to the foreground process
group and so the parent process will receive the same signal as the
child.

Reported-by: Matt Liberty <mliberty@precisioninno.com>
Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 months agoThe 19th batch
Junio C Hamano [Fri, 20 Sep 2024 15:59:27 +0000 (08:59 -0700)] 
The 19th batch

Merge the topics that have been cooking since 2024-09-13 or so in
'next'.

Let's try a new workflow to update the maintenance track by removing
the "merge ... later to maint" comments from the draft release notes
on the 'master' track.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 months agoMerge branch 'jk/git-pm-bare-repo-fix'
Junio C Hamano [Fri, 20 Sep 2024 18:16:32 +0000 (11:16 -0700)] 
Merge branch 'jk/git-pm-bare-repo-fix'

In Git 2.39, Git.pm stopped working in a bare repository, which has
been corrected.

* jk/git-pm-bare-repo-fix:
  Git.pm: use "rev-parse --absolute-git-dir" rather than perl code
  Git.pm: fix bare repository search with Directory option

9 months agoMerge branch 'bb/unicode-width-table-16'
Junio C Hamano [Fri, 20 Sep 2024 18:16:32 +0000 (11:16 -0700)] 
Merge branch 'bb/unicode-width-table-16'

Update the character width table for Unicode 16.

* bb/unicode-width-table-16:
  unicode: update the width tables to Unicode 16

9 months agoMerge branch 'ma/test-libcurl-prereq'
Junio C Hamano [Fri, 20 Sep 2024 18:16:31 +0000 (11:16 -0700)] 
Merge branch 'ma/test-libcurl-prereq'

Test portability fix.

* ma/test-libcurl-prereq:
  t0211: add missing LIBCURL prereq
  t1517: add missing LIBCURL prereq

9 months agoMerge branch 'jk/interop-test-build-options'
Junio C Hamano [Fri, 20 Sep 2024 18:16:31 +0000 (11:16 -0700)] 
Merge branch 'jk/interop-test-build-options'

The support to customize build options to adjust for older versions
and/or older systems for the interop tests has been improved.

* jk/interop-test-build-options:
  t/interop: allow per-version make options

9 months agoMerge branch 'jk/no-openssl-with-openssl-sha1'
Junio C Hamano [Fri, 20 Sep 2024 18:16:30 +0000 (11:16 -0700)] 
Merge branch 'jk/no-openssl-with-openssl-sha1'

The "imap-send" now allows to be compiled with NO_OPENSSL and
OPENSSL_SHA1 defined together.

* jk/no-openssl-with-openssl-sha1:
  imap-send: handle NO_OPENSSL even when openssl exists

9 months agoMerge branch 'ps/leakfixes-part-6'
Junio C Hamano [Fri, 20 Sep 2024 18:16:30 +0000 (11:16 -0700)] 
Merge branch 'ps/leakfixes-part-6'

More leakfixes.

* ps/leakfixes-part-6: (22 commits)
  builtin/repack: fix leaking keep-pack list
  merge-ort: fix two leaks when handling directory rename modifications
  match-trees: fix leaking prefixes in `shift_tree()`
  builtin/fmt-merge-msg: fix leaking buffers
  builtin/grep: fix leaking object context
  builtin/pack-objects: plug leaking list of keep-packs
  builtin/repack: fix leaking line buffer when packing promisors
  negotiator/skipping: fix leaking commit entries
  shallow: fix leaking members of `struct shallow_info`
  shallow: free grafts when unregistering them
  object: clear grafts when clearing parsed object pool
  gpg-interface: fix misdesigned signing key interfaces
  send-pack: fix leaking push cert nonce
  remote: fix leak in reachability check of a remote-tracking ref
  remote: fix leaking tracking refs
  builtin/submodule--helper: fix leaking refs on push-check
  submodule: fix leaking fetch task data
  upload-pack: fix leaking child process data on reachability checks
  builtin/push: fix leaking refspec query result
  send-pack: fix leaking common object IDs
  ...

9 months agoMerge branch 'pw/rebase-autostash-fix'
Junio C Hamano [Fri, 20 Sep 2024 18:16:29 +0000 (11:16 -0700)] 
Merge branch 'pw/rebase-autostash-fix'

"git rebase --autostash" failed to resurrect the autostashed
changes when the command gets aborted after giving back control
asking for hlep in conflict resolution.

* pw/rebase-autostash-fix:
  rebase: apply and cleanup autostash when rebase fails to start

9 months agogitlab-ci: upgrade machine type of Linux runners
Patrick Steinhardt [Wed, 18 Sep 2024 06:49:37 +0000 (08:49 +0200)] 
gitlab-ci: upgrade machine type of Linux runners

With the recent effort to make the test suite free of memory leaks we
now run a lot more of test suites with the leak-sanitizer enabled. While
we were originally only executing around 23000 tests, we're now at 30000
tests. Naturally, this has a significant impact on the runtime of such a
test run.

Naturally, this impact can also be felt for our leak-checking CI jobs.
While macOS used to be the slowest-executing job on GitLab CI with ~15
minutes of runtime, nowadays it is our leak checks which take around 45
to 55 minutes.

Our Linux runners for GitLab CI are untagged, which means that they
default to the "small" machine type with two CPU cores [1]. Upgrade
these to the "medium" runner, which provide four CPU cores and which
should thus provide a noticeable speedup.

In theory, we could upgrade to an ever larger machine than that. The
official mirror [2] has an Ultimate license, so we could get up to 128
cores. But anybody running a fork of the Git project without such a
license wouldn't be able to use those beefier machines and thus their
pipelines would fail.

[1]: https://docs.gitlab.com/ee/ci/runners/hosted_runners/linux.html
[2]: https://gitlab.com/git-scm/git/

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 months agoref-filter: fix a typo
Andrew Kreimer [Thu, 19 Sep 2024 18:34:34 +0000 (18:34 +0000)] 
ref-filter: fix a typo

Fix a typo in comments.

Signed-off-by: Andrew Kreimer <algonell@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 months agoupload-pack: fix a typo
Andrew Kreimer [Thu, 19 Sep 2024 18:34:40 +0000 (18:34 +0000)] 
upload-pack: fix a typo

Fix a typo in comments.

Signed-off-by: Andrew Kreimer <algonell@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 months agosideband: fix a typo
Andrew Kreimer [Thu, 19 Sep 2024 18:34:39 +0000 (18:34 +0000)] 
sideband: fix a typo

Fix a typo in comments.

Signed-off-by: Andrew Kreimer <algonell@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 months agosetup: fix a typo
Andrew Kreimer [Thu, 19 Sep 2024 18:34:38 +0000 (18:34 +0000)] 
setup: fix a typo

Fix a typo in comments.

Signed-off-by: Andrew Kreimer <algonell@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 months agorun-command: fix a typo
Andrew Kreimer [Thu, 19 Sep 2024 18:34:37 +0000 (18:34 +0000)] 
run-command: fix a typo

Fix a typo in comments.

Signed-off-by: Andrew Kreimer <algonell@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 months agorevision: fix a typo
Andrew Kreimer [Thu, 19 Sep 2024 18:34:36 +0000 (18:34 +0000)] 
revision: fix a typo

Fix a typo in comments.

Signed-off-by: Andrew Kreimer <algonell@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 months agorefs: fix typos
Andrew Kreimer [Thu, 19 Sep 2024 18:34:35 +0000 (18:34 +0000)] 
refs: fix typos

Fix typos in comments.

Signed-off-by: Andrew Kreimer <algonell@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 months agorebase: fix a typo
Andrew Kreimer [Thu, 19 Sep 2024 18:34:33 +0000 (18:34 +0000)] 
rebase: fix a typo

Fix a typo in comments.

Signed-off-by: Andrew Kreimer <algonell@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 months agoread-cache-ll: fix a typo
Andrew Kreimer [Thu, 19 Sep 2024 18:34:32 +0000 (18:34 +0000)] 
read-cache-ll: fix a typo

Fix a typo in comments.

Signed-off-by: Andrew Kreimer <algonell@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 months agopretty: fix a typo
Andrew Kreimer [Thu, 19 Sep 2024 18:34:31 +0000 (18:34 +0000)] 
pretty: fix a typo

Fix a typo in comments.

Signed-off-by: Andrew Kreimer <algonell@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 months agoobject-file: fix a typo
Andrew Kreimer [Thu, 19 Sep 2024 18:34:30 +0000 (18:34 +0000)] 
object-file: fix a typo

Fix a typo in comments.

Signed-off-by: Andrew Kreimer <algonell@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 months agomerge-ort: fix typos
Andrew Kreimer [Thu, 19 Sep 2024 18:34:29 +0000 (18:34 +0000)] 
merge-ort: fix typos

Fix typos in comments.

Signed-off-by: Andrew Kreimer <algonell@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 months agomerge-ll: fix a typo
Andrew Kreimer [Thu, 19 Sep 2024 18:34:28 +0000 (18:34 +0000)] 
merge-ll: fix a typo

Fix a typo in comments.

Signed-off-by: Andrew Kreimer <algonell@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 months agohttp: fix a typo
Andrew Kreimer [Thu, 19 Sep 2024 18:34:27 +0000 (18:34 +0000)] 
http: fix a typo

Fix a typo in comments.

Signed-off-by: Andrew Kreimer <algonell@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 months agogpg-interface: fix a typo
Andrew Kreimer [Thu, 19 Sep 2024 18:34:26 +0000 (18:34 +0000)] 
gpg-interface: fix a typo

Fix a typo in comments.

Signed-off-by: Andrew Kreimer <algonell@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 months agogit-p4: fix typos
Andrew Kreimer [Thu, 19 Sep 2024 18:34:25 +0000 (18:34 +0000)] 
git-p4: fix typos

Fix typos in comments.

Signed-off-by: Andrew Kreimer <algonell@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 months agogit-instaweb: fix a typo
Andrew Kreimer [Thu, 19 Sep 2024 18:34:24 +0000 (18:34 +0000)] 
git-instaweb: fix a typo

Fix a typo in comments.

Signed-off-by: Andrew Kreimer <algonell@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 months agofsmonitor-settings: fix a typo
Andrew Kreimer [Thu, 19 Sep 2024 18:34:23 +0000 (18:34 +0000)] 
fsmonitor-settings: fix a typo

Fix a typo in comments.

Signed-off-by: Andrew Kreimer <algonell@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 months agodiffcore-rename: fix typos
Andrew Kreimer [Thu, 19 Sep 2024 18:34:22 +0000 (18:34 +0000)] 
diffcore-rename: fix typos

Fix typos in comments.

Signed-off-by: Andrew Kreimer <algonell@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 months agoconfig.mak.dev: fix a typo
Andrew Kreimer [Thu, 19 Sep 2024 18:34:21 +0000 (18:34 +0000)] 
config.mak.dev: fix a typo

Fix a typo in comments.

Signed-off-by: Andrew Kreimer <algonell@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 months agocmake: generalize the handling of the `UNIT_TEST_OBJS` list
Johannes Schindelin [Wed, 18 Sep 2024 19:29:29 +0000 (19:29 +0000)] 
cmake: generalize the handling of the `UNIT_TEST_OBJS` list

In a15d4465a991 (cmake: also build unit tests, 2023-09-25), I
accommodated the CMake definition. Seeing that a `UNIT_TEST_OBJS` list
was introduced that was built by transforming the `UNIT_TEST_PROGRAMS`
list and then adding a single, hard-coded file
("t/unit-tests/test-lib.c"), I decided to hard-code that in the CMake
definition, too.

The reason why I hard-coded it instead of imitating the
`parse_makefile_for_sources()` paradigm that was used elsewhere when
using the `Makefile` as source of truth for given lists of files: This
function expects _only_ hard-coded values, and that transformed
`UNIT_TEST_PROGRAMS` list complicated everything.

In 872721538c26 (cmake: fix build of `t-oidtree`, 2024-07-12), I
accommodated the CMake definition again, after seeing that the
`UNIT_TEST_OBJS` was still defined via that transformed list but now
appending _two_ hard-coded files ("t/unit-tests/lib-oid.c" joined the
fray).

In 428672a3b16 (Makefile: stop listing test library objects twice,
2024-09-16), the `Makefile` was changed so that `UNIT_TEST_OBJS` is
finally only constructed using hard-coded file names just like the other
`*_OBJS` variables. I missed that and therefore did not adjust the CMake
definition. Besides, the code was working, so there was no real need to
adjust it.

With a4f50bb1e9b (t/unit-tests: introduce reftable library, 2024-09-16),
however, the `UNIT_TEST_OBJS` list became a trio, and the CMake
definition has to be adjusted again. Now that we can use the
`parse_makefile_for_sources()` function without many complications,
let's do that.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 months agocmake: stop looking for `REFTABLE_TEST_OBJS` in the Makefile
Johannes Schindelin [Wed, 18 Sep 2024 19:23:20 +0000 (19:23 +0000)] 
cmake: stop looking for `REFTABLE_TEST_OBJS` in the Makefile

As of 15e29ea1c648 (t: move reftable/stack_test.c to the unit testing
framework, 2024-09-08), the reftable tests are no longer part of
`test-tool.exe`, so let's stop looking for those lines that are no
longer in the `Makefile`.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 months agocmake: rename clar-related variables to avoid confusion
Johannes Schindelin [Wed, 18 Sep 2024 19:21:16 +0000 (19:21 +0000)] 
cmake: rename clar-related variables to avoid confusion

In c3de556a841f (Makefile: rename clar-related variables to avoid
confusion, 2024-09-10) some `Makefile` variables were renamed that were
partially used by the CMake definition. Adapt the latter to the new lay
of the land.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 months agoMerge branch 'ps/reftable-exclude' into jc/cmake-unit-test-updates
Junio C Hamano [Thu, 19 Sep 2024 01:05:44 +0000 (18:05 -0700)] 
Merge branch 'ps/reftable-exclude' into jc/cmake-unit-test-updates

* ps/reftable-exclude:
  refs/reftable: wire up support for exclude patterns
  reftable/reader: make table iterator reseekable
  t/unit-tests: introduce reftable library
  Makefile: stop listing test library objects twice
  builtin/receive-pack: fix exclude patterns when announcing refs
  refs: properly apply exclude patterns to namespaced refs

9 months agoThe eighteenth batch
Junio C Hamano [Thu, 19 Sep 2024 00:47:14 +0000 (17:47 -0700)] 
The eighteenth batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 months agoMerge branch 'es/chainlint-message-updates'
Junio C Hamano [Thu, 19 Sep 2024 01:02:05 +0000 (18:02 -0700)] 
Merge branch 'es/chainlint-message-updates'

The error messages from the test script checker have been improved.

* es/chainlint-message-updates:
  chainlint: reduce annotation noise-factor
  chainlint: make error messages self-explanatory
  chainlint: don't be fooled by "?!...?!" in test body

9 months agoMerge branch 'ps/clar-unit-test'
Junio C Hamano [Thu, 19 Sep 2024 01:02:05 +0000 (18:02 -0700)] 
Merge branch 'ps/clar-unit-test'

Import clar unit tests framework libgit2 folks invented for our
use.

* ps/clar-unit-test:
  Makefile: rename clar-related variables to avoid confusion
  clar: add CMake support
  t/unit-tests: convert ctype tests to use clar
  t/unit-tests: convert strvec tests to use clar
  t/unit-tests: implement test driver
  Makefile: wire up the clar unit testing framework
  Makefile: do not use sparse on third-party sources
  Makefile: make hdr-check depend on generated headers
  Makefile: fix sparse dependency on GENERATED_H
  clar: stop including `shellapi.h` unnecessarily
  clar(win32): avoid compile error due to unused `fs_copy()`
  clar: avoid compile error with mingw-w64
  t/clar: fix compatibility with NonStop
  t: import the clar unit testing framework
  t: do not pass GIT_TEST_OPTS to unit tests with prove

9 months agoapply: refactor `struct image` to use a `struct strbuf`
Patrick Steinhardt [Tue, 17 Sep 2024 10:08:08 +0000 (12:08 +0200)] 
apply: refactor `struct image` to use a `struct strbuf`

The `struct image` uses a character array to track the pre- or postimage
of a patch operation. This has multiple downsides:

  - It is somewhat hard to track memory ownership. In fact, we have
    several memory leaks in git-apply(1) because we do not (and cannot
    easily) free the buffer in all situations.

  - We have to reinvent the wheel and manually implement a lot of
    functionality that would already be provided by `struct strbuf`.

  - We have to carefully track whether `update_pre_post_images()` can do
    an in-place update of the postimage or whether it has to allocate a
    new buffer for it.

This is all rather cumbersome, and especially `update_pre_post_images()`
is really hard to understand as a consequence even though what it is
doing is rather trivial.

Refactor the code to use a `struct strbuf` instead, addressing all of
the above. Like this we can easily perform in-place updates in all
situations, the logic to perform those updates becomes way simpler and
the lifetime of the buffer becomes a ton easier to track.

This refactoring also plugs some leaking buffers as a side effect.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 months agoapply: rename members that track line count and allocation length
Patrick Steinhardt [Tue, 17 Sep 2024 10:08:06 +0000 (12:08 +0200)] 
apply: rename members that track line count and allocation length

The `struct image` has two members `nr` and `alloc` that track the
number of lines as well as how large its array is. It is somewhat easy
to confuse these members with `len` though, which tracks the length of
the `buf` member.

Rename these members to `line_nr` and `line_alloc` respectively to avoid
confusion. This is in line with how we typically name variables that
track an array in this way.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 months agoapply: refactor code to drop `line_allocated`
Patrick Steinhardt [Tue, 17 Sep 2024 10:08:03 +0000 (12:08 +0200)] 
apply: refactor code to drop `line_allocated`

The `struct image` has two members `line` and `line_allocated`. The
former member is the one that should be used throughout the code,
whereas the latter one is used to track whether the lines have been
allocated or not.

In practice, the array of lines is always allocated. The reason why we
have `line_allocated` is that `remove_first_line()` will advance the
array pointer to drop the first entry, and thus it points into the array
instead of to the array header.

Refactor the function to use memmove(3P) instead, which allows us to get
rid of this double bookkeeping. This is less efficient, but I doubt that
this matters much in practice. If this judgement call is found to be
wrong at a later point in time we can likely refactor the surrounding
loop such that we first calculate the number of leading context lines to
remove and then remove them in a single call to memmove(3P).

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 months agoapply: introduce macro and function to init images
Patrick Steinhardt [Tue, 17 Sep 2024 10:08:01 +0000 (12:08 +0200)] 
apply: introduce macro and function to init images

We're about to convert the `struct image` to gain a `struct strbuf`
member, which requires more careful initialization than just memsetting
it to zeros. Introduce the `IMAGE_INIT` macro and `image_init()`
function to prepare for this change.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>