]> git.ipfire.org Git - thirdparty/git.git/log
thirdparty/git.git
6 months agomingw_rename: do support directory renames
Johannes Schindelin [Tue, 17 Dec 2024 12:52:04 +0000 (12:52 +0000)] 
mingw_rename: do support directory renames

In 391bceae435 (compat/mingw: support POSIX semantics for atomic
renames, 2024-10-27), we taught the `mingw_rename()` function to respect
POSIX semantics, but we did so only as a fallback after `_wrename()`
fails.

This hid a bug in the implementation that was not caught by Git's test
suite: The `CreateFileW()` function _can_ open handles to directories,
but not when asked to use the `FILE_ATTRIBUTE_NORMAL` flag, as that flag
only is allowed for files.

Let's fix this by using the common `FILE_FLAG_BACKUP_SEMANTICS` flag
that can be used for opening handles to directories, too.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 months agocompat/mingw: support POSIX semantics for atomic renames
Patrick Steinhardt [Sun, 27 Oct 2024 15:39:43 +0000 (16:39 +0100)] 
compat/mingw: support POSIX semantics for atomic renames

By default, Windows restricts access to files when those files have been
opened by another process. As explained in the preceding commits, these
restrictions can be loosened such that reads, writes and/or deletes of
files with open handles _are_ allowed.

While we set up those sharing flags in most relevant code paths now, we
still don't properly handle POSIX-style atomic renames in case the
target path is open. This is failure demonstrated by t0610, where one of
our tests spawns concurrent writes in a reftable-enabled repository and
expects all of them to succeed. This test fails most of the time because
the process that has acquired the "tables.list" lock is unable to rename
it into place while other processes are busy reading that file.

Windows 10 has introduced the `FILE_RENAME_FLAG_POSIX_SEMANTICS` flag
that allows us to fix this usecase [1]. When set, it is possible to
rename a file over a preexisting file even when the target file still
has handles open. Those handles must have been opened with the
`FILE_SHARE_DELETE` flag, which we have ensured in the preceding
commits.

Careful readers might have noticed that [1] does not mention the above
flag, but instead mentions `FILE_RENAME_POSIX_SEMANTICS`. This flag is
not for use with `SetFileInformationByHandle()` though, which is what we
use. And while the `FILE_RENAME_FLAG_POSIX_SEMANTICS` flag exists, it is
not documented on [2] or anywhere else as far as I can tell.

Unfortunately, we still support Windows systems older than Windows 10
that do not yet have this new flag. Our `_WIN32_WINNT` SDK version still
targets 0x0600, which is Windows Vista and later. And even though that
Windows version is out-of-support, bumping the SDK version all the way
to 0x0A00, which is Windows 10 and later, is not an option as it would
make it impossible to compile on Windows 8.1, which is still supported.
Instead, we have to manually declare the relevant infrastructure to make
this feature available and have fallback logic in place in case we run
on a Windows version that does not yet have this flag.

On another note: `mingw_rename()` has a retry loop that is used in case
deleting a file failed because it's still open in another process. One
might be pressed to not use this loop anymore when we can use POSIX
semantics. But unfortunately, we have to keep it around due to our
dependence on the `FILE_SHARE_DELETE` flag. While we know to set that
sharing flag now, other applications may not do so and may thus still
cause sharing violations when we try to rename a file.

This fixes concurrent writes in the reftable backend as demonstrated in
t0610, but may also end up fixing other usecases where Git wants to
perform renames.

[1]: https://learn.microsoft.com/en-us/windows-hardware/drivers/ddi/ntifs/ns-ntifs-_file_rename_information
[2]: https://learn.microsoft.com/en-us/windows/win32/api/winbase/ns-winbase-file_rename_info

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Taylor Blau <me@ttaylorr.com>
Reviewed-by: Johannes Sixt <j6t@kdbg.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 months agocompat/mingw: allow deletion of most opened files
Patrick Steinhardt [Sun, 27 Oct 2024 15:39:40 +0000 (16:39 +0100)] 
compat/mingw: allow deletion of most opened files

On Windows, we emulate open(3p) via `mingw_open()`. This function
implements handling of some platform-specific quirks that are required
to make it behave as closely as possible like open(3p) would, but for
most cases we just call the Windows-specific `_wopen()` function.

This function has a major downside though: it does not allow us to
specify the sharing mode. While there is `_wsopen()` that allows us to
pass sharing flags, those sharing flags are not the same `FILE_SHARE_*`
flags as `CreateFileW()` accepts. Instead, `_wsopen()` only allows
concurrent read- and write-access, but does not allow for concurrent
deletions. Unfortunately though, we have to allow concurrent deletions
if we want to have POSIX-style atomic renames on top of an existing file
that has open file handles.

Implement a new function that emulates open(3p) for existing files via
`CreateFileW()` such that we can set the required sharing flags.

While we have the same issue when calling open(3p) with `O_CREAT`,
implementing that mode would be more complex due to the required
permission handling. Furthermore, atomic updates via renames typically
write to exclusive lockfile and then perform the rename, and thus we
don't have to handle the case where the locked path has been created
with `O_CREATE`. So while it would be nice to have proper POSIX
semantics in all paths, we instead aim for a minimum viable fix here.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Taylor Blau <me@ttaylorr.com>
7 months agocompat/mingw: share file handles created via `CreateFileW()`
Patrick Steinhardt [Sun, 27 Oct 2024 15:39:37 +0000 (16:39 +0100)] 
compat/mingw: share file handles created via `CreateFileW()`

Unless told otherwise, Windows will keep other processes from reading,
writing and deleting files when one has an open handle that was created
via `CreateFileW()`. This behaviour can be altered via `FILE_SHARE_*`
flags:

  - `FILE_SHARE_READ` allows a concurrent process to open the file for
    reading.

  - `FILE_SHARE_WRITE` allows a concurrent process to open the file for
    writing.

  - `FILE_SHARE_DELETE` allows a concurrent process to delete the file
    or to replace it via an atomic rename.

This sharing mechanism is quite important in the context of Git, as we
assume POSIX semantics all over the place. But there are two callsites
where we don't pass all three of these flags:

  - We don't set `FILE_SHARE_DELETE` when creating a file for appending
    via `mingw_open_append()`. This makes it impossible to delete the
    file from another process or to replace it via an atomic rename. The
    function was introduced via d641097589 (mingw: enable atomic
    O_APPEND, 2018-08-13) and has been using `FILE_SHARE_READ |
    FILE_SHARE_WRITE` since the inception. There aren't any indicators
    that the omission of `FILE_SHARE_DELETE` was intentional.

  - We don't set any sharing flags in `mingw_utime()`, which changes the
    access and modification of a file. This makes it impossible to
    perform any kind of operation on this file at all from another
    process. While we only open the file for a short amount of time to
    update its timestamps, this still opens us up for a race condition
    with another process.

    `mingw_utime()` was originally implemented via `_wopen()`, which
    doesn't give you full control over the sharing mode. Instead, it
    calls `_wsopen()` with `_SH_DENYNO`, which ultimately translates to
    `FILE_SHARE_READ | FILE_SHARE_WRITE`. It was then refactored via
    090a3085bc (t/helper/test-chmtime: update mingw to support chmtime
    on directories, 2022-03-02) to use `CreateFileW()`, but we stopped
    setting any sharing flags at all, which seems like an unintentional
    side effect. By restoring `FILE_SHARE_READ | FILE_SHARE_WRITE` we
    thus fix this and get back the old behaviour of `_wopen()`.

    The fact that we didn't set the equivalent of `FILE_SHARE_DELETE`
    can be explained, as well: neither `_wopen()` nor `_wsopen()` allow
    you to do so. So overall, it doesn't seem intentional that we didn't
    allow deletions here, either.

Adapt both of these callsites to pass all three sharing flags.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Taylor Blau <me@ttaylorr.com>
8 months agoThe third batch
Taylor Blau [Tue, 22 Oct 2024 18:43:46 +0000 (14:43 -0400)] 
The third batch

Signed-off-by: Taylor Blau <me@ttaylorr.com>
8 months agoMerge branch 'cw/worktree-relative'
Taylor Blau [Tue, 22 Oct 2024 18:40:39 +0000 (14:40 -0400)] 
Merge branch 'cw/worktree-relative'

