]> git.ipfire.org Git - thirdparty/git.git/log
thirdparty/git.git
10 months agoMerge branch 'ds/add-i-color-configuration-fix'
Junio C Hamano [Thu, 22 Jun 2023 23:29:06 +0000 (16:29 -0700)] 
Merge branch 'ds/add-i-color-configuration-fix'

The reimplemented "git add -i" did not honor color.ui configuration.

* ds/add-i-color-configuration-fix:
  add: test use of brackets when color is disabled
  add: check color.ui for interactive add

10 months agoMerge branch 'ps/cat-file-null-output'
Junio C Hamano [Thu, 22 Jun 2023 23:29:06 +0000 (16:29 -0700)] 
Merge branch 'ps/cat-file-null-output'

"git cat-file --batch" and friends learned "-Z" that uses NUL
delimiter for both input and output.

* ps/cat-file-null-output:
  cat-file: add option '-Z' that delimits input and output with NUL
  cat-file: simplify reading from standard input
  strbuf: provide CRLF-aware helper to read until a specified delimiter
  t1006: modernize test style to use `test_cmp`
  t1006: don't strip timestamps from expected results

10 months agoMerge branch 'ds/disable-replace-refs'
Junio C Hamano [Thu, 22 Jun 2023 23:29:05 +0000 (16:29 -0700)] 
Merge branch 'ds/disable-replace-refs'

Introduce a mechanism to disable replace refs globally and per
repository.

* ds/disable-replace-refs:
  repository: create read_replace_refs setting
  replace-objects: create wrapper around setting
  repository: create disable_replace_refs()

10 months agoMerge branch 'tb/pack-bitmap-traversal-with-boundary'
Junio C Hamano [Thu, 22 Jun 2023 23:29:05 +0000 (16:29 -0700)] 
Merge branch 'tb/pack-bitmap-traversal-with-boundary'

The object traversal using reachability bitmap done by
"pack-object" has been tweaked to take advantage of the fact that
using "boundary" commits as representative of all the uninteresting
ones can save quite a lot of object enumeration.

* tb/pack-bitmap-traversal-with-boundary:
  pack-bitmap.c: use commit boundary during bitmap traversal
  pack-bitmap.c: extract `fill_in_bitmap()`
  object: add object_array initializer helper function

10 months agoMerge branch 'ja/worktree-orphan'
Junio C Hamano [Thu, 22 Jun 2023 23:29:05 +0000 (16:29 -0700)] 
Merge branch 'ja/worktree-orphan'

'git worktree add' learned how to create a worktree based on an
orphaned branch with `--orphan`.

* ja/worktree-orphan:
  worktree add: emit warn when there is a bad HEAD
  worktree add: extend DWIM to infer --orphan
  worktree add: introduce "try --orphan" hint
  worktree add: add --orphan flag
  t2400: add tests to verify --quiet
  t2400: refactor "worktree add" opt exclusion tests
  t2400: cleanup created worktree in test
  worktree add: include -B in usage docs

11 months agoThe second batch for 2.42
Junio C Hamano [Tue, 20 Jun 2023 22:12:15 +0000 (15:12 -0700)] 
The second batch for 2.42

Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 months agoMerge branch 'la/doc-interpret-trailers'
Junio C Hamano [Tue, 20 Jun 2023 22:53:13 +0000 (15:53 -0700)] 
Merge branch 'la/doc-interpret-trailers'

Doc update.

* la/doc-interpret-trailers:
  doc: trailer: add more examples in DESCRIPTION
  doc: trailer: mention 'key' in DESCRIPTION
  doc: trailer.<token>.command: emphasize deprecation
  doc: trailer: use angle brackets for <token> and <value>
  doc: trailer: remove redundant phrasing
  doc: trailer: examples: avoid the word "message" by itself
  doc: trailer: drop "commit message part" phrasing
  doc: trailer: swap verb order
  doc: trailer: fix grammar

11 months agoMerge branch 'jk/log-follow-with-non-literal-pathspec'
Junio C Hamano [Tue, 20 Jun 2023 22:53:13 +0000 (15:53 -0700)] 
Merge branch 'jk/log-follow-with-non-literal-pathspec'

"git [-c log.follow=true] log [--follow] ':(glob)f**'" used to barf.

* jk/log-follow-with-non-literal-pathspec:
  diff: detect pathspec magic not supported by --follow
  diff: factor out --follow pathspec check
  pathspec: factor out magic-to-name function

11 months agoMerge branch 'vd/worktree-config-is-per-repository'
Junio C Hamano [Tue, 20 Jun 2023 22:53:13 +0000 (15:53 -0700)] 
Merge branch 'vd/worktree-config-is-per-repository'

The value of config.worktree is per-repository, but has been kept
in a singleton global variable per process. This has been OK as
most Git operations interacted with a single repository at a time,
but not right for operations like recursive "grep" that want to
access multiple repositories from a single process without forking.

The global variable has been eliminated and made into a member in
the per-repository data structure.

* vd/worktree-config-is-per-repository:
  repository: move 'repository_format_worktree_config' to repo scope
  config: pass 'repo' directly to 'config_with_options()'
  config: use gitdir to get worktree config

11 months agoMerge branch 'tb/submodule-null-deref-fix'
Junio C Hamano [Tue, 20 Jun 2023 22:53:12 +0000 (15:53 -0700)] 
Merge branch 'tb/submodule-null-deref-fix'

"git submodule" code trusted the data coming from the config (and
the in-tree .gitmodules file) too much without validating, leading
to NULL dereference if the user mucks with a repository (e.g.
submodule.<name>.url is removed).  This has been corrected.

* tb/submodule-null-deref-fix:
  builtin/submodule--helper.c: handle missing submodule URLs

11 months agoMerge branch 'jc/test-modernization-2'
Junio C Hamano [Tue, 20 Jun 2023 22:53:12 +0000 (15:53 -0700)] 
Merge branch 'jc/test-modernization-2'

Test style updates.

* jc/test-modernization-2:
  t9400-git-cvsserver-server: modernize test format
  t9200-git-cvsexportcommit: modernize test format
  t9104-git-svn-follow-parent: modernize test format
  t9100-git-svn-basic: modernize test format
  t7700-repack: modernize test format
  t7600-merge: modernize test format
  t7508-status: modernize test format
  t7201-co: modernize test format
  t7111-reset-table: modernize test format
  t7110-reset-merge: modernize test format

11 months agoMerge branch 'jc/test-modernization'
Junio C Hamano [Tue, 20 Jun 2023 22:53:12 +0000 (15:53 -0700)] 
Merge branch 'jc/test-modernization'

* jc/test-modernization:
  t7101-reset-empty-subdirs: modernize test format
  t6050-replace: modernize test format
  t5306-pack-nobase: modernize test format
  t5303-pack-corruption-resilience: modernize test format
  t5301-sliding-window: modernize test format
  t5300-pack-object: modernize test format
  t4206-log-follow-harder-copies: modernize test format
  t4202-log: modernize test format
  t4004-diff-rename-symlink: modernize test format
  t4003-diff-rename-1: modernize test format
  t4002-diff-basic: modernize test format
  t3903-stash: modernize test format
  t3700-add: modernize test format
  t3500-cherry: modernize test format
  t1006-cat-file: modernize test format
  t1002-read-tree-m-u-2way: modernize test format
  t1001-read-tree-m-2way: modernize test format
  t3210-pack-refs: modernize test format
  t0030-stripspace: modernize test format
  t0000-basic: modernize test format

11 months agoMerge branch 'kh/use-default-notes-doc'
Junio C Hamano [Tue, 20 Jun 2023 22:53:12 +0000 (15:53 -0700)] 
Merge branch 'kh/use-default-notes-doc'

Doc update.

* kh/use-default-notes-doc:
  notes: move the documentation to the struct
  notes: update documentation for `use_default_notes`

11 months agoMerge branch 'pb/complete-and-document-auto-merge-and-friends'
Junio C Hamano [Tue, 20 Jun 2023 22:53:11 +0000 (15:53 -0700)] 
Merge branch 'pb/complete-and-document-auto-merge-and-friends'

Document more pseudo-refs and teach the command line completion
machinery to complete AUTO_MERGE.

* pb/complete-and-document-auto-merge-and-friends:
  completion: complete AUTO_MERGE
  Documentation: document AUTO_MERGE
  git-merge.txt: modernize word choice in "True merge" section
  completion: complete REVERT_HEAD and BISECT_HEAD
  revisions.txt: document more special refs
  revisions.txt: use description list for special refs

