Commit graph

72403 commits

Author SHA1 Message Date
Junio C Hamano 36ffba1c7b sideband: avoid short write(2)
The sideband demultiplexor writes the data it receives on sideband
with xwrite().  We can lose data if the underlying write(2) results
in a short write.

If they are limited to unimportant bytes like eye-candy progress
meter, it may be OK to lose them, but lets be careful and ensure
that we use write_in_full() instead.  Note that the original does
not check for errors, and this rewrite does not check for one.  At
least not yet.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-03-02 11:12:16 -08:00
Junio C Hamano fa6c383309 unpack: replace xwrite() loop with write_in_full()
We have two packfile stream consumers, index-pack and
unpack-objects, that allow excess payload after the packfile stream
data. Their code to relay excess data hasn't changed significantly
since their original implementation that appeared in 67e5a5ec
(git-unpack-objects: re-write to read from stdin, 2005-06-28) and
9bee2478 (mimic unpack-objects when --stdin is used with index-pack,
2006-10-25).

These code blocks contain hand-rolled loops using xwrite(), written
before our write_in_full() helper existed. This helper now provides
the same functionality.

Replace these loops with write_in_full() for shorter, clearer
code. Update related variables accordingly.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-03-02 11:12:16 -08:00
Junio C Hamano b387623c12 The third batch
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-03-01 14:38:56 -08:00
Junio C Hamano 421d5a7574 Merge branch 'tb/multi-pack-verbatim-reuse' into HEAD
Docfix.

* tb/multi-pack-verbatim-reuse:
  Documentation/config/pack.txt: fix broken AsciiDoc mark-up
2024-03-01 14:38:56 -08:00
Junio C Hamano 2b5738c867 Merge branch 'hs/rebase-not-in-progress' into HEAD
Error message update.

* hs/rebase-not-in-progress:
  rebase: make warning less passive aggressive
2024-03-01 14:38:56 -08:00
Junio C Hamano 8e69efba8f Merge branch 'jw/remote-doc-typofix' into HEAD
Docfix.

* jw/remote-doc-typofix:
  git-remote.txt: fix typo
2024-03-01 14:38:56 -08:00
Junio C Hamano fd6e3cdaea Merge branch 'jc/doc-add-placeholder-fix' into HEAD
Practice the new mark-up rule for <placeholders> with "git add"
documentation page.

* jc/doc-add-placeholder-fix:
  doc: apply the new placeholder rules to git-add documentation
2024-03-01 14:38:55 -08:00
Junio C Hamano 9ce1ca3045 Merge branch 'ja/doc-placeholders-markup-rules' into HEAD
The way placeholders are to be marked-up in documentation have been
specified; use "_<placeholder>_" to typeset the word inside a pair
of <angle-brakets> emphasized.

* ja/doc-placeholders-markup-rules:
  doc: clarify the format of placeholders
2024-03-01 14:38:55 -08:00
Junio C Hamano 510a27e9e4 Merge branch 'ps/reflog-list' into HEAD
"git reflog" learned a "list" subcommand that enumerates known reflogs.

* ps/reflog-list:
  builtin/reflog: introduce subcommand to list reflogs
  refs: stop resolving ref corresponding to reflogs
  refs: drop unused params from the reflog iterator callback
  refs: always treat iterators as ordered
  refs/files: sort merged worktree and common reflogs
  refs/files: sort reflogs returned by the reflog iterator
  dir-iterator: support iteration in sorted order
  dir-iterator: pass name to `prepare_next_entry_data()` directly
2024-03-01 14:38:55 -08:00
Junio C Hamano 221c3daef4 Merge branch 'ds/doc-send-email-capitalization' into HEAD
Doc update.

* ds/doc-send-email-capitalization:
  documentation: send-email: use camel case consistently
2024-03-01 14:38:54 -08:00
Junio C Hamano af88fbd949 Merge branch 'ja/docfixes' into HEAD
Doc update.

* ja/docfixes:
  doc: end sentences with full-stop
  doc: close unclosed angle-bracket of a placeholder in git-clone doc
  doc: git-rev-parse: enforce command-line description syntax
2024-03-01 14:38:54 -08:00
Junio C Hamano 90c0c15e56 Merge branch 'cp/t9146-use-test-path-helpers' into HEAD
Test script clean-up.

* cp/t9146-use-test-path-helpers:
  t9146: replace test -d/-e/-f with appropriate test_path_is_* function
