Commit Graph

75205 Commits

Author SHA1 Message Date
Xing Xin
0f490d270a 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>
2024-10-08 10:22:10 -07:00
Xing Xin
148bc7bf4b 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>
2024-10-08 10:22:09 -07:00
Xing Xin
094f78a16a transport.c:🤝 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>
2024-10-08 10:22:08 -07:00
Xing Xin
72da5cfb1c 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>
2024-10-08 10:22:07 -07:00
Xing Xin
06708ce180 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>
2024-10-08 10:22:06 -07:00
Johannes Schindelin
4154ed4108 docs: fix the maintain-git links in technical/platform-support
These links should point to `.html` files, not to `.txt` ones.

Compare also to 4945f046c7 (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>
2024-10-07 15:34:16 -07:00
Patrick Steinhardt
ecb5c4318c 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>
2024-10-07 15:08:11 -07:00
Patrick Steinhardt
2be7fc012e 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>
2024-10-07 15:08:11 -07:00
Patrick Steinhardt
9f119599a6 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>
2024-10-07 15:08:11 -07:00
Junio C Hamano
777489f9e0 Git 2.47
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-10-06 15:56:06 -07:00
Junio C Hamano
5c97f7ba5c l10n-2.47.0-rnd2
-----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCAAdFiEE37vMEzKDqYvVxs51k24VDd1FMtUFAmcCD90ACgkQk24VDd1F
 MtVEzw//Q5cfCdENqI3+sgkY6vYmpaO4xhGsjDPXz9BB7w/gAhQ63s4ZcppL38bG
 MOsHfRRpyh2wNoMN+apwAqv6huYIhQdrfaI7HjSRiA6RiQXxEFhNdIr4dqF+RlV5
 wwfQ3ePFtHmQg+Ys6KkZOBVDgWjoX8IbRmsZJGIdA/30z9jeQtgwm76vlIA/M0ll
 UbJz+L2TRjngei6IiHKb8k+3N6ERrsh9yELsVVDeBks6XjCZ4acLqEgcCzIWMXDS
 dLse7is2J4momeBpCr4maHVZyoFBFbNHfqoxqEgwIq80TZSltPo/KUW/jX3Vfq+0
 2pBH8CWsetwA0dT7wfLFDY01IAgs6nvFsI/Ahe1vk0H4Nne0/PM9OTOj8+EiTKtr
 biWx968Xy/7szZT8v1iZuhA9Ku1DdUiIpH1ybqNMVzzMCBG8UzZaGS90bCuZEg4A
 GOGPH5KtutAyK/FdRGqVVkLBT2KBQvmDXbdWCDR9Ct82mXRaDQJ7QW+6ucbH7OJB
 X9YgiakCmNaoWMaLl4BhOHoX2UESk+FzLudbltU4QmFwHPr7tV9jKEz3H8QWaMLQ
 lB3mACJ1ks0CZmq/kTwrV3s0rOT22YiNLktpYjVN0Id7vEFLWc0nBq4DjqX4VI67
 l6s25Ugj893/9K93XRFtYLlow4jdRCof6UE+lqtXXAwSR6YpBUQ=
 =LYel
 -----END PGP SIGNATURE-----

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
2024-10-06 11:14:12 -07:00
Jiang Xin
81e7bd6151 Merge branch 'l10n-de-2.47' of github.com:ralfth/git
* 'l10n-de-2.47' of github.com:ralfth/git:
  l10n: Update German translation
2024-10-06 12:06:21 +08:00
Jiang Xin
dde6096b16 Merge branch 'master' of github.com:alshopov/git-po
* 'master' of github.com:alshopov/git-po:
  l10n: bg.po: Updated Bulgarian translation (5772t)
2024-10-06 12:04:11 +08:00
Jiang Xin
93d2fa651f Merge branch 'catalan-247' of github.com:Softcatala/git-po
* 'catalan-247' of github.com:Softcatala/git-po:
  l10n: Update Catalan translation
2024-10-06 12:03:46 +08:00
Jiang Xin
be0bd9669d 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
2024-10-06 12:03:08 +08:00
Jiang Xin
498f8cb54c 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
2024-10-06 11:39:29 +08:00
Jiang Xin
c1b5fb0f01 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
2024-10-06 11:39:03 +08:00
Jiang Xin
1ff21bff12 Merge branch 'master' of github.com:nafmo/git-l10n-sv
* 'master' of github.com:nafmo/git-l10n-sv:
  l10n: sv.po: Update Swedish translation
2024-10-06 11:38:15 +08:00
Jiang Xin
fc49119c03 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
2024-10-06 11:37:56 +08:00
Jiang Xin
3a19f2d4fc 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
2024-10-06 11:35:59 +08:00
Jiang Xin
770ea7bee7 Merge branch 'po-id' of github.com:bagasme/git-po
* 'po-id' of github.com:bagasme/git-po:
  l10n: po-id for 2.47
2024-10-06 11:35:06 +08:00
Ralf Thielow
f4110efbc3 l10n: Update German translation
Reviewed-by: Matthias Rüster <matthias.ruester@gmail.com>
Signed-off-by: Ralf Thielow <ralf.thielow@gmail.com>
2024-10-05 19:28:19 +02:00
Alexander Shopov
d6aa1da141 l10n: bg.po: Updated Bulgarian translation (5772t)
Signed-off-by: Alexander Shopov <ash@kambanaria.org>
2024-10-05 13:21:30 +02:00
Vũ Tiến Hưng
365a7ed9bd l10n: vi: Updated translation for 2.47
Signed-off-by: Vũ Tiến Hưng <newcomerminecraft@gmail.com>
2024-10-05 17:23:48 +07:00
Yi-Jyun Pan
507b364f44
l10n: zh_TW: Git 2.47
Co-authored-by: Lumynous <lumynou5.tw@gmail.com>
Signed-off-by: Yi-Jyun Pan <pan93412@gmail.com>
2024-10-05 15:47:12 +08:00
Jordi Mas
52d4a65070 l10n: new lead for Catalan translation
Signed-off-by: Jordi Mas <jmas@softcatala.org>
2024-10-05 09:26:43 +02:00
Jordi Mas
cd0ef8b6e3 l10n: Update Catalan translation
Signed-off-by: Jordi Mas <jmas@softcatala.org>
2024-10-05 09:19:18 +02:00
Junio C Hamano
90fe3800b9 Mostly there for 2.47 final
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-10-04 14:21:44 -07:00
Junio C Hamano
2ab53b59ef 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
2024-10-04 14:21:43 -07:00
Junio C Hamano
bffc417e7c Merge branch 'ak/doc-typofix'
Typofixes.

* ak/doc-typofix:
  Documentation: fix typos
  Documentation/config: fix typos
2024-10-04 14:21:43 -07:00
Junio C Hamano
68ac04ad85 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
2024-10-04 14:21:42 -07:00
Junio C Hamano
b1c6ed40cd Merge branch 'ps/reftable-concurrent-writes'
Test fix.

* ps/reftable-concurrent-writes:
  t0610: work around flaky test with concurrent writers
2024-10-04 14:21:42 -07:00
Junio C Hamano
d30c2c4c53 Merge branch 'mh/w-unused-fix'
Buildfix.

* mh/w-unused-fix:
  utf8.h: squelch unused-parameter warnings with NO_ICONV
2024-10-04 14:21:41 -07:00
Junio C Hamano
12841c449c Merge branch 'rs/archive-with-attr-pathspec-fix'
Message update.

* rs/archive-with-attr-pathspec-fix:
  archive: fix misleading error message
2024-10-04 14:21:40 -07:00
Junio C Hamano
4861bbf85a 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
2024-10-04 14:21:40 -07:00
Jean-Noël Avila
5187f2b738 l10n: fr.po: 2.47.0
Signed-off-by: Jean-Noël Avila <jn.avila@free.fr>
2024-10-04 23:04:55 +02:00
Teng Long
5d5cd454e9 l10n: zh_CN: updated translation for 2.47
Signed-off-by: Teng Long <dyroneteng@gmail.com>
2024-10-05 03:32:47 +08:00
Junio C Hamano
8895aca996 A bit more after 2.47-rc1
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-10-04 10:14:07 -07:00
Junio C Hamano
b4efdfe165 Merge branch 'ds/read-cache-mempool-leakfix'
Leakfix.

* ds/read-cache-mempool-leakfix:
  read-cache: free threaded memory pool
2024-10-04 10:14:07 -07:00
Junio C Hamano
b9b995e371 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
2024-10-04 10:14:07 -07:00
Junio C Hamano
441e0df980 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
2024-10-04 10:14:06 -07:00
Patrick Steinhardt
7355574a22 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>
2024-10-04 09:34:47 -07:00
Koji Nakamaru
435a6900d2 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>
2024-10-04 08:01:27 -07:00
Patrick Steinhardt
2179b5c831 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>
2024-10-04 07:59:31 -07:00
Bagas Sanjaya
cc64e172c4 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>
2024-10-04 08:55:32 +07:00
Jeff King
1164e270b5 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>
2024-10-03 14:22:22 -07:00
Jeff King
19752d9c91 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>
2024-10-03 14:22:22 -07:00
Jeff King
436728fe9d 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>
2024-10-03 14:22:22 -07:00
Jeff King
2011bb4f34 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>
2024-10-03 14:22:21 -07:00
Jeff King
8aeff2c287 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>
2024-10-03 14:22:21 -07:00