11 months agoMerge branch 'mh/commit-reach-get-reachable-plug-leak'
Junio C Hamano [Tue, 20 Jun 2023 22:53:11 +0000 (15:53 -0700)] 
Merge branch 'mh/commit-reach-get-reachable-plug-leak'

Plug memory leak.

* mh/commit-reach-get-reachable-plug-leak:
  commit-reach: fix memory leak in get_reachable_subset()

11 months agoMerge branch 'tz/test-fix-pthreads-prereq'
Junio C Hamano [Tue, 20 Jun 2023 22:53:11 +0000 (15:53 -0700)] 
Merge branch 'tz/test-fix-pthreads-prereq'

Test fix.

* tz/test-fix-pthreads-prereq:
  trace2 tests: fix PTHREADS prereq

11 months agoMerge branch 'tz/test-ssh-verifytime-fix'
Junio C Hamano [Tue, 20 Jun 2023 22:53:11 +0000 (15:53 -0700)] 
Merge branch 'tz/test-ssh-verifytime-fix'

Test fix.

* tz/test-ssh-verifytime-fix:
  t/lib-gpg: fix ssh-keygen -Y check-novalidate with openssh-9.0

11 months agoMerge branch 'jk/ci-use-clang-for-sanitizer-jobs'
Junio C Hamano [Tue, 20 Jun 2023 22:53:11 +0000 (15:53 -0700)] 
Merge branch 'jk/ci-use-clang-for-sanitizer-jobs'

Clang's sanitizer implementation seems to work better than GCC's.

* jk/ci-use-clang-for-sanitizer-jobs:
  ci: drop linux-clang job
  ci: run ASan/UBSan in a single job
  ci: use clang for ASan/UBSan checks

11 months agoMerge branch 'tl/quote-problematic-arg-for-clarity'
Junio C Hamano [Tue, 20 Jun 2023 22:53:10 +0000 (15:53 -0700)] 
Merge branch 'tl/quote-problematic-arg-for-clarity'

Error message fix.

* tl/quote-problematic-arg-for-clarity:
  surround %s with quotes when failed to lookup commit

11 months agoMerge branch 'ps/fetch-cleanups'
Junio C Hamano [Tue, 20 Jun 2023 22:53:10 +0000 (15:53 -0700)] 
Merge branch 'ps/fetch-cleanups'

Code clean-up.

* ps/fetch-cleanups:
  fetch: use `fetch_config` to store "submodule.fetchJobs" value
  fetch: use `fetch_config` to store "fetch.parallel" value
  fetch: use `fetch_config` to store "fetch.recurseSubmodules" value
  fetch: use `fetch_config` to store "fetch.showForcedUpdates" value
  fetch: use `fetch_config` to store "fetch.pruneTags" value
  fetch: use `fetch_config` to store "fetch.prune" value
  fetch: pass through `fetch_config` directly
  fetch: drop unneeded NULL-check for `remote_ref`
  fetch: drop unused DISPLAY_FORMAT_UNKNOWN enum value

11 months agodoc: trailer: add more examples in DESCRIPTION
Linus Arver [Thu, 15 Jun 2023 02:53:50 +0000 (02:53 +0000)] 
doc: trailer: add more examples in DESCRIPTION

Be more up-front about what trailers are in practice with examples, to
give the reader a visual cue while they go on to read the rest of the
description.

Also add an example for multiline values.

Signed-off-by: Linus Arver <linusa@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 months agodoc: trailer: mention 'key' in DESCRIPTION
Linus Arver [Thu, 15 Jun 2023 02:53:49 +0000 (02:53 +0000)] 
doc: trailer: mention 'key' in DESCRIPTION

The 'key' option is used frequently in the examples at the bottom but
there is no mention of it in the description.

Signed-off-by: Linus Arver <linusa@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 months agodoc: trailer.<token>.command: emphasize deprecation
Linus Arver [Thu, 15 Jun 2023 02:53:48 +0000 (02:53 +0000)] 
doc: trailer.<token>.command: emphasize deprecation

This puts the deprecation notice up front, instead of leaving it to the
next paragraph.

Signed-off-by: Linus Arver <linusa@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 months agodoc: trailer: use angle brackets for <token> and <value>
Linus Arver [Thu, 15 Jun 2023 02:53:47 +0000 (02:53 +0000)] 
doc: trailer: use angle brackets for <token> and <value>

We already use angle brackets elsewhere, so this makes things more
consistent.

Signed-off-by: Linus Arver <linusa@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 months agodoc: trailer: remove redundant phrasing
Linus Arver [Thu, 15 Jun 2023 02:53:46 +0000 (02:53 +0000)] 
doc: trailer: remove redundant phrasing

The phrase "many rules" gets essentially repeated again with "many other
rules", so remove this repetition.

Signed-off-by: Linus Arver <linusa@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 months agodoc: trailer: examples: avoid the word "message" by itself
Linus Arver [Thu, 15 Jun 2023 02:53:45 +0000 (02:53 +0000)] 
doc: trailer: examples: avoid the word "message" by itself

Previously, "message" could mean the input, output, commit message, or
"internal body text inside the commit message" (in the EXAMPLES
section). Avoid overloading this term by using the appropriate meanings
explicitly.

Signed-off-by: Linus Arver <linusa@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 months agodoc: trailer: drop "commit message part" phrasing
Linus Arver [Thu, 15 Jun 2023 02:53:44 +0000 (02:53 +0000)] 
doc: trailer: drop "commit message part" phrasing

The command can take inputs that are either just a commit message, or
an email-like output such as git-format-patch which includes a commit
message, "---" divider, and patch part. The existing explanation blends
these two inputs together in the first sentence

    This command reads some patches or commit messages

which then necessitates using the "commit message part" phrasing (as
opposed to just "commit message") because the input is ambiguous per the
above definition.

This change separates the two input types and explains them separately,
and so there is no longer a need to use the "commit message part"
phrase.

Signed-off-by: Linus Arver <linusa@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 months agodoc: trailer: swap verb order
Linus Arver [Thu, 15 Jun 2023 02:53:43 +0000 (02:53 +0000)] 
doc: trailer: swap verb order

This matches the order already used in the NAME section.

Signed-off-by: Linus Arver <linusa@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 months agodoc: trailer: fix grammar
Linus Arver [Thu, 15 Jun 2023 02:53:42 +0000 (02:53 +0000)] 
doc: trailer: fix grammar

Signed-off-by: Linus Arver <linusa@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 months agoStart the 2.42 cycle
Junio C Hamano [Tue, 13 Jun 2023 15:00:28 +0000 (08:00 -0700)] 
Start the 2.42 cycle

Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 months agoMerge branch 'zh/ls-files-format-atoms'
Junio C Hamano [Tue, 13 Jun 2023 19:29:46 +0000 (12:29 -0700)] 
Merge branch 'zh/ls-files-format-atoms'

Some atoms that can be used in "--format=<format>" for "git ls-tree"
were not supported by "git ls-files", even though they were relevant
in the context of the latter.

* zh/ls-files-format-atoms:
  ls-files: align format atoms with ls-tree

11 months agoMerge branch 'sl/diff-tree-sparse'
Junio C Hamano [Tue, 13 Jun 2023 19:29:46 +0000 (12:29 -0700)] 
Merge branch 'sl/diff-tree-sparse'

"git diff-tree" has been taught to take advantage of the
sparse-index feature.

* sl/diff-tree-sparse:
  diff-tree: integrate with sparse index

11 months agoMerge branch 'jk/format-patch-message-id-unleak'
Junio C Hamano [Tue, 13 Jun 2023 19:29:46 +0000 (12:29 -0700)] 
Merge branch 'jk/format-patch-message-id-unleak'

Leakfix.

* jk/format-patch-message-id-unleak:
  format-patch: free elements of rev.ref_message_ids list
  format-patch: free rev.message_id when exiting

11 months agoMerge branch 'jc/pack-ref-exclude-include'
Junio C Hamano [Tue, 13 Jun 2023 19:29:45 +0000 (12:29 -0700)] 
Merge branch 'jc/pack-ref-exclude-include'

"git pack-refs" learns "--include" and "--exclude" to tweak the ref
hierarchy to be packed using pattern matching.

* jc/pack-ref-exclude-include:
  pack-refs: teach pack-refs --include option
  pack-refs: teach --exclude option to exclude refs from being packed
  docs: clarify git-pack-refs --all will pack all refs

11 months agoMerge branch 'sa/doc-ls-remote'
Junio C Hamano [Tue, 13 Jun 2023 19:29:45 +0000 (12:29 -0700)] 
Merge branch 'sa/doc-ls-remote'

Doc update.