2024-03-01 14:38:54 -08:00
Junio C Hamano a87469cc99 Merge branch 'ps/difftool-dir-diff-exit-code' into HEAD
"git difftool --dir-diff" learned to honor the "--trust-exit-code"
option; it used to always exit with 0 and signalled success.

* ps/difftool-dir-diff-exit-code:
  git-difftool--helper: honor `--trust-exit-code` with `--dir-diff`
2024-03-01 14:38:54 -08:00
Junio C Hamano 0f9d4d28b7 The second batch
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-02-27 16:04:33 -08:00
Junio C Hamano ebd46baf99 Merge branch 'jb/doc-interactive-singlekey-do-not-need-perl'
Doc clean-up.

* jb/doc-interactive-singlekey-do-not-need-perl:
  doc: remove outdated information about interactive.singleKey
2024-02-27 16:04:33 -08:00
Junio C Hamano a56bb9f66a Merge branch 'jk/t0303-clean'
Test clean-up.

* jk/t0303-clean:
  t0303: check that helper_test_clean removes all credentials
2024-02-27 16:04:33 -08:00
Junio C Hamano 70dadd510b Merge branch 'mh/libsecret-empty-password-fix'
Credential helper based on libsecret (in contrib/) has been updated
to handle an empty password correctly.

* mh/libsecret-empty-password-fix:
  libsecret: retrieve empty password
2024-02-27 16:04:32 -08:00
Junio C Hamano f71ed54f4d Merge branch 'bb/completion-no-grep-into-awk'
Some parts of command line completion script (in contrib/) have
been micro-optimized.

* bb/completion-no-grep-into-awk:
  completion: use awk for filtering the config entries
2024-02-27 16:04:32 -08:00
Junio C Hamano 66b1160141 Merge branch 'km/mergetool-vimdiff-layout-fallback'
Variants of vimdiff learned to honor mergetool.<variant>.layout settings.

* km/mergetool-vimdiff-layout-fallback:
  mergetools: vimdiff: use correct tool's name when reading mergetool config
2024-02-27 16:04:32 -08:00
Junio C Hamano 03f9f1a3a2 Merge branch 'ba/credential-test-clean-fix'
Test clean-up.

* ba/credential-test-clean-fix:
  t/lib-credential: clean additional credential
2024-02-27 16:04:32 -08:00
Junio C Hamano 98793866b9 Merge branch 'rj/tag-column-fix'
"git tag --column" failed to check the exit status of its "git
column" invocation, which has been corrected.

* rj/tag-column-fix:
  tag: error when git-column fails
2024-02-27 16:04:32 -08:00
Junio C Hamano 45072eefef Merge branch 'jc/am-whitespace-doc'
"git am --help" now tells readers what actions are available in
"git am --whitespace=<action>", in addition to saying that the
option is passed through to the underlying "git apply".

* jc/am-whitespace-doc:
  doc: add shortcut to "am --whitespace=<action>"
2024-02-27 16:04:31 -08:00
Junio C Hamano a2082dbdd3 Start the 2.45 cycle
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-02-26 18:10:25 -08:00
Junio C Hamano 7ece6ad823 Merge branch 'ps/ref-tests-update-even-more'
More tests that are marked as "ref-files only" have been updated to
improve test coverage of reftable backend.

* ps/ref-tests-update-even-more:
  t7003: ensure filter-branch prunes reflogs with the reftable backend
  t2011: exercise D/F conflicts with HEAD with the reftable backend
  t1405: remove unneeded cleanup step
  t1404: make D/F conflict tests compatible with reftable backend
  t1400: exercise reflog with gaps with reftable backend
  t0410: convert tests to use DEFAULT_REPO_FORMAT prereq
  t: move tests exercising the "files" backend
2024-02-26 18:10:25 -08:00
Junio C Hamano 65462776c2 Merge branch 'gt/at-is-synonym-for-head-in-add-patch'
Teach "git checkout -p" and friends that "@" is a synonym for
"HEAD".

* gt/at-is-synonym-for-head-in-add-patch:
  add -p tests: remove PERL prerequisites
  add-patch: classify '@' as a synonym for 'HEAD'
2024-02-26 18:10:25 -08:00
Junio C Hamano cf258a9e4e Merge branch 'kh/column-reject-negative-padding'
"git column" has been taught to reject negative padding value, as
it would lead to nonsense behaviour including division by zero.

* kh/column-reject-negative-padding:
  column: guard against negative padding
  column: disallow negative padding
