]> git.ipfire.org Git - thirdparty/git.git/log
thirdparty/git.git
9 months agoci: remove 'Upload failed tests' directories' step from linux32 jobs
Junio C Hamano [Mon, 9 Sep 2024 23:00:20 +0000 (16:00 -0700)] 
ci: remove 'Upload failed tests' directories' step from linux32 jobs

Linux32 jobs seem to be getting:

    Error: This request has been automatically failed because it uses a
    deprecated version of `actions/upload-artifact: v1`. Learn more:
    https://github.blog/changelog/2024-02-13-deprecation-notice-v1-and-v2-of-the-artifact-actions/

before doing anything useful.  For now, disable the step.

Ever since actions/upload-artifact@v1 got disabled, mentioning the
offending version of it seems to stop anything from happening.  At
least this should run the same build and test.

See

    https://github.com/git/git/actions/runs/10780030750/job/29894867249

for example.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 months agoA bit more topics for 2.46.x maintenance track
Junio C Hamano [Mon, 26 Aug 2024 18:13:19 +0000 (11:13 -0700)] 
A bit more topics for 2.46.x maintenance track

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

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

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

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

Unit test simplification.

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

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

Follow-up on 2.45.1 regression fix.

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

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

Doc update.

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

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

Code clean-up.

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

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

Leakfix.

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

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

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

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

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

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

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

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

Docfix.

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

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

Leakfix.

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

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

Leakfix.

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

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

Remove leftover debugging cruft from a test script.

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

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

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

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

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

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

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

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

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

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

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

Sync with Windows+VS build jobs used at CI.

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

10 months agoci(win+VS): download the vcpkg artifacts using a dedicated GitHub Action
Johannes Schindelin [Tue, 20 Aug 2024 14:31:10 +0000 (14:31 +0000)] 
ci(win+VS): download the vcpkg artifacts using a dedicated GitHub Action

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

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

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

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

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

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 months agoPrepare for 2.46.1
Junio C Hamano [Wed, 14 Aug 2024 22:02:29 +0000 (15:02 -0700)] 
Prepare for 2.46.1

Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 months agoMerge branch 'ps/p4-tests-updates' into maint-2.46
Junio C Hamano [Fri, 16 Aug 2024 19:50:56 +0000 (12:50 -0700)] 
Merge branch 'ps/p4-tests-updates' into maint-2.46

Perforce tests have been updated.
cf. <na5mwletzpnacietbc7pzqcgb622mvrwgrkjgjosysz3gvjcso@gzxxi7d7icr7>

* ps/p4-tests-updates:
  t98xx: mark Perforce tests as memory-leak free
  ci: update Perforce version to r23.2
  t98xx: fix Perforce tests with p4d r23 and newer

10 months agoMerge branch 'ks/unit-test-comment-typofix' into maint-2.46
Junio C Hamano [Fri, 16 Aug 2024 19:50:56 +0000 (12:50 -0700)] 
Merge branch 'ks/unit-test-comment-typofix' into maint-2.46

Typofix.

* ks/unit-test-comment-typofix:
  unit-tests/test-lib: fix typo in check_pointer_eq() description

10 months agoMerge branch 'dh/encoding-trace-optim' into maint-2.46
Junio C Hamano [Fri, 16 Aug 2024 19:50:55 +0000 (12:50 -0700)] 
Merge branch 'dh/encoding-trace-optim' into maint-2.46

An expensive operation to prepare tracing was done in re-encoding
code path even when the tracing was not requested, which has been
corrected.

* dh/encoding-trace-optim:
  convert: return early when not tracing

10 months agoMerge branch 'dd/notes-empty-no-edit-by-default' into maint-2.46
Junio C Hamano [Fri, 16 Aug 2024 19:50:55 +0000 (12:50 -0700)] 
Merge branch 'dd/notes-empty-no-edit-by-default' into maint-2.46

"git notes add -m '' --allow-empty" and friends that take prepared
data to create notes should not invoke an editor, but it started
doing so since Git 2.42, which has been corrected.

* dd/notes-empty-no-edit-by-default:
  notes: do not trigger editor when adding an empty note

10 months agoMerge branch 'jc/doc-rebase-fuzz-vs-offset-fix' into maint-2.46
Junio C Hamano [Fri, 16 Aug 2024 19:50:54 +0000 (12:50 -0700)] 
Merge branch 'jc/doc-rebase-fuzz-vs-offset-fix' into maint-2.46

"git rebase --help" referred to "offset" (the difference between
the location a change was taken from and the change gets replaced)
incorrectly and called it "fuzz", which has been corrected.

* jc/doc-rebase-fuzz-vs-offset-fix:
  doc: difference in location to apply is "offset", not "fuzz"

10 months agoMerge branch 'tn/doc-commit-fix' into maint-2.46
Junio C Hamano [Fri, 16 Aug 2024 19:50:54 +0000 (12:50 -0700)] 
Merge branch 'tn/doc-commit-fix' into maint-2.46

Docfix.

* tn/doc-commit-fix:
  doc: remove dangling closing parenthesis

10 months agoMerge branch 'pw/add-patch-with-suppress-blank-empty' into maint-2.46
Junio C Hamano [Fri, 16 Aug 2024 19:50:53 +0000 (12:50 -0700)] 
Merge branch 'pw/add-patch-with-suppress-blank-empty' into maint-2.46

"git add -p" by users with diff.suppressBlankEmpty set to true
failed to parse the patch that represents an unmodified empty line
with an empty line (not a line with a single space on it), which
has been corrected.

* pw/add-patch-with-suppress-blank-empty:
  add-patch: use normalize_marker() when recounting edited hunk
  add-patch: handle splitting hunks with diff.suppressBlankEmpty

10 months agoMerge branch 'jt/doc-post-receive-hook-update' into maint-2.46
Junio C Hamano [Fri, 16 Aug 2024 19:50:53 +0000 (12:50 -0700)] 
Merge branch 'jt/doc-post-receive-hook-update' into maint-2.46

Doc update.

* jt/doc-post-receive-hook-update:
  doc: clarify post-receive hook behavior

10 months agoMerge branch 'jc/how-to-maintain-updates' (early part) into maint-2.46
Junio C Hamano [Fri, 16 Aug 2024 19:50:52 +0000 (12:50 -0700)] 
Merge branch 'jc/how-to-maintain-updates' (early part) into maint-2.46

* 'jc/how-to-maintain-updates' (early part):
  howto-maintain: update daily tasks
  howto-maintain: cover a whole development cycle

10 months agoMerge branch 'jc/doc-one-shot-export-with-shell-func' into maint-2.46
Junio C Hamano [Fri, 16 Aug 2024 19:50:51 +0000 (12:50 -0700)] 
Merge branch 'jc/doc-one-shot-export-with-shell-func' into maint-2.46

It has been documented that we avoid "VAR=VAL shell_func" and why.

* jc/doc-one-shot-export-with-shell-func:
  CodingGuidelines: document a shell that "fails" "VAR=VAL shell_func"

