]> git.ipfire.org Git - thirdparty/git.git/log
thirdparty/git.git
6 months agoconfig: forbid newline as core.commentChar
Jeff King [Tue, 12 Mar 2024 09:17:06 +0000 (05:17 -0400)] 
config: forbid newline as core.commentChar

Since we usually look for a comment char while parsing line-oriented
files, setting core.commentChar to a single newline can confuse our code
quite a bit. For example, using it with "git commit" causes us to fail
to recognize any of the template as comments, including it in the config
message. Which kind of makes sense, since the template content is on its
own line (so no line can "start" with a newline). In other spots I would
not be surprised if you can create more mischief (e.g., violating loop
assumptions) but I didn't dig into it.

Since comment characters are a local preference, to some degree this is
a case of "if it hurts, don't do it". But given that this would be a
silly and pointless thing to do, and that it makes it harder to reason
about code parsing comment lines, let's just forbid it.

There are other cases that are perhaps questionable (e.g., setting the
comment char to a single space), but they seem to behave reasonably (at
least a simple "git commit" will correctly identify and strip the
template lines). So I haven't worried about going on a hunt for every
stupid thing a user might do to themselves, and just focused on the most
confusing case.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 months agoThe fourth batch
Junio C Hamano [Tue, 5 Mar 2024 17:31:41 +0000 (09:31 -0800)] 
The fourth batch

Also update the DEF_VER in GIT-VERSION-GEN, which I forgot to do
earlier (it should have been done when we started the new cycle).

Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 months agoMerge branch 'ak/rebase-autosquash'
Junio C Hamano [Tue, 5 Mar 2024 17:44:44 +0000 (09:44 -0800)] 
Merge branch 'ak/rebase-autosquash'

Typofix.

* ak/rebase-autosquash:
  rebase: fix typo in autosquash documentation

6 months agoMerge branch 'kn/for-all-refs'
Junio C Hamano [Tue, 5 Mar 2024 17:44:44 +0000 (09:44 -0800)] 
Merge branch 'kn/for-all-refs'

"git for-each-ref" learned "--include-root-refs" option to show
even the stuff outside the 'refs/' hierarchy.

* kn/for-all-refs:
  for-each-ref: add new option to include root refs
  ref-filter: rename 'FILTER_REFS_ALL' to 'FILTER_REFS_REGULAR'
  refs: introduce `refs_for_each_include_root_refs()`
  refs: extract out `loose_fill_ref_dir_regular_file()`
  refs: introduce `is_pseudoref()` and `is_headref()`

6 months agoMerge branch 'pb/ort-make-submodule-conflict-message-an-advice'
Junio C Hamano [Tue, 5 Mar 2024 17:44:43 +0000 (09:44 -0800)] 
Merge branch 'pb/ort-make-submodule-conflict-message-an-advice'

When a merge conflicted at a submodule, merge-ort backend used to
unconditionally give a lengthy message to suggest how to resolve
it.  Now the message can be squelched as an advice message.

* pb/ort-make-submodule-conflict-message-an-advice:
  merge-ort: turn submodule conflict suggestions into an advice

6 months agoMerge branch 'jc/doc-compat-util'
Junio C Hamano [Tue, 5 Mar 2024 17:44:43 +0000 (09:44 -0800)] 
Merge branch 'jc/doc-compat-util'

Clarify wording in the CodingGuidelines that requires <git-compat-util.h>
to be the first header file.

* jc/doc-compat-util:
  doc: clarify the wording on <git-compat-util.h> requirement

6 months agoMerge branch 'sg/upload-pack-error-message-fix'
Junio C Hamano [Tue, 5 Mar 2024 17:44:43 +0000 (09:44 -0800)] 
Merge branch 'sg/upload-pack-error-message-fix'

An error message from "git upload-pack", which responds to "git
fetch" requests, had a trialing NUL in it, which has been
corrected.

* sg/upload-pack-error-message-fix:
  upload-pack: don't send null character in abort message to the client

6 months agoMerge branch 'rs/submodule-prefix-simplify'
Junio C Hamano [Tue, 5 Mar 2024 17:44:43 +0000 (09:44 -0800)] 
Merge branch 'rs/submodule-prefix-simplify'

Code simplification.

* rs/submodule-prefix-simplify:
  submodule: use strvec_pushf() for --submodule-prefix

6 months agoMerge branch 'rs/name-rev-with-mempool'
Junio C Hamano [Tue, 5 Mar 2024 17:44:43 +0000 (09:44 -0800)] 
Merge branch 'rs/name-rev-with-mempool'

Many small allocations "git name-rev" makes have been updated to
allocate from a mem-pool.

* rs/name-rev-with-mempool:
  name-rev: use mem_pool_strfmt()
  mem-pool: add mem_pool_strfmt()

6 months agoMerge branch 'rs/fetch-simplify-with-starts-with'
Junio C Hamano [Tue, 5 Mar 2024 17:44:42 +0000 (09:44 -0800)] 
Merge branch 'rs/fetch-simplify-with-starts-with'

Code simplification.

* rs/fetch-simplify-with-starts-with:
  fetch: convert strncmp() with strlen() to starts_with()

6 months agoMerge branch 'jk/reflog-special-cases-fix'
Junio C Hamano [Tue, 5 Mar 2024 17:44:42 +0000 (09:44 -0800)] 
Merge branch 'jk/reflog-special-cases-fix'

The logic to access reflog entries by date and number had ugly
corner cases at the boundaries, which have been cleaned up.

* jk/reflog-special-cases-fix:
  read_ref_at(): special-case ref@{0} for an empty reflog
  get_oid_basic(): special-case ref@{n} for oldest reflog entry
  Revert "refs: allow @{n} to work with n-sized reflog"

6 months agoMerge branch 'jc/no-include-of-compat-util-from-headers'
Junio C Hamano [Tue, 5 Mar 2024 17:44:42 +0000 (09:44 -0800)] 
Merge branch 'jc/no-include-of-compat-util-from-headers'

Header file clean-up.

* jc/no-include-of-compat-util-from-headers:
  compat: drop inclusion of <git-compat-util.h>

6 months agoMerge branch 'js/remove-cruft-files'
Junio C Hamano [Tue, 5 Mar 2024 17:44:42 +0000 (09:44 -0800)] 
Merge branch 'js/remove-cruft-files'

Remove an empty file that shouldn't have been added in the first
place.

* js/remove-cruft-files:
  neue: remove a bogus empty file