An extra worktree attached to a repository points at each other to
allow finding the repository from the worktree and vice versa
possible.  Turn this linkage to relative paths.

* cw/worktree-relative:
  worktree: add test for path handling in linked worktrees
  worktree: link worktrees with relative paths
  worktree: refactor infer_backlink() to use *strbuf
  worktree: repair copied repository and linked worktrees

8 months agoMerge branch 'ps/cache-tree-w-broken-index-entry'
Taylor Blau [Tue, 22 Oct 2024 18:40:38 +0000 (14:40 -0400)] 
Merge branch 'ps/cache-tree-w-broken-index-entry'

Fail gracefully instead of crashing when attempting to write the
contents of a corrupt in-core index as a tree object.

* ps/cache-tree-w-broken-index-entry:
  unpack-trees: detect mismatching number of cache-tree/index entries
  cache-tree: detect mismatching number of index entries
  cache-tree: refactor verification to return error codes

8 months agoThe third batch
Taylor Blau [Fri, 18 Oct 2024 18:01:50 +0000 (14:01 -0400)] 
The third batch

Signed-off-by: Taylor Blau <me@ttaylorr.com>
8 months agoMerge branch 'ps/maintenance-start-crash-fix'
Taylor Blau [Fri, 18 Oct 2024 17:56:26 +0000 (13:56 -0400)] 
Merge branch 'ps/maintenance-start-crash-fix'

"git maintenance start" crashed due to an uninitialized variable
reference, which has been corrected.

* ps/maintenance-start-crash-fix:
  builtin/gc: fix crash when running `git maintenance start`

8 months agoMerge branch 'xx/protocol-v2-doc-markup-fix'
Taylor Blau [Fri, 18 Oct 2024 17:56:25 +0000 (13:56 -0400)] 
Merge branch 'xx/protocol-v2-doc-markup-fix'

Docfix.

* xx/protocol-v2-doc-markup-fix:
  Documentation/gitprotocol-v2.txt: fix a slight inconsistency in format

8 months agoMerge branch 'tc/bundle-uri-leakfix'
Taylor Blau [Fri, 18 Oct 2024 17:56:24 +0000 (13:56 -0400)] 
Merge branch 'tc/bundle-uri-leakfix'

Leakfix.

* tc/bundle-uri-leakfix:
  bundle-uri: plug leak in unbundle_from_file()

8 months agoMerge branch 'kh/checkout-ignore-other-docfix'
Taylor Blau [Fri, 18 Oct 2024 17:56:24 +0000 (13:56 -0400)] 
Merge branch 'kh/checkout-ignore-other-docfix'

Doc updates.

* kh/checkout-ignore-other-docfix:
  checkout: refer to other-worktree branch, not ref

8 months agoMerge branch 'kh/merge-tree-doc'
Taylor Blau [Fri, 18 Oct 2024 17:56:23 +0000 (13:56 -0400)] 
Merge branch 'kh/merge-tree-doc'

Docfix.

* kh/merge-tree-doc:
  doc: merge-tree: improve example script

8 months agoMerge branch 'ng/rebase-merges-branch-name-as-label'
Taylor Blau [Fri, 18 Oct 2024 17:56:22 +0000 (13:56 -0400)] 
Merge branch 'ng/rebase-merges-branch-name-as-label'

"git rebase --rebase-merges" now uses branch names as labels when
able.

* ng/rebase-merges-branch-name-as-label:
  rebase-merges: try and use branch names as labels
  rebase-update-refs: extract load_branch_decorations
  load_branch_decorations: fix memory leak with non-static filters

8 months agoMerge branch 'kn/loose-object-layer-wo-global-hash'
Taylor Blau [Fri, 18 Oct 2024 17:56:22 +0000 (13:56 -0400)] 
Merge branch 'kn/loose-object-layer-wo-global-hash'

Code clean-up.

* kn/loose-object-layer-wo-global-hash:
  loose: don't rely on repository global state

8 months agoMerge branch 'jc/doc-refspec-syntax'
Taylor Blau [Fri, 18 Oct 2024 17:56:20 +0000 (13:56 -0400)] 
Merge branch 'jc/doc-refspec-syntax'

Doc updates.

* jc/doc-refspec-syntax:
  doc: clarify <src> in refspec syntax

8 months agoMerge branch 'aa/t7300-modernize'
Taylor Blau [Fri, 18 Oct 2024 17:54:43 +0000 (13:54 -0400)] 
Merge branch 'aa/t7300-modernize'

Test modernization.

* aa/t7300-modernize:
  t7300-clean.sh: use test_path_* helper functions for error logging

8 months agoThe second batch
Taylor Blau [Tue, 15 Oct 2024 21:12:40 +0000 (17:12 -0400)] 
The second batch

Signed-off-by: Taylor Blau <me@ttaylorr.com>
8 months agoMerge branch 'jk/fsmonitor-event-listener-race-fix'
Taylor Blau [Tue, 15 Oct 2024 20:56:43 +0000 (16:56 -0400)] 
Merge branch 'jk/fsmonitor-event-listener-race-fix'

On macOS, fsmonitor can fall into a race condition that results in
a client waiting forever to be notified for an event that have
already happened.  This problem has been corrected.

* jk/fsmonitor-event-listener-race-fix:
  fsmonitor: initialize fs event listener before accepting clients
  simple-ipc: split async server initialization and running

8 months agoMerge branch 'xx/remote-server-option-config'
Taylor Blau [Tue, 15 Oct 2024 20:56:43 +0000 (16:56 -0400)] 
Merge branch 'xx/remote-server-option-config'

A new configuration variable remote.<name>.serverOption makes the
transport layer act as if the --serverOption=<value> option is
given from the command line.

* xx/remote-server-option-config:
  ls-remote: leakfix for not clearing server_options
  fetch: respect --server-option when fetching multiple remotes
  transport.c::handshake: make use of server options from remote
  remote: introduce remote.<name>.serverOption configuration
  transport: introduce parse_transport_option() method

8 months agoMerge branch 'js/doc-platform-support-link-fix'
Taylor Blau [Tue, 15 Oct 2024 20:56:43 +0000 (16:56 -0400)] 
Merge branch 'js/doc-platform-support-link-fix'

Docfix.

* js/doc-platform-support-link-fix:
  docs: fix the `maintain-git` links in `technical/platform-support`

8 months agoMerge branch 'jh/config-unset-doc-fix'
Taylor Blau [Tue, 15 Oct 2024 20:56:43 +0000 (16:56 -0400)] 
Merge branch 'jh/config-unset-doc-fix'

Docfix.

* jh/config-unset-doc-fix:
  git-config.1: remove value from positional args in unset usage

8 months agoStart the 2.48 cycle
Junio C Hamano [Thu, 10 Oct 2024 21:22:07 +0000 (14:22 -0700)] 
Start the 2.48 cycle

Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 months agoMerge branch 'jk/output-prefix-cleanup'
Junio C Hamano [Thu, 10 Oct 2024 21:22:29 +0000 (14:22 -0700)] 
Merge branch 'jk/output-prefix-cleanup'

Code clean-up.

* jk/output-prefix-cleanup:
  diff: store graph prefix buf in git_graph struct
  diff: return line_prefix directly when possible
  diff: return const char from output_prefix callback
  diff: drop line_prefix_length field
  line-log: use diff_line_prefix() instead of custom helper

8 months agoMerge branch 'ps/leakfixes-part-8'
Junio C Hamano [Thu, 10 Oct 2024 21:22:27 +0000 (14:22 -0700)] 
Merge branch 'ps/leakfixes-part-8'

More leakfixes.

* ps/leakfixes-part-8: (23 commits)
  builtin/send-pack: fix leaking list of push options
  remote: fix leaking push reports
  t/helper: fix leaks in proc-receive helper
  pack-write: fix return parameter of `write_rev_file_order()`
  revision: fix leaking saved parents
  revision: fix memory leaks when rewriting parents
  midx-write: fix leaking buffer
  pack-bitmap-write: fix leaking OID array
  pseudo-merge: fix leaking strmap keys
  pseudo-merge: fix various memory leaks
  line-log: fix several memory leaks
  diff: improve lifecycle management of diff queues
  builtin/revert: fix leaking `gpg_sign` and `strategy` config
  t/helper: fix leaking repository in partial-clone helper
  builtin/clone: fix leaking repo state when cloning with bundle URIs
  builtin/pack-redundant: fix various memory leaks
  builtin/stash: fix leaking `pathspec_from_file`
  submodule: fix leaking submodule entry list
  wt-status: fix leaking buffer with sparse directories
  shell: fix leaking strings
  ...