10 months agoMerge branch 'jc/checkout-no-op-switch-errors' into maint-2.46
Junio C Hamano [Fri, 16 Aug 2024 19:50:51 +0000 (12:50 -0700)] 
Merge branch 'jc/checkout-no-op-switch-errors' into maint-2.46

"git checkout --ours" (no other arguments) complained that the
option is incompatible with branch switching, which is technically
correct, but found confusing by some users.  It now says that the
user needs to give pathspec to specify what paths to checkout.

* jc/checkout-no-op-switch-errors:
  checkout: special case error messages during noop switching

10 months agodiff-tree: fix crash when used with --remerge-diff
Xing Xin [Fri, 9 Aug 2024 07:24:52 +0000 (07:24 +0000)] 
diff-tree: fix crash when used with --remerge-diff

When using "git-diff-tree" to get the tree diff for merge commits with
the diff format set to `remerge`, a bug is triggered as shown below:

  $ git diff-tree -r --remerge-diff 363337e6eb
  363337e6eb812d0c0d785ed4261544f35559ff8b
  BUG: log-tree.c:1006: did a remerge diff without remerge_objdir?!?

This bug is reported by `log-tree.c:do_remerge_diff`, where a bug check
added in commit 7b90ab467a (log: clean unneeded objects during log
--remerge-diff, 2022-02-02) detects the absence of `remerge_objdir` when
attempting to clean up temporary objects generated during the remerge
process.

After some further digging, I find that the remerge-related diff options
were introduced in db757e8b8d (show, log: provide a --remerge-diff
capability, 2022-02-02), which also affect the setup of `rev_info` for
"git-diff-tree", but were not accounted for in the original
implementation (inferred from the commit message).

Elijah Newren, the author of the remerge diff feature, notes that other
callers of `log-tree.c:log_tree_commit` (the only caller of
`log-tree.c:do_remerge_diff`) also exist, but:

  `builtin/am.c`: manually sets all flags; remerge_diff is not among them
  `sequencer.c`: manually sets all flags; remerge_diff is not among them

so `builtin/diff-tree.c` really is the only caller that was overlooked
when remerge-diff functionality was added.

This commit resolves the crash by adding `remerge_objdir` setup logic to
`builtin/diff-tree.c`, mirroring `builtin/log.c:cmd_log_walk_no_free`.
It also includes the necessary cleanup for `remerge_objdir`.

Reviewed-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Xing Xin <xingxin.xx@bytedance.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 months agot6421: fix test to work when repo dir contains d0
Kyle Lippincott [Mon, 5 Aug 2024 17:10:08 +0000 (17:10 +0000)] 
t6421: fix test to work when repo dir contains d0

The `grep` statement in this test looks for `d0.*<string>`, attempting
to filter to only show lines that had tabular output where the 2nd
column had `d0` and the final column had a substring of
[`git -c `]`fetch.negotiationAlgorithm`. These lines also have
`child_start` in the 4th column, but this isn't part of the condition.

A subsequent line will have `d1` in the 2nd column, `start` in the 4th
column, and `/path/to/git/git -c fetch.negotiationAlgorihm` in the final
column. If `/path/to/git/git` contains the substring `d0`, then this
line is included by `grep` as well as the desired line, leading to an
effective doubling of the number of lines, and test failures.

Tighten the grep expression to require `d0` to be surrounded by spaces,
and to have the `child_start` label.

Signed-off-by: Kyle Lippincott <spectral@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 months agoset errno=0 before strtoX calls
Kyle Lippincott [Mon, 5 Aug 2024 17:10:07 +0000 (17:10 +0000)] 
set errno=0 before strtoX calls

To detect conversion failure after calls to functions like `strtod`, one
can check `errno == ERANGE`. These functions are not guaranteed to set
`errno` to `0` on successful conversion, however. Manual manipulation of
`errno` can likely be avoided by checking that the output pointer
differs from the input pointer, but that's not how other locations, such
as parse.c:139, handle this issue; they set errno to 0 prior to
executing the function.

For every place I could find a strtoX function with an ERANGE check
following it, set `errno = 0;` prior to executing the conversion
function.

Signed-off-by: Kyle Lippincott <spectral@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 months agolog-tree: use decimal_width()
René Scharfe [Sat, 3 Aug 2024 12:33:24 +0000 (14:33 +0200)] 
log-tree: use decimal_width()

Reduce code duplication by calling decimal_width() to count the digits
in the number of commits instead of calculating it locally.

It also has the advantage of returning int, which is the exact type
expected by the printf()-like function strbuf_addf() for field width
arguments.

Additionally, decimal_width() supports numbers bigger than 1410065407,
which is (hopefully) just a theoretical advantage.

Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 months agorefs/files: prevent memory leak by freeing packed_ref_store
Sven Strickroth [Mon, 5 Aug 2024 09:53:32 +0000 (09:53 +0000)] 
refs/files: prevent memory leak by freeing packed_ref_store

This complements 64a6dd8ffc (refs: implement removal of ref storages,
2024-06-06).

Signed-off-by: Sven Strickroth <email@cs-ware.de>
Acked-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 months agobuiltin/ls-remote: fall back to SHA1 outside of a repo
Patrick Steinhardt [Fri, 2 Aug 2024 04:44:11 +0000 (06:44 +0200)] 
builtin/ls-remote: fall back to SHA1 outside of a repo

In c8aed5e8da (repository: stop setting SHA1 as the default object hash,
2024-05-07), we have stopped setting the default hash algorithm for
`the_repository`. Consequently, code that relies on `the_hash_algo` will
now crash when it hasn't explicitly been initialized, which may be the
case when running outside of a Git repository.

It was reported that git-ls-remote(1) may crash in such a way when using
a remote helper that advertises refspecs. This is because the refspec
announced by the helper will get parsed during capability negotiation.
At that point we haven't yet figured out what object format the remote
uses though, so when run outside of a repository then we will fail.

The course of action is somewhat dubious in the first place. Ideally, we
should only parse object IDs once we have asked the remote helper for
the object format. And if the helper didn't announce the "object-format"
capability, then we should always assume SHA256. But instead, we used to
take either SHA1 if there was no repository, or we used the hash of the
local repository, which is wrong.

Arguably though, crashing hard may not be in the best interest of our
users, either. So while the old behaviour was buggy, let's restore it
for now as a short-term fix. We should eventually revisit, potentially
by deferring the point in time when we parse the refspec until after we
have figured out the remote's object hash.

Reported-by: Mike Hommey <mh@glandium.org>
Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 months agot0018: remove leftover debugging cruft
Junio C Hamano [Thu, 1 Aug 2024 18:51:12 +0000 (11:51 -0700)] 
t0018: remove leftover debugging cruft

The actual file is copied out to /tmp, presumably so that the tester
can inspect it after the test is done, which may have been a useful
debugging aid.

But in the final shape of the test suite, such a code should not
exist.  We cannot even assume that we are allowed to write into /tmp
(our TMPDIR may not even be pointing at it) or read from it for that
matter.

Noticed-by: Randall S. Becker <rsbecker@nexbridge.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 months agoconfig.c: avoid segfault with --fixed-value and valueless config
Taylor Blau [Thu, 1 Aug 2024 17:06:54 +0000 (13:06 -0400)] 
config.c: avoid segfault with --fixed-value and valueless config