6 months agoMerge branch 'jk/textconv-cache-outside-repo-fix'
Junio C Hamano [Tue, 5 Mar 2024 17:44:42 +0000 (09:44 -0800)] 
Merge branch 'jk/textconv-cache-outside-repo-fix'

The code incorrectly attempted to use textconv cache when asked,
even when we are not running in a repository, which has been
corrected.

* jk/textconv-cache-outside-repo-fix:
  userdiff: skip textconv caching when not in a repository

6 months agoThe third batch
Junio C Hamano [Fri, 1 Mar 2024 17:23:17 +0000 (09:23 -0800)] 
The third batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 months agoMerge branch 'tb/multi-pack-verbatim-reuse' into HEAD
Junio C Hamano [Fri, 1 Mar 2024 22:38:56 +0000 (14:38 -0800)] 
Merge branch 'tb/multi-pack-verbatim-reuse' into HEAD

Docfix.

* tb/multi-pack-verbatim-reuse:
  Documentation/config/pack.txt: fix broken AsciiDoc mark-up

6 months agoMerge branch 'hs/rebase-not-in-progress' into HEAD
Junio C Hamano [Fri, 1 Mar 2024 22:38:56 +0000 (14:38 -0800)] 
Merge branch 'hs/rebase-not-in-progress' into HEAD

Error message update.

* hs/rebase-not-in-progress:
  rebase: make warning less passive aggressive

6 months agoMerge branch 'jw/remote-doc-typofix' into HEAD
Junio C Hamano [Fri, 1 Mar 2024 22:38:56 +0000 (14:38 -0800)] 
Merge branch 'jw/remote-doc-typofix' into HEAD

Docfix.

* jw/remote-doc-typofix:
  git-remote.txt: fix typo

6 months agoMerge branch 'jc/doc-add-placeholder-fix' into HEAD
Junio C Hamano [Fri, 1 Mar 2024 22:38:55 +0000 (14:38 -0800)] 
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

6 months agoMerge branch 'ja/doc-placeholders-markup-rules' into HEAD
Junio C Hamano [Fri, 1 Mar 2024 22:38:55 +0000 (14:38 -0800)] 
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

6 months agoMerge branch 'ps/reflog-list' into HEAD
Junio C Hamano [Fri, 1 Mar 2024 22:38:55 +0000 (14:38 -0800)] 
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

6 months agoMerge branch 'ds/doc-send-email-capitalization' into HEAD
Junio C Hamano [Fri, 1 Mar 2024 22:38:54 +0000 (14:38 -0800)] 
Merge branch 'ds/doc-send-email-capitalization' into HEAD

Doc update.

* ds/doc-send-email-capitalization:
  documentation: send-email: use camel case consistently

6 months agoMerge branch 'ja/docfixes' into HEAD
Junio C Hamano [Fri, 1 Mar 2024 22:38:54 +0000 (14:38 -0800)] 
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

6 months agoMerge branch 'cp/t9146-use-test-path-helpers' into HEAD
Junio C Hamano [Fri, 1 Mar 2024 22:38:54 +0000 (14:38 -0800)] 
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