8 months agoMerge branch 'ds/line-log-asan-fix'
Junio C Hamano [Thu, 10 Oct 2024 21:22:27 +0000 (14:22 -0700)] 
Merge branch 'ds/line-log-asan-fix'

Use after free and double freeing at the end in "git log -L... -p"
had been identified and fixed.

* ds/line-log-asan-fix:
  line-log: protect inner strbuf from free

8 months agoMerge branch 'sk/doc-maintenance-schedule'
Junio C Hamano [Thu, 10 Oct 2024 21:22:26 +0000 (14:22 -0700)] 
Merge branch 'sk/doc-maintenance-schedule'

Doc update to clarify how periodical maintenance are scheduled,
spread across time to avoid thundering hurds.

* sk/doc-maintenance-schedule:
  doc: add a note about staggering of maintenance

8 months agoMerge branch 'tb/notes-amlog-doc'
Junio C Hamano [Thu, 10 Oct 2024 21:22:25 +0000 (14:22 -0700)] 
Merge branch 'tb/notes-amlog-doc'

Document "amlog" notes.

* tb/notes-amlog-doc:
  Documentation: mention the amlog in howto/maintain-git.txt

8 months agoMerge branch 'ps/reftable-alloc-failures'
Junio C Hamano [Thu, 10 Oct 2024 21:22:24 +0000 (14:22 -0700)] 
Merge branch 'ps/reftable-alloc-failures'

The reftable library is now prepared to expect that the memory
allocation function given to it may fail to allocate and to deal
with such an error.

* ps/reftable-alloc-failures: (26 commits)
  reftable/basics: fix segfault when growing `names` array fails
  reftable/basics: ban standard allocator functions
  reftable: introduce `REFTABLE_FREE_AND_NULL()`
  reftable: fix calls to free(3P)
  reftable: handle trivial allocation failures
  reftable/tree: handle allocation failures
  reftable/pq: handle allocation failures when adding entries
  reftable/block: handle allocation failures
  reftable/blocksource: handle allocation failures
  reftable/iter: handle allocation failures when creating indexed table iter
  reftable/stack: handle allocation failures in auto compaction
  reftable/stack: handle allocation failures in `stack_compact_range()`
  reftable/stack: handle allocation failures in `reftable_new_stack()`
  reftable/stack: handle allocation failures on reload
  reftable/reader: handle allocation failures in `reader_init_iter()`
  reftable/reader: handle allocation failures for unindexed reader
  reftable/merged: handle allocation failures in `merged_table_init_iter()`
  reftable/writer: handle allocation failures in `reftable_new_writer()`
  reftable/writer: handle allocation failures in `writer_index_hash()`
  reftable/record: handle allocation failures when decoding records
  ...

8 months agoMerge branch 'ja/doc-synopsis-markup'
Junio C Hamano [Thu, 10 Oct 2024 21:22:24 +0000 (14:22 -0700)] 
Merge branch 'ja/doc-synopsis-markup'

The way AsciiDoc is used for SYNOPSIS part of the manual pages has
been revamped.  The sources, at least for the simple cases, got
vastly pleasant to work with.

* ja/doc-synopsis-markup:
  doc: apply synopsis simplification on git-clone and git-init
  doc: update the guidelines to reflect the current formatting rules
  doc: introduce a synopsis typesetting

8 months agocheckout: refer to other-worktree branch, not ref
Kristoffer Haugsbakk [Thu, 10 Oct 2024 18:39:29 +0000 (20:39 +0200)] 
checkout: refer to other-worktree branch, not ref

We can only check out commits or branches, not refs in general.  And the
problem here is if another worktree is using the branch that we want to
check out.

Let’s be more direct and just talk about branches instead of refs.

Also replace “be held” with “in use”.  Further, “in use” is not
restricted to a branch being checked out (e.g. the branch could be busy
on a rebase), hence generalize to “or otherwise in use” in the option
description.

Signed-off-by: Kristoffer Haugsbakk <code@khaugsbakk.name>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 months agoDocumentation/gitprotocol-v2.txt: fix a slight inconsistency in format
Xing Xin [Thu, 10 Oct 2024 13:20:42 +0000 (13:20 +0000)] 
Documentation/gitprotocol-v2.txt: fix a slight inconsistency in format

Signed-off-by: Xing Xin <xingxin.xx@bytedance.com>
Acked-by: Kristoffer Haugsbakk <kristofferhaugsbakk@fastmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 months agobundle-uri: plug leak in unbundle_from_file()
Toon Claes [Thu, 10 Oct 2024 09:12:49 +0000 (11:12 +0200)] 
bundle-uri: plug leak in unbundle_from_file()

The function `unbundle_from_file()` has two memory leaks:

  - We do not release the `struct bundle_header header` when hitting
    errors because we return early without any cleanup.

  - We do not release the `struct strbuf bundle_ref` at all.

Plug these leaks by creating a common exit path where both of these
variables are released.

While at it, refactor the code such that the variable assignments do not
happen inside the conditional statement itself according to our coding
style.

Signed-off-by: Toon Claes <toon@iotcl.com>
Acked-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 months agobuiltin/gc: fix crash when running `git maintenance start`
Patrick Steinhardt [Thu, 10 Oct 2024 05:33:01 +0000 (07:33 +0200)] 
builtin/gc: fix crash when running `git maintenance start`

It was reported on the mailing list that running `git maintenance start`
immediately segfaults starting with b6c3f8e12c (builtin/maintenance: fix
leak in `get_schedule_cmd()`, 2024-09-26). And indeed, this segfault is
trivial to reproduce up to a point where one is scratching their head
why we didn't catch this regression in our test suite.

The root cause of this error is `get_schedule_cmd()`, which does not
populate the `out` parameter in all cases anymore starting with the
mentioned commit. Callers do assume it to always be populated though and
will e.g. call `strvec_split()` on the returned value, which will of
course segfault when the variable is uninitialized.

So why didn't we catch this trivial regression? The reason is that our
tests always set up the "GIT_TEST_MAINT_SCHEDULER" environment variable
via "t/test-lib.sh", which allows us to override the scheduler command
with a custom one so that we don't accidentally modify the developer's
system. But the faulty code where we don't set the `out` parameter will
only get hit in case that environment variable is _not_ set, which is
never the case when executing our tests.

Fix the regression by again unconditionally allocating the value in the
`out` parameter, if provided. Add a test that unsets the environment
variable to catch future regressions in this area.

Reported-by: Shubham Kanodia <shubham.kanodia10@gmail.com>
Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 months agodoc: clarify <src> in refspec syntax
Junio C Hamano [Tue, 1 Oct 2024 18:36:52 +0000 (11:36 -0700)] 
doc: clarify <src> in refspec syntax

We explicitly avoid saying "ref <src>" when introducing the source
side of a refspec, because it can be a fully-spelled hexadecimal
object name, and it also can be a pattern that is not quite a "ref".

But we are loose when we introduce <dst> and say "ref <dst>", even
though it can also be a pattern.  Let's omit "ref" also from the
destination side.

Clarify that <src> can be a ref, a (limited glob) pattern, or an
object name.

Even though the very original design of refspec expected that '*'
was used only at the end (e.g., "refs/heads/*" was expected, but not
"refs/heads/*-wip"), the code and its use evolved to handle a single
'*' anywhere in the pattern.  Update the text to remove the mention
of "the same prefix".  Anything that matches the pattern are named
by such a (limited glob) pattern in <src>.

Also put a bit more stress on the fact that we accept only one '*'
in the pattern by saying "one and only one `*`".

Helped-by: Monika Kairaitytė <monika@kibit.lt>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 months agot7300-clean.sh: use test_path_* helper functions for error logging
Abraham Samuel Adekunle [Wed, 9 Oct 2024 18:22:02 +0000 (18:22 +0000)] 
t7300-clean.sh: use test_path_* helper functions for error logging

This test script uses "test - [def]", but when a test fails because
the file passed to it does not exist,
it fails silently without an error message.
Use test_path_* helper functions, which are designed to give better
error messages when their expectations are not met.