When using `--fixed-value` with a key whose value is left empty (implied
as being "true"), 'git config' may crash when invoked like either of:

    $ git config set --file=config --value=value --fixed-value \
        section.key pattern
    $ git config --file=config --fixed-value section.key value pattern

The original bugreport[1] bisects to 00bbdde141 (builtin/config:
introduce "set" subcommand, 2024-05-06), which is a red-herring, since
the original bugreport uses the new 'git config set' invocation.

The behavior likely bisects back to c90702a1f6 (config: plumb
--fixed-value into config API, 2020-11-25), which introduces the new
--fixed-value option in the first place.

Looking at the relevant frame from a failed process's coredump, the
crash appears in config.c::matches() like so:

    (gdb) up
    #1  0x000055b3e8b06022 in matches (key=0x55b3ea894360 "section.key", value=0x0,
        store=0x7ffe99076eb0) at config.c:2884
    2884 return !strcmp(store->fixed_value, value);

where we are trying to compare the `--fixed-value` argument to `value`,
which is NULL.

Avoid attempting to match `--fixed-value` for configuration keys with no
explicit value. A future patch could consider the empty value to mean
"true", "yes", "on", etc. when invoked with `--type=bool`, but let's
punt on that for now in the name of avoiding the segfault.

[1]: https://lore.kernel.org/git/CANrWfmTek1xErBLrnoyhHN+gWU+rw14y6SQ+abZyzGoaBjmiKA@mail.gmail.com/

Reported-by: Han Jiang <jhcarl0814@gmail.com>
Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 months agocredential/osxkeychain: respect NUL terminator in username
Jeff King [Thu, 1 Aug 2024 08:25:56 +0000 (04:25 -0400)] 
credential/osxkeychain: respect NUL terminator in username

This patch fixes a case where git-credential-osxkeychain might output
uninitialized bytes to stdout.

We need to get the username string from a system API using
CFStringGetCString(). To do that, we get the max size for the string
from CFStringGetMaximumSizeForEncoding(), allocate a buffer based on
that, and then read into it. But then we print the entire buffer to
stdout, including the trailing NUL and any extra bytes which were not
needed. Instead, we should stop at the NUL.

This code comes from 9abe31f5f1 (osxkeychain: replace deprecated
SecKeychain API, 2024-02-17). The bug was probably overlooked back then
because this code is only used as a fallback when we can't get the
string via CFStringGetCStringPtr(). According to Apple's documentation:

  Whether or not this function returns a valid pointer or NULL depends
  on many factors, all of which depend on how the string was created and
  its properties.

So it's not clear how we could make a test for this, and we'll have to
rely on manually testing on a system that triggered the bug in the first
place.

Reported-by: Hong Jiang <ilford@gmail.com>
Signed-off-by: Jeff King <peff@peff.net>
Tested-by: Hong Jiang <ilford@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 months agot98xx: mark Perforce tests as memory-leak free
Patrick Steinhardt [Wed, 31 Jul 2024 10:37:56 +0000 (12:37 +0200)] 
t98xx: mark Perforce tests as memory-leak free

All the Perforce tests are free of memory leaks. This went unnoticed
because most folks do not have p4 and p4d installed on their computers.
Consequently, given that the prerequisites for running those tests
aren't fulfilled, `TEST_PASSES_SANITIZE_LEAK=check` won't notice that
those tests are indeed memory leak free.

Mark those tests accordingly.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 months agoci: update Perforce version to r23.2
Patrick Steinhardt [Wed, 31 Jul 2024 10:37:45 +0000 (12:37 +0200)] 
ci: update Perforce version to r23.2

Update our Perforce version from r21.2 to r23.2. Note that the updated
version is not the newest version. Instead, it is the last version where
the way that Perforce is being distributed remains the same as in r21.2.
Newer releases stopped distributing p4 and p4d executables as well as
the macOS archives directly and would thus require more work.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 months agot98xx: fix Perforce tests with p4d r23 and newer
Patrick Steinhardt [Wed, 31 Jul 2024 10:37:40 +0000 (12:37 +0200)] 
t98xx: fix Perforce tests with p4d r23 and newer

Some of the tests in t98xx modify the Perforce depot in ways that the
tool wouldn't normally allow. This is done to test behaviour of git-p4
in certain edge cases that we have observed in the wild, but which
should in theory not be possible.

Naturally, modifying the depot on disk directly is quite intimate with
the tool and thus prone to breakage when Perforce updates the way that
data is stored. And indeed, those tests are broken nowadays with r23 of
Perforce. While a file revision was previously stored as a plain file
"depot/file,v", it is now stored in a directory "depot/file,d" with
compression.

Adapt those tests to handle both old- and new-style depot layouts.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 months agoconvert: return early when not tracing
D Harithamma [Wed, 31 Jul 2024 13:33:59 +0000 (13:33 +0000)] 
convert: return early when not tracing

When Git adds a file requiring encoding conversion and tracing of encoding
conversion is not requested via the GIT_TRACE_WORKING_TREE_ENCODING
environment variable, the `trace_encoding()` function still allocates &
prepares "human readable" copies of the file contents before and after
conversion to show in the trace. This results in a high memory footprint
and increased runtime without providing any user-visible benefit.

This fix introduces an early exit from the `trace_encoding()` function
when tracing is not requested, preventing unnecessary memory allocation
and processing.

Signed-off-by: D Harithamma <harithamma.d@ibm.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 months agot-example-decorate: remove test messages
René Scharfe [Tue, 30 Jul 2024 14:00:20 +0000 (16:00 +0200)] 
t-example-decorate: remove test messages

The test_msg() calls only repeat information already present in test
descriptions and check definitions, which are shown automatically if
the checks fail.  Remove the redundant messages to simplify the tests
and their output.  Here it is with all of them failing before:

 # check "ret == NULL" failed at t/unit-tests/t-example-decorate.c:18
 # when adding a brand-new object, NULL should be returned
 # check "ret == NULL" failed at t/unit-tests/t-example-decorate.c:21
 # when adding a brand-new object, NULL should be returned
 not ok 1 - Add 2 objects, one with a non-NULL decoration and one with a NULL decoration.
 # check "ret == &vars->decoration_a" failed at t/unit-tests/t-example-decorate.c:29
 # when readding an already existing object, existing decoration should be returned
 # check "ret == NULL" failed at t/unit-tests/t-example-decorate.c:32
 # when readding an already existing object, existing decoration should be returned
 not ok 2 - When re-adding an already existing object, the old decoration is returned.
 # check "ret == NULL" failed at t/unit-tests/t-example-decorate.c:40
 # lookup should return added declaration
 # check "ret == &vars->decoration_b" failed at t/unit-tests/t-example-decorate.c:43
 # lookup should return added declaration
 # check "ret == NULL" failed at t/unit-tests/t-example-decorate.c:46
 # lookup for unknown object should return NULL
 not ok 3 - Lookup returns the added declarations, or NULL if the object was never added.
 # check "objects_noticed == 2" failed at t/unit-tests/t-example-decorate.c:58
 #    left: 1
 #   right: 2
 # should have 2 objects
 not ok 4 - The user can also loop through all entries.
 1..4