2024-02-26 18:10:25 -08:00
Junio C Hamano 225f892685 Merge branch 'jc/t9210-lazy-fix'
Adjust use of "rev-list --missing" in an existing tests so that it
does not depend on a buggy failure mode.

* jc/t9210-lazy-fix:
  t9210: do not rely on lazy fetching to fail
2024-02-26 18:10:24 -08:00
Junio C Hamano 9f67cbd0a7 Merge branch 'ps/reftable-iteration-perf'
The code to iterate over refs with the reftable backend has seen
some optimization.

* ps/reftable-iteration-perf:
  reftable/reader: add comments to `table_iter_next()`
  reftable/record: don't try to reallocate ref record name
  reftable/block: swap buffers instead of copying
  reftable/pq: allocation-less comparison of entry keys
  reftable/merged: skip comparison for records of the same subiter
  reftable/merged: allocation-less dropping of shadowed records
  reftable/record: introduce function to compare records by key
2024-02-26 18:10:24 -08:00
Junio C Hamano 274400998b Merge branch 'rs/use-xstrncmpz'
Code clean-up.

* rs/use-xstrncmpz:
  use xstrncmpz()
2024-02-26 18:10:24 -08:00
Junio C Hamano cf47fb7ec7 Merge branch 'cp/apply-core-filemode'
"git apply" on a filesystem without filemode support have learned
to take a hint from what is in the index for the path, even when
not working with the "--index" or "--cached" option, when checking
the executable bit match what is required by the preimage in the
patch.

* cp/apply-core-filemode:
  apply: code simplification
  apply: correctly reverse patch's pre- and post-image mode bits
  apply: ignore working tree filemode when !core.filemode
2024-02-26 18:10:24 -08:00
Junio C Hamano b4385bf016 Merge branch 'ps/reftable-backend'
Integrate the reftable code into the refs framework as a backend.

* ps/reftable-backend:
  refs/reftable: fix leak when copying reflog fails
  ci: add jobs to test with the reftable backend
  refs: introduce reftable backend
2024-02-26 18:10:23 -08:00
Taylor Blau 97d1f233c6 Documentation/config/pack.txt: fix broken AsciiDoc mark-up
In af626ac0e0 (pack-bitmap: enable reuse from all bitmapped packs,
2023-12-14), the documentation for `pack.allowPackReuse` was amended to
include its effect when set to "multi".

This split the documentation into two paragraphs, but did not de-dent
the second paragraph on the right-hand side of a line-continuation
marker. This causes the rendered documentation to appear oddly, where
the second paragraph is treated as a <pre> block when rendered as HTML.

Fix this by correctly removing the indentation on the second paragraph.

Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-02-23 13:47:16 -08:00
Junio C Hamano 3c2a3fdc38 Git 2.43.3
-----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCAAdFiEE4fA2sf7nIh/HeOzvsLXohpav5ssFAmXX4zkACgkQsLXohpav
 5ssYqRAAkVcMK1RgXJaa7CRp0LuCpBVyzzn6oAxhLwDlG0y20WfbaVc9TLQP5SGl
 nxAlGUMFTNdIcNES0gV0H+w1N/4j+WzjujGpssPHNl6/drRMFjUZRosQIczwJpP/
 bxViF4QV3Tdl9xUPpn9gdt9GDez0HAhDBc48Vc/EYMakWq30KFcviHesiEIRmgaw
 IvSbmRNDBHm7wQ6DY70lug/THNDDVWdYYPirzJ+Q9N14JS8ARxEKOom2oQ4ycoG+
 E9I88R4aP2Ohb8+kZoLrejFuMn0xPotO8LyrdQhfleJjQIjIFi50v1PYcAoL+2qf
 GXE7jY7KnN6Ebm2HY1dJSeK2aU1bgSIYdEmoqGcthE9ifwA+pjjPIRbO6ZnhAQ4p
 v2lIclXrSMbxI7YxhXIu9GujR3CpCfjk999s3hNPR41r3uvrl/2oBCryHurLqbDl
 WNCxjZxTt8nLNAjKU04W5OswDREJHZENuTHziBJoN4gSxHCskqjnSYXbLLJNvUzh
 I25fI52ZTGPx+cASC9lSslyocmDU+MubQi6v8+wzKO2yPQZw+nPuodA3f+KWg2Du
 gwSvwVwdyZxJy9Gq2RUExWl09GZHYq5snUNe1nqOAHbepNr6QWB6I6BRPv9pDCMU
 uNR6P7U2IKRqXYfUuFeW6QxhdqibnNA3Qc6Wr4Y7yyM1Au9SpGg=
 =c/2C
 -----END PGP SIGNATURE-----