I have added a mechanical validation that applies the same transformation
done in this patch, when the test script is passed to a sed script as shown
below.

sed -e 's/^\( *\)test -f /\1test_path_is_file /' \
    -e 's/^\( *\)test -d /\1test_path_is_dir /' \
    -e 's/^\( *\)test -e /\1test_path_exists /' \
    -e 's/^\( *\)! test -[edf] /\1test_path_is_missing /' \
    -e 's/^\( *\)test ! -[edf] /\1test_path_is_missing /' \
       "$1" >foo.sh

Reviewers can use the sed script to tranform the original test script and
compare the result in foo.sh with the results of applying the patch.
You will see an instance of "!(test -e 3)" which was manually replaced with
""test_path_is_missing 3", and everything else should match.

Careful and deliberate observation was done to check instances where
"test ! - [df] foo" was used in the test script to make sure that the test
instances were expecting foo to EITHER be a file or a directory, and NOT a
possibility of being both as this would make replacing "test ! -f foo" with
"test_path_is_missing foo" unreasonable.

In the tests control flow, foo has been created as EITHER a
reguar file OR a directory and should NOT exist
after "git clean" or "git clean -d", as the case maybe, has been called.
This made it reasonable to replace
"test ! -[df] foo" with "test_path_is_missing foo".

Signed-off-by: Abraham Samuel Adekunle <abrahamadekunle50@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 months agoloose: don't rely on repository global state
Karthik Nayak [Wed, 9 Oct 2024 09:58:59 +0000 (02:58 -0700)] 
loose: don't rely on repository global state

In `loose.c`, we rely on the global variable `the_hash_algo`. As such we
have guarded the file with the 'USE_THE_REPOSITORY_VARIABLE' definition.
Let's derive the hash algorithm from the available repository variable
and remove this guard. This brings us one step closer to removing the
global 'the_repository' variable.

Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 months agorebase-merges: try and use branch names as labels
Nicolas Guichard [Wed, 9 Oct 2024 07:58:20 +0000 (07:58 +0000)] 
rebase-merges: try and use branch names as labels

When interactively rebasing merge commits, the commit message is parsed to
extract a probably meaningful label name. For instance if the merge commit
is “Merge branch 'feature0'”, then the rebase script will have thes lines:
```
label feature0

merge -C $sha feature0 # “Merge branch 'feature0'
```

This heuristic fails in the case of octopus merges or when the merge commit
message is actually unrelated to the parent commits.

An example that combines both is:
```
*---.   967bfa4 (HEAD -> integration) Integration
|\ \ \
| | | * 2135be1 (feature2, feat2) Feature 2
| |_|/
|/| |
| | * c88b01a Feature 1
| |/
|/|
| * 75f3139 (feat0) Feature 0
|/
25c86d0 (main) Initial commit
```
yields the labels Integration, Integration-2 and Integration-3.

Fix this by using a branch name for each merge commit's parent that is the
tip of at least one branch, and falling back to a label derived from the
merge commit message otherwise.
In the example above, the labels become feat0, Integration and feature2.

Signed-off-by: Nicolas Guichard <nicolas@guichard.eu>
Acked-by: Phillip Wood <phillip.wood@dunelm.org.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 months agorebase-update-refs: extract load_branch_decorations
Nicolas Guichard [Wed, 9 Oct 2024 07:58:19 +0000 (07:58 +0000)] 
rebase-update-refs: extract load_branch_decorations

Extract load_branch_decorations from todo_list_add_update_ref_commands so
it can be re-used in make_script_with_merges.

Since it can now be called multiple times, use non-static lists and place
it next to load_ref_decorations to re-use the decoration_loaded guard.

Signed-off-by: Nicolas Guichard <nicolas@guichard.eu>
Acked-by: Phillip Wood <phillip.wood@dunelm.org.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 months agoload_branch_decorations: fix memory leak with non-static filters
Nicolas Guichard [Wed, 9 Oct 2024 07:58:18 +0000 (07:58 +0000)] 
load_branch_decorations: fix memory leak with non-static filters

load_branch_decorations calls normalize_glob_ref on each string of filter's
string_lists. This effectively replaces the potentially non-owning char* of
those items with an owning char*.

Set the strdup_string flag on those string_lists.

This was not caught until now because:
- when passing string_lists already with the strdup_string already set, the
  behaviour was correct
- when passing static string_lists, the new char* remain reachable until
  program exit

Signed-off-by: Nicolas Guichard <nicolas@guichard.eu>
Acked-by: Phillip Wood <phillip.wood@dunelm.org.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 months agodoc: merge-tree: improve example script
Kristoffer Haugsbakk [Wed, 9 Oct 2024 16:53:45 +0000 (18:53 +0200)] 
doc: merge-tree: improve example script

• Provide a commit message in the example command.

  The command will hang since it is waiting for a commit message on
  stdin.  Which is usable but not straightforward enough since this is
  example code.
• Use `||` directly since that is more straightforward than checking the
  last exit status.

  Also use `echo` and `exit` since `die` is not defined.
• Expose variable declarations.

Signed-off-by: Kristoffer Haugsbakk <code@khaugsbakk.name>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 months agogit-config.1: remove value from positional args in unset usage
Josh Heinrichs [Tue, 8 Oct 2024 14:29:20 +0000 (08:29 -0600)] 
git-config.1: remove value from positional args in unset usage

The synopsis for `git config unset` mentions two positional arguments:
`<name>` and `<value>`. While the first argument is correct, the second
is not. Users are expected to provide the value via `--value=<value>`.

Remove the positional argument. The `--value=<value>` option is already
documented correctly, so this is all we need to do to fix the
documentation.

Signed-off-by: Josh Heinrichs <joshiheinrichs@gmail.com>
Reviewed-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 months agofsmonitor: initialize fs event listener before accepting clients
Jeff King [Tue, 8 Oct 2024 08:36:13 +0000 (04:36 -0400)] 
fsmonitor: initialize fs event listener before accepting clients

There's a racy hang in fsmonitor on macOS that we sometimes see in CI.
When we serve a client, what's supposed to happen is:

  1. The client thread calls with_lock__wait_for_cookie() in which we
     create a cookie file and then wait for a pthread_cond event

  2. The filesystem event listener sees the cookie file creation, does
     some internal book-keeping, and then triggers the pthread_cond.

But there's a problem: we start the listener that accepts client threads
before we start the fs event thread. So it's possible for us to accept a
client which creates the cookie file and starts waiting before the fs
event thread is initialized, and we miss those filesystem events
entirely. That leaves the client thread hanging forever.

In CI, the symptom is that t9210 (which is testing scalar, which always
enables fsmonitor under the hood) may hang forever in "scalar clone". It
is waiting on "git fetch" which is waiting on the fsmonitor daemon.