* sa/doc-ls-remote:
  ls-remote doc: document the output format
  ls-remote doc: explain what each example does
  ls-remote doc: show peeled tags in examples
  ls-remote doc: remove redundant --tags example
  show-branch doc: say <ref>, not <reference>
  show-ref doc: update for internal consistency

11 months agoMerge branch 'gc/doc-cocci-updates'
Junio C Hamano [Tue, 13 Jun 2023 19:29:45 +0000 (12:29 -0700)] 
Merge branch 'gc/doc-cocci-updates'

Update documentation regarding Coccinelle patches.

* gc/doc-cocci-updates:
  cocci: codify authoring and reviewing practices
  cocci: add headings to and reword README

11 months agoMerge branch 'jc/diff-s-with-other-options'
Junio C Hamano [Tue, 13 Jun 2023 19:29:44 +0000 (12:29 -0700)] 
Merge branch 'jc/diff-s-with-other-options'

The "-s" (silent, squelch) option of the "diff" family of commands
did not interact with other options that specify the output format
well.  This has been cleaned up so that it will clear all the
formatting options given before.

* jc/diff-s-with-other-options:
  diff: fix interaction between the "-s" option and other options

11 months agoMerge branch 'kh/keep-tag-editmsg-upon-failure'
Junio C Hamano [Tue, 13 Jun 2023 19:29:44 +0000 (12:29 -0700)] 
Merge branch 'kh/keep-tag-editmsg-upon-failure'

"git tag" learned to leave the "$GIT_DIR/TAG_EDITMSG" file when the
command failed, so that the user can salvage what they typed.

* kh/keep-tag-editmsg-upon-failure:
  tag: keep the message file in case ref transaction fails
  t/t7004-tag: add regression test for successful tag creation
  doc: tag: document `TAG_EDITMSG`

11 months agorepository: create read_replace_refs setting
Derrick Stolee [Tue, 6 Jun 2023 13:24:37 +0000 (13:24 +0000)] 
repository: create read_replace_refs setting

The 'read_replace_refs' global specifies whether or not we should
respect the references of the form 'refs/replace/<oid>' to replace which
object we look up when asking for '<oid>'. This global has caused issues
when it is not initialized properly, such as in b6551feadfd (merge-tree:
load default git config, 2023-05-10).

To make this more robust, move its config-based initialization out of
git_default_config and into prepare_repo_settings(). This provides a
repository-scoped version of the 'read_replace_refs' global.

The global still has its purpose: it is disabled process-wide by the
GIT_NO_REPLACE_OBJECTS environment variable or by a call to
disable_replace_refs() in some specific Git commands.

Since we already encapsulated the use of the constant inside
replace_refs_enabled(), we can perform the initialization inside that
method, if necessary. This solves the problem of forgetting to check the
config, as we will check it before returning this value.

Due to this encapsulation, the global can move to be static within
replace-object.c.

There is an interesting behavior change possible here: we now have a
repository-scoped understanding of this config value. Thus, if there was
a command that recurses into submodules and might follow replace refs,
then it would now respect the core.useReplaceRefs config value in each
repository.

'git grep --recurse-submodules' is such a command that recurses into
submodules in-process. We can demonstrate the granularity of this config
value via a test in t7814.

Signed-off-by: Derrick Stolee <derrickstolee@github.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 months agoreplace-objects: create wrapper around setting
Derrick Stolee [Tue, 6 Jun 2023 13:24:36 +0000 (13:24 +0000)] 
replace-objects: create wrapper around setting

The 'read_replace_objects' constant is initialized by git_default_config
(if core.useReplaceRefs is disabled) and within setup_git_env (if
GIT_NO_REPLACE_OBJECTS) is set. To ensure that this variable cannot be
set accidentally in other places, wrap it in a replace_refs_enabled()
method.

Since we still assign this global in config.c, we are not able to remove
the global scope of this variable and make it a static within
replace-object.c. This will happen in a later change which will also
prevent the variable from being read before it is initialized.

Centralizing read access to the variable is an important first step.

Signed-off-by: Derrick Stolee <derrickstolee@github.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 months agorepository: create disable_replace_refs()
Derrick Stolee [Tue, 6 Jun 2023 13:24:35 +0000 (13:24 +0000)] 
repository: create disable_replace_refs()

Several builtins depend on being able to disable the replace references
so we actually operate on each object individually. These currently do
so by directly mutating the 'read_replace_refs' global.

A future change will move this global into a different place, so it will
be necessary to change all of these lines. However, we can simplify that
transition by abstracting the purpose of these global assignments with a
method call.

We will need to keep this read_replace_refs global forever, as we want
to make sure that we never use replace refs throughout the life of the
process if this method is called. Future changes may present a
repository-scoped version of the variable to represent that repository's
core.useReplaceRefs config value, but a zero-valued read_replace_refs
will always override such a setting.

Signed-off-by: Derrick Stolee <derrickstolee@github.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 months agocat-file: add option '-Z' that delimits input and output with NUL
Patrick Steinhardt [Tue, 6 Jun 2023 05:19:45 +0000 (07:19 +0200)] 
cat-file: add option '-Z' that delimits input and output with NUL

In db9d67f2e9 (builtin/cat-file.c: support NUL-delimited input with
`-z`, 2022-07-22), we have introduced a new mode to read the input via
NUL-delimited records instead of newline-delimited records. This allows
the user to query for revisions that have newlines in their path
component. While unusual, such queries are perfectly valid and thus it
is clear that we should be able to support them properly.

Unfortunately, the commit only changed the input to be NUL-delimited,
but didn't change the output at the same time. While this is fine for
queries that are processed successfully, it is less so for queries that
aren't. In the case of missing commits for example the result can become
entirely unparsable:

```
$ printf "7ce4f05bae8120d9fa258e854a8669f6ea9cb7b1 blob 10\n1234567890\n\n\commit000" |
    git cat-file --batch -z
7ce4f05bae8120d9fa258e854a8669f6ea9cb7b1 blob 10
1234567890

commit missing
```

This is of course a crafted query that is intentionally gaming the
deficiency, but more benign queries that contain newlines would have
similar problems.

Ideally, we should have also changed the output to be NUL-delimited when
`-z` is specified to avoid this problem. As the input is NUL-delimited,
it is clear that the output in this case cannot ever contain NUL
characters by itself. Furthermore, Git does not allow NUL characters in
revisions anyway, further stressing the point that using NUL-delimited
output is safe. The only exception is of course the object data itself,
but as git-cat-file(1) prints the size of the object data clients should
read until that specified size has been consumed.

But even though `-z` has only been introduced a few releases ago in Git
v2.38.0, changing the output format retroactively to also NUL-delimit
output would be a backwards incompatible change. And while one could
make the argument that the output is inherently broken already, we need
to assume that there are existing users out there that use it just fine
given that revisions containing newlines are quite exotic.

Instead, introduce a new option `-Z` that switches to NUL-delimited
input and output. While this new option could arguably only switch the
output format to be NUL-delimited, the consequence would be that users
have to always specify both `-z` and `-Z` when the input may contain
newlines. On the other hand, if the user knows that there never will be
newlines in the input, they don't have to use either of those options.
There is thus no usecase that would warrant treating input and output
format separately, which is why we instead opt to "do the right thing"
and have `-Z` mean to NUL-terminate both formats.

The old `-z` option is marked as deprecated with a hint that its output
may become unparsable. It is thus hidden both from the synopsis as well
as the command's help output.

Co-authored-by: Toon Claes <toon@iotcl.com>
Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 months agocat-file: simplify reading from standard input
Patrick Steinhardt [Tue, 6 Jun 2023 05:19:41 +0000 (07:19 +0200)] 
cat-file: simplify reading from standard input

The batch modes of git-cat-file(1) read queries from stantard input that
are either newline- or NUL-delimited. This code was introduced via
db9d67f2e9 (builtin/cat-file.c: support NUL-delimited input with `-z`,
2022-07-22), which notes that:

"""
The refactoring here is slightly unfortunate, since we turn loops like:

     while (strbuf_getline(&buf, stdin) != EOF)

 into:

     while (1) {
         int ret;
         if (opt->nul_terminated)
             ret = strbuf_getline_nul(&input, stdin);
         else
             ret = strbuf_getline(&input, stdin);

         if (ret == EOF)
             break;
     }
"""

The commit proposed introducing a helper function that is easier to use,
which is just what we have done in the preceding commit. Refactor the
code to use this new helper to simplify the loop.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 months agostrbuf: provide CRLF-aware helper to read until a specified delimiter
Patrick Steinhardt [Tue, 6 Jun 2023 05:19:37 +0000 (07:19 +0200)] 
strbuf: provide CRLF-aware helper to read until a specified delimiter