Git 2.44

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-02-22 16:14:53 -08:00
Junio C Hamano 0d464a4e6a Git 2.43.3
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-02-22 16:13:38 -08:00
Junio C Hamano 5dc7366297 Merge branch 'la/trailer-cleanups' into maint-2.43
* la/trailer-cleanups:
  trailer: fix comment/cut-line regression with opts->no_divider
2024-02-22 16:09:45 -08:00
Junio C Hamano 41bff66e35 doc: apply the new placeholder rules to git-add documentation
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-02-21 14:03:57 -08:00
Jean-Noël Avila 0824639ddf doc: clarify the format of placeholders
Add the new format rule when using placeholders in the description of
commands and options.

Signed-off-by: Jean-Noël Avila <jn.avila@free.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-02-21 14:01:46 -08:00
Jakub Wilk 6835f0efe9 git-remote.txt: fix typo
Signed-off-by: Jakub Wilk <jwilk@jwilk.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-02-21 10:02:55 -08:00
Patrick Steinhardt d699d15c32 builtin/reflog: introduce subcommand to list reflogs
While the git-reflog(1) command has subcommands to show reflog entries
or check for reflog existence, it does not have any subcommands that
would allow the user to enumerate all existing reflogs. This makes it
quite hard to discover which reflogs a repository has. While this can
be worked around with the "files" backend by enumerating files in the
".git/logs" directory, users of the "reftable" backend don't enjoy such
a luxury.

Introduce a new subcommand `git reflog list` that lists all reflogs the
repository knows of to fill this gap.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-02-21 09:58:07 -08:00
Patrick Steinhardt 59c50a96c5 refs: stop resolving ref corresponding to reflogs
The reflog iterator tries to resolve the corresponding ref for every
reflog that it is about to yield. Historically, this was done due to
multiple reasons:

  - It ensures that the refname is safe because we end up calling
    `check_refname_format()`. Also, non-conformant refnames are skipped
    altogether.

  - The iterator used to yield the resolved object ID as well as its
    flags to the callback. This info was never used though, and the
    corresponding parameters were dropped in the preceding commit.

  - When a ref is corrupt then the reflog is not emitted at all.

We're about to introduce a new `git reflog list` subcommand that will
print all reflogs that the refdb knows about. Skipping over reflogs
whose refs are corrupted would be quite counterproductive in this case
as the user would have no way to learn about reflogs which may still
exist in their repository to help and rescue such a corrupted ref. Thus,
the only remaining reason for why we'd want to resolve the ref is to
verify its refname.

Refactor the code to call `check_refname_format()` directly instead of
trying to resolve the ref. This is significantly more efficient given
that we don't have to hit the object database anymore to list reflogs.
And second, it ensures that we end up showing reflogs of broken refs,
which will help to make the reflog more useful.

Note that this really only impacts the case where the corresponding ref
is corrupt. Reflogs for nonexistent refs would have been returned to the
caller beforehand already as we did not pass `RESOLVE_REF_READING` to
the function, and thus `refs_resolve_ref_unsafe()` would have returned
successfully in that case.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-02-21 09:58:06 -08:00
Patrick Steinhardt 31f898397b refs: drop unused params from the reflog iterator callback
The ref and reflog iterators share much of the same underlying code to
iterate over the corresponding entries. This results in some weird code
because the reflog iterator also exposes an object ID as well as a flag
to the callback function. Neither of these fields do refer to the reflog
though -- they refer to the corresponding ref with the same name. This
is quite misleading. In practice at least the object ID cannot really be
implemented in any other way as a reflog does not have a specific object
ID in the first place. This is further stressed by the fact that none of
the callbacks except for our test helper make use of these fields.

Split up the infrastucture so that ref and reflog iterators use separate
callback signatures. This allows us to drop the nonsensical fields from
the reflog iterator.

Note that internally, the backends still use the same shared infra to
iterate over both types. As the backends should never end up being
called directly anyway, this is not much of a problem and thus kept
as-is for simplicity's sake.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-02-21 09:58:06 -08:00
Patrick Steinhardt 5e01d83841 refs: always treat iterators as ordered
In the preceding commit we have converted the reflog iterator of the
"files" backend to be ordered, which was the only remaining ref iterator
that wasn't ordered. Refactor the ref iterator infrastructure so that we
always assume iterators to be ordered, thus simplifying the code.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-02-21 09:58:06 -08:00
Patrick Steinhardt 6f22780017 refs/files: sort merged worktree and common reflogs
When iterating through reflogs in a worktree we create a merged iterator
that merges reflogs from both refdbs. The resulting refs are ordered so
that instead we first return all worktree reflogs before we return all
common refs.