... and here with the patch applied:

 # check "ret == NULL" failed at t/unit-tests/t-example-decorate.c:18
 # check "ret == NULL" failed at t/unit-tests/t-example-decorate.c:20
 not ok 1 - Add 2 objects, one with a non-NULL decoration and one with a NULL decoration.
 # check "ret == &vars->decoration_a" failed at t/unit-tests/t-example-decorate.c:27
 # check "ret == NULL" failed at t/unit-tests/t-example-decorate.c:29
 not ok 2 - When re-adding an already existing object, the old decoration is returned.
 # check "ret == NULL" failed at t/unit-tests/t-example-decorate.c:36
 # check "ret == &vars->decoration_b" failed at t/unit-tests/t-example-decorate.c:38
 # check "ret == NULL" failed at t/unit-tests/t-example-decorate.c:40
 not ok 3 - Lookup returns the added declarations, or NULL if the object was never added.
 # check "objects_noticed == 2" failed at t/unit-tests/t-example-decorate.c:51
 #    left: 1
 #   right: 2
 not ok 4 - The user can also loop through all entries.
 1..4

Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 months agosafe.directory: setting safe.directory="." allows the "current" directory
Junio C Hamano [Tue, 30 Jul 2024 18:43:52 +0000 (11:43 -0700)] 
safe.directory: setting safe.directory="." allows the "current" directory

When "git daemon" enters a repository, it chdir's to the requested
repository and then uses "." (the curent directory) to consult the
"is this repository considered safe?" when it is not owned by the
same owner as the process.

Make sure this access will be allowed by setting safe.directory to
".", as that was once advertised on the list as a valid workaround
to the overly tight safe.directory settings introduced by 2.45.1
(cf. <834862fd-b579-438a-b9b3-5246bf27ce8a@gmail.com>).

Also add simlar test to show what happens in the same setting if the
safe.directory is set to "*" instead of "."; in short, "." is a bit
tighter (as it is custom designed for git-daemon situation) than
"anything goes" settings given by "*".

Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 months agosafe.directory: normalize the configured path
Junio C Hamano [Tue, 30 Jul 2024 18:43:51 +0000 (11:43 -0700)] 
safe.directory: normalize the configured path

The pathname of a repository comes from getcwd() and it could be a
path aliased via symbolic links, e.g., the real directory may be
/home/u/repository but a symbolic link /home/u/repo may point at it,
and the clone request may come as "git clone file:///home/u/repo/"

A request to check if /home/u/repository is safe would be rejected
if the safe.directory configuration allows /home/u/repo/ but not its
alias /home/u/repository/.  Normalize the paths configured for the
safe.directory configuration variable before comparing them with the
path being checked.

Two and a half things to note, compared to the previous step to
normalize the actual path of the suspected repository, are:

 - A configured safe.directory may be coming from .gitignore in the
   home directory that may be shared across machines.  The path
   meant to match with an entry may not necessarily exist on all of
   such machines, so not being able to convert them to real path on
   this machine is *not* a condition that is worthy of warning.
   Hence, we ignore a path that cannot be converted to a real path.

 - A configured safe.directory is essentially a random string that
   user throws at us, written completely unrelated to the directory
   the current process happens to be in.  Hence it makes little
   sense to give a non-absolute path.  Hence we ignore any
   non-absolute paths, except for ".".

 - The safe.directory set to "." was once advertised on the list as
   a valid workaround for the regression caused by the overly tight
   safe.directory check introduced in 2.45.1; we treat it to mean
   "if we are at the top level of a repository, it is OK".
   (cf. <834862fd-b579-438a-b9b3-5246bf27ce8a@gmail.com>).

Suggested-by: Phillip Wood <phillip.wood123@gmail.com>
Helped-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 months agosafe.directory: normalize the checked path
Junio C Hamano [Tue, 30 Jul 2024 18:43:50 +0000 (11:43 -0700)] 
safe.directory: normalize the checked path

The pathname of a repository comes from getcwd() and it could be a
path aliased via symbolic links, e.g., the real directory may be
/home/u/repository but a symbolic link /home/u/repo may point at it,
and the clone request may come as "git clone file:///home/u/repo/".

A request to check if /home/u/repo is safe would be rejected if the
safe.directory configuration allows /home/u/repository/ but not its
alias /home/u/repo/.  Normalize the path being checked before
comparing with safe.directory value(s).

Suggested-by: Phillip Wood <phillip.wood123@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 months agosafe.directory: preliminary clean-up
Junio C Hamano [Tue, 30 Jul 2024 18:43:49 +0000 (11:43 -0700)] 
safe.directory: preliminary clean-up

