summaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2024-02-26Revert "refs: allow @{n} to work with n-sized reflog"Jeff King3-51/+50
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>
2024-02-26upload-pack: don't send null character in abort message to the clientSZEDER Gábor1-1/+1
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>
2024-02-26submodule: use strvec_pushf() for --submodule-prefixRené Scharfe1-15/+4
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>
2024-02-26userdiff: skip textconv caching when not in a repositoryJeff King2-1/+25
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>
2024-02-26name-rev: use mem_pool_strfmt()René Scharfe1-19/+20
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>
2024-02-26mem-pool: add mem_pool_strfmt()René Scharfe2-0/+44
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>
2024-02-26fetch: convert strncmp() with strlen() to starts_with()René Scharfe1-3/+2
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>
2024-02-24compat: drop inclusion of <git-compat-util.h>Junio C Hamano2-2/+0
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>
2024-02-23Documentation/config/pack.txt: fix broken AsciiDoc mark-upTaylor Blau1-5/+4
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-23for-each-ref: add new option to include root refsKarthik Nayak6-11/+79
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>
2024-02-23ref-filter: rename 'FILTER_REFS_ALL' to 'FILTER_REFS_REGULAR'Karthik Nayak3-4/+4
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>
2024-02-23refs: introduce `refs_for_each_include_root_refs()`Karthik Nayak4-5/+79
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>
2024-02-23refs: extract out `loose_fill_ref_dir_regular_file()`Karthik Nayak1-29/+33
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>
2024-02-23refs: introduce `is_pseudoref()` and `is_headref()`Karthik Nayak2-0/+44
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>
2024-02-23fill_tree_descriptor(): mark error message for translationJohannes Schindelin2-2/+2
There is an error message in that function to report a missing tree; In contrast to three other, similar error messages, it is not marked for translation yet. Mark it for translation, and while at it, make the error message consistent with the others by enclosing the SHA in parentheses. This requires a change to t6030 which expects the previous format of the commit message. Theoretically, this could present problems with existing scripts that use `git bisect` and parse its output (because Git does not provide other means for callers to discern between error conditions). However, this is unlikely to matter in practice because the most common course of action to deal with fatal corruptions is to report the error message to the user and exit, rather than trying to do something with the reported SHA of the missing tree. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-02-23cache-tree: avoid an unnecessary checkJohannes Schindelin1-1/+1
The first thing the `parse_tree()` function does is to return early if the tree has already been parsed. Therefore we do not need to guard the `parse_tree()` call behind a check of that flag. As of time of writing, there are no other instances of this in Git's code bases: whenever the `parsed` flag guards a `parse_tree()` call, it guards more than just that call. Suggested-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-02-23Always check `parse_tree*()`'s return valueJohannes Schindelin12-10/+52
Otherwise we may easily run into serious crashes: For example, if we run `init_tree_desc()` directly after a failed `parse_tree()`, we are accessing uninitialized data or trying to dereference `NULL`. Note that the `parse_tree()` function already takes care of showing an error message. The `parse_tree_indirectly()` and `repo_get_commit_tree()` functions do not, therefore those latter call sites need to show a useful error message while the former do not. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-02-23t4301: verify that merge-tree fails on missing blob objectsJohannes Schindelin1-0/+16
We just fixed a problem where `merge-tree` would not fail on missing tree objects. Let's ensure that that problem does not occur with blob objects (and won't, in the future, either). Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-02-23merge-ort: do check `parse_tree()`'s return valueJohannes Schindelin1-2/+4
The previous commit fixed a bug where a missing tree was reported, but not treated as an error. This patch addresses the same issue for the remaining two callers of `parse_tree()`. This change is not accompanied by a regression test because the code in question is only reached at the `checkout` stage, i.e. after the merge has happened (and therefore the tree objects could only be missing if the disk had gone bad in that short time window, or something similarly tricky to recreate in the test suite). Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-02-23merge-tree: fail with a non-zero exit code on missing tree objectsJohannes Schindelin2-3/+15
When `git merge-tree` encounters a missing tree object, it should error out and not continue quietly as if nothing had happened. However, as of time of writing, `git merge-tree` _does_ continue, and then offers the empty tree as result. Let's fix this. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-02-22Git 2.44v2.44.0Junio C Hamano2-1/+13
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-02-22Git 2.43.3v2.43.3Junio C Hamano3-2/+14
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-02-22Merge branch 'la/trailer-cleanups' into maint-2.43Junio C Hamano3-8/+44
* la/trailer-cleanups: trailer: fix comment/cut-line regression with opts->no_divider
2024-02-21doc: apply the new placeholder rules to git-add documentationJunio C Hamano1-10/+10
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-02-21doc: clarify the format of placeholdersJean-Noël Avila1-0/+7
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-21git-remote.txt: fix typoJakub Wilk1-1/+1
Signed-off-by: Jakub Wilk <jwilk@jwilk.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-02-21builtin/reflog: introduce subcommand to list reflogsPatrick Steinhardt3-0/+145
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-21refs: stop resolving ref corresponding to reflogsPatrick Steinhardt2-14/+4
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-21refs: drop unused params from the reflog iterator callbackPatrick Steinhardt11-54/+65
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-21refs: always treat iterators as orderedPatrick Steinhardt8-50/+20
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-21refs/files: sort merged worktree and common reflogsPatrick Steinhardt4-73/+56
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-21refs/files: sort reflogs returned by the reflog iteratorPatrick Steinhardt4-6/+6
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-21dir-iterator: support iteration in sorted orderPatrick Steinhardt2-13/+89
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-21dir-iterator: pass name to `prepare_next_entry_data()` directlyPatrick Steinhardt1-4/+4
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-21rebase: make warning less passive aggressiveHarmen Stoppels1-1/+1
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-20doc: end sentences with full-stopJean-Noël Avila2-3/+3
Signed-off-by: Jean-Noël Avila <jn.avila@free.fr> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-02-20doc: close unclosed angle-bracket of a placeholder in git-clone docJean-Noël Avila1-1/+1
Signed-off-by: Jean-Noël Avila <jn.avila@free.fr> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-02-20doc: git-rev-parse: enforce command-line description syntaxJean-Noël Avila1-12/+12
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-20documentation: send-email: use camel case consistentlyDragan Simic2-15/+15
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>
2024-02-20git-difftool--helper: honor `--trust-exit-code` with `--dir-diff`Patrick Steinhardt3-46/+67
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>
2024-02-19Git 2.44-rc2v2.44.0-rc2Junio C Hamano2-1/+2
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-02-19Merge branch 'la/trailer-cleanups'Junio C Hamano3-8/+44
Fix to an already-graduated topic. * la/trailer-cleanups: trailer: fix comment/cut-line regression with opts->no_divider
2024-02-19trailer: fix comment/cut-line regression with opts->no_dividerJeff King3-8/+44
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>
2024-02-19doc: remove outdated information about interactive.singleKeyJulio Bacellari1-3/+1
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>
2024-02-19t0303: check that helper_test_clean removes all credentialsJeff King1-2/+24
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>
2024-02-19Merge branch 'ba/credential-test-clean-fix' into jk/t0303-cleanJunio C Hamano1-0/+1
* ba/credential-test-clean-fix: t/lib-credential: clean additional credential
2024-02-19libsecret: retrieve empty passwordM Hickford1-0/+3
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>
2024-02-19Merge branch 'ps/reftable-backend' into ps/reflog-listJunio C Hamano17-7/+3248
* 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-19mergetools: vimdiff: use correct tool's name when reading mergetool configKipras Melnikovas3-9/+25
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>
2024-02-19Merge tag 'l10n-2.44.0-rnd3' of https://github.com/git-l10n/git-poJunio C Hamano11-1509/+2894
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