6 months agoMerge branch 'ps/difftool-dir-diff-exit-code' into HEAD
Junio C Hamano [Fri, 1 Mar 2024 22:38:54 +0000 (14:38 -0800)] 
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`

6 months agoThe second batch
Junio C Hamano [Wed, 28 Feb 2024 00:04:14 +0000 (16:04 -0800)] 
The second batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 months agoMerge branch 'jb/doc-interactive-singlekey-do-not-need-perl'
Junio C Hamano [Wed, 28 Feb 2024 00:04:33 +0000 (16:04 -0800)] 
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

6 months agoMerge branch 'jk/t0303-clean'
Junio C Hamano [Wed, 28 Feb 2024 00:04:32 +0000 (16:04 -0800)] 
Merge branch 'jk/t0303-clean'

Test clean-up.

* jk/t0303-clean:
  t0303: check that helper_test_clean removes all credentials

6 months agoMerge branch 'mh/libsecret-empty-password-fix'
Junio C Hamano [Wed, 28 Feb 2024 00:04:32 +0000 (16:04 -0800)] 
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

6 months agoMerge branch 'bb/completion-no-grep-into-awk'
Junio C Hamano [Wed, 28 Feb 2024 00:04:32 +0000 (16:04 -0800)] 
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

6 months agoMerge branch 'km/mergetool-vimdiff-layout-fallback'
Junio C Hamano [Wed, 28 Feb 2024 00:04:32 +0000 (16:04 -0800)] 
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

6 months agoMerge branch 'ba/credential-test-clean-fix'
Junio C Hamano [Wed, 28 Feb 2024 00:04:32 +0000 (16:04 -0800)] 
Merge branch 'ba/credential-test-clean-fix'

Test clean-up.

* ba/credential-test-clean-fix:
  t/lib-credential: clean additional credential

6 months agoMerge branch 'rj/tag-column-fix'
Junio C Hamano [Wed, 28 Feb 2024 00:04:31 +0000 (16:04 -0800)] 
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

6 months agoMerge branch 'jc/am-whitespace-doc'
Junio C Hamano [Wed, 28 Feb 2024 00:04:31 +0000 (16:04 -0800)] 
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>"

6 months agodoc: clarify the wording on <git-compat-util.h> requirement
Junio C Hamano [Mon, 26 Feb 2024 23:28:16 +0000 (15:28 -0800)] 
doc: clarify the wording on <git-compat-util.h> requirement

The reason why we require the <git-compat-util.h> file to be the
first header file to be included is because it insulates other
header files and source files from platform differences, like which
system header files must be included in what order, and what C
preprocessor feature macros must be defined to trigger certain
features we want out of the system.

We tried to clarify the rule in the coding guidelines document, but
the wording was a bit fuzzy that can lead to misinterpretations like
you can include <xdiff/xinclude.h> only to avoid having to include
<git-compat-util.h> even if you have nothing to do with the xdiff
implementation, for example.  "You do not have to include more than
one of these" was also misleading and would have been puzzling if
you _needed_ to depend on more than one of these approved headers
(answer: you are allowed to include them all if you need the
declarations in them for reasons other than that you want to avoid
including compat-util yourself).

Instead of using the phrase "approved headers", enumerate them as
exceptions, each labeled with its intended audiences, to avoid such
misinterpretations.  The structure also makes it easier to add new
exceptions, so add the description of "t/unit-tests/test-lib.h"
being an exception only for the unit tests implementation as an
example.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
Acked-by: Kyle Lippincott <spectral@google.com>
Acked-by: Elijah Newren <newren@gmail.com>
6 months agorebase: fix typo in autosquash documentation
Richard Macklin [Tue, 27 Feb 2024 06:32:58 +0000 (06:32 +0000)] 
rebase: fix typo in autosquash documentation

This is a minor follow-up to cb00f524df (rebase: rewrite
--(no-)autosquash documentation, 2023-11-14) to fix a typo introduced in
that commit.

Signed-off-by: Richard Macklin <code@rmacklin.dev>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 months agoStart the 2.45 cycle
Junio C Hamano [Tue, 27 Feb 2024 01:23:44 +0000 (17:23 -0800)] 
Start the 2.45 cycle

Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 months agoMerge branch 'ps/ref-tests-update-even-more'
Junio C Hamano [Tue, 27 Feb 2024 02:10:25 +0000 (18:10 -0800)] 
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

6 months agoMerge branch 'gt/at-is-synonym-for-head-in-add-patch'
Junio C Hamano [Tue, 27 Feb 2024 02:10:25 +0000 (18:10 -0800)] 
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'

6 months agoMerge branch 'kh/column-reject-negative-padding'
Junio C Hamano [Tue, 27 Feb 2024 02:10:25 +0000 (18:10 -0800)] 
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

6 months agoMerge branch 'jc/t9210-lazy-fix'
Junio C Hamano [Tue, 27 Feb 2024 02:10:24 +0000 (18:10 -0800)] 
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

6 months agoMerge branch 'ps/reftable-iteration-perf'
Junio C Hamano [Tue, 27 Feb 2024 02:10:24 +0000 (18:10 -0800)] 
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

6 months agoMerge branch 'rs/use-xstrncmpz'
Junio C Hamano [Tue, 27 Feb 2024 02:10:24 +0000 (18:10 -0800)] 
Merge branch 'rs/use-xstrncmpz'

Code clean-up.

* rs/use-xstrncmpz:
  use xstrncmpz()

6 months agoMerge branch 'cp/apply-core-filemode'
Junio C Hamano [Tue, 27 Feb 2024 02:10:24 +0000 (18:10 -0800)] 
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

6 months agoMerge branch 'ps/reftable-backend'
Junio C Hamano [Tue, 27 Feb 2024 02:10:23 +0000 (18:10 -0800)] 
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

6 months agoneue: remove a bogus empty file
Johannes Schindelin [Mon, 26 Feb 2024 14:36:23 +0000 (14:36 +0000)] 
neue: remove a bogus empty file

This file has been added as part of 2232a88ab6b (attr: add builtin
objectmode values support, 2023-11-16) and most likely serves no
relevant purpose.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 months agomerge-ort: turn submodule conflict suggestions into an advice
Philippe Blain [Mon, 26 Feb 2024 13:27:28 +0000 (13:27 +0000)] 
merge-ort: turn submodule conflict suggestions into an advice

Add a new advice type 'submoduleMergeConflict' for the error message
shown when a non-trivial submodule conflict is encountered, which
was added in 4057523a40 (submodule merge: update conflict error
message, 2022-08-04). That commit mentions making this message an
advice as possible future work.  The message can now be disabled
with the advice mechanism.

Update the tests as the expected message now appears on stderr instead
of stdout.

Signed-off-by: Philippe Blain <levraiphilippeblain@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 months agoread_ref_at(): special-case ref@{0} for an empty reflog
Jeff King [Mon, 26 Feb 2024 10:08:03 +0000 (05:08 -0500)] 
read_ref_at(): special-case ref@{0} for an empty reflog

The previous commit special-cased get_oid_basic()'s handling of ref@{n}
for a reflog with n entries. But its special case doesn't work for
ref@{0} in an empty reflog, because read_ref_at() dies when it notices
the empty reflog!

We can make this work by special-casing this in read_ref_at(). It's
somewhat gross, for two reasons:

  1. We have no reflog entry to describe in the "msg" out-parameter. So
     we have to leave it uninitialized or make something up.

  2. Likewise, we have no oid to put in the "oid" out-parameter. Leaving
     it untouched is actually the best thing here, as all of the callers
     will have initialized it with the current ref value via
     repo_dwim_log(). This is rather subtle, but it is how things worked
     in 6436a20284 (refs: allow @{n} to work with n-sized reflog,
     2021-01-07) before we reverted it.

The key difference from 6436a20284 here is that we'll return "1" to
indicate that we _didn't_ find the requested reflog entry. Coupled with
the special-casing in get_oid_basic() in the previous commit, that's
enough to make looking up ref@{0} work, and we can flip 6436a20284's
test back to expect_success.

It also means that the call in show-branch which segfaulted with
6436a20284 (and which is now tested in t3202) remains OK. The caller
notices that we could not find any reflog entry, and so it breaks out of
its loop, showing nothing. This is different from the current behavior
of producing an error, but it's just as reasonable (and is exactly what
we'd do if you asked it to walk starting at ref@{1} but there was only 1
entry).

Thus nobody should actually look at the reflog entry info we return. But
we'll still put in some fake values just to be on the safe side, since
this is such a subtle and confusing interface. Likewise, we'll document
what's going on in a comment above the function declaration. If this
were a function with a lot of callers, the footgun would probably not be
worth it. But it has only ever had two callers in its 18-year existence,
and it seems unlikely to grow more. So let's hold our noses and let
users enjoy the convenience of a simulated ref@{0}.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 months agoget_oid_basic(): special-case ref@{n} for oldest reflog entry
Jeff King [Mon, 26 Feb 2024 10:04:07 +0000 (05:04 -0500)] 
get_oid_basic(): special-case ref@{n} for oldest reflog entry

The goal of 6436a20284 (refs: allow @{n} to work with n-sized reflog,
2021-01-07) was that if we have "n" entries in a reflog, we should still
be able to resolve ref@{n} by looking at the "old" value of the oldest
entry.

Commit 6436a20284 tried to put the logic into read_ref_at() by shifting
its idea of "n" by one. But we reverted that in the previous commit,
since it led to bugs in other callers which cared about the details of
the reflog entry we found. Instead, let's put the special case into the
caller that resolves @{n}, as it cares only about the oid.

read_ref_at() is even kind enough to return the "old" value from the
final reflog; it just returns "1" to signal to us that we ran off the
end of the reflog. But we can notice in the caller that we read just
enough records for that "old" value to be the one we're looking for, and
use it.

Note that read_ref_at() could notice this case, too, and just return 0.
But we don't want to do that, because the caller must be made aware that
we only found the oid, not an actual reflog entry (and the call sites in
show-branch do care about this).

There is one complication, though. When read_ref_at() hits a truncated
reflog, it will return the "old" value of the oldest entry only if it is
not the null oid. Otherwise, it actually returns the "new" value from
that entry! This bit of fudging is due to d1a4489a56 (avoid null SHA1 in
oldest reflog, 2008-07-08), where asking for "ref@{20.years.ago}" for a
ref created recently will produce the initial value as a convenience
(even though technically it did not exist 20 years ago).

But this convenience is only useful for time-based cutoffs. For
count-based cutoffs, get_oid_basic() has always simply complained about
going too far back:

  $ git rev-parse HEAD@{20}
  fatal: log for 'HEAD' only has 16 entries

and we should continue to do so, rather than returning a nonsense value
(there's even a test in t1508 already which covers this). So let's have
the d1a4489a56 code kick in only when doing timestamp-based cutoffs.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 months agoRevert "refs: allow @{n} to work with n-sized reflog"
Jeff King [Mon, 26 Feb 2024 10:02:26 +0000 (05:02 -0500)] 
Revert "refs: allow @{n} to work with n-sized reflog"

This reverts commit 6436a20284f33d42103cac93bd82e65bebb31526.

The idea of that commit is that if read_ref_at() is counting back to the
Nth reflog but the reflog is short by one entry (e.g., because it was
pruned), we can find the oid of the missing entry by looking at the
"before" oid value of the entry that comes after it (whereas before, we
looked at the "after" value of each entry and complained that we
couldn't find the one from before the truncation).

This works fine for resolving the oid of ref@{n}, as it is used by
get_oid_basic(), which does not look at any other aspect of the reflog
we found (e.g., its timestamp or message). But there's another caller of
read_ref_at(): in show-branch we use it to walk over the reflog, and we
do care about the reflog entry. And so that commit broke "show-branch
--reflog"; it shows the reflog message for ref@{0} as ref@{1}, ref@{1}
as ref@{2}, and so on.

For example, in the new test in t3202 we produce:

  ! [branch@{0}] (0 seconds ago) commit: three
   ! [branch@{1}] (0 seconds ago) commit: three
    ! [branch@{2}] (60 seconds ago) commit: two
     ! [branch@{3}] (2 minutes ago) reset: moving to HEAD^

instead of the correct:

  ! [branch@{0}] (0 seconds ago) commit: three
   ! [branch@{1}] (60 seconds ago) commit: two
    ! [branch@{2}] (2 minutes ago) reset: moving to HEAD^
     ! [branch@{3}] (2 minutes ago) commit: one

But there's another bug, too: because it is looking at the "old" value
of the reflog after the one we're interested in, it has to special-case
ref@{0} (since there isn't anything after it). That's why it doesn't
show the offset bug in the output above. But this special-case code
fails to handle the situation where the reflog is empty or missing; it
returns success even though the reflog message out-parameter has been
left uninitialized. You can't trigger this through get_oid_basic(), but
"show-branch --reflog" will pretty reliably segfault as it tries to
access the garbage pointer.

Fixing the segfault would be pretty easy. But the off-by-one problem is
inherent in this approach. So let's start by reverting the commit to
give us a clean slate to work with.

This isn't a pure revert; all of the code changes are reverted, but for
the tests:

  1. We'll flip the cases in t1508 to expect_failure; making these work
     was the goal of 6436a2028, and we'll want to use them for our
     replacement approach.

  2. There's a test in t3202 for "show-branch --reflog", but it expects
     the broken output! It was added by f2463490c4 (show-branch: show
     reflog message, 2021-12-02) which was fixing another bug, and I
     think the author simply didn't notice that the second line showed
     the wrong reflog.

     Rather than fixing that test, let's replace it with one that is
     more thorough (while still covering the reflog message fix from
     that commit). We'll use a longer reflog, which lets us see more
     entries (thus making the "off by one" pattern much more clear). And
     we'll use a more recent timestamp for "now" so that our relative
     dates have more resolution. That lets us see that the reflog dates
     are correct (whereas when you are 4 years away, two entries that
     are 60 seconds apart will have the same "4 years ago" relative
     date). Because we're adjusting the repository state, I've moved
     this new test to the end of the script, leaving the other tests
     undisturbed.

     We'll also add a new test which covers the missing reflog case;
     previously it segfaulted, but now it reports the empty reflog).

Reported-by: Yasushi SHOJI <yasushi.shoji@gmail.com>
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 months agoupload-pack: don't send null character in abort message to the client
SZEDER Gábor [Sun, 25 Feb 2024 18:34:52 +0000 (19:34 +0100)] 
upload-pack: don't send null character in abort message to the client

Since 583b7ea31b (upload-pack/fetch-pack: support side-band
communication, 2006-06-21) the abort message sent by upload-pack in
case of possible repository corruption ends with a null character.
This can be seen in several test cases in 't5530-upload-pack-error.sh'
where 'grep <pattern> output.err' often reports "Binary file
output.err matches" because of that null character.

The reason for this is that the abort message is defined as a string
literal, and we pass its size to the send function as
sizeof(abort_msg), which also counts the terminating null character.

Use strlen() instead to avoid sending that terminating null character.

Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 months agosubmodule: use strvec_pushf() for --submodule-prefix
René Scharfe [Sun, 25 Feb 2024 18:24:39 +0000 (19:24 +0100)] 
submodule: use strvec_pushf() for --submodule-prefix

Add the option --submodule-prefix and its argument directly using
strvec_pushf() instead of via a detour through a strbuf.  This is
shorter, easier to read and doesn't require any explicit cleanup
afterwards.

Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 months agouserdiff: skip textconv caching when not in a repository
Jeff King [Mon, 26 Feb 2024 10:27:29 +0000 (05:27 -0500)] 
userdiff: skip textconv caching when not in a repository

The textconv caching system uses git-notes to store its cache entries.
But if you're using "diff --no-index" outside of a repository, then
obviously that isn't going to work.

Since caching is just an optimization, it's OK for us to skip it.
However, the current behavior is much worse: we call notes_cache_init()
which tries to look up the ref, and the low-level ref code hits a BUG(),
killing the program. Instead, we should notice before setting up the
cache that it there's no repository, and just silently skip it.

Reported-by: Paweł Dominiak <dominiak.pawel@gmail.com>
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 months agoname-rev: use mem_pool_strfmt()
René Scharfe [Sun, 25 Feb 2024 11:39:45 +0000 (12:39 +0100)] 
name-rev: use mem_pool_strfmt()

1c56fc2084 (name-rev: pre-size buffer in get_parent_name(), 2020-02-04)
got a big performance boost in an unusual repository by calculating the
name length in advance.  This is a bit awkward, as it references the
name components twice.

Use a memory pool to store the strings for the struct rev_name member
tip_name.  Using mem_pool_strfmt() allows efficient allocation without
explicit size calculation.  This simplifies the formatting part of the
code without giving up performance:

Benchmark 1: ./git_2.44.0 -C ../chromium/src name-rev --all
  Time (mean ± σ):      1.231 s ±  0.013 s    [User: 1.082 s, System: 0.136 s]
  Range (min … max):    1.214 s …  1.252 s    10 runs

Benchmark 2: ./git -C ../chromium/src name-rev --all
  Time (mean ± σ):      1.220 s ±  0.020 s    [User: 1.083 s, System: 0.130 s]
  Range (min … max):    1.197 s …  1.254 s    10 runs

Don't bother discarding the memory pool just before exiting.  The effort
for that would be very low, but actually measurable in the above
example, with no benefit to users.  At least UNLEAK it to calm down leak
checkers.  This addresses the leaks that 45a14f578e (Revert "name-rev:
release unused name strings", 2022-04-22) brought back.

Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 months agomem-pool: add mem_pool_strfmt()
René Scharfe [Sun, 25 Feb 2024 11:39:44 +0000 (12:39 +0100)] 
mem-pool: add mem_pool_strfmt()

Add a function for building a string, printf style, using a memory pool.
It uses the free space in the current block in the first attempt.  If
that suffices then the result can already be used without copying or
reformatting.

For strings that are significantly shorter on average than the block
size (ca. 1 MiB by default) this is the case most of the time, leading
to a better perfomance than a solution that doesn't access mem-pool
internals.

Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 months agofetch: convert strncmp() with strlen() to starts_with()
René Scharfe [Sat, 24 Feb 2024 21:47:06 +0000 (22:47 +0100)] 
fetch: convert strncmp() with strlen() to starts_with()

Using strncmp() and strlen() to check whether a string starts with
another one requires repeating the prefix candidate.  Use starts_with()
instead, which reduces repetition and is more readable.

Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 months agocompat: drop inclusion of <git-compat-util.h>
Junio C Hamano [Sat, 24 Feb 2024 20:32:51 +0000 (12:32 -0800)] 
compat: drop inclusion of <git-compat-util.h>

These two header files are included from ordinary source files that
already include <git-compat-util.h> as the first header file as they
should.  There is no need to include the compat-util in these
headers.

"make hdr-check" is not affected, as it is designed to assume that
what <git-compat-util.h> offers is available to everybody without
being included.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 months agoDocumentation/config/pack.txt: fix broken AsciiDoc mark-up
Taylor Blau [Fri, 23 Feb 2024 20:30:58 +0000 (15:30 -0500)] 
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>
6 months agofor-each-ref: add new option to include root refs
Karthik Nayak [Fri, 23 Feb 2024 10:01:12 +0000 (11:01 +0100)] 
for-each-ref: add new option to include root refs

The git-for-each-ref(1) command doesn't provide a way to print root refs
i.e pseudorefs and HEAD with the regular "refs/" prefixed refs.

This commit adds a new option "--include-root-refs" to
git-for-each-ref(1). When used this would also print pseudorefs and HEAD
for the current worktree.

Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 months agoref-filter: rename 'FILTER_REFS_ALL' to 'FILTER_REFS_REGULAR'
Karthik Nayak [Fri, 23 Feb 2024 10:01:11 +0000 (11:01 +0100)] 
ref-filter: rename 'FILTER_REFS_ALL' to 'FILTER_REFS_REGULAR'

The flag 'FILTER_REFS_ALL' is a bit ambiguous, where ALL doesn't specify
if it means to contain refs from all worktrees or whether all types of
refs (regular, HEAD & pseudorefs) or all of the above.

Since here it is actually referring to all refs with the "refs/" prefix,
let's rename it to 'FILTER_REFS_REGULAR' to indicate that this is
specifically for regular refs.

Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 months agorefs: introduce `refs_for_each_include_root_refs()`
Karthik Nayak [Fri, 23 Feb 2024 10:01:10 +0000 (11:01 +0100)] 
refs: introduce `refs_for_each_include_root_refs()`

Introduce a new ref iteration flag `DO_FOR_EACH_INCLUDE_ROOT_REFS`,
which will be used to iterate over regular refs plus pseudorefs and
HEAD.

Refs which fall outside the `refs/` and aren't either pseudorefs or HEAD
are more of a grey area. This is because we don't block the users from
creating such refs but they are not officially supported.

Introduce `refs_for_each_include_root_refs()` which calls
`do_for_each_ref()` with this newly introduced flag.

In `refs/files-backend.c`, introduce a new function
`add_pseudoref_and_head_entries()` to add pseudorefs and HEAD to the
`ref_dir`. We then finally call `add_pseudoref_and_head_entries()`
whenever the `DO_FOR_EACH_INCLUDE_ROOT_REFS` flag is set. Any new ref
backend will also have to implement similar changes on its end.

Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 months agorefs: extract out `loose_fill_ref_dir_regular_file()`
Karthik Nayak [Fri, 23 Feb 2024 10:01:09 +0000 (11:01 +0100)] 
refs: extract out `loose_fill_ref_dir_regular_file()`

Extract out the code for adding a single file to the loose ref dir as
`loose_fill_ref_dir_regular_file()` from `loose_fill_ref_dir()` in
`refs/files-backend.c`.

This allows us to use this function independently in the following
commits where we add code to also add pseudorefs to the ref dir.

Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 months agorefs: introduce `is_pseudoref()` and `is_headref()`
Karthik Nayak [Fri, 23 Feb 2024 10:01:08 +0000 (11:01 +0100)] 
refs: introduce `is_pseudoref()` and `is_headref()`

Introduce two new functions `is_pseudoref()` and `is_headref()`. This
provides the necessary functionality for us to add pseudorefs and HEAD
to the loose ref cache in the files backend, allowing us to build
tooling to print these refs.

The `is_pseudoref()` function internally calls `is_pseudoref_syntax()`
but adds onto it by also checking to ensure that the pseudoref either
ends with a "_HEAD" suffix or matches a list of exceptions. After which
we also parse the contents of the pseudoref to ensure that it conforms
to the ref format.

We cannot directly add the new syntax checks to `is_pseudoref_syntax()`
because the function is also used by `is_current_worktree_ref()` and
making it stricter to match only known pseudorefs might have unintended
consequences due to files like 'BISECT_START' which isn't a pseudoref
but sometimes contains object ID.

Keeping this in mind, we leave `is_pseudoref_syntax()` as is and create
`is_pseudoref()` which is stricter. Ideally we'd want to move the new
syntax checks to `is_pseudoref_syntax()` but a prerequisite for this
would be to actually remove the exception list by converting those
pseudorefs to also contain a '_HEAD' suffix and perhaps move bisect
related files like 'BISECT_START' to a new directory similar to the
'rebase-merge' directory.

Helped-by: Jeff King <peff@peff.net>
Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 months agoGit 2.44 v2.44.0
Junio C Hamano [Fri, 23 Feb 2024 00:14:53 +0000 (16:14 -0800)] 
Git 2.44

Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 months agoGit 2.43.3 v2.43.3
Junio C Hamano [Fri, 23 Feb 2024 00:13:38 +0000 (16:13 -0800)] 
Git 2.43.3

Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 months agoMerge branch 'la/trailer-cleanups' into maint-2.43
Junio C Hamano [Fri, 23 Feb 2024 00:09:45 +0000 (16:09 -0800)] 
Merge branch 'la/trailer-cleanups' into maint-2.43

* la/trailer-cleanups:
  trailer: fix comment/cut-line regression with opts->no_divider

6 months agodoc: apply the new placeholder rules to git-add documentation
Junio C Hamano [Wed, 21 Feb 2024 22:03:57 +0000 (14:03 -0800)] 
doc: apply the new placeholder rules to git-add documentation

Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 months agodoc: clarify the format of placeholders
Jean-Noël Avila [Wed, 21 Feb 2024 21:18:59 +0000 (21:18 +0000)] 
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>
6 months agogit-remote.txt: fix typo
Jakub Wilk [Wed, 21 Feb 2024 08:35:54 +0000 (09:35 +0100)] 
git-remote.txt: fix typo

Signed-off-by: Jakub Wilk <jwilk@jwilk.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 months agobuiltin/reflog: introduce subcommand to list reflogs
Patrick Steinhardt [Wed, 21 Feb 2024 12:37:47 +0000 (13:37 +0100)] 
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>
6 months agorefs: stop resolving ref corresponding to reflogs
Patrick Steinhardt [Wed, 21 Feb 2024 12:37:43 +0000 (13:37 +0100)] 
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>
6 months agorefs: drop unused params from the reflog iterator callback
Patrick Steinhardt [Wed, 21 Feb 2024 12:37:39 +0000 (13:37 +0100)] 
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>
6 months agorefs: always treat iterators as ordered
Patrick Steinhardt [Wed, 21 Feb 2024 12:37:35 +0000 (13:37 +0100)] 
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>
6 months agorefs/files: sort merged worktree and common reflogs
Patrick Steinhardt [Wed, 21 Feb 2024 12:37:31 +0000 (13:37 +0100)] 
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>
6 months agorefs/files: sort reflogs returned by the reflog iterator
Patrick Steinhardt [Wed, 21 Feb 2024 12:37:27 +0000 (13:37 +0100)] 
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>
6 months agodir-iterator: support iteration in sorted order
Patrick Steinhardt [Wed, 21 Feb 2024 12:37:23 +0000 (13:37 +0100)] 
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>
6 months agodir-iterator: pass name to `prepare_next_entry_data()` directly
Patrick Steinhardt [Wed, 21 Feb 2024 12:37:19 +0000 (13:37 +0100)] 
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>
6 months agorebase: make warning less passive aggressive
Harmen Stoppels [Wed, 21 Feb 2024 17:38:17 +0000 (17:38 +0000)] 
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>
6 months agodoc: end sentences with full-stop
Jean-Noël Avila [Tue, 20 Feb 2024 22:32:54 +0000 (22:32 +0000)] 
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>
6 months agodoc: close unclosed angle-bracket of a placeholder in git-clone doc
Jean-Noël Avila [Tue, 20 Feb 2024 22:32:53 +0000 (22:32 +0000)] 
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>
6 months agodoc: git-rev-parse: enforce command-line description syntax
Jean-Noël Avila [Tue, 20 Feb 2024 22:32:52 +0000 (22:32 +0000)] 
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>
6 months agodocumentation: send-email: use camel case consistently
Dragan Simic [Tue, 20 Feb 2024 22:22:51 +0000 (23:22 +0100)] 
documentation: send-email: use camel case consistently

Correct a few random "sendemail.*" configuration parameter names in the
documentation that, for some unknown reason and contrary to the expected,
didn't use camel case format.

The majority of the corrections are straightforward, by using camel case
to denote boundaries of the individual words that, stringed together, make
up configuration parameter names.  A couple of abbreviations found in some
of the corrected configuration parameter names present some exceptions,
which are described in detail below.

First, there's "SSL" as the abbreviation for "Secure Sockets Layer". [1]
As such, it's written using all uppercase letters, which is pretty much the
general rule for making abbreviations, although with certain exceptions.

Second, there's "Cc" as the abbreviation for "carbon copy", which is another
exception.  As the acronym for "carbon copy", "cc" (mind the all lowercase
letters) stems from the rather old times when, literally, carbon copies were
made. [2]  Therefore, using "CC" (mind the all uppercase letters) or "cc"
(mind the all lowercase letters) would be technically correct in the email
domain, as the abbreviation or as mentioned in RFC2076, [3] respectively, but
the age of email has established "Cc" (mind the mixed uppercase and lowercase
letters) as some kind of de facto standard. [1][4][5]  Moreover, some of the
git utilities, primarily git-send-email(1), already refer to making email
carbon copies as specifying "Cc:" email headers.  As a result, "Cc" becomes
one of the exceptions to the general rule for making abbreviations.

[1] https://en.wikipedia.org/wiki/Transport_Layer_Security
[2] https://en.wikipedia.org/wiki/Carbon_copy
[3] https://datatracker.ietf.org/doc/html/rfc2076
[4] https://bugzilla.mozilla.org/show_bug.cgi?id=212059
[5] https://bugzilla.mozilla.org/show_bug.cgi?id=50826

Signed-off-by: Dragan Simic <dsimic@manjaro.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 months agogit-difftool--helper: honor `--trust-exit-code` with `--dir-diff`
Patrick Steinhardt [Tue, 20 Feb 2024 10:08:25 +0000 (11:08 +0100)] 
git-difftool--helper: honor `--trust-exit-code` with `--dir-diff`

The `--trust-exit-code` option for git-diff-tool(1) was introduced via
2b52123fcf (difftool: add support for --trust-exit-code, 2014-10-26).
When set, it makes us return the exit code of the invoked diff tool when
diffing multiple files. This patch didn't change the code path where
`--dir-diff` was passed because we already returned the exit code of the
diff tool unconditionally in that case.

This was changed a month later via c41d3fedd8 (difftool--helper: add
explicit exit statement, 2014-11-20), where an explicit `exit 0` was
added to the end of git-difftool--helper.sh. While the stated intent of
that commit was merely a cleanup, it had the consequence that we now
to ignore the exit code of the diff tool when `--dir-diff` was set. This
change in behaviour is thus very likely an unintended side effect of
this patch.

Now there are two ways to fix this:

  - We can either restore the original behaviour, which unconditionally
    returned the exit code of the diffing tool when `--dir-diff` is
    passed.

  - Or we can make the `--dir-diff` case respect the `--trust-exit-code`
    flag.

The fact that we have been ignoring exit codes for 7 years by now makes
me rather lean towards the latter option. Furthermore, respecting the
flag in one case but not the other would needlessly make the user
interface more complex.

Fix the bug so that we also honor `--trust-exit-code` for dir diffs and
adjust the documentation accordingly.

Reported-by: Jean-Rémy Falleri <jr.falleri@gmail.com>
Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 months agoGit 2.44-rc2 v2.44.0-rc2
Junio C Hamano [Tue, 20 Feb 2024 05:01:01 +0000 (21:01 -0800)] 
Git 2.44-rc2

Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 months agoMerge branch 'la/trailer-cleanups'
Junio C Hamano [Tue, 20 Feb 2024 04:58:06 +0000 (20:58 -0800)] 
Merge branch 'la/trailer-cleanups'

Fix to an already-graduated topic.

* la/trailer-cleanups:
  trailer: fix comment/cut-line regression with opts->no_divider

7 months agotrailer: fix comment/cut-line regression with opts->no_divider
Jeff King [Tue, 20 Feb 2024 01:09:36 +0000 (20:09 -0500)] 
trailer: fix comment/cut-line regression with opts->no_divider

Commit 97e9d0b78a (trailer: find the end of the log message, 2023-10-20)
combined two code paths for finding the end of the log message. For the
"no_divider" case, we used to use find_trailer_end(), and that has now
been rolled into find_end_of_log_message(). But there's a regression;
that function returns early when no_divider is set, returning the whole
string.

That's not how find_trailer_end() behaved. Although it did skip the
"---" processing (which is what "no_divider" is meant to do), we should
still respect ignored_log_message_bytes(), which covers things like
comments, "commit -v" cut lines, and so on.

The bug is actually in the interpret-trailers command, but the obvious
way to experience it is by running "commit -v" with a "--trailer"
option. The new trailer will be added at the end of the verbose diff,
rather than before it (and consequently will be ignored entirely, since
everything after the diff's intro scissors line is thrown away).

I've added two tests here: one for interpret-trailers directly, which
shows the bug via the parsing routines, and one for "commit -v".

The fix itself is pretty simple: instead of returning early, no_divider
just skips the "---" handling but still calls ignored_log_message_bytes().

Reported-by: Philippe Blain <levraiphilippeblain@gmail.com>
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 months agodoc: remove outdated information about interactive.singleKey
Julio Bacellari [Sun, 18 Feb 2024 03:02:59 +0000 (05:02 +0200)] 
doc: remove outdated information about interactive.singleKey

The Perl implementation of add --interactive was removed in commit [1].

Additionally, the interactive.singleKey setting is no longer silently
ignored. The internal implementation of ReadKey [2] displays a warning
if the platform is unsupported.

[1] 20b813d7d (add: remove "add.interactive.useBuiltin" & Perl "git add--interactive", 2023-02-06)
[2] a5e46e6b0 (terminal: add a new function to read a single keystroke, 2020-01-14)

Signed-off-by: Julio Bacellari <julio.bacel@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 months agot0303: check that helper_test_clean removes all credentials
Jeff King [Sat, 17 Feb 2024 04:58:14 +0000 (23:58 -0500)] 
t0303: check that helper_test_clean removes all credentials

Our lib-credential.sh library comes with a "clean" function that removes
all of the credentials used in its tests (to avoid leaving cruft in
system credential storage). But it's easy to add a test that uses a new
credential but forget to add it to the clean function.  E.g., the case
fixed by 83e6eb7d7a (t/lib-credential: clean additional credential,
2024-02-15).

We should be able to catch this automatically, but it's a little tricky.

We can't just compare the contents of the helper's storage before and
after the test run, because there isn't a way to ask a helper to dump
all of its storage. And in most cases we don't have direct access to the
underlying storage (since the whole point of the helper is to abstract
that away). We can work around that by using our own "store" helper,
since we can directly inspect its state by looking at its on-disk file.

But there's a catch: the "store" helper doesn't support features like
caching or expiration, so using it naively fails tests (and skipping
those tests would give us incomplete coverage). Implementing all of
those features would be non-trivial. But we can hack around that by
overriding the "check" function used by the tests to turn most requests
into noop success (except for "approve" requests, which actually store
things).

And then at the end we can check that running the "clean" function takes
us back to an empty state.

Note that because we've skipped any tests that erase credentials
(because of our noop check function), the state we see at cleanup time
may be larger than it would be normally. That's OK. The point of the
clean function is to clean up any cruft we _might_ have left in place,
so we're just being doubly thorough.

The way this is bolted onto t0303 feels a little messy. But it's really
the best place to do it, because then we know that it is running the
exact sequence of tests that we'd use for testing a real external
helper. In a normal run of "make test" it currently does nothing (the
idea is that you run it manually after pointing it at some helper
program). But now with this patch, "make test" will sanity-check the
script itself.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 months agoMerge branch 'ba/credential-test-clean-fix' into jk/t0303-clean
Junio C Hamano [Mon, 19 Feb 2024 23:01:32 +0000 (15:01 -0800)] 
Merge branch 'ba/credential-test-clean-fix' into jk/t0303-clean

* ba/credential-test-clean-fix:
  t/lib-credential: clean additional credential

7 months agolibsecret: retrieve empty password
M Hickford [Mon, 19 Feb 2024 20:40:58 +0000 (20:40 +0000)] 
libsecret: retrieve empty password

Since 0ce02e2f (credential/libsecret: store new attributes, 2023-06-16)
a test that stores empty username and password fails when
t0303-credential-external.sh is run with
GIT_TEST_CREDENTIAL_HELPER=libsecret.

Retrieve empty password carefully. This fixes test:

    ok 14 - helper (libsecret) can store empty username

Signed-off-by: M Hickford <mirth.hickford@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 months agoMerge branch 'ps/reftable-backend' into ps/reflog-list
Junio C Hamano [Mon, 19 Feb 2024 18:50:07 +0000 (10:50 -0800)] 
Merge branch 'ps/reftable-backend' into ps/reflog-list

* ps/reftable-backend:
  refs/reftable: fix leak when copying reflog fails
  ci: add jobs to test with the reftable backend
  refs: introduce reftable backend

7 months agomergetools: vimdiff: use correct tool's name when reading mergetool config
Kipras Melnikovas [Sat, 17 Feb 2024 16:27:18 +0000 (18:27 +0200)] 
mergetools: vimdiff: use correct tool's name when reading mergetool config

The /mergetools/vimdiff script, which handles both vimdiff, nvimdiff
and gvimdiff mergetools (the latter 2 simply source the vimdiff script), has a
function merge_cmd() which read the layout variable from git config, and it
would always read the value of mergetool.**vimdiff**.layout, instead of the
mergetool being currently used (vimdiff or nvimdiff or gvimdiff).

It looks like in 7b5cf8be18 (vimdiff: add tool documentation, 2022-03-30),
we explained the current behavior in Documentation/config/mergetool.txt:

```
mergetool.vimdiff.layout::
The vimdiff backend uses this variable to control how its split
windows look like. Applies even if you are using Neovim (`nvim`) or
gVim (`gvim`) as the merge tool. See BACKEND SPECIFIC HINTS section
```

which makes sense why it's explained this way - the vimdiff backend is used by
gvim and nvim. But the mergetool's configuration should be separate for each tool,
and indeed that's confirmed in same commit at Documentation/mergetools/vimdiff.txt:

```
Variants