The paths given in the safe.directory configuration variable are
allowed to contain "~user" (which interpolates to user's home
directory) and "%(prefix)" (which interpolates to the installation
location in RUNTIME_PREFIX-enabled builds, and a call to the
git_config_pathname() function is tasked to obtain a copy of the
path with these constructs interpolated.

The function, when it succeeds, always yields an allocated string in
the location given as the out-parameter; even when there is nothing
to interpolate in the original, a literal copy is made.  The code
path that contains this caller somehow made two contradicting and
incorrect assumptions of the behaviour when there is no need for
interpolation, and was written with extra defensiveness against
two phantom risks that do not exist.

One wrong assumption was that the function might yield NULL when
there is no interpolation.  This led to the use of an extra "check"
variable, conditionally holding either the interpolated or the
original string.  The assumption was with us since 8959555c
(setup_git_directory(): add an owner check for the top-level
directory, 2022-03-02) originally introduced the safe.directory
feature.

Another wrong assumption was that the function might yield the same
pointer as the input when there is no interpolation.  This led to a
conditional free'ing of the interpolated copy, that the conditional
never skipped, as we always received an allocated string.

Simplify the code by removing the extra defensiveness.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 months agonotes: do not trigger editor when adding an empty note
David Disseldorp [Mon, 29 Jul 2024 15:14:00 +0000 (17:14 +0200)] 
notes: do not trigger editor when adding an empty note

With "git notes add -C $blob", the given blob contents are to be made
into a note without involving an editor.  But when "--allow-empty" is
given, the editor is invoked, which can cause problems for
non-interactive callers[1].

This behaviour started with 90bc19b3ae (notes.c: introduce
'--separator=<paragraph-break>' option, 2023-05-27), which changed
editor invocation logic to check for a zero length note_data buffer.

Restore the original behaviour of "git note" that takes the contents
given via the "-m", "-C", "-F" options without invoking an editor, by
checking for any prior parameter callbacks, indicated by a non-zero
note_data.msg_nr.  Remove the now-unneeded note_data.given flag.

Add a test for this regression by checking whether GIT_EDITOR is
invoked alongside "git notes add -C $empty_blob --allow-empty"

[1] https://github.com/ddiss/icyci/issues/12

Signed-off-by: David Disseldorp <ddiss@suse.de>
[jc: enhanced the test with -m/-F options]
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 months agounit-tests/test-lib: fix typo in check_pointer_eq() description
Kousik Sanagavarapu [Mon, 29 Jul 2024 04:32:48 +0000 (10:02 +0530)] 
unit-tests/test-lib: fix typo in check_pointer_eq() description

The comment surrounding check_pointer_eq() should explain about what
this function does instead of explaining check_int().  Correct this.

Signed-off-by: Kousik Sanagavarapu <five231003@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 months agoGit 2.46 v2.46.0
Junio C Hamano [Mon, 29 Jul 2024 14:14:09 +0000 (07:14 -0700)] 
Git 2.46

Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 months agoMerge tag 'l10n-2.46.0-rnd2' of https://github.com/git-l10n/git-po
Junio C Hamano [Mon, 29 Jul 2024 14:11:16 +0000 (07:11 -0700)] 
Merge tag 'l10n-2.46.0-rnd2' of https://github.com/git-l10n/git-po

l10n-2.46.0-rnd2

* tag 'l10n-2.46.0-rnd2' of https://github.com/git-l10n/git-po:
  l10n: zh_CN: updated translation for 2.46
  l10n: sv.po: Update Swedish translation
  l10n: zh_TW: Git 2.46
  l10n: Update German translation
  l10n: vi: Updated translation for 2.46
  l10n: uk: v2.46 update
  l10n: bg.po: Updated Bulgarian translation (5734t)
  l10n: fr: v2.46.0
  l10n: tr: Update Turkish translations
  l10n: po-id for 2.46

10 months agol10n: zh_CN: updated translation for 2.46
Teng Long [Thu, 18 Jul 2024 11:36:09 +0000 (19:36 +0800)] 
l10n: zh_CN: updated translation for 2.46

Signed-off-by: Teng Long <dyroneteng@gmail.com>
Co-authored-by: 依云 <lilydjwg@gmail.com>
Reviewed-by: 依云 <lilydjwg@gmail.com>
Signed-off-by: Jiang Xin <worldhello.net@gmail.com>
11 months agol10n: sv.po: Update Swedish translation
Peter Krefting [Sun, 21 Jul 2024 14:05:05 +0000 (15:05 +0100)] 
l10n: sv.po: Update Swedish translation

Signed-off-by: Peter Krefting <peter@softwolves.pp.se>
11 months agoMerge branch 'l10n/zh-TW/2024-07-24' of github.com:l10n-tw/git-po
Jiang Xin [Sat, 27 Jul 2024 08:27:25 +0000 (16:27 +0800)] 
Merge branch 'l10n/zh-TW/2024-07-24' of github.com:l10n-tw/git-po

* 'l10n/zh-TW/2024-07-24' of github.com:l10n-tw/git-po:
  l10n: zh_TW: Git 2.46

11 months agoMerge branch 'l10n-de-2.46' of github.com:ralfth/git
Jiang Xin [Sat, 27 Jul 2024 08:25:13 +0000 (16:25 +0800)] 
Merge branch 'l10n-de-2.46' of github.com:ralfth/git

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

11 months agoMerge branch 'vi-2.46' of github.com:Nekosha/git-po
Jiang Xin [Sat, 27 Jul 2024 08:24:48 +0000 (16:24 +0800)] 
Merge branch 'vi-2.46' of github.com:Nekosha/git-po

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

11 months agoMerge branch '2.46-uk-update' of github.com:arkid15r/git-ukrainian-l10n
Jiang Xin [Sat, 27 Jul 2024 08:21:09 +0000 (16:21 +0800)] 
Merge branch '2.46-uk-update' of github.com:arkid15r/git-ukrainian-l10n

* '2.46-uk-update' of github.com:arkid15r/git-ukrainian-l10n:
  l10n: uk: v2.46 update

11 months agoMerge branch 'master' of github.com:alshopov/git-po
Jiang Xin [Sat, 27 Jul 2024 08:20:29 +0000 (16:20 +0800)] 
Merge branch 'master' of github.com:alshopov/git-po

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

11 months agoMerge branch 'l10N_fr_2.46' of github.com:jnavila/git
Jiang Xin [Sat, 27 Jul 2024 08:18:53 +0000 (16:18 +0800)] 
Merge branch 'l10N_fr_2.46' of github.com:jnavila/git

* 'l10N_fr_2.46' of github.com:jnavila/git:
  l10n: fr: v2.46.0

11 months agoMerge branch 'tr-l10n' of github.com:bitigchi/git-po
Jiang Xin [Sat, 27 Jul 2024 08:17:45 +0000 (16:17 +0800)] 
Merge branch 'tr-l10n' of github.com:bitigchi/git-po

* 'tr-l10n' of github.com:bitigchi/git-po:
  l10n: tr: Update Turkish translations

11 months agoMerge branch 'po-id' of github.com:bagasme/git-po
Jiang Xin [Sat, 27 Jul 2024 08:16:43 +0000 (16:16 +0800)] 
Merge branch 'po-id' of github.com:bagasme/git-po

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

11 months agol10n: zh_TW: Git 2.46
Yi-Jyun Pan [Sat, 27 Jul 2024 06:34:25 +0000 (14:34 +0800)] 
l10n: zh_TW: Git 2.46

Co-authored-by: Lumynous <lumynou5.tw@gmail.com>
Co-authored-by: Ngoo Ka-iu <willy04wu69@gmail.com>
Co-authored-by: Nightfeather Chen <slat@nightfeather.me>
Co-authored-by: Kisaragi Hiu <mail@kisaragi-hiu.com>
Co-authored-by: hms5232 <hms5232@hhming.moe>
Signed-off-by: Yi-Jyun Pan <pan93412@gmail.com>
11 months agodoc: fix hex code escapes in git-ls-files
Jayson Rhynas [Fri, 26 Jul 2024 15:41:40 +0000 (11:41 -0400)] 
doc: fix hex code escapes in git-ls-files

The --format option on the git-ls-files man page states that `%xx`
interpolates to the character with hex code `xx`. This mirrors the
documentation and behavior of `git for-each-ref --format=...`. However,
in reality it requires the character with code `XX` to be specified as
`%xXX`, mirroring the behaviour of  `git log --format`.

Signed-off-by: Jayson Rhynas <jayrhynas@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 months agocsum-file: introduce discard_hashfile()
Junio C Hamano [Thu, 25 Jul 2024 23:07:28 +0000 (16:07 -0700)] 
csum-file: introduce discard_hashfile()

The hashfile API is used to write out a "hashfile", which has a
final checksum (typically SHA-1) at the end.  An in-core hashfile
structure has up to two file descriptors and a few buffers that can
only be freed by calling a helper function that is private to the
csum-file implementation.

The usual flow of a user of the API is to first open a file
descriptor for writing, obtain a hashfile associated with that write
file descriptor by calling either hashfd() or hashfd_check(), call
hashwrite() number of times to write data to the file, and then call
finalize_hashfile(), which appends th checksum to the end of the
file, closes file descriptors and releases associated buffers.

But what if a caller finds some error after calling hashfd() to
start the process and/or hashwrite() to send some data to the file,
and wants to abort the operation?  The underlying file descriptor is
often managed by the tempfile API, so aborting will clean the file
out of the filesystem, but the resources associated with the in-core
hashfile structure is lost.

Introduce discard_hashfile() API function to allow them to release
the resources held by a hashfile structure the callers want to
dispose of, and use that in read-cache.c:do_write_index(), which is
a central place that writes the index file.

Mark t2107 as leak-free, as this leak in "update-index --cacheinfo"
test that deliberately makes it fail is now plugged.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 months agol10n: Update German translation
Ralf Thielow [Sat, 13 Jul 2024 12:42:34 +0000 (14:42 +0200)] 
l10n: Update German translation

Reviewed-by: Matthias Rüster <matthias.ruester@gmail.com>
Signed-off-by: Ralf Thielow <ralf.thielow@gmail.com>
11 months agomailmap: plug memory leak in read_mailmap_blob()
Junio C Hamano [Thu, 25 Jul 2024 23:12:41 +0000 (16:12 -0700)] 
mailmap: plug memory leak in read_mailmap_blob()

When a named object to read mailmap from is not a blob, the code
correctly errors out, but it forgot to free the object data before
doing so.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 months agol10n: vi: Updated translation for 2.46
Vũ Tiến Hưng [Fri, 26 Jul 2024 04:03:27 +0000 (11:03 +0700)] 
l10n: vi: Updated translation for 2.46

Signed-off-by: Vũ Tiến Hưng <newcomerminecraft@gmail.com>
11 months agodoc: difference in location to apply is "offset", not "fuzz"
Junio C Hamano [Thu, 25 Jul 2024 17:27:29 +0000 (10:27 -0700)] 
doc: difference in location to apply is "offset", not "fuzz"

The documentation to "git rebase" says that the line numbers (in the
rebased change) may not exactly be the same as the line numbers the
change gets replayed on top of the new base, but uses a wrong noun
"fuzz".  It should have said "offset".

They are both terms of art.  "fuzz" is about context lines not
exactly matching.  "offset" is about the difference in the location
that a change was taken from the original and the change gets
replayed on the target.  "offset" is often inevitable and part of
normal life.  "fuzz" on the other hand is often a sign of trouble
(and indeed "Git" refuses to apply a change with "fuzz", except
there are options to be fuzzy about whitespaces).

Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 months agol10n: uk: v2.46 update
Arkadii Yakovets [Wed, 24 Jul 2024 21:30:10 +0000 (14:30 -0700)] 
l10n: uk: v2.46 update

Co-authored-by: Kate Golovanova <kate@kgthreads.com>
Signed-off-by: Arkadii Yakovets <ark@cho.red>
Signed-off-by: Kate Golovanova <kate@kgthreads.com>
11 months agoGit 2.46-rc2 v2.46.0-rc2
Junio C Hamano [Tue, 23 Jul 2024 23:54:19 +0000 (16:54 -0700)] 
Git 2.46-rc2

Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 months agoMerge branch 'ps/ref-storage-migration-fix'
Junio C Hamano [Tue, 23 Jul 2024 23:54:34 +0000 (16:54 -0700)] 
Merge branch 'ps/ref-storage-migration-fix'

Hotfix for a topic already in -rc.

* ps/ref-storage-migration-fix:
  refs: fix format migration on Cygwin

11 months agoMerge branch 'js/doc-markup-updates-fix'
Junio C Hamano [Tue, 23 Jul 2024 23:54:34 +0000 (16:54 -0700)] 
Merge branch 'js/doc-markup-updates-fix'

Work around asciidoctor's css that renders `monospace` material
in the SYNOPSIS section of manual pages as block elements.

* js/doc-markup-updates-fix:
  Doc: fix Asciidoctor css workaround
  asciidoctor: fix `synopsis` rendering

11 months agoMerge branch 'ja/doc-markup-updates-fix'
Junio C Hamano [Tue, 23 Jul 2024 23:54:33 +0000 (16:54 -0700)] 
Merge branch 'ja/doc-markup-updates-fix'

Fix documentation mark-up regression in 2.45.

* ja/doc-markup-updates-fix:
  doc: git-clone fix discrepancy between asciidoc and asciidoctor

11 months agoMerge branch 'ds/midx-write-repack-fix'
Junio C Hamano [Tue, 23 Jul 2024 23:54:33 +0000 (16:54 -0700)] 
Merge branch 'ds/midx-write-repack-fix'

Repacking a repository with multi-pack index started making stupid
pack selections in Git 2.45, which has been corrected.

* ds/midx-write-repack-fix:
  midx-write: revert use of --stdin-packs
  t5319: add failing test case for repack/expire

11 months agoDoc: fix Asciidoctor css workaround
Junio C Hamano [Mon, 22 Jul 2024 21:17:55 +0000 (14:17 -0700)] 
Doc: fix Asciidoctor css workaround

The previous step introduced docinfo.html to be used to tweak the
CSS used by the asciidoctor, that by default renders <code> inside
<pre> as a block element, breaking the SYNOPSIS section of a few
pages that adopted a new convention we use since Git 2.45.

But in this project, HTML files are all generated.  We do not force
any human to write HTML by hand, which is an unusual and cruel
punishment.  "*.html" is in the .gitignore file, and "make clean"
removes them.  Having a tracked .html file makes "make clean" make
the tree dirty by removing the tracked docinfo.html file.

Let's do an obvious, minimum and stupid workaround to generate that
file at runtime instead.  The mark-up is being rethought in a major
way for the next development cycle, and the CSS workaround we added
in the previous step may have to adjusted, possibly in a large way,
anyway.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 months agorefs: fix format migration on Cygwin
Patrick Steinhardt [Tue, 23 Jul 2024 12:31:28 +0000 (14:31 +0200)] 
refs: fix format migration on Cygwin

It was reported that t1460-refs-migrate.sh fails when using Cygwin with
errors like the following:

    error: could not link file '.git/ref_migration.sr9pEF/reftable' to '.git/reftable': Permission denied

As some debugging surfaced, the root cause of this is that some files of
the newly-initialized ref store are still open when the target format is
the "reftable" format, and Cygwin refuses to rename open files.

Fix this issue by closing the new ref store before renaming its files
into place. This is a slight change in behaviour compared to before,
where we kept the new ref store open and then updated the repository's
ref store to point to it.

While we could re-open the new ref store after we have moved files
around, this is ultimately unnecessary. We know that the only user of
`repo_migrate_ref_storage_format()` is the git-refs(1) command, and it
won't access the ref store after it has been migrated anyway. So
reinitializing the ref store would be a waste of time. Regardless of
that it is still sensible to leave the repository in a consistent state.
But instead of reinitializing the ref store, we can simply unset the
repo's ref store altogether and let `get_main_ref_store()` lazily
initialize the new ref store as required.

Reported-by: Ramsay Jones <ramsay@ramsayjones.plus.com>
Helped-by: Jeff King <peff@peff.net>
Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 months agoCodingGuidelines: document a shell that "fails" "VAR=VAL shell_func"
Junio C Hamano [Tue, 23 Jul 2024 00:04:54 +0000 (17:04 -0700)] 
CodingGuidelines: document a shell that "fails" "VAR=VAL shell_func"

Over the years, we accumulated the community wisdom to avoid the
common "one-short export" construct for shell functions, but seem to
have lost on which exact platform it is known to fail.  Now during
an investigation on a breakage for a recent topic, we found one
example of failing shell.  Let's document that.

This does *not* mean that we can freely start using the construct
once Ubuntu 20.04 is retired.  But it does mean that we cannot use
the construct until Ubuntu 20.04 is fully retired from the machines
that matter.  Moreover, posix explicitly says that the behaviour for
the construct is unspecified.

Helped-by: Kyle Lippincott <spectral@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 months agodoc: remove dangling closing parenthesis
Tomas Nordin [Mon, 22 Jul 2024 22:53:02 +0000 (22:53 +0000)] 
doc: remove dangling closing parenthesis

The second line of the synopsis, starting with [--dry-run] has a
dangling closing paren in the second optional group. Probably added by
mistake, so remove it.

Signed-off-by: Tomas Nordin <tomasn@posteo.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 months agoasciidoctor: fix `synopsis` rendering
Johannes Schindelin [Mon, 22 Jul 2024 20:25:49 +0000 (20:25 +0000)] 
asciidoctor: fix `synopsis` rendering

Since 76880f0510c (doc: git-clone: apply new documentation formatting
guidelines, 2024-03-29), the synopsis of `git clone`'s manual page is
rendered differently than before; Its parent commit did the same for
`git init`.

The result looks quite nice. When rendered with AsciiDoc, that is. When
rendered using AsciiDoctor and displayed in a graphical web browser such
as Firefox, Chrome, Edge, etc, the result is quite unpleasant to my eye,
reading something like this:

SYNOPSIS

 git clone
  [
 --template=
 <template-directory>]
  [
 -l
 ] [
 -s
 ] [
 --no-hardlinks
 ] [
 -q
 ] [
[... continuing like this ...]

The reason is that AsciiDoctor's default style sheet contains this (see
https://github.com/asciidoctor/asciidoctor/blob/854923b15533/src/stylesheets/asciidoctor.css#L519-L521
for context):

pre > code {
  display: block;
}

It is this `display: block` that forces the parts that are enclosed in
`<code>` tags (such as the `git clone` or the `--template=` part) to be
rendered on their own line.

Side note: This seems not to affect console web browsers like `lynx` or
`w3m`, most likely because most style sheet directions cannot be
respected in text terminals and therefore they seem to punt on style
sheets altogether.

To fix this, let's apply the method recommended by AsciiDoctor in
https://docs.asciidoctor.org/asciidoctor/latest/html-backend/default-stylesheet/#customize-docinfo
to partially override AsciiDoctor's default style sheet so that the
`<code>` sections of the synopsis are no longer each rendered on their
own, individual lines.

This fixes https://github.com/git-for-windows/git/issues/5063.

Even on the Git home page, where AsciiDoctor's default stylesheet is
_not_ used, this change resulted in some unpleasant rendering where not
only the font is changed for the `<code>` sections of the synopsis, but
padding and a different background color make the visual impression
quite uneven. This has been addressed in the meantime, via
https://github.com/git/git-scm.com/commit/a492d0565512.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 months agol10n: bg.po: Updated Bulgarian translation (5734t)
Alexander Shopov [Sun, 21 Jul 2024 19:31:10 +0000 (22:31 +0300)] 
l10n: bg.po: Updated Bulgarian translation (5734t)

Signed-off-by: Alexander Shopov <ash@kambanaria.org>
11 months agoadd-patch: use normalize_marker() when recounting edited hunk
Phillip Wood [Sat, 20 Jul 2024 16:02:00 +0000 (16:02 +0000)] 
add-patch: use normalize_marker() when recounting edited hunk

After the user has edited a hunk the number of lines in the pre- and
post- image lines is recounted the hunk header can be updated before
passing the hunk to "git apply". The recounting code correctly handles
empty context lines where the leading ' ' is omitted by treating '\n'
and '\r' as context lines.

Update this code to use normalize_marker() so that the handling of empty
context lines is consistent with the rest of the hunk parsing
code. There is a small change in behavior as normalize_marker() only
treats "\r\n" as an empty context line rather than any line starting
with '\r'. This should not matter in practice as Macs have used Unix
line endings since MacOs 10 was released in 2001 and if it transpires
that someone is still using an earlier version of MacOs where lines end
with '\r' then we will need to change the handling of '\r' in
normalize_marker() anyway.

Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 months agoadd-patch: handle splitting hunks with diff.suppressBlankEmpty
Phillip Wood [Sat, 20 Jul 2024 16:01:59 +0000 (16:01 +0000)] 
add-patch: handle splitting hunks with diff.suppressBlankEmpty

When "add -p" parses diffs, it looks for context lines starting with a
single space. But when diff.suppressBlankEmpty is in effect, an empty
context line will omit the space, giving us a true empty line. This
confuses the parser, which is unable to split based on such a line.

It's tempting to say that we should just make sure that we generate a
diff without that option.  However, although we do not parse hunks that
the user has manually edited with parse_diff() we do allow the user
to split such hunks. As POSIX calls the decision of whether to print the
space here "implementation-defined" we need to handle edited hunks where
empty context lines omit the space.

So let's handle both cases: a context line either starts with a space or
consists of a totally empty line by normalizing the first character to a
space when we parse them. Normalizing the first character rather than
changing the code to check for a space or newline will hopefully future
proof against introducing similar bugs if the code is changed.

Reported-by: Ilya Tumaykin <itumaykin@gmail.com>
Helped-by: Jeff King <peff@peff.net>
Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 months agodoc: git-clone fix discrepancy between asciidoc and asciidoctor
Jean-Noël Avila [Sat, 20 Jul 2024 17:34:13 +0000 (17:34 +0000)] 
doc: git-clone fix discrepancy between asciidoc and asciidoctor

Asciidoc.py does not have the concept of generalized roles, whereas
asciidoctor interprets [foo]`blah` as blah with role foo in the
synopsis, making in effect foo disappear in the output. Note that
square brackets not directly followed by an inline markup do not
define a role, which is why we do not have the issue on other parts of
the documentation.

In order to get a consistant result across asciidoctor and
asciidoc.py, the hack is to use the {empty} entity
to split the bracket part from the inline format part.

Signed-off-by: Jean-Noël Avila <jn.avila@free.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 months agohowto-maintain: update daily tasks
Junio C Hamano [Fri, 19 Jul 2024 20:52:09 +0000 (13:52 -0700)] 
howto-maintain: update daily tasks

Some "implementation details" of how I perform these integration
tasks day to day have changed since the document was originally
written.  Update to reflect the way things are currently done.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 months agohowto-maintain: cover a whole development cycle
Junio C Hamano [Fri, 19 Jul 2024 20:44:35 +0000 (13:44 -0700)] 
howto-maintain: cover a whole development cycle

The "policy" part is more important than the "daily operation" part
in that it establishes why certain maintainer tasks exist and are
performed the way they are.

The text briefly touches the role each integration branches play in
the workflow, but does not give the whole picture of what happens in
a single development cycle using these branches.  Extend the
description to describe a whole development cycle.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 months agol10n: fr: v2.46.0
Jean-Noël Avila [Wed, 17 Jul 2024 20:39:57 +0000 (22:39 +0200)] 
l10n: fr: v2.46.0

Signed-off-by: Jean-Noël Avila <jn.avila@free.fr>
11 months agomidx-write: revert use of --stdin-packs
Derrick Stolee [Thu, 18 Jul 2024 19:55:46 +0000 (19:55 +0000)] 
midx-write: revert use of --stdin-packs

This reverts b7d6f23a171 (midx-write.c: use `--stdin-packs` when
repacking, 2024-04-01) and then marks the test created in the previous
change as passing.

The fundamental issue with the reverted change is that the focus on
pack-files separates the object selection from how the multi-pack-index
selects a single pack-file for an object ID with multiple copies among
the tracked pack-files.

The change was made with the intention of improving delta compression in
the resulting pack-file, but that can be resolved with the existing
object list mechanism. There are other potential pitfalls of doing an
object walk at this time if the repository is a blobless partial clone,
and that will require additional testing on top of the one that changes
here.

Signed-off-by: Derrick Stolee <stolee@gmail.com>
Acked-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 months agol10n: tr: Update Turkish translations
Emir SARI [Sun, 14 Jul 2024 19:20:03 +0000 (22:20 +0300)] 
l10n: tr: Update Turkish translations

Signed-off-by: Emir SARI <emir_sari@icloud.com>
11 months agol10n: po-id for 2.46
Bagas Sanjaya [Sun, 14 Jul 2024 07:50:43 +0000 (14:50 +0700)] 
l10n: po-id for 2.46

Update following components:

  * builtin/clone.c
  * builtin/config.c
  * builtin/for-each-repo.c
  * builtin/refs.c
  * command-list.h
  * commit-graph.c
  * http.c
  * pack-bitmap-write.c
  * pack-bitmap.c
  * promisor-remote.c
  * refs.c
  * sequencer.c

Translate following new components:

  * pseudo-merge.c
  * refs/files-backend.c

Signed-off-by: Bagas Sanjaya <bagasdotme@gmail.com>
11 months agot5319: add failing test case for repack/expire
Derrick Stolee [Thu, 18 Jul 2024 19:55:45 +0000 (19:55 +0000)] 
t5319: add failing test case for repack/expire

Git 2.45.0 included the change b7d6f23a171 (midx-write.c: use
`--stdin-packs` when repacking, 2024-04-01) which caused the 'git
multi-pack-index repack' command to use 'git pack-objects --stdin-packs'
instead of listing the objects to repack. While this change was
motivated by efficient cross-process communication and the ability to
improve delta compression, it breaks a fundamental function of the
'incremental-repack' task that is enabled by default in Scalar clones or
Git repositories that run 'git maintenance start'.

The 'incremental-repack' task performs a two-step process of the
'expire' and 'repack' subcommands of the 'git multi-pack-index' builtin.
The 'expire' command removes any pack-files listed in the
multi-pack-index but without any referenced objects. The 'repack' task
then finds a batch of pack-files to repack and sends their objects to
'git pack-objects'. Both the pack-files chosen for the batch and the
objects chosen to repack are based on the ones that the multi-pack-index
references. Objects that appear in a pack-file but have a duplicate copy
in a newer pack-file are not considered in this case. Since the
multi-pack-index references only the newest copy of an object, this
allows the next 'incremental-repack' task to remove the pack-files in
the next 'expire' task. This delay is intentional due to how Windows
handles may block deletion of files with open read handles.

However, the mentioned commit changed this behavior to divorce the set
of objects referenced by the multi-pack-index and instead use a set of
"included" and "excluded" pack-files in the 'git pack-objects' builtin.
When a pack-file is selected as "included", only the objects it contains
but are not in any "excluded" pack-files are considered for repacking.
This has led to client repositories failing to remove old pack-files as
they still have some referenced objects. This grows over time until the
point that Git is trying to repack the same pack-files over and over.

For now, create a test case that demonstrates the expected behavior, but
also fails in its final line. The setup here it attempting to recreate a
typical situation for a repository that uses a blobless partial clone.
There would be a large initial pack-file from the clone that is never
selected in the 'repack' batch. There are other pack-files that have a
combination of new objects from incremental fetches and possibly blobs
that are not connected to those incremental fetches; these blobs could
be filled in from commands like 'git checkout' or 'git blame'. The
pack-files also have some overlap on purpose so test-1 has some
duplicates in test-2 and test-2 has some duplicates in test-3.

At the end of the test, the test-2 pack-file still exists though it
should have been expired. This test will pass when reverting the
offending commit.

Signed-off-by: Derrick Stolee <stolee@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 months agoGit 2.46-rc1 v2.46.0-rc1
Junio C Hamano [Thu, 18 Jul 2024 15:23:53 +0000 (08:23 -0700)] 
Git 2.46-rc1

Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 months agoMerge branch 'jk/am-retry'
Junio C Hamano [Thu, 18 Jul 2024 15:30:27 +0000 (08:30 -0700)] 
Merge branch 'jk/am-retry'

Test fix as a follow-up to an already graduated topic.

* jk/am-retry:
  t4153: stop redirecting input from /dev/zero

11 months agoMerge branch 'tb/pseudo-merge-reachability-bitmap'
Junio C Hamano [Thu, 18 Jul 2024 15:30:27 +0000 (08:30 -0700)] 
Merge branch 'tb/pseudo-merge-reachability-bitmap'

Doc update.

* tb/pseudo-merge-reachability-bitmap:
  Documentation/gitpacking: make sample configs listing blocks

11 months agoMerge branch 'ps/pseudo-ref-terminology'
Junio C Hamano [Thu, 18 Jul 2024 15:30:26 +0000 (08:30 -0700)] 
Merge branch 'ps/pseudo-ref-terminology'

Doc update.

* ps/pseudo-ref-terminology:
  Documentation/glossary: fix double word

11 months agoMerge branch 'tb/doc-max-tree-depth-fix'
Junio C Hamano [Thu, 18 Jul 2024 15:30:26 +0000 (08:30 -0700)] 
Merge branch 'tb/doc-max-tree-depth-fix'

Doc update.

* tb/doc-max-tree-depth-fix:
  Documentation: fix default value for core.maxTreeDepth

11 months agoMerge branch 'ch/refs-without-the-repository-fix'
Junio C Hamano [Thu, 18 Jul 2024 15:30:25 +0000 (08:30 -0700)] 
Merge branch 'ch/refs-without-the-repository-fix'

Comment fix.

* ch/refs-without-the-repository-fix:
  refs: correct the version numbers in a comment

11 months agoPost 2.46-rc0 batch #3
Junio C Hamano [Wed, 17 Jul 2024 17:47:05 +0000 (10:47 -0700)] 
Post 2.46-rc0 batch #3

Signed-off-by: Junio C Hamano <gitster@pobox.com>