Many of our commands support reading input that is separated either via
newlines or via NUL characters. Furthermore, in order to be a better
cross platform citizen, these commands typically know to strip the CRLF
sequence so that we also support reading newline-separated inputs on
e.g. the Windows platform. This results in the following kind of awkward
pattern:

```
struct strbuf input = STRBUF_INIT;

while (1) {
int ret;

if (nul_terminated)
ret = strbuf_getline_nul(&input, stdin);
else
ret = strbuf_getline(&input, stdin);
if (ret)
break;

...
}
```

Introduce a new CRLF-aware helper function that can read up to a user
specified delimiter. If the delimiter is `\n` the function knows to also
strip CRLF, otherwise it will only strip the specified delimiter. This
results in the following, much more readable code pattern:

```
struct strbuf input = STRBUF_INIT;

while (strbuf_getdelim_strip_crlf(&input, stdin, delim) != EOF) {
...
}
```

The new function will be used in a subsequent commit.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 months agot1006: modernize test style to use `test_cmp`
Patrick Steinhardt [Tue, 6 Jun 2023 05:19:33 +0000 (07:19 +0200)] 
t1006: modernize test style to use `test_cmp`

The tests for git-cat-file(1) are quite old and haven't ever been
updated since they were introduced. They thus tend to use old idioms
that have since grown outdated. Most importantly, many of the tests use
`test $A = $B` to compare expected and actual output. This has the
downside that it is impossible to tell what exactly is different between
both versions in case the test fails.

Refactor the tests to instead use `test_cmp`. While more verbose, it
both tends to be more readable and will result in a nice diff in case
states don't match.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 months agot1006: don't strip timestamps from expected results
Patrick Steinhardt [Tue, 6 Jun 2023 05:19:29 +0000 (07:19 +0200)] 
t1006: don't strip timestamps from expected results

In t1006 we have a bunch of tests that verify the output format of the
git-cat-file(1) command. But while part of the output for some tests
would include commit timestamps, we don't verify those but instead strip
them before comparing expected with actual results. This is done by the
function `maybe_remove_timestamp`, which goes all the way back to the
ancient commit b335d3f121 (Add tests for git cat-file, 2008-04-23).

Our tests had been in a different shape back then. Most importantly we
didn't yet have the infrastructure to create objects with deterministic
timestamps. Nowadays we do though, and thus there is no reason anymore
to strip the timestamps.

Refactor the tests to not strip the timestamp anymore.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 months agoadd: test use of brackets when color is disabled
Derrick Stolee [Wed, 7 Jun 2023 13:44:48 +0000 (09:44 -0400)] 
add: test use of brackets when color is disabled

From 02156b81bbb2cafb19d702c55d45714fcf224048 Mon Sep 17 00:00:00 2001
From: Derrick Stolee <derrickstolee@github.com>
Date: Wed, 7 Jun 2023 09:39:01 -0400
Subject: [PATCH v2 2/2] add: test use of brackets when color is disabled

The interactive add command, 'git add -i', displays a menu of options
using full words. When color is enabled, the first letter of each word
is changed to a highlight color to signal that the first letter could be
used as a command. Without color, brackets ("[]") are used around these
first letters.

This behavior was not previously tested directly in t3701, so add a test
for it now. Since we use 'git add -i >actual <input' without
'force_color', the color system recognizes that colors are not available
on stdout and will be disabled by default.

This test would reproduce correctly with or without the fix in the
previous commit to make sure that color.ui is respected in 'git add'.

Reported-by: Phillip Wood <phillip.wood@dunelm.org.uk>
Signed-off-by: Derrick Stolee <derrickstolee@github.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 months agoadd: check color.ui for interactive add
Derrick Stolee [Tue, 6 Jun 2023 14:20:18 +0000 (14:20 +0000)] 
add: check color.ui for interactive add

When 'git add -i' and 'git add -p' were converted to a builtin, they
introduced a color bug: the 'color.ui' config setting is ignored.

The included test demonstrates an example that is similar to the
previous test, which focuses on customizing colors. Here, we are
demonstrating that colors are not being used at all by comparing the raw
output and the color-decoded version of that output.

The fix is simple, to use git_color_default_config() as the fallback for
git_add_config(). A more robust change would instead encapsulate the
git_use_color_default global in methods that would check the config
setting if it has not been initialized yet. Some ideas are being
discussed on this front [1], but nothing has been finalized.

[1] https://lore.kernel.org/git/pull.1539.git.1685716420.gitgitgadget@gmail.com/

This test case naturally bisects down to 0527ccb1b55 (add -i: default to
the built-in implementation, 2021-11-30), but the fix makes it clear
that this would be broken even if we added the config to use the builtin
earlier than this.

Reported-by: Greg Alexander <gitgreg@galexander.org>
Signed-off-by: Derrick Stolee <derrickstolee@github.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 months agonotes: move the documentation to the struct
Kristoffer Haugsbakk [Mon, 5 Jun 2023 10:05:23 +0000 (12:05 +0200)] 
notes: move the documentation to the struct

Its better to document the struct members directly instead of on a
function that takes a pointer to the struct. This will also make it
easier to update the documentation in the future.

Make adjustments for this new context. Also drop “may contain” since we
don’t need to emphasize that a list could be empty.

Suggested-by: Jeff King <peff@peff.net>
Signed-off-by: Kristoffer Haugsbakk <code@khaugsbakk.name>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 months agonotes: update documentation for `use_default_notes`
Kristoffer Haugsbakk [Mon, 5 Jun 2023 10:05:22 +0000 (12:05 +0200)] 
notes: update documentation for `use_default_notes`

`suppress_default_notes` was renamed to `use_default_notes` in
3a03cf6b1d (notes: refactor display notes default handling,
2011-03-29).

The commit message says that “values less than one [indicates] “not
set” ”, but what was meant was probably “less than zero” (the author of
3a03cf6b1d agrees on this point).

Signed-off-by: Kristoffer Haugsbakk <code@khaugsbakk.name>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 months agocommit-reach: fix memory leak in get_reachable_subset()
Mike Hommey [Sat, 3 Jun 2023 00:28:19 +0000 (09:28 +0900)] 
commit-reach: fix memory leak in get_reachable_subset()

This is a leak that has existed since the method was first created
in fcb2c0769db (commit-reach: implement get_reachable_subset,
2018-11-02).

Signed-off-by: Mike Hommey <mh@glandium.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 months agoci: drop linux-clang job
Jeff King [Thu, 1 Jun 2023 18:10:40 +0000 (14:10 -0400)] 
ci: drop linux-clang job

Since the linux-asan-ubsan job runs using clang under Linux, there is
not much point in running a separate clang job. Any errors that a normal
clang compile-and-test cycle would find are likely to be a subset of
what the sanitizer job will find. Since this job takes ~14 minutes to
run in CI, this shaves off some of our CPU load (though it does not
affect end-to-end runtime, since it's typically run in parallel and is
not the longest job).

Technically this provides us with slightly less signal for a given run,
since you won't immediately know if a failure in the sanitizer job is
from using clang or from the sanitizers themselves. But it's generally
obvious from the logs, and anyway your next step would be to fix the
probvlem and re-run CI, since we expect all of these jobs to pass
normally.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 months agoci: run ASan/UBSan in a single job
Jeff King [Thu, 1 Jun 2023 18:09:47 +0000 (14:09 -0400)] 
ci: run ASan/UBSan in a single job

When we started running sanitizers in CI via 1c0962c0c4 (ci: add address
and undefined sanitizer tasks, 2022-10-20), we ran them as two separate
CI jobs, since as that commit notes, the combination "seems to take
forever".

And indeed, it does with gcc. However, since the previous commit
switched to using clang, the situation is different, and we can save
some CPU by using a single job for both. Comparing before/after CI runs,
this saved about 14 minutes (the single combined job took 54m, versus
44m plus 24m for ASan and UBSan jobs, respectively). That's wall-clock
and not CPU, but since our jobs are mostly CPU-bound, the two should be
closely proportional.

This does increase the end-to-end time of a CI run, though, since before
this patch the two jobs could run in parallel, and the sanitizer job is
our longest single job. It also means that we won't get a separate
result for "this passed with UBSan but not with ASan" or vice versa).
But as 1c0962c0c4 noted, that is not a very useful signal in practice.

Below are some more detailed timings of gcc vs clang that I measured by
running the test suite on my local workstation. Each measurement counts
only the time to run the test suite with each compiler (not the compile
time itself). We'll focus on the wall-clock times for simplicity, though
the CPU times follow roughly similar trends.

Here's a run with CC=gcc as a baseline:

  real 1m12.931s
  user 9m30.566s
  sys 8m9.538s