This is the only remaining case where a ref iterator returns entries in
a non-lexicographic order. The result would look something like the
following (listed with a command we introduce in a subsequent commit):

```
$ git reflog list
HEAD
refs/worktree/per-worktree
refs/heads/main
refs/heads/wt
```

So we first print the per-worktree reflogs in lexicographic order, then
the common reflogs in lexicographic order. This is confusing and not
consistent with how we print per-worktree refs, which are exclusively
sorted lexicographically.

Sort reflogs lexicographically in the same way as we sort normal refs.
As this is already implemented properly by the "reftable" backend via a
separate selection function, we simply pull out that logic and reuse it
for the "files" backend. As logs are properly sorted now, mark the
merged reflog iterator as sorted.

Tests will be added in a subsequent commit.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-02-21 09:58:06 -08:00
Patrick Steinhardt e69e8ffef7 refs/files: sort reflogs returned by the reflog iterator
We use a directory iterator to return reflogs via the reflog iterator.
This iterator returns entries in the same order as readdir(3P) would and
will thus yield reflogs with no discernible order.

Set the new `DIR_ITERATOR_SORTED` flag that was introduced in the
preceding commit so that the order is deterministic. While the effect of
this can only been observed in a test tool, a subsequent commit will
start to expose this functionality to users via a new `git reflog list`
subcommand.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-02-21 09:58:05 -08:00
Patrick Steinhardt de34f2651e dir-iterator: support iteration in sorted order
The `struct dir_iterator` is a helper that allows us to iterate through
directory entries. This iterator returns entries in the exact same order
as readdir(3P) does -- or in other words, it guarantees no specific
order at all.

This is about to become problematic as we are introducing a new reflog
subcommand to list reflogs. As the "files" backend uses the directory
iterator to enumerate reflogs, returning reflog names and exposing them
to the user would inherit the indeterministic ordering. Naturally, it
would make for a terrible user interface to show a list with no
discernible order.

While this could be handled at a higher level by the new subcommand
itself by collecting and ordering the reflogs, this would be inefficient
because we would first have to collect all reflogs before we can sort
them, which would introduce additional latency when there are many
reflogs.

Instead, introduce a new option into the directory iterator that asks
for its entries to be yielded in lexicographical order. If set, the
iterator will read all directory entries greedily and sort them before
we start to iterate over them.

While this will of course also incur overhead as we cannot yield the
directory entries immediately, it should at least be more efficient than
having to sort the complete list of reflogs as we only need to sort one
directory at a time.

This functionality will be used in a follow-up commit.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-02-21 09:58:05 -08:00
Patrick Steinhardt 0218de2bdb dir-iterator: pass name to prepare_next_entry_data() directly
When adding the next directory entry for `struct dir_iterator` we pass
the complete `struct dirent *` to `prepare_next_entry_data()` even
though we only need the entry's name.

Refactor the code to pass in the name, only. This prepares for a
subsequent commit where we introduce the ability to iterate through
dir entries in an ordered manner.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-02-21 09:58:05 -08:00
Harmen Stoppels 244001aa20 rebase: make warning less passive aggressive
When you run `git rebase --continue` when no rebase is in progress, git
outputs `fatal: No rebase in progress?` which is not a question but a
statement. Make it appear as a statement, and use lowercase to align
with error message style.

Signed-off-by: Harmen Stoppels <me@harmenstoppels.nl>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-02-21 09:52:34 -08:00
Jean-Noël Avila abab32a613 doc: end sentences with full-stop
Signed-off-by: Jean-Noël Avila <jn.avila@free.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-02-20 15:03:13 -08:00
Jean-Noël Avila 2e48553fda doc: close unclosed angle-bracket of a placeholder in git-clone doc
Signed-off-by: Jean-Noël Avila <jn.avila@free.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-02-20 15:02:27 -08:00
Jean-Noël Avila de2852ab6f doc: git-rev-parse: enforce command-line description syntax
git-rev-parse(1) manpage is completely off with respect to the
command-line description syntax with badly formatted placeholders and
malformed alternatives.

Signed-off-by: Jean-Noël Avila <jn.avila@free.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-02-20 14:41:37 -08:00