The race happens more frequently under load, but you can trigger it
predictably with a sleep like this, which delays the start of the fs
event thread:

  --- a/compat/fsmonitor/fsm-listen-darwin.c
  +++ b/compat/fsmonitor/fsm-listen-darwin.c
  @@ -510,6 +510,7 @@ void fsm_listen__loop(struct fsmonitor_daemon_state *state)
          FSEventStreamSetDispatchQueue(data->stream, data->dq);
          data->stream_scheduled = 1;

  +       sleep(1);
          if (!FSEventStreamStart(data->stream)) {
                  error(_("Failed to start the FSEventStream"));
                  goto force_error_stop_without_loop;

One solution might be to reverse the order of initialization: start the
fs event thread before we start the thread listening for clients. But
the fsmonitor code explicitly does it in the opposite direction. The fs
event thread wants to refer to the ipc_server_data struct, so we need it
to be initialized first.

A further complication is that we need a signal from the fs event thread
that it is actually ready and listening. And those details happen within
backend-specific fsmonitor code, whereas the initialization is in the
shared code.

So instead, let's use the ipc_server init/start split added in the
previous commit. The generic fsmonitor code will init the ipc_server but
_not_ start it, leaving that to the backend specific code, which now
needs to call ipc_server_start_async() at the right time.

For macOS, that is right after we start the FSEventStream that you can
see in the diff above.

It's not clear to me if Windows suffers from the same problem (and we
simply don't trigger it in CI), or if it is immune. Regardless, the
obvious place to start accepting clients there is right after we've
established the ReadDirectoryChanges watch.

This makes the hangs go away in our macOS CI environment, even when
compiled with the sleep() above.

Helped-by: Koji Nakamaru <koji.nakamaru@gree.net>
Signed-off-by: Jeff King <peff@peff.net>
Acked-by: Koji Nakamaru <koji.nakamaru@gree.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 months agosimple-ipc: split async server initialization and running
Jeff King [Tue, 8 Oct 2024 08:33:47 +0000 (04:33 -0400)] 
simple-ipc: split async server initialization and running

To start an async ipc server, you call ipc_server_run_async(). That
initializes the ipc_server_data object, and starts all of the threads
running, which may immediately start serving clients.

This can create some awkward timing problems, though. In the fsmonitor
daemon (the sole user of the simple-ipc system), we want to create the
ipc server early in the process, which means we may start serving
clients before the rest of the daemon is fully initialized.

To solve this, let's break run_async() into two parts: an initialization
which allocates all data and spawns the threads (without letting them
run), and a start function which actually lets them begin work. Since we
have two simple-ipc implementations, we have to handle this twice:

  - in ipc-unix-socket.c, we have a central listener thread which hands
    connections off to worker threads using a work_available mutex. We
    can hold that mutex after init, and release it when we're ready to
    start.

    We do need an extra "started" flag so that we know whether the main
    thread is holding the mutex or not (e.g., if we prematurely stop the
    server, we want to make sure all of the worker threads are released
    to hear about the shutdown).

  - in ipc-win32.c, we don't have a central mutex. So we'll introduce a
    new startup_barrier mutex, which we'll similarly hold until we're
    ready to let the threads proceed.

    We again need a "started" flag here to make sure that we release the
    barrier mutex when shutting down, so that the sub-threads can
    proceed to the finish.

I've renamed the run_async() function to init_async() to make sure we
catch all callers, since they'll now need to call the matching
start_async().

We could leave run_async() as a wrapper that does both, but there's not
much point. There are only two callers, one of which is fsmonitor, which
will want to actually do work between the two calls. And the other is
just a test-tool wrapper.

For now I've added the start_async() calls in fsmonitor where they would
otherwise have happened, so there should be no behavior change with this
patch.

Signed-off-by: Jeff King <peff@peff.net>
Acked-by: Koji Nakamaru <koji.nakamaru@gree.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 months agoworktree: add test for path handling in linked worktrees
Caleb White [Tue, 8 Oct 2024 03:12:32 +0000 (22:12 -0500)] 
worktree: add test for path handling in linked worktrees

A failure scenario reported in an earlier patch series[1] that several
`git worktree` subcommands failed or misbehaved when invoked from within
linked worktrees that used relative paths.

This adds a test that executes a `worktree prune` command inside both an
internally and an externally linked worktree and asserts that the other
worktree was not pruned.

[1]: https://lore.kernel.org/git/CAPig+cQXFy=xPVpoSq6Wq0pxMRCjS=WbkgdO+3LySPX=q0nPCw@mail.gmail.com/

Reported-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Caleb White <cdwhite3@pm.me>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 months agoworktree: link worktrees with relative paths
Caleb White [Tue, 8 Oct 2024 03:12:31 +0000 (22:12 -0500)] 
worktree: link worktrees with relative paths

Git currently stores absolute paths to both the main repository and
linked worktrees. However, this causes problems when moving repositories
or working in containerized environments where absolute paths differ
between systems. The worktree links break, and users are required to
manually execute `worktree repair` to repair them, leading to workflow
disruptions. Additionally, mapping repositories inside of containerized
environments renders the repository unusable inside the containers, and
this is not repairable as repairing the worktrees inside the containers
will result in them being broken outside the containers.

To address this, this patch makes Git always write relative paths when
linking worktrees. Relative paths increase the resilience of the
worktree links across various systems and environments, particularly
when the worktrees are self-contained inside the main repository (such
as when using a bare repository with worktrees). This improves
portability, workflow efficiency, and reduces overall breakages.

Although Git now writes relative paths, existing repositories with
absolute paths are still supported. There are no breaking changes
to workflows based on absolute paths, ensuring backward compatibility.

At a low level, the changes involve modifying functions in `worktree.c`
and `builtin/worktree.c` to use `relative_path()` when writing the
worktree’s `.git` file and the main repository’s `gitdir` reference.
Instead of hardcoding absolute paths, Git now computes the relative path
between the worktree and the repository, ensuring that these links are
portable. Locations where these respective file are read have also been
updated to properly handle both absolute and relative paths. Generally,
relative paths are always resolved into absolute paths before any
operations or comparisons are performed.

Additionally, `repair_worktrees_after_gitdir_move()` has been introduced
to address the case where both the `<worktree>/.git` and
`<repo>/worktrees/<id>/gitdir` links are broken after the gitdir is
moved (such as during a re-initialization). This function repairs both
sides of the worktree link using the old gitdir path to reestablish the
correct paths after a move.

The `worktree.path` struct member has also been updated to always store
the absolute path of a worktree. This ensures that worktree consumers
never have to worry about trying to resolve the absolute path themselves.

Signed-off-by: Caleb White <cdwhite3@pm.me>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 months agoworktree: refactor infer_backlink() to use *strbuf
Caleb White [Tue, 8 Oct 2024 03:12:30 +0000 (22:12 -0500)] 
worktree: refactor infer_backlink() to use *strbuf

This lays the groundwork for the next patch, which needs the backlink
returned from infer_backlink() as a `strbuf`. It seemed inefficient to
convert from `strbuf` to `char*` and back to `strbuf` again.

This refactors infer_backlink() to return an integer result and use a
pre-allocated `strbuf` for the inferred backlink path, replacing the
previous `char*` return type and improving efficiency.

Signed-off-by: Caleb White <cdwhite3@pm.me>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 months agoMerge branch 'es/worktree-repair-copied' into cw/worktrees-relative
Junio C Hamano [Tue, 8 Oct 2024 18:49:13 +0000 (11:49 -0700)] 
Merge branch 'es/worktree-repair-copied' into cw/worktrees-relative

* es/worktree-repair-copied:
  worktree: repair copied repository and linked worktrees

8 months agols-remote: leakfix for not clearing server_options
Xing Xin [Tue, 8 Oct 2024 03:38:19 +0000 (03:38 +0000)] 
ls-remote: leakfix for not clearing server_options

Ensure `server_options` is properly cleared using `string_list_clear()`
in `builtin/ls-remote.c:cmd_ls_remote`.

Although we cannot yet enable `TEST_PASSES_SANITIZE_LEAK=true` for
`t/t5702-protocol-v2.sh` due to other existing leaks, this fix ensures
that "git-ls-remote" related server options tests pass the sanitize leak
check:

  ...
  ok 12 - server-options are sent when using ls-remote
  ok 13 - server-options from configuration are used by ls-remote
  ...

Signed-off-by: Xing Xin <xingxin.xx@bytedance.com>
Reviewed-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 months agofetch: respect --server-option when fetching multiple remotes
Xing Xin [Tue, 8 Oct 2024 03:38:18 +0000 (03:38 +0000)] 
fetch: respect --server-option when fetching multiple remotes

Fix an issue where server options specified via the command line
(`--server-option` or `-o`) were not sent when fetching from multiple
remotes using Git protocol v2.

To reproduce the issue with a repository containing multiple remotes:

  GIT_TRACE_PACKET=1 git -c protocol.version=2 fetch --server-option=demo --all

Observe that no server options are sent to any remote.

The root cause was identified in `builtin/fetch.c:fetch_multiple`, which
is invoked when fetching from more than one remote. This function forks
a `git-fetch` subprocess for each remote but did not include the
specified server options in the subprocess arguments.

This commit ensures that command-line specified server options are
properly passed to each subprocess. Relevant tests have been added.

Signed-off-by: Xing Xin <xingxin.xx@bytedance.com>
Reviewed-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 months agotransport.c::handshake: make use of server options from remote
Xing Xin [Tue, 8 Oct 2024 03:38:17 +0000 (03:38 +0000)] 
transport.c::handshake: make use of server options from remote

Utilize the `server_options` from the corresponding remote during the
handshake in `transport.c` when Git protocol v2 is detected. This helps
initialize the `server_options` in `transport.h:transport` if no server
options are set for the transport (typically via `--server-option` or
`-o`).

While another potential place to incorporate server options from the
remote is in `transport.c:transport_get`, setting server options for a
transport using a protocol other than v2 could lead to unexpected errors
(see `transport.c:die_if_server_options`).

Relevant tests and documentation have been updated accordingly.

Signed-off-by: Xing Xin <xingxin.xx@bytedance.com>
Reviewed-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 months agoremote: introduce remote.<name>.serverOption configuration
Xing Xin [Tue, 8 Oct 2024 03:38:16 +0000 (03:38 +0000)] 
remote: introduce remote.<name>.serverOption configuration

Currently, server options for Git protocol v2 can only be specified via
the command line option "--server-option" or "-o", which is inconvenient
when users want to specify a list of default options to send. Therefore,
we are introducing a new configuration to hold a list of default server
options, akin to the `push.pushOption` configuration for push options.

Initially, I named the new configuration `fetch.serverOption` to align
with `push.pushOption`. However, after discussing with Patrick, it was
renamed to `remote.<name>.serverOption` as suggested, because:

1. Server options are designed to be server-specific, making it more
   logical to use a per-remote configuration.
2. Using "fetch." prefixed configurations in git-clone or git-ls-remote
   seems out of place and inconsistent in design.

The parsing logic for `remote.<name>.serverOption` also relies on
`transport.c:parse_transport_option`, similar to `push.pushOption`, and
they follow the same priority design:

1. Server options set in lower-priority configuration files (e.g.,
   /etc/gitconfig or $HOME/.gitconfig) can be overridden or unset in
   more specific repository configurations using an empty string.
2. Command-line specified server options take precedence over those from
   the configuration.

Server options from configuration are stored to the corresponding
`remote.h:remote` as a new field `server_options`.  The field will be
utilized in the subsequent commit to help initialize the
`server_options` of `transport.h:transport`.

And documentation have been updated accordingly.

Helped-by: Patrick Steinhardt <ps@pks.im>
Helped-by: Junio C Hamano <gitster@pobox.com>
Reported-by: Liu Zhongbo <liuzhongbo.6666@bytedance.com>
Signed-off-by: Xing Xin <xingxin.xx@bytedance.com>
Reviewed-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 months agotransport: introduce parse_transport_option() method
Xing Xin [Tue, 8 Oct 2024 03:38:15 +0000 (03:38 +0000)] 
transport: introduce parse_transport_option() method

Add the `parse_transport_option()` method to parse the `push.pushOption`
configuration. This method will also be used in the next commit to
handle the new `remote.<name>.serverOption` configuration for setting
server options in Git protocol v2.

Signed-off-by: Xing Xin <xingxin.xx@bytedance.com>
Reviewed-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 months agodocs: fix the `maintain-git` links in `technical/platform-support`
Johannes Schindelin [Mon, 7 Oct 2024 21:49:24 +0000 (21:49 +0000)] 
docs: fix the `maintain-git` links in `technical/platform-support`

These links should point to `.html` files, not to `.txt` ones.

Compare also to 4945f046c7f (api docs: link to html version of
api-trace2, 2022-09-16).

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 months agounpack-trees: detect mismatching number of cache-tree/index entries
Patrick Steinhardt [Mon, 7 Oct 2024 04:38:21 +0000 (06:38 +0200)] 
unpack-trees: detect mismatching number of cache-tree/index entries

Same as the preceding commit, we unconditionally dereference the index's
cache entries depending on the number of cache-tree entries, which can
lead to a segfault when the cache-tree is corrupted. Fix this bug.

This also makes t4058 pass with the leak sanitizer enabled.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 months agocache-tree: detect mismatching number of index entries
Patrick Steinhardt [Mon, 7 Oct 2024 04:38:18 +0000 (06:38 +0200)] 
cache-tree: detect mismatching number of index entries

In t4058 we have some tests that exercise git-read-tree(1) when used
with a tree that contains duplicate entries. While the expectation is
that we fail, we ideally should fail gracefully without a segfault.

But that is not the case: we never check that the number of entries in
the cache-tree is less than or equal to the number of entries in the
index. This can lead to an out-of-bounds read as we unconditionally
access `istate->cache[idx]`, where `idx` is controlled by the number of
cache-tree entries and the current position therein. The result is a
segfault.

Fix this segfault by adding a sanity check for the number of index
entries before dereferencing them.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 months agocache-tree: refactor verification to return error codes
Patrick Steinhardt [Mon, 7 Oct 2024 04:38:15 +0000 (06:38 +0200)] 
cache-tree: refactor verification to return error codes

The function `cache_tree_verify()` will `BUG()` whenever it finds that
the cache-tree extension of the index is corrupt. The function is thus
inherently untestable because the resulting call to `abort()` will be
detected by our testing framework and labelled an error. And rightfully
so: it shouldn't ever be possible to hit bugs, as they should indicate a
programming error rather than corruption of on-disk state.

Refactor the function to instead return error codes. This also ensures
that the function can be used e.g. by git-fsck(1) without the whole
process dying. Furthermore, this refactoring plugs some memory leaks
when returning early by creating a common exit path.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 months agoGit 2.47 v2.47.0
Junio C Hamano [Sun, 6 Oct 2024 22:56:06 +0000 (15:56 -0700)] 
Git 2.47

Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 months agoMerge tag 'l10n-2.47.0-rnd2' of https://github.com/git-l10n/git-po
Junio C Hamano [Sun, 6 Oct 2024 18:14:12 +0000 (11:14 -0700)] 
Merge tag 'l10n-2.47.0-rnd2' of https://github.com/git-l10n/git-po

l10n-2.47.0-rnd2

* tag 'l10n-2.47.0-rnd2' of https://github.com/git-l10n/git-po:
  l10n: Update German translation
  l10n: bg.po: Updated Bulgarian translation (5772t)
  l10n: vi: Updated translation for 2.47
  l10n: zh_TW: Git 2.47
  l10n: new lead for Catalan translation
  l10n: Update Catalan translation
  l10n: fr.po: 2.47.0
  l10n: zh_CN: updated translation for 2.47
  l10n: po-id for 2.47
  l10n: tr: Update Turkish translations for 2.47.0
  l10n: sv.po: Update Swedish translation

8 months agoMerge branch 'l10n-de-2.47' of github.com:ralfth/git
Jiang Xin [Sun, 6 Oct 2024 04:06:21 +0000 (12:06 +0800)] 
Merge branch 'l10n-de-2.47' of github.com:ralfth/git

* 'l10n-de-2.47' of github.com:ralfth/git:
  l10n: Update German translation

8 months agoMerge branch 'master' of github.com:alshopov/git-po
Jiang Xin [Sun, 6 Oct 2024 04:04:11 +0000 (12:04 +0800)] 
Merge branch 'master' of github.com:alshopov/git-po

* 'master' of github.com:alshopov/git-po:
  l10n: bg.po: Updated Bulgarian translation (5772t)

8 months agoMerge branch 'catalan-247' of github.com:Softcatala/git-po
Jiang Xin [Sun, 6 Oct 2024 04:03:46 +0000 (12:03 +0800)] 
Merge branch 'catalan-247' of github.com:Softcatala/git-po

* 'catalan-247' of github.com:Softcatala/git-po:
  l10n: Update Catalan translation

8 months agoMerge branch 'new-catalan-maintainer' of github.com:Softcatala/git-po
Jiang Xin [Sun, 6 Oct 2024 04:03:08 +0000 (12:03 +0800)] 
Merge branch 'new-catalan-maintainer' of github.com:Softcatala/git-po

* 'new-catalan-maintainer' of github.com:Softcatala/git-po:
  l10n: new lead for Catalan translation

8 months agoMerge branch 'l10n/zh-TW/2024-10-05' of github.com:l10n-tw/git-po
Jiang Xin [Sun, 6 Oct 2024 03:39:29 +0000 (11:39 +0800)] 
Merge branch 'l10n/zh-TW/2024-10-05' of github.com:l10n-tw/git-po

* 'l10n/zh-TW/2024-10-05' of github.com:l10n-tw/git-po:
  l10n: zh_TW: Git 2.47

8 months agoMerge branch 'tl/zh_CN_2.47.0_rnd' of github.com:dyrone/git
Jiang Xin [Sun, 6 Oct 2024 03:39:03 +0000 (11:39 +0800)] 
Merge branch 'tl/zh_CN_2.47.0_rnd' of github.com:dyrone/git

* 'tl/zh_CN_2.47.0_rnd' of github.com:dyrone/git:
  l10n: zh_CN: updated translation for 2.47

8 months agoMerge branch 'master' of github.com:nafmo/git-l10n-sv
Jiang Xin [Sun, 6 Oct 2024 03:38:15 +0000 (11:38 +0800)] 
Merge branch 'master' of github.com:nafmo/git-l10n-sv

* 'master' of github.com:nafmo/git-l10n-sv:
  l10n: sv.po: Update Swedish translation

8 months agoMerge branch 'fr_2.47.0_rnd1' of github.com:jnavila/git
Jiang Xin [Sun, 6 Oct 2024 03:37:56 +0000 (11:37 +0800)] 
Merge branch 'fr_2.47.0_rnd1' of github.com:jnavila/git

* 'fr_2.47.0_rnd1' of github.com:jnavila/git:
  l10n: fr.po: 2.47.0

8 months agoMerge branch 'vi-2.47' of github.com:Nekosha/git-po
Jiang Xin [Sun, 6 Oct 2024 03:35:59 +0000 (11:35 +0800)] 
Merge branch 'vi-2.47' of github.com:Nekosha/git-po

* 'vi-2.47' of github.com:Nekosha/git-po:
  l10n: vi: Updated translation for 2.47

8 months agoMerge branch 'po-id' of github.com:bagasme/git-po
Jiang Xin [Sun, 6 Oct 2024 03:35:06 +0000 (11:35 +0800)] 
Merge branch 'po-id' of github.com:bagasme/git-po

* 'po-id' of github.com:bagasme/git-po:
  l10n: po-id for 2.47

8 months agol10n: Update German translation
Ralf Thielow [Sat, 5 Oct 2024 17:28:19 +0000 (19:28 +0200)] 
l10n: Update German translation

Reviewed-by: Matthias Rüster <matthias.ruester@gmail.com>
Signed-off-by: Ralf Thielow <ralf.thielow@gmail.com>
8 months agol10n: bg.po: Updated Bulgarian translation (5772t)
Alexander Shopov [Sat, 5 Oct 2024 11:16:48 +0000 (13:16 +0200)] 
l10n: bg.po: Updated Bulgarian translation (5772t)

Signed-off-by: Alexander Shopov <ash@kambanaria.org>
8 months agol10n: vi: Updated translation for 2.47
Vũ Tiến Hưng [Thu, 26 Sep 2024 07:41:59 +0000 (14:41 +0700)] 
l10n: vi: Updated translation for 2.47

Signed-off-by: Vũ Tiến Hưng <newcomerminecraft@gmail.com>
8 months agol10n: zh_TW: Git 2.47
Yi-Jyun Pan [Sat, 5 Oct 2024 03:36:12 +0000 (11:36 +0800)] 
l10n: zh_TW: Git 2.47

Co-authored-by: Lumynous <lumynou5.tw@gmail.com>
Signed-off-by: Yi-Jyun Pan <pan93412@gmail.com>
8 months agol10n: new lead for Catalan translation
Jordi Mas [Sat, 5 Oct 2024 07:26:43 +0000 (09:26 +0200)] 
l10n: new lead for Catalan translation

Signed-off-by: Jordi Mas <jmas@softcatala.org>
8 months agol10n: Update Catalan translation
Jordi Mas [Sat, 5 Oct 2024 07:19:18 +0000 (09:19 +0200)] 
l10n: Update Catalan translation

Signed-off-by: Jordi Mas <jmas@softcatala.org>
8 months agoMostly there for 2.47 final
Junio C Hamano [Fri, 4 Oct 2024 21:21:16 +0000 (14:21 -0700)] 
Mostly there for 2.47 final

Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 months agoMerge branch 'kn/osx-fsmonitor-with-submodules-fix'
Junio C Hamano [Fri, 4 Oct 2024 21:21:43 +0000 (14:21 -0700)] 
Merge branch 'kn/osx-fsmonitor-with-submodules-fix'

macOS with fsmonitor daemon can hang forever when a submodule is
involved, which has been corrected.

* kn/osx-fsmonitor-with-submodules-fix:
  fsmonitor OSX: fix hangs for submodules

8 months agoMerge branch 'ak/doc-typofix'
Junio C Hamano [Fri, 4 Oct 2024 21:21:43 +0000 (14:21 -0700)] 
Merge branch 'ak/doc-typofix'

Typofixes.

* ak/doc-typofix:
  Documentation: fix typos
  Documentation/config: fix typos

8 months agoMerge branch 'tb/weak-sha1-for-tail-sum'
Junio C Hamano [Fri, 4 Oct 2024 21:21:42 +0000 (14:21 -0700)] 
Merge branch 'tb/weak-sha1-for-tail-sum'

Build fix.

* tb/weak-sha1-for-tail-sum:
  hash.h: set NEEDS_CLONE_HELPER_UNSAFE in fallback mode

8 months agoMerge branch 'ps/reftable-concurrent-writes'
Junio C Hamano [Fri, 4 Oct 2024 21:21:41 +0000 (14:21 -0700)] 
Merge branch 'ps/reftable-concurrent-writes'

Test fix.

* ps/reftable-concurrent-writes:
  t0610: work around flaky test with concurrent writers

8 months agoMerge branch 'mh/w-unused-fix'
Junio C Hamano [Fri, 4 Oct 2024 21:21:41 +0000 (14:21 -0700)] 
Merge branch 'mh/w-unused-fix'

Buildfix.

* mh/w-unused-fix:
  utf8.h: squelch unused-parameter warnings with NO_ICONV

8 months agoMerge branch 'rs/archive-with-attr-pathspec-fix'
Junio C Hamano [Fri, 4 Oct 2024 21:21:40 +0000 (14:21 -0700)] 
Merge branch 'rs/archive-with-attr-pathspec-fix'

Message update.

* rs/archive-with-attr-pathspec-fix:
  archive: fix misleading error message

8 months agoMerge branch 'ak/typofix-2.46-maint'
Junio C Hamano [Fri, 4 Oct 2024 21:21:40 +0000 (14:21 -0700)] 
Merge branch 'ak/typofix-2.46-maint'

Typofixes.

* ak/typofix-2.46-maint:
  perl: fix a typo
  mergetool: fix a typo
  reftable: fix a typo
  trace2: fix typos

8 months agol10n: fr.po: 2.47.0
Jean-Noël Avila [Fri, 27 Sep 2024 20:05:44 +0000 (22:05 +0200)] 
l10n: fr.po: 2.47.0

Signed-off-by: Jean-Noël Avila <jn.avila@free.fr>
8 months agol10n: zh_CN: updated translation for 2.47
Teng Long [Fri, 4 Oct 2024 18:56:55 +0000 (02:56 +0800)] 
l10n: zh_CN: updated translation for 2.47

Signed-off-by: Teng Long <dyroneteng@gmail.com>
8 months agoA bit more after 2.47-rc1
Junio C Hamano [Fri, 4 Oct 2024 17:13:51 +0000 (10:13 -0700)] 
A bit more after 2.47-rc1

Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 months agoMerge branch 'ds/read-cache-mempool-leakfix'
Junio C Hamano [Fri, 4 Oct 2024 17:14:07 +0000 (10:14 -0700)] 
Merge branch 'ds/read-cache-mempool-leakfix'

Leakfix.

* ds/read-cache-mempool-leakfix:
  read-cache: free threaded memory pool

8 months agoMerge branch 'jc/doc-discarding-stalled-topics'
Junio C Hamano [Fri, 4 Oct 2024 17:14:06 +0000 (10:14 -0700)] 
Merge branch 'jc/doc-discarding-stalled-topics'

Document that inactive topics are subject to be discarded.

* jc/doc-discarding-stalled-topics:
  howto-maintain-git: discarding inactive topics

8 months agoMerge branch 'jk/test-lsan-improvements'
Junio C Hamano [Fri, 4 Oct 2024 17:14:06 +0000 (10:14 -0700)] 
Merge branch 'jk/test-lsan-improvements'

Usability improvements for running tests in leak-checking mode.

* jk/test-lsan-improvements:
  test-lib: check for leak logs after every test
  test-lib: show leak-sanitizer logs on --immediate failure
  test-lib: stop showing old leak logs

8 months agot0610: work around flaky test with concurrent writers
Patrick Steinhardt [Fri, 4 Oct 2024 15:32:16 +0000 (17:32 +0200)] 
t0610: work around flaky test with concurrent writers

In 6241ce2170 (refs/reftable: reload locked stack when preparing
transaction, 2024-09-24) we have introduced a new test that exercises
how the reftable backend behaves with many concurrent writers all racing
with each other. This test was introduced after a couple of fixes in
this context that should make concurrent writes behave gracefully. As it
turns out though, Windows systems do not yet handle concurrent writes
properly, as we've got two reports for Cygwin and MinGW failing in this
newly added test.

The root cause of this is how we update the "tables.list" file: when
writing a new stack of tables we first write the data into a lockfile
and then rename that file into place. But Windows forbids us from doing
that rename when the target path is open for reading by another process.
And as the test races both readers and writers with each other we are
quite likely to hit this edge case.

This is not a regression: the logic didn't work before the mentioned
commit, and after the commit it performs well on Linux and macOS, and
the situation on Windows should have at least improved a bit. But the
test shows that we need to put more thought into how to make this work
properly there.

Work around the issue by disabling the test on Windows for now. While at
it, increase the locking timeout to address reported timeouts when using
either the address or memory sanitizer, which also tend to significantly
extend the runtime of this test.

This should be revisited after Git v2.47 is out.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 months agofsmonitor OSX: fix hangs for submodules
Koji Nakamaru [Fri, 4 Oct 2024 00:07:13 +0000 (00:07 +0000)] 
fsmonitor OSX: fix hangs for submodules

fsmonitor_classify_path_absolute() expects state->path_gitdir_watch.buf
has no trailing '/' or '.' For a submodule, fsmonitor_run_daemon() sets
the value with trailing "/." (as repo_get_git_dir(the_repository) on
Darwin returns ".") so that fsmonitor_classify_path_absolute() returns
IS_OUTSIDE_CONE.

In this case, fsevent_callback() doesn't update cookie_list so that
fsmonitor_publish() does nothing and with_lock__mark_cookies_seen() is
not invoked.

As with_lock__wait_for_cookie() infinitely waits for state->cookies_cond
that with_lock__mark_cookies_seen() should unlock, the whole daemon
hangs.

Remove trailing "/." from state->path_gitdir_watch.buf for submodules
and add a corresponding test in t7527-builtin-fsmonitor.sh. The test is
disabled for MINGW because hangs treated with this patch occur only for
Darwin and there is no simple way to terminate the win32 fsmonitor
daemon that hangs.

Suggested-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Suggested-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Koji Nakamaru <koji.nakamaru@gree.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 months agoreftable/basics: fix segfault when growing `names` array fails
Patrick Steinhardt [Fri, 4 Oct 2024 04:58:53 +0000 (06:58 +0200)] 
reftable/basics: fix segfault when growing `names` array fails

When growing the `names` array fails we would end up with a `NULL`
pointer. This causes two problems:

  - We would run into a segfault because we try to free names that we
    have assigned to the array already.

  - We lose track of the old array and cannot free its contents.

Fix this issue by using a temporary variable. Like this we do not
clobber the old array that we tried to reallocate, which will remain
valid when a call to realloc(3P) fails.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 months agol10n: po-id for 2.47
Bagas Sanjaya [Tue, 24 Sep 2024 02:52:25 +0000 (09:52 +0700)] 
l10n: po-id for 2.47

Update following components:

  * add-patch.c
  * apply.c
  * builtin/check-mailmap.c
  * builtin/checkout.c
  * builtin/commit.c
  * builtin/config.c
  * builtin/fetch.c
  * builtin/gc.c
  * builtin/multi-pack-index.c
  * builtin/refs.c
  * builtin/show-refs.c
  * builtin/sparse-checkout.c
  * builtin/submodule--helper.c
  * loose.c
  * midx-write.c
  * midx.c
  * object-file.c
  * ref-filter.c
  * refs/file-backend.c
  * scalar.c
  * setup.c
  * git-send-email.perl

Translate following new components:

  * t/unit-tests/unit-tests.c

Signed-off-by: Bagas Sanjaya <bagasdotme@gmail.com>
8 months agodiff: store graph prefix buf in git_graph struct
Jeff King [Thu, 3 Oct 2024 21:13:17 +0000 (17:13 -0400)] 
diff: store graph prefix buf in git_graph struct

The diffopt output_prefix interface makes it the callback's job to
handle ownership of the memory it returns, keeping it valid while
callers are using it and then eventually freeing it when we are done
diffing.

In diff_output_prefix_callback() we handle this with a static strbuf,
effectively "leaking" it when the diff is done (but not triggering any
leak detectors because it's technically still reachable). This has not
been a big problem in practice, but it is a problem for libification:
two diffs running in the same process could stomp on each other's prefix
buffers.

Since we only need the strbuf when we are formatting graph padding, we
can give ownership of the strbuf to the git_graph struct, letting us
free it when that struct is no longer in use.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 months agodiff: return line_prefix directly when possible
Jeff King [Thu, 3 Oct 2024 21:11:31 +0000 (17:11 -0400)] 
diff: return line_prefix directly when possible

We may point our output_prefix callback to diff_output_prefix_callback()
in any of these cases:

  1. we have a user-provided line_prefix

  2. we have a graph prefix to show

  3. both (1) and (2)

The function combines the available elements into a strbuf and returns
its pointer.

In the case that we just have the line_prefix, though, there is no need
for the strbuf. We can return the string directly.

This is a minor optimization by itself, but also will allow us to clean
up some memory ownership issues on top.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 months agodiff: return const char from output_prefix callback
Jeff King [Thu, 3 Oct 2024 21:09:24 +0000 (17:09 -0400)] 
diff: return const char from output_prefix callback

The diff_options structure has an output_prefix callback for returning a
prefix string, but it does so by returning a pointer to a strbuf.

This makes the interface awkward. There's no reason the callback should
need to use a strbuf, and it creates questions about whether the
ownership of the resulting buffer should be transferred to the caller
(it should not be, but a recent attempt to clean up this code led to a
double-free in some cases).

The one advantage we get is that the strbuf contains a ptr/len pair, so
we could in theory have a prefix with embedded NULs. But we can observe
that none of the existing callbacks would ever produce such a NUL (they
are usually just indentation or graph symbols, and even the
"--line-prefix" option takes a NUL-terminated string).

And anyway, only one caller (the one in log_tree_diff_flush) actually
looks at the strbuf length. In every other case we use a helper function
which discards the length and just returns the NUL-terminated string.

So let's just have the callback return a "const char *" pointer. It's up
to the callbacks themselves if they want to use a strbuf under the hood.
And now the caller in log_tree_diff_flush() can just use the helper
function along with everybody else. That lets us even simplify out the
function pointer check, since the helper returns an empty string
(technically this does mean we'll sometimes issue an empty fputs() call,
but I don't think this code path is hot enough to care about that).

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 months agodiff: drop line_prefix_length field
Jeff King [Thu, 3 Oct 2024 21:06:54 +0000 (17:06 -0400)] 
diff: drop line_prefix_length field

The diff_options structure holds a line_prefix string and an associated
length. But the length is always just the strlen() of the NUL-terminated
string. Let's simplify the code by just storing the string pointer and
assuming it is NUL-terminated when we use it.

This will cause us to compute the string length in a few extra spots,
but I don't think any of these are particularly hot code paths.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 months agoline-log: use diff_line_prefix() instead of custom helper
Jeff King [Thu, 3 Oct 2024 21:06:27 +0000 (17:06 -0400)] 
line-log: use diff_line_prefix() instead of custom helper

Our local output_prefix() is exactly the same as the public
diff_line_prefix() function. Let's just use that one, saving us a little
bit of code.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 months agoperl: fix a typo
Andrew Kreimer [Wed, 2 Oct 2024 22:38:16 +0000 (01:38 +0300)] 
perl: 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>
8 months agomergetool: fix a typo
Andrew Kreimer [Wed, 2 Oct 2024 22:38:14 +0000 (01:38 +0300)] 
mergetool: 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>