Running with SANITIZE=address increases the time by a factor of ~4.7x:

  real 5m40.352s
  user 49m37.044s
  sys 36m42.950s

Running with SANITIZE=undefined increases the time by a factor of ~1.7x:

  real 2m5.956s
  user 12m42.847s
  sys 19m27.067s

So let's call that 6.4 time units to run them separately (where a unit
is the time it takes to run the test suite with no sanitizers). As a
simplistic model, we might imagine that running them together would take
5.4 units (we save 1 unit because we are no longer running the test
suite twice, but just paying the sanitizer overhead on top of a single
run).

But that's not what happens. Running with SANITIZE=address,undefined
results in a factor of 9.3x:

  real 11m9.817s
  user 77m31.284s
  sys 96m40.454s

So not only did we not get faster when doing them together, we actually
spent 1.5x as much CPU as doing them separately! And while those
wall-clock numbers might not look too terrible, keep in mind that this
is on an unloaded 8-core machine. In the CI environment, wall-clock
times will be much closer to CPU times. So not only are we wasting CPU,
but we risk hitting timeouts.

Now let's try the same thing with clang. Here's our no-sanitizer
baseline run, which is almost identical to the gcc one (which is quite
convenient, because we can keep using the same "time units" to get an
apples-to-apples comparison):

  real 1m11.844s
  user 9m28.313s
  sys 8m8.240s

And now again with SANITIZE=address, we get a 5x factor (so slightly
worse than gcc's 4.7x, though I wouldn't read too much into it; there is
a fair bit of run-to-run noise):

  real 6m7.662s
  user 49m24.330s
  sys 44m13.846s

And with SANITIZE=undefined, we are at 1.5x, slightly outperforming gcc
(though again, that's probably mostly noise):

  real 1m50.028s
  user 11m0.973s
  sys 16m42.731s

So running them separately, our total cost is 6.5x. But if we combine
them in a single run (SANITIZE=address,undefined), we get:

  real 6m51.804s
  user 52m32.049s
  sys 51m46.711s

which is a factor of 5.7x. That's along the lines we'd hoped for!
Running them together saves us almost a whole time unit. And that's not
counting any time spent outside the test suite itself (starting the job,
setting up the environment, compiling) that we're no longer duplicating
by having two jobs.

So clang behaves like we'd hope: the overhead to run the sanitizers is
additive as you add more sanitizers. Whereas gcc's numbers seem very
close to multiplicative, almost as if the sanitizers were enforcing
their overheads on each other (though that is purely a guess on what is
going on; ultimately what matters to us is the amount of time it takes).

And that roughly matches the CI improvement I saw. A "time unit" there
is more like 12 minutes, and the observed time savings was 14 minutes
(with the extra presumably coming from avoiding duplicated setup, etc).

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 months agoci: use clang for ASan/UBSan checks
Jeff King [Thu, 1 Jun 2023 18:03:51 +0000 (14:03 -0400)] 
ci: use clang for ASan/UBSan checks

Both gcc and clang support the "address" and "undefined" sanitizers.
However, they may produce different results. We've seen at least two
real world cases where gcc missed a UBSan problem but clang found it:

  1. Clang's UBSan (using clang 14.0.6) found a string index that was
     subtracted to "-1", causing an out-of-bounds read (curiously this
     didn't trigger ASan, but that may be because the string was in the
     argv memory, not stack or heap). Using gcc (version 12.2.0) didn't
     find the same problem.

     Original thread:
     https://lore.kernel.org/git/20230519005447.GA2955320@coredump.intra.peff.net/

  2. Clang's UBSan (using clang 4.0.1) complained about pointer
     arithmetic with NULL, but gcc at the time did not. This was in
     2017, and modern gcc does seem to find the issue, though.

     Original thread:
     https://lore.kernel.org/git/32a8b949-638a-1784-7fba-948ae32206fc@web.de/

Since we don't otherwise have a particular preference for one compiler
over the other for this test, let's switch to the one that we think may
be more thorough.

Note that it's entirely possible that the two are simply _different_,
and we are trading off problems that gcc would find that clang wouldn't.
However, my subjective and anecdotal experience has been that clang's
sanitizer support is a bit more mature (e.g., I recall other oddities
around leak-checking where clang performed more sensibly).

Obviously running both and cross-checking the results would give us the
best coverage, but that's very expensive to run (and these are already
some of our most expensive CI jobs). So let's use clang as our best
guess, and we can re-evaluate if we get more data points.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 months agodiff: detect pathspec magic not supported by --follow
Jeff King [Thu, 1 Jun 2023 17:43:51 +0000 (13:43 -0400)] 
diff: detect pathspec magic not supported by --follow

The --follow code doesn't handle most forms of pathspec magic. We check
that no unexpected ones have made it to try_to_follow_renames() with a
runtime GUARD_PATHSPEC() check, which gives behavior like this:

  $ git log --follow ':(icase)makefile' >/dev/null
  BUG: tree-diff.c:596: unsupported magic 10
  Aborted

The same is true of ":(glob)", ":(attr)", and so on. It's good that we
notice the problem rather than continuing and producing a wrong answer.
But there are two non-ideal things:

  1. The idea of GUARD_PATHSPEC() is to catch programming errors where
     low-level code gets unexpected pathspecs. We'd usually try to catch
     unsupported pathspecs by passing a magic_mask to parse_pathspec(),
     which would give the user a much better message like:

       pathspec magic not supported by this command: 'icase'

     That doesn't happen here because git-log usually _does_ support
     all types of pathspec magic, and so it passes "0" for the mask
     (this call actually happens in setup_revisions()). It needs to
     distinguish the normal case from the "--follow" one but currently
     doesn't.

  2. In addition to --follow, we have the log.follow config option. When
     that is set, we try to turn on --follow mode only when there is a
     single pathspec (since --follow doesn't handle anything else). But
     really, that ought to be expanded to "use --follow when the
     pathspec supports it". Otherwise, we'd complain any time you use an
     exotic pathspec:

       $ git config log.follow true
       $ git log ':(icase)makefile' >/dev/null
       BUG: tree-diff.c:596: unsupported magic 10
       Aborted

     We should instead just avoid enabling follow mode if it's not
     supported by this particular invocation.

This patch expands our diff_check_follow_pathspec() function to cover
pathspec magic, solving both problems.

A few final notes:

  - we could also solve (1) by passing the appropriate mask to
    parse_pathspec(). But that's not great for two reasons. One is that
    the error message is less precise. It says "magic not supported by
    this command", but really it is not the command, but rather the
    --follow option which is the problem. The second is that it always
    calls die(). But for our log.follow code, we want to speculatively
    ask "is this pathspec OK?" and just get a boolean result.

  - This is obviously the right thing to do for ':(icase)' and most
    other magic options. But ':(glob)' is a bit odd here. The --follow
    code doesn't support wildcards, but we allow them anyway. From
    try_to_follow_renames():

#if 0
        /*
         * We should reject wildcards as well. Unfortunately we
         * haven't got a reliable way to detect that 'foo\*bar' in
         * fact has no wildcards. nowildcard_len is merely a hint for
         * optimization. Let it slip for now until wildmatch is taught
         * about dry-run mode and returns wildcard info.
         */
        if (opt->pathspec.has_wildcard)
                BUG("wildcards are not supported");
#endif

    So something like "git log --follow 'Make*'" is already doing the
    wrong thing, since ":(glob)" behavior is already the default (it is
    used only to countermand an earlier --noglob-pathspecs).

    So we _could_ loosen the guard to allow :(glob), since it just
    behaves the same as pathspecs do by default. But it seems like a
    backwards step to do so. It already doesn't work (it hits the BUG()
    case currently), and given that the user took an explicit step to
    say "this pathspec should glob", it is reasonable for us to say "no,
    --follow does not support globbing" (or in the case of log.follow,
    avoid turning on follow mode). Which is what happens after this
    patch.

  - The set of allowed pathspec magic is obviously the same as in
    GUARD_PATHSPEC(). We could perhaps factor these out to avoid
    repetition. The point of having separate masks and GUARD calls is
    that we don't necessarily know which parsed pathspecs will be used
    where. But in this case, the two are heavily correlated. Still,
    there may be some value in keeping them separate; it would make
    anyone think twice about adding new magic to the list in
    diff_check_follow_pathspec(). They'd need to touch
    try_to_follow_renames() as well, which is the code that would
    actually need to be updated to handle more exotic pathspecs.

  - The documentation for log.follow says that it enables --follow
    "...when a single <path> is given". We could possibly expand that to
    say "with no unsupported pathspec magic", but that raises the
    question of documenting which magic is supported. I think the
    existing wording of "single <path>" sufficiently encompasses the
    idea (the forbidden magic is stuff that might match multiple
    entries), and the spirit remains the same.