Instead of `--tool=vimdiff`, you can also use one of these other variants:
  * `--tool=gvimdiff`, to open gVim instead of Vim.
  * `--tool=nvimdiff`, to open Neovim instead of Vim.

When using these variants, in order to specify a custom layout you will have to
set configuration variables `mergetool.gvimdiff.layout` and
`mergetool.nvimdiff.layout` instead of `mergetool.vimdiff.layout`
```

So it looks like we just forgot to update the 1 part of the vimdiff script
that read the config variable. Cheers.

Though, for backward compatibility, I've kept the mergetool.vimdiff
fallback, so that people who unknowingly relied on it, won't have their
setup broken now.

Signed-off-by: Kipras Melnikovas <kipras@kipras.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 months agoMerge tag 'l10n-2.44.0-rnd3' of https://github.com/git-l10n/git-po
Junio C Hamano [Mon, 19 Feb 2024 16:35:40 +0000 (08:35 -0800)] 
Merge tag 'l10n-2.44.0-rnd3' of https://github.com/git-l10n/git-po

l10n-2.44.0-rnd3

* tag 'l10n-2.44.0-rnd3' of https://github.com/git-l10n/git-po:
  l10n: zh_TW: Git 2.44
  l10n: zh_CN: for git 2.44 rounds
  l10n: Update German translation
  l10n: tr: Update Turkish translations for 2.44
  l10n: fr.po: v2.44.0 round 3
  l10n: bg.po: Updated Bulgarian translation (5610t)
  l10n: sv.po: Update Swedish translation
  l10n: Update Catalan translation
  l10n: po-id for 2.44 (round 1)
  l10n: ci: disable cache for setup-go to suppress warnings
  l10n: ci: remove unused param for add-pr-comment@v2
  l10n: uk: v2.44 update (round 3)
  l10n: uk: v2.44 update (round 2)
  l10n: uk: v2.44 localization update
  l10n: bump Actions versions in l10n.yml

7 months agol10n: zh_TW: Git 2.44
Yi-Jyun Pan [Sun, 18 Feb 2024 12:53:27 +0000 (20:53 +0800)] 
l10n: zh_TW: Git 2.44

Co-Authored-By: lumynou5 <lumynou5.tw@gmail.com>
Signed-off-by: Yi-Jyun Pan <pan93412@gmail.com>
7 months agoMerge branch 'master' of github.com:ralfth/git
Jiang Xin [Sun, 18 Feb 2024 12:33:01 +0000 (20:33 +0800)] 
Merge branch 'master' of github.com:ralfth/git

* 'master' of github.com:ralfth/git:
  l10n: Update German translation

7 months agoMerge branch 'po-id' of github.com:bagasme/git-po
Jiang Xin [Sun, 18 Feb 2024 12:31:55 +0000 (20:31 +0800)] 
Merge branch 'po-id' of github.com:bagasme/git-po

* 'po-id' of github.com:bagasme/git-po:
  l10n: po-id for 2.44 (round 1)

7 months agoMerge branch '2.44-uk-update' of github.com:arkid15r/git-ukrainian-l10n
Jiang Xin [Sun, 18 Feb 2024 12:30:05 +0000 (20:30 +0800)] 
Merge branch '2.44-uk-update' of github.com:arkid15r/git-ukrainian-l10n

* '2.44-uk-update' of github.com:arkid15r/git-ukrainian-l10n:
  l10n: uk: v2.44 update (round 3)
  l10n: uk: v2.44 update (round 2)
  l10n: uk: v2.44 localization update

7 months agoMerge branch 'master' of github.com:alshopov/git-po
Jiang Xin [Sun, 18 Feb 2024 12:28:57 +0000 (20:28 +0800)] 
Merge branch 'master' of github.com:alshopov/git-po

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

7 months agoMerge branch 'tr-l10n' of github.com:bitigchi/git-po
Jiang Xin [Sun, 18 Feb 2024 12:27:47 +0000 (20:27 +0800)] 
Merge branch 'tr-l10n' of github.com:bitigchi/git-po

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

7 months agoMerge branch 'fr_2.44.0' of github.com:jnavila/git
Jiang Xin [Sun, 18 Feb 2024 12:26:45 +0000 (20:26 +0800)] 
Merge branch 'fr_2.44.0' of github.com:jnavila/git

* 'fr_2.44.0' of github.com:jnavila/git:
  l10n: fr.po: v2.44.0 round 3