Reported-by: Jim Pryor <dubiousjim@gmail.com>
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 months agodiff: factor out --follow pathspec check
Jeff King [Thu, 1 Jun 2023 17:41:06 +0000 (13:41 -0400)] 
diff: factor out --follow pathspec check

In --follow mode, we require exactly one pathspec. We check this
condition in two places:

  - in diff_setup_done(), we complain if --follow is used with an
    inapropriate pathspec

  - in git-log's revision "tweak" function, we enable log.follow only if
    the pathspec allows it

The duplication isn't a big deal right now, since the logic is so
simple. But in preparation for it becoming more complex, let's pull it
into a shared function.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 months agopathspec: factor out magic-to-name function
Jeff King [Thu, 1 Jun 2023 17:38:14 +0000 (13:38 -0400)] 
pathspec: factor out magic-to-name function

When we have unsupported magic in a pathspec (because a command or code
path does not support particular items), we list the unsupported ones in
an error message.

Let's factor out the code here that converts the bits back into their
human-readable names, so that it can be used from other callers, which
may want to provide more flexible error messages.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 months agosurround %s with quotes when failed to lookup commit
Teng Long [Mon, 29 May 2023 13:27:56 +0000 (21:27 +0800)] 
surround %s with quotes when failed to lookup commit

The output may become confusing to recognize if the user
accidentally gave an extra opening space, like:

   $ git commit --fixup=" 6d6360b67e99c2fd82d64619c971fdede98ee74b"
   fatal: could not lookup commit  6d6360b67e99c2fd82d64619c971fdede98ee74b

and it will be better if we surround the %s specifier with single quotes.

Signed-off-by: Teng Long <dyroneteng@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 months agoGit 2.41 v2.41.0
Junio C Hamano [Thu, 1 Jun 2023 06:28:26 +0000 (15:28 +0900)] 
Git 2.41

Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 months agoMerge tag 'l10n-2.41.0-2' of https://github.com/git-l10n/git-po
Junio C Hamano [Thu, 1 Jun 2023 06:27:43 +0000 (15:27 +0900)] 
Merge tag 'l10n-2.41.0-2' of https://github.com/git-l10n/git-po

l10n-2.41.0-2

* tag 'l10n-2.41.0-2' of https://github.com/git-l10n/git-po:
  l10n: zh_TW.po: Git 2.41.0
  l10n: sv.po: Update Swedish translation (5515t0f0u)
  l10n: Update Catalan translation
  l10n: Update German translation
  l10n: po-id for 2.41 (round 1)
  l10n: Update Catalan translation
  l10n: tr: Update Turkish translations for 2.41.0
  l10n: fr.po v2.41.0 rnd2
  l10n: fr.po v2.41.0 rnd1
  l10n: fr: fix translation of stash save help
  l10n: zh_CN: Git 2.41.0 round #1
  l10n: bg.po: Updated Bulgarian translation (5515t)
  l10n: update uk localization
  l10n: uk: remove stale lines
  l10n: uk: add initial translation
  l10n: TEAMS: Update pt_PT repo link

11 months agol10n: zh_TW.po: Git 2.41.0
Yi-Jyun Pan [Wed, 31 May 2023 16:53:09 +0000 (00:53 +0800)] 
l10n: zh_TW.po: Git 2.41.0

Co-authored-by: Peter Dave Hello <hsu@peterdavehello.org>
Signed-off-by: Yi-Jyun Pan <pan93412@gmail.com>
11 months agoMerge branch 'add-uk-initial-l10n' of github.com:arkid15r/git-ukrainian-l10n
Jiang Xin [Wed, 31 May 2023 13:11:25 +0000 (21:11 +0800)] 
Merge branch 'add-uk-initial-l10n' of github.com:arkid15r/git-ukrainian-l10n

* 'add-uk-initial-l10n' of github.com:arkid15r/git-ukrainian-l10n:
  l10n: update uk localization
  l10n: uk: remove stale lines
  l10n: uk: add initial translation

11 months agol10n: sv.po: Update Swedish translation (5515t0f0u)
Peter Krefting [Wed, 31 May 2023 12:16:21 +0000 (13:16 +0100)] 
l10n: sv.po: Update Swedish translation (5515t0f0u)

Signed-off-by: Peter Krefting <peter@softwolves.pp.se>
11 months agol10n: Update Catalan translation
Jordi Mas [Fri, 26 May 2023 18:02:14 +0000 (20:02 +0200)] 
l10n: Update Catalan translation

Signed-off-by: Jordi Mas <jmas@softcatala.org>
11 months agorepository: move 'repository_format_worktree_config' to repo scope
Victoria Dye [Fri, 26 May 2023 01:33:00 +0000 (01:33 +0000)] 
repository: move 'repository_format_worktree_config' to repo scope

Move 'repository_format_worktree_config' out of the global scope and into
the 'repository' struct. This change is similar to how
'repository_format_partial_clone' was moved in ebaf3bcf1ae (repository: move
global r_f_p_c to repo struct, 2021-06-17), adding it to the 'repository'
struct and updating 'setup.c' & 'repository.c' functions to assign the value
appropriately.

The primary goal of this change is to be able to load the worktree config of
a submodule depending on whether that submodule - not its superproject - has
'extensions.worktreeConfig' enabled. To ensure 'do_git_config_sequence()'
has access to the newly repo-scoped configuration, add a 'struct repository'
argument to 'do_git_config_sequence()' and pass it the 'repo' value from
'config_with_options()'.

Finally, add/update tests in 't3007-ls-files-recurse-submodules.sh' to
verify 'extensions.worktreeConfig' is read an used independently by
superprojects and submodules.

Signed-off-by: Victoria Dye <vdye@github.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 months agoconfig: pass 'repo' directly to 'config_with_options()'
Victoria Dye [Fri, 26 May 2023 01:32:59 +0000 (01:32 +0000)] 
config: pass 'repo' directly to 'config_with_options()'

Add a 'struct repository' argument to 'config_with_options()' and remove the
'repo' field from 'struct git_config_source'.

A 'struct repository' instance was originally added to the config source in
e3e8bf046e9 (submodule-config: pass repo upon blob config read, 2021-08-16)
to improve how submodule blob config content was accessed. At the time, this
was the only use for a 'repository' instance, so it was naturally added only
where it was needed: to 'struct git_config_source'. However, in upcoming
patches, 'config_with_options()' will need the repository instance to access
extension information (regardless of whether a 'config_source' exists). To
make the 'struct repository' instance more easily accessible, move it into
the function's arguments.

Update all callers of 'config_with_options()' to pass the appropriate 'repo'
value:

* in 'builtin/config.c', use 'the_repository'
* in 'submodule--config.c', use the 'repo' arg in 'config_from_gitmodules()'
* in 'read_[very_]early_config()' & 'read_protected_config()', set 'repo' to
  NULL (repository instances aren't available there)
* in 'populate_remote_urls()', use the repo instance that has been added to
  the 'struct config_include_data'
* in 'repo_read_config()', use the given 'repo' arg

Finally, note that this patch eliminates the fallback to 'the_repository'
that previously existed for the 'config_source' repo instance if it was
NULL. The fallback is no longer necessary, as the 'repo' is set explicitly
in all cases where it is needed.

Signed-off-by: Victoria Dye <vdye@github.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 months agoconfig: use gitdir to get worktree config
Victoria Dye [Fri, 26 May 2023 01:32:58 +0000 (01:32 +0000)] 
config: use gitdir to get worktree config

Update 'do_git_config_sequence()' to read the worktree config from
'config.worktree' in 'opts->git_dir' rather than the gitdir of
'the_repository'.

The worktree config is loaded from the path returned by
'git_pathdup("config.worktree")', the 'config.worktree' relative to the
gitdir of 'the_repository'. If loading the config for a submodule, this path
is incorrect, since 'the_repository' is the superproject. 'opts->git_dir' is
the gitdir of the submodule being configured, so the config file in that
location should be read instead.

To ensure the use of 'opts->git_dir' is safe, require that 'opts->git_dir'
is set if-and-only-if 'opts->commondir' is set (rather than "only-if" as it
is now). In all current usage of 'config_options', these values are set
together, so the stricter check does not change any behavior.

Finally, add tests to 't3007-ls-files-recurse-submodules.sh' to verify the
corrected config is loaded. Use 'ls-files' to test this because, unlike some
other '--recurse-submodules' commands, 'ls-files' parses the config of the
submodule in the same process as the superproject (via 'show_submodule()' ->
'repo_read_index()' -> 'prepare_repo_settings()'). As a result,
'the_repository' points to the config of the superproject but the
commondir/gitdir in the config sequence will be that of the submodule,
providing the exact scenario needed to verify this patch.

The first test ('--recurse-submodules parses submodule repo config') checks
that the submodule's *repo* config is read when running 'ls-files' on the
superproject; this confirms already-working behavior, serving as a reference
for how worktree config parsing should behave. The second test
('--recurse-submodules parses submodule worktree config') tests the same
scenario as the previous but instead using the *worktree* config,
demonstrating the corrected behavior. The 'test_config' helper is extended
for this case so that it properly applies the '--worktree' option to the
configure/unconfigure operations it performs.

Note that, although the submodule worktree config is now parsed instead of
the superproject's, 'extensions.worktreeConfig' in the superproject still
controls whether or not the worktree config is enabled at all in the
submodule. This will be fixed in a later patch.

Signed-off-by: Victoria Dye <vdye@github.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 months agot/lib-gpg: fix ssh-keygen -Y check-novalidate with openssh-9.0
Todd Zullinger [Thu, 25 May 2023 03:10:24 +0000 (23:10 -0400)] 
t/lib-gpg: fix ssh-keygen -Y check-novalidate with openssh-9.0

OpenSSH-9.0 requires a namespace option with `-Y check-novalidate`.
This was added in openssh-portable commit a0b5816f8 (upstream:
ssh-keygen -Y check-novalidate requires namespace or SEGV, 2022-03-18).

The -n option was documented as a required option since check-novalidate
was added in openssh-portable 8aa2aa3cd (upstream: Allow testing
signature syntax and validity without verifying, 2019-09-16).

Signed-off-by: Todd Zullinger <tmz@pobox.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 months agotrace2 tests: fix PTHREADS prereq
Todd Zullinger [Thu, 25 May 2023 03:12:07 +0000 (23:12 -0400)] 
trace2 tests: fix PTHREADS prereq

The prereq guard added in 14903c8e92 (trace2 tests: guard pthread test
with "PTHREAD", 2022-11-24) lacks the S in PTHREADS, causing it to never
be satisfied.  Fix the spelling of the prereq.

Signed-off-by: Todd Zullinger <tmz@pobox.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 months agoMerge branch 'l10n-de-2.41' of github.com:ralfth/git
Jiang Xin [Thu, 25 May 2023 06:06:01 +0000 (14:06 +0800)] 
Merge branch 'l10n-de-2.41' of github.com:ralfth/git

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

11 months agoMerge branch 'catalan' of github.com:Softcatala/git-po
Jiang Xin [Thu, 25 May 2023 06:05:21 +0000 (14:05 +0800)] 
Merge branch 'catalan' of github.com:Softcatala/git-po

* 'catalan' of github.com:Softcatala/git-po:
  l10n: Update Catalan translation

11 months agoMerge branch 'tr' of github.com:bitigchi/git-po
Jiang Xin [Thu, 25 May 2023 06:04:42 +0000 (14:04 +0800)] 
Merge branch 'tr' of github.com:bitigchi/git-po

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

11 months agoMerge branch 'main' of github.com:alshopov/git-po
Jiang Xin [Thu, 25 May 2023 06:03:58 +0000 (14:03 +0800)] 
Merge branch 'main' of github.com:alshopov/git-po

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

11 months agoMerge branch 'fr_2.41.0_rnd1' of github.com:jnavila/git
Jiang Xin [Thu, 25 May 2023 06:03:22 +0000 (14:03 +0800)] 
Merge branch 'fr_2.41.0_rnd1' of github.com:jnavila/git

* 'fr_2.41.0_rnd1' of github.com:jnavila/git:
  l10n: fr.po v2.41.0 rnd2
  l10n: fr.po v2.41.0 rnd1
  l10n: fr: fix translation of stash save help

11 months agoMerge branch 'po-id' of github.com:bagasme/git-po
Jiang Xin [Thu, 25 May 2023 06:01:59 +0000 (14:01 +0800)] 
Merge branch 'po-id' of github.com:bagasme/git-po

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

11 months agoMerge branch 'tl/zh_CN_2.41.0_rnd1' of github.com:dyrone/git
Jiang Xin [Thu, 25 May 2023 05:58:10 +0000 (13:58 +0800)] 
Merge branch 'tl/zh_CN_2.41.0_rnd1' of github.com:dyrone/git

* 'tl/zh_CN_2.41.0_rnd1' of github.com:dyrone/git:
  l10n: zh_CN: Git 2.41.0 round #1

11 months agoGit 2.41-rc2 v2.41.0-rc2
Junio C Hamano [Wed, 24 May 2023 20:55:19 +0000 (05:55 +0900)] 
Git 2.41-rc2

Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 months agoMerge branch 'sl/sparse-write-tree-part-2'
Junio C Hamano [Wed, 24 May 2023 20:53:55 +0000 (05:53 +0900)] 
Merge branch 'sl/sparse-write-tree-part-2'

Fix-up to a topic already graduated to 'master'.

* sl/sparse-write-tree-part-2:
  t1092: update a write-tree test

11 months agobuiltin/submodule--helper.c: handle missing submodule URLs
Taylor Blau [Wed, 24 May 2023 19:51:43 +0000 (15:51 -0400)] 
builtin/submodule--helper.c: handle missing submodule URLs

In e0a862fdaf (submodule helper: convert relative URL to absolute URL if
needed, 2018-10-16), `prepare_to_clone_next_submodule()` lost the
ability to handle URL-less submodules, due to a change from:

    if (repo_get_config_string_const(the_repostiory, sb.buf, &url))
        url = sub->url;

to

    if (repo_get_config_string_const(the_repostiory, sb.buf, &url)) {
        if (starts_with_dot_slash(sub->url) ||
            starts_with_dot_dot_slash(sub->url)) {
                /* ... */
            }
    }

, which will segfault when `sub->url` is NULL, since both
`starts_with_dot_slash()` does not guard its arguments as non-NULL.

Guard the checks to both of the above functions by first checking
whether `sub->url` is non-NULL. There is no need to check whether `sub`
itself is NULL, since we already perform this check earlier in
`prepare_to_clone_next_submodule()`.

By adding a NULL-ness check on `sub->url`, we'll fall into the 'else'
branch, setting `url` to `sub->url` (which is NULL). Before attempting
to invoke `git submodule--helper clone`, check whether `url` is NULL,
and die() if it is.

Reported-by: Tribo Dar <3bodar@gmail.com>
Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 months agols-files: align format atoms with ls-tree
ZheNing Hu [Tue, 23 May 2023 09:00:18 +0000 (09:00 +0000)] 
ls-files: align format atoms with ls-tree

"git ls-files --format" can be used to format the output of
multiple file entries in the index, while "git ls-tree --format"
can be used to format the contents of a tree object. However,
the current set of %(objecttype), "(objectsize)", and
"%(objectsize:padded)" atoms supported by "git ls-files --format"
is a subset of what is available in "git ls-tree --format".

Users sometimes need to establish a unified view between the index
and tree, which can help with comparison or conversion between the two.

Therefore, this patch adds the missing atoms to "git ls-files --format".
"%(objecttype)" can be used to retrieve the object type corresponding
to a file in the index, "(objectsize)" can be used to retrieve the
object size corresponding to a file in the index, and "%(objectsize:padded)"
is the same as "(objectsize)", except with padded format.

Signed-off-by: ZheNing Hu <adlternative@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 months agocompletion: complete AUTO_MERGE
Philippe Blain [Mon, 22 May 2023 19:29:01 +0000 (19:29 +0000)] 
completion: complete AUTO_MERGE

The pseudoref AUTO_MERGE is documented since the previous commit. To
make it easier to use, let __git_refs in the Bash completion code
complete it.

Signed-off-by: Philippe Blain <levraiphilippeblain@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 months agoDocumentation: document AUTO_MERGE
Philippe Blain [Mon, 22 May 2023 19:29:00 +0000 (19:29 +0000)] 
Documentation: document AUTO_MERGE

Since 5291828df8 (merge-ort: write $GIT_DIR/AUTO_MERGE whenever we hit a
conflict, 2021-03-20), when using the 'ort' merge strategy, the special
ref AUTO_MERGE is written when a merge operation results in conflicts.
This ref points to a tree recording the conflicted state of the working
tree and is very useful during conflict resolution. However, this ref is
not documented.

Add some documentation for AUTO_MERGE in git-diff(1), git-merge(1),
gitrevisions(7) and in the user manual.

In git-diff(1), mention it at the end of the description section, when
we mention that the command also accepts trees instead of commits, and
also add an invocation to the "Various ways to check your working tree"
example.

In git-merge(1), add a step to the list of things that happen "when it
is not obvious how to reconcile the changes", under the "True merge"
section. Also mention AUTO_MERGE in the "How to resolve conflicts"
section, when mentioning 'git diff'.

In gitrevisions(7), add a mention of AUTO_MERGE along with the other
special refs.

In the user manual, add a paragraph describing AUTO_MERGE to the
"Getting conflict-resolution help during a merge" section, and include
an example of a 'git diff AUTO_MERGE' invocation for the example
conflict used in that section. Note that for uniformity we do not use
backticks around AUTO_MERGE here since the rest of the document does not
typeset special refs differently.

Closes: https://github.com/gitgitgadget/git/issues/1471
Signed-off-by: Philippe Blain <levraiphilippeblain@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 months agogit-merge.txt: modernize word choice in "True merge" section
Philippe Blain [Mon, 22 May 2023 19:28:59 +0000 (19:28 +0000)] 
git-merge.txt: modernize word choice in "True merge" section

The "True merge" section of the 'git merge' documentation mentions that
in case of conflicts, the conflicted working tree files contain "the
result of the "merge" program". This probably refers to RCS's 'merge'
program, which is mentioned further down under "How conflicts are
presented".

Since it is not clear at that point of the document which program is
referred to, and since most modern readers probably do not relate to RCS
anyway, let's just write "the merge operation" instead.

Signed-off-by: Philippe Blain <levraiphilippeblain@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 months agocompletion: complete REVERT_HEAD and BISECT_HEAD
Philippe Blain [Mon, 22 May 2023 19:28:58 +0000 (19:28 +0000)] 
completion: complete REVERT_HEAD and BISECT_HEAD

The pseudorefs REVERT_HEAD and BISECT_HEAD are not suggested
by the __git_refs function. Add them there.

Signed-off-by: Philippe Blain <levraiphilippeblain@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 months agorevisions.txt: document more special refs
Philippe Blain [Mon, 22 May 2023 19:28:57 +0000 (19:28 +0000)] 
revisions.txt: document more special refs

Some special refs, namely HEAD, FETCH_HEAD, ORIG_HEAD, MERGE_HEAD and
CHERRY_PICK_HEAD, are mentioned and described in 'gitrevisions', but some
others, namely REBASE_HEAD, REVERT_HEAD, and BISECT_HEAD, are not.

Add a small description of these special refs.

Signed-off-by: Philippe Blain <levraiphilippeblain@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 months agorevisions.txt: use description list for special refs
Philippe Blain [Mon, 22 May 2023 19:28:56 +0000 (19:28 +0000)] 
revisions.txt: use description list for special refs

The special refs listed in 'gitrevisions' (under the '<refname>' entry)
are on separate lines in the Asciidoc source, but end up as a single
continuous paragraph in the rendered documentation (see e.g. [1]). In
following commits we will mention additional special refs, so to improve
legibility, use a description list such that every entry appears on its
own line. Since we are already in a description list, use ':::' as the
term delimiter.

In order for the new description list to be aligned with the description
under the '<refname>' entry, instead of being aligned with the last
entry of the "in the following rules" nested list, use the "ancestor
list continuation" syntax [2], i.e., leave an empty line before the
continuation '+'. Do the same for the paragraph following the new
description list ("Note that any...").

While at it, also use a continuation '+' before the "in the following
rules" list, for correctness. The parser seems not to care here, but
it's best to keep the sources correct.

[1] https://git-scm.com/docs/gitrevisions#Documentation/gitrevisions.txt-emltrefnamegtemegemmasterememheadsmasterememrefsheadsmasterem
[2] https://docs.asciidoctor.org/asciidoc/latest/lists/continuation/#ancestor-list-continuation

Suggested-by: Victoria Dye <vdye@github.com>
Based-on-patch-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Philippe Blain <levraiphilippeblain@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 months agot9400-git-cvsserver-server: modernize test format
John Cai [Sat, 20 May 2023 16:13:58 +0000 (16:13 +0000)] 
t9400-git-cvsserver-server: modernize test format

Some tests still use the old format with four spaces indentation.
Standardize the tests to the new format with tab indentation.

Signed-off-by: John Cai <johncai86@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 months agot9200-git-cvsexportcommit: modernize test format
John Cai [Sat, 20 May 2023 16:13:57 +0000 (16:13 +0000)] 
t9200-git-cvsexportcommit: modernize test format

Some tests still use the old format with four spaces indentation.
Standardize the tests to the new format with tab indentation.

Signed-off-by: John Cai <johncai86@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 months agot9104-git-svn-follow-parent: modernize test format
John Cai [Sat, 20 May 2023 16:13:56 +0000 (16:13 +0000)] 
t9104-git-svn-follow-parent: modernize test format

Some tests still use the old format with four spaces indentation.
Standardize the tests to the new format with tab indentation.

Signed-off-by: John Cai <johncai86@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 months agot9100-git-svn-basic: modernize test format
John Cai [Sat, 20 May 2023 16:13:55 +0000 (16:13 +0000)] 
t9100-git-svn-basic: modernize test format

Some tests still use the old format with four spaces indentation.
Standardize the tests to the new format with tab indentation.

Signed-off-by: John Cai <johncai86@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 months agot7700-repack: modernize test format
John Cai [Sat, 20 May 2023 16:13:54 +0000 (16:13 +0000)] 
t7700-repack: modernize test format

Some tests still use the old format with four spaces indentation.
Standardize the tests to the new format with tab indentation.

Signed-off-by: John Cai <johncai86@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 months agot7600-merge: modernize test format
John Cai [Sat, 20 May 2023 16:13:53 +0000 (16:13 +0000)] 
t7600-merge: modernize test format

Some tests still use the old format with four spaces indentation.
Standardize the tests to the new format with tab indentation.

Signed-off-by: John Cai <johncai86@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 months agot7508-status: modernize test format
John Cai [Sat, 20 May 2023 16:13:52 +0000 (16:13 +0000)] 
t7508-status: modernize test format

Some tests still use the old format with four spaces indentation.
Standardize the tests to the new format with tab indentation.

Signed-off-by: John Cai <johncai86@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 months agot7201-co: modernize test format
John Cai [Sat, 20 May 2023 16:13:51 +0000 (16:13 +0000)] 
t7201-co: modernize test format

Some tests still use the old format with four spaces indentation.
Standardize the tests to the new format with tab indentation.

Signed-off-by: John Cai <johncai86@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 months agot7111-reset-table: modernize test format
John Cai [Sat, 20 May 2023 16:13:50 +0000 (16:13 +0000)] 
t7111-reset-table: modernize test format

Some tests still use the old format with four spaces indentation.
Standardize the tests to the new format with tab indentation.

Signed-off-by: John Cai <johncai86@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 months agot7110-reset-merge: modernize test format
John Cai [Sat, 20 May 2023 16:13:49 +0000 (16:13 +0000)] 
t7110-reset-merge: modernize test format

Some tests still use the old format with four spaces indentation.
Standardize the tests to the new format with tab indentation.

Signed-off-by: John Cai <johncai86@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 months agol10n: Update German translation
Ralf Thielow [Mon, 22 May 2023 15:17:49 +0000 (17:17 +0200)] 
l10n: Update German translation

Signed-off-by: Ralf Thielow <ralf.thielow@gmail.com>
Reviewed-by: Matthias Rüster <matthias.ruester@gmail.com>
11 months agol10n: po-id for 2.41 (round 1)
Bagas Sanjaya [Sun, 23 Apr 2023 09:15:06 +0000 (16:15 +0700)] 
l10n: po-id for 2.41 (round 1)

Update following components:

  * advice.c
  * archive.c
  * attr.c
  * config.c
  * pack-revindex.c
  * builtin/branch.c
  * builtin/bundle.c
  * builtin/pack-redundant.c
  * builtin/rebase.c
  * builtin/sparse-checkout.c

Signed-off-by: Bagas Sanjaya <bagasdotme@gmail.com>
12 months agol10n: Update Catalan translation
Jordi Mas [Sat, 20 May 2023 12:09:46 +0000 (14:09 +0200)] 
l10n: Update Catalan translation

Signed-off-by: Jordi Mas <jmas@softcatala.org>
12 months agol10n: tr: Update Turkish translations for 2.41.0
Emir SARI [Sat, 20 May 2023 10:57:05 +0000 (13:57 +0300)] 
l10n: tr: Update Turkish translations for 2.41.0

Signed-off-by: Emir SARI <emir_sari@icloud.com>