]> git.ipfire.org Git - thirdparty/git.git/log
thirdparty/git.git
2 years agot5563: add tests for basic and anoymous HTTP access
Matthew John Cheetham [Mon, 27 Feb 2023 17:20:18 +0000 (17:20 +0000)] 
t5563: add tests for basic and anoymous HTTP access

Add a test showing simple anoymous HTTP access to an unprotected
repository, that results in no credential helper invocations.
Also add a test demonstrating simple basic authentication with
simple credential helper support.

Leverage a no-parsed headers (NPH) CGI script so that we can directly
control the HTTP responses to simulate a multitude of good, bad and ugly
remote server implementations around auth.

Signed-off-by: Matthew John Cheetham <mjcheetham@outlook.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agoThe fourteenth batch
Junio C Hamano [Wed, 8 Feb 2023 17:14:51 +0000 (09:14 -0800)] 
The fourteenth batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agoMerge branch 'ds/scalar-ignore-cron-error'
Junio C Hamano [Wed, 8 Feb 2023 17:14:42 +0000 (09:14 -0800)] 
Merge branch 'ds/scalar-ignore-cron-error'

Allow "scalar" to warn but continue when its periodic maintenance
feature cannot be enabled.

* ds/scalar-ignore-cron-error:
  scalar: only warn when background maintenance fails
  t921*: test scalar behavior starting maintenance
  t: allow 'scalar' in test_must_fail

2 years agoMerge branch 'mh/doc-credential-cache-only-in-core'
Junio C Hamano [Wed, 8 Feb 2023 17:14:42 +0000 (09:14 -0800)] 
Merge branch 'mh/doc-credential-cache-only-in-core'

Documentation clarification.

* mh/doc-credential-cache-only-in-core:
  Documentation: clarify that cache forgets credentials if the system restarts

2 years agoMerge branch 'gm/request-pull-with-non-pgp-signed-tags'
Junio C Hamano [Wed, 8 Feb 2023 17:14:42 +0000 (09:14 -0800)] 
Merge branch 'gm/request-pull-with-non-pgp-signed-tags'

Adjust "git request-pull" to strip embedded signature from signed
tags to notice non-PGP signatures.

* gm/request-pull-with-non-pgp-signed-tags:
  request-pull: filter out SSH/X.509 tag signatures

2 years agoThe thirteenth batch
Junio C Hamano [Fri, 3 Feb 2023 22:31:25 +0000 (14:31 -0800)] 
The thirteenth batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agoMerge branch 'en/ls-files-doc-update'
Junio C Hamano [Sat, 4 Feb 2023 00:08:22 +0000 (16:08 -0800)] 
Merge branch 'en/ls-files-doc-update'

Doc update to ls-files.

* en/ls-files-doc-update:
  ls-files: guide folks to --exclude-standard over other --exclude* options
  ls-files: clarify descriptions of status tags for -t
  ls-files: clarify descriptions of file selection options
  ls-files: add missing documentation for --resolve-undo option

2 years agoMerge branch 'en/rebase-incompatible-opts'
Junio C Hamano [Sat, 4 Feb 2023 00:08:21 +0000 (16:08 -0800)] 
Merge branch 'en/rebase-incompatible-opts'

"git rebase" often ignored incompatible options instead of
complaining, which has been corrected.

* en/rebase-incompatible-opts:
  rebase: provide better error message for apply options vs. merge config
  rebase: put rebase_options initialization in single place
  rebase: fix formatting of rebase --reapply-cherry-picks option in docs
  rebase: clarify the OPT_CMDMODE incompatibilities
  rebase: add coverage of other incompatible options
  rebase: fix incompatiblity checks for --[no-]reapply-cherry-picks
  rebase: fix docs about incompatibilities with --root
  rebase: remove --allow-empty-message from incompatible opts
  rebase: flag --apply and --merge as incompatible
  rebase: mark --update-refs as requiring the merge backend

2 years agoMerge branch 'as/ssh-signing-improve-key-missing-error'
Junio C Hamano [Sat, 4 Feb 2023 00:08:21 +0000 (16:08 -0800)] 
Merge branch 'as/ssh-signing-improve-key-missing-error'

Improve the error message given when private key is not loaded in
the ssh agent in the codepath to sign with an ssh key.

* as/ssh-signing-improve-key-missing-error:
  ssh signing: better error message when key not in agent

2 years agoMerge branch 'jc/attr-doc-fix'
Junio C Hamano [Sat, 4 Feb 2023 00:08:21 +0000 (16:08 -0800)] 
Merge branch 'jc/attr-doc-fix'

Comment fix.

* jc/attr-doc-fix:
  attr: fix instructions on how to check attrs

2 years agoThe twelfth batch
Junio C Hamano [Mon, 30 Jan 2023 22:24:32 +0000 (14:24 -0800)] 
The twelfth batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agoMerge branch 'ar/markup-em-dash'
Junio C Hamano [Mon, 30 Jan 2023 22:24:24 +0000 (14:24 -0800)] 
Merge branch 'ar/markup-em-dash'

Doc mark-up updates.

* ar/markup-em-dash:
  Documentation: render dash correctly

2 years agoMerge branch 'tb/t0003-invoke-dd-more-portably'
Junio C Hamano [Mon, 30 Jan 2023 22:24:23 +0000 (14:24 -0800)] 
Merge branch 'tb/t0003-invoke-dd-more-portably'

Test portability fix.

* tb/t0003-invoke-dd-more-portably:
  t0003: call dd with portable blocksize

2 years agoMerge branch 'jk/hash-object-fsck'
Junio C Hamano [Mon, 30 Jan 2023 22:24:22 +0000 (14:24 -0800)] 
Merge branch 'jk/hash-object-fsck'

"git hash-object" now checks that the resulting object is well
formed with the same code as "git fsck".

* jk/hash-object-fsck:
  fsck: do not assume NUL-termination of buffers
  hash-object: use fsck for object checks
  fsck: provide a function to fsck buffer without object struct
  t: use hash-object --literally when created malformed objects
  t7030: stop using invalid tag name
  t1006: stop using 0-padded timestamps
  t1007: modernize malformed object tests

2 years agoMerge branch 'po/pretty-format-columns-doc'
Junio C Hamano [Mon, 30 Jan 2023 22:24:22 +0000 (14:24 -0800)] 
Merge branch 'po/pretty-format-columns-doc'

Clarify column-padding operators in the pretty format string.

* po/pretty-format-columns-doc:
  doc: pretty-formats note wide char limitations, and add tests
  doc: pretty-formats describe use of ellipsis in truncation
  doc: pretty-formats document negative column alignments
  doc: pretty-formats: delineate `%<|(` parameter values
  doc: pretty-formats: separate parameters from placeholders

2 years agoMerge branch 'jc/doc-checkout-b'
Junio C Hamano [Mon, 30 Jan 2023 22:24:21 +0000 (14:24 -0800)] 
Merge branch 'jc/doc-checkout-b'

Clarify how "checkout -b/-B" and "git branch [-f]" are similar but
different in the documentation.

* jc/doc-checkout-b:
  checkout: document -b/-B to highlight the differences from "git branch"

2 years agoDocumentation: clarify that cache forgets credentials if the system restarts
M Hickford [Sat, 28 Jan 2023 20:13:34 +0000 (20:13 +0000)] 
Documentation: clarify that cache forgets credentials if the system restarts

Signed-off-by: M Hickford <mirth.hickford@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agoscalar: only warn when background maintenance fails
Derrick Stolee [Fri, 27 Jan 2023 20:06:03 +0000 (20:06 +0000)] 
scalar: only warn when background maintenance fails

A user reported issues with 'scalar clone' and 'scalar register' when
working in an environment that had locked down the ability to run
'crontab' or 'systemctl' in that those commands registered as _failures_
instead of opportunistically reporting a success with just a warning
about background maintenance.

As a workaround, they can use GIT_TEST_MAINT_SCHEDULER to fake a
successful background maintenance, but this is not a viable strategy for
long-term.

Update 'scalar register' and 'scalar clone' to no longer fail by
modifying register_dir() to only warn when toggle_maintenance(1) fails.

Since background maintenance is a "nice to have" and not a requirement
for a working repository, it is best to move this from hard error to
gentle warning.

Signed-off-by: Derrick Stolee <derrickstolee@github.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agot921*: test scalar behavior starting maintenance
Derrick Stolee [Fri, 27 Jan 2023 20:06:02 +0000 (20:06 +0000)] 
t921*: test scalar behavior starting maintenance

A user recently reported issues with 'scalar register' and 'scalar
clone' in that they failed when the system had permissions locked down
so both 'crontab' and 'systemctl' commands failed when trying to enable
background maintenance.

This hard error is undesirable, but let's create tests that demonstrate
this behavior before modiying the behavior. We can use
GIT_TEST_MAINT_SCHEDULER to guarantee failure and check the exit code
and error message.

Signed-off-by: Derrick Stolee <derrickstolee@github.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agot: allow 'scalar' in test_must_fail
Derrick Stolee [Fri, 27 Jan 2023 20:06:01 +0000 (20:06 +0000)] 
t: allow 'scalar' in test_must_fail

This will enable scalar tests to use the test_must_fail helper, when
necessary.

Signed-off-by: Derrick Stolee <derrickstolee@github.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agoThe eleventh batch
Junio C Hamano [Fri, 27 Jan 2023 16:51:41 +0000 (08:51 -0800)] 
The eleventh batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agoMerge branch 'cw/fetch-remote-group-with-duplication'
Junio C Hamano [Fri, 27 Jan 2023 16:51:41 +0000 (08:51 -0800)] 
Merge branch 'cw/fetch-remote-group-with-duplication'

"git fetch <group>", when "<group>" of remotes lists the same
remote twice, unnecessarily failed when parallel fetching was
enabled, which has been corrected.

* cw/fetch-remote-group-with-duplication:
  fetch: fix duplicate remote parallel fetch bug

2 years agoMerge branch 'jc/doc-branch-update-checked-out-branch'
Junio C Hamano [Fri, 27 Jan 2023 16:51:41 +0000 (08:51 -0800)] 
Merge branch 'jc/doc-branch-update-checked-out-branch'

Document that "branch -f <branch>" disables only the safety to
avoid recreating an existing branch.

* jc/doc-branch-update-checked-out-branch:
  branch: document `-f` and linked worktree behaviour

2 years agoMerge branch 'jk/hash-object-literally-fd-leak'
Junio C Hamano [Fri, 27 Jan 2023 16:51:41 +0000 (08:51 -0800)] 
Merge branch 'jk/hash-object-literally-fd-leak'

Leakfix.

* jk/hash-object-literally-fd-leak:
  hash-object: fix descriptor leak with --literally

2 years agoMerge branch 'pb/branch-advice-recurse-submodules'
Junio C Hamano [Fri, 27 Jan 2023 16:51:40 +0000 (08:51 -0800)] 
Merge branch 'pb/branch-advice-recurse-submodules'

Improve advice message given when "git branch --recurse-submodules"
fails.

* pb/branch-advice-recurse-submodules:
  branch: improve advice when --recurse-submodules fails

2 years agoMerge branch 'km/send-email-with-v-reroll-count'
Junio C Hamano [Fri, 27 Jan 2023 16:51:40 +0000 (08:51 -0800)] 
Merge branch 'km/send-email-with-v-reroll-count'

"git send-email -v 3" used to be expanded to "git send-email
--validate 3" when the user meant to pass them down to
"format-patch", which has been corrected.

* km/send-email-with-v-reroll-count:
  send-email: relay '-v N' to format-patch

2 years agoMerge branch 'cb/grep-pcre-ucp'
Junio C Hamano [Fri, 27 Jan 2023 16:51:40 +0000 (08:51 -0800)] 
Merge branch 'cb/grep-pcre-ucp'

"grep -P" learned to use Unicode Character Property to grok
character classes when processing \b and \w etc.

* cb/grep-pcre-ucp:
  grep: correctly identify utf-8 characters with \{b,w} in -P

2 years agoMerge branch 'sa/cat-file-mailmap--batch-check'
Junio C Hamano [Fri, 27 Jan 2023 16:51:40 +0000 (08:51 -0800)] 
Merge branch 'sa/cat-file-mailmap--batch-check'

Docfix.

* sa/cat-file-mailmap--batch-check:
  git-cat-file.txt: fix list continuations rendering literally

2 years agoMerge branch 'ab/cache-api-cleanup-users'
Junio C Hamano [Fri, 27 Jan 2023 16:51:38 +0000 (08:51 -0800)] 
Merge branch 'ab/cache-api-cleanup-users'

Updates the users of the cache API.

* ab/cache-api-cleanup-users:
  treewide: always have a valid "index_state.repo" member

2 years agoattr: fix instructions on how to check attrs
John Cai [Thu, 26 Jan 2023 21:21:47 +0000 (21:21 +0000)] 
attr: fix instructions on how to check attrs

The instructions in attr.h describing what functions to call to check
attributes is missing the index as the first argument to
git_check_attr(), as well as tree_oid as the second argument.

When 7a400a2c (attr: remove an implicit dependency on the_index,
2018-08-13) started passing an index_state instance to git_check_attr(),
it forgot to update the API documentation in
Documentation/technical/api-gitattributes.txt. Later, 3a1b3415
(attr: move doc to attr.h, 2019-11-17) moved the API documentation to
attr.h as a comment, but still left out the index_state as an argument.

In 47cfc9b (attr: add flag `--source` to work with tree-ish 2023-01-14)
added tree_oid as an optional parameter but was not added to the docs in
attr.h

Fix this to make the documentation in the comment consistent with the
actual function signature.

Signed-off-by: John Cai <johncai86@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agorequest-pull: filter out SSH/X.509 tag signatures
Gwyneth Morgan [Wed, 25 Jan 2023 23:47:27 +0000 (23:47 +0000)] 
request-pull: filter out SSH/X.509 tag signatures

git request-pull filters PGP signatures out of the tag message, but not
SSH or X.509 signatures.

Signed-off-by: Gwyneth Morgan <gwymor@tilde.club>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agorebase: provide better error message for apply options vs. merge config
Elijah Newren [Wed, 25 Jan 2023 04:03:54 +0000 (04:03 +0000)] 
rebase: provide better error message for apply options vs. merge config

When config which selects the merge backend (currently,
rebase.autosquash=true or rebase.updateRefs=true) conflicts with other
options on the command line (such as --whitespace=fix), make the error
message specifically call out the config option and specify how to
override that config option on the command line.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agorebase: put rebase_options initialization in single place
Elijah Newren [Wed, 25 Jan 2023 04:03:53 +0000 (04:03 +0000)] 
rebase: put rebase_options initialization in single place

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agorebase: fix formatting of rebase --reapply-cherry-picks option in docs
Elijah Newren [Wed, 25 Jan 2023 04:03:52 +0000 (04:03 +0000)] 
rebase: fix formatting of rebase --reapply-cherry-picks option in docs

Commit ce5238a690 ("rebase --keep-base: imply --reapply-cherry-picks",
2022-10-17) accidentally added some blank lines that cause extra
paragraphs about --reapply-cherry-picks to be considered not part of
the documentation of that option.  Remove the blank lines to make it
clear we are still discussing --reapply-cherry-picks.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agorebase: clarify the OPT_CMDMODE incompatibilities
Elijah Newren [Wed, 25 Jan 2023 04:03:51 +0000 (04:03 +0000)] 
rebase: clarify the OPT_CMDMODE incompatibilities

--edit-todo was documented as being incompatible with any of the options
for the apply backend.  However, it is also incompatible with any of the
options for the merge backend, and is incompatible with any options that
are not backend specific as well.  The same can be said for --continue,
--skip, --abort, --quit, etc.

This is already somewhat implicitly covered by the synopsis, but since
"[<options>]" in the first two variants are vague it might be easy to
miss this.  That might not be a big deal, but since the rebase manpage
has to spend so much verbiage about incompatibility of options, making
a separate section for these options that are incompatible with
everything else seems clearer.  Do that, and remove the needless
inclusion of --edit-todo in the explicit incompatibility list.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agorebase: add coverage of other incompatible options
Elijah Newren [Wed, 25 Jan 2023 04:03:50 +0000 (04:03 +0000)] 
rebase: add coverage of other incompatible options

The git-rebase manual noted several sets of incompatible options, but
we were missing tests for a few of these.  Further, we were missing
code checks for one of these, which could result in command line
options being silently ignored.

Also, note that adding a check for autosquash means that using
--whitespace=fix together with the config setting rebase.autosquash=true
will trigger an error.  A subsequent commit will improve the error
message.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agorebase: fix incompatiblity checks for --[no-]reapply-cherry-picks
Elijah Newren [Wed, 25 Jan 2023 04:03:49 +0000 (04:03 +0000)] 
rebase: fix incompatiblity checks for --[no-]reapply-cherry-picks

--[no-]reapply-cherry-picks was traditionally only supported by the
sequencer.  Support was added for the apply backend, when --keep-base is
also specified, in commit ce5238a690 ("rebase --keep-base: imply
--reapply-cherry-picks", 2022-10-17).  Make the code error out when
--[no-]reapply-cherry-picks is specified AND the apply backend is used
AND --keep-base is not specified.  Also, clarify a number of comments
surrounding the interaction of these flags.

Helped-by: Phillip Wood <phillip.wood@dunelm.org.uk>
Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agorebase: fix docs about incompatibilities with --root
Elijah Newren [Wed, 25 Jan 2023 04:03:48 +0000 (04:03 +0000)] 
rebase: fix docs about incompatibilities with --root

In commit 5dacd4abdd ("git-rebase.txt: document incompatible options",
2018-06-25), I added notes about incompatibilities between options for
the apply and merge backends.  Unfortunately, I inverted the condition
when --root was incompatible with the apply backend.  Fix the
documentation, and add a testcase that verifies the documentation
matches the code.

While at it, the documentation for --root also tried to cover some of
the backend differences between the apply and merge backends in relation
to reapplying cherry picks.  The information:
  * assumed that the apply backend was the default (it isn't anymore)
  * was written before --reapply-cherry-picks became an option
  * was written before the detailed information on backend differences
All of these factors make the sentence under --root about reapplying
cherry picks contradict information that is now available elsewhere in
the manual, and the other references are correct.  So just strike this
sentence.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agorebase: remove --allow-empty-message from incompatible opts
Elijah Newren [Wed, 25 Jan 2023 04:03:47 +0000 (04:03 +0000)] 
rebase: remove --allow-empty-message from incompatible opts

--allow-empty-message was turned into a no-op and even documented
as such; the flag is simply ignored.  Since the flag is ignored, it
shouldn't be documented as being incompatible with other flags.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agorebase: flag --apply and --merge as incompatible
Elijah Newren [Wed, 25 Jan 2023 04:03:46 +0000 (04:03 +0000)] 
rebase: flag --apply and --merge as incompatible

Previously, we flagged options which implied --apply as being
incompatible with options which implied --merge.  But if both options
were given explicitly, then we didn't flag the incompatibility.  The
same is true with --apply and --interactive.  Add the check, and add
some testcases to verify these are also caught.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agorebase: mark --update-refs as requiring the merge backend
Elijah Newren [Wed, 25 Jan 2023 04:03:45 +0000 (04:03 +0000)] 
rebase: mark --update-refs as requiring the merge backend

--update-refs is built in terms of the sequencer, which requires the
merge backend.  It was already marked as incompatible with the apply
backend in the git-rebase manual, but the code didn't check for this
incompatibility and warn the user.  Check and error now.

While at it, fix a typo in t3422...and fix some misleading wording
(most options which used to be am-specific have since been implemented
in the merge backend as well).

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agossh signing: better error message when key not in agent
Adam Szkoda [Wed, 25 Jan 2023 12:40:50 +0000 (12:40 +0000)] 
ssh signing: better error message when key not in agent

When signing a commit with a SSH key, with the private key missing from
ssh-agent, a confusing error message is produced:

    error: Load key
    "/var/folders/t5/cscwwl_n3n1_8_5j_00x_3t40000gn/T//.git_signing_key_tmpkArSj7":
    invalid format? fatal: failed to write commit object

The temporary file .git_signing_key_tmpkArSj7 created by git contains a
valid *public* key.  The error message comes from `ssh-keygen -Y sign' and
is caused by a fallback mechanism in ssh-keygen whereby it tries to
interpret .git_signing_key_tmpkArSj7 as a *private* key if it can't find in
the agent [1].  A fix is scheduled to be released in OpenSSH 9.1. All that
needs to be done is to pass an additional backward-compatible option -U to
'ssh-keygen -Y sign' call.  With '-U', ssh-keygen always interprets the file
as public key and expects to find the private key in the agent.

As a result, when the private key is missing from the agent, a more accurate
error message gets produced:

    error: Couldn't find key in agent

[1] https://bugzilla.mindrot.org/show_bug.cgi?id=3429

Signed-off-by: Adam Szkoda <adaszko@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agoThe tenth batch
Junio C Hamano [Mon, 23 Jan 2023 21:39:26 +0000 (13:39 -0800)] 
The tenth batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agoMerge branch 'zh/scalar-progress'
Junio C Hamano [Mon, 23 Jan 2023 21:39:52 +0000 (13:39 -0800)] 
Merge branch 'zh/scalar-progress'

"scalar" learned to give progress bar.

* zh/scalar-progress:
  scalar: show progress if stderr refers to a terminal

2 years agoMerge branch 'ds/omit-trailing-hash-in-index'
Junio C Hamano [Mon, 23 Jan 2023 21:39:52 +0000 (13:39 -0800)] 
Merge branch 'ds/omit-trailing-hash-in-index'

Quickfix for a topic already in 'master'.

* ds/omit-trailing-hash-in-index:
  t1600: fix racy index.skipHash test

2 years agoMerge branch 'jc/format-patch-v-unleak'
Junio C Hamano [Mon, 23 Jan 2023 21:39:52 +0000 (13:39 -0800)] 
Merge branch 'jc/format-patch-v-unleak'

Plug a small leak.

* jc/format-patch-v-unleak:
  format-patch: unleak "-v <num>"

2 years agoMerge branch 'sk/win32-close-handle-upon-pthread-join'
Junio C Hamano [Mon, 23 Jan 2023 21:39:51 +0000 (13:39 -0800)] 
Merge branch 'sk/win32-close-handle-upon-pthread-join'

Pthread emulation on Win32 leaked thread handle when a thread is
joined.

* sk/win32-close-handle-upon-pthread-join:
  win32: close handles of threads that have been joined
  win32: prepare pthread.c for change by formatting

2 years agoMerge branch 'rs/use-enhanced-bre-on-macos'
Junio C Hamano [Mon, 23 Jan 2023 21:39:51 +0000 (13:39 -0800)] 
Merge branch 'rs/use-enhanced-bre-on-macos'

Newer regex library macOS stopped enabling GNU-like enhanced BRE,
where '\(A\|B\)' works as alternation, unless explicitly asked with
the REG_ENHANCED flag.  "git grep" now can be compiled to do so, to
retain the old behaviour.

* rs/use-enhanced-bre-on-macos:
  use enhanced basic regular expressions on macOS

2 years agoMerge branch 'ab/test-env-helper'
Junio C Hamano [Mon, 23 Jan 2023 21:39:51 +0000 (13:39 -0800)] 
Merge branch 'ab/test-env-helper'

Remove "git env--helper" and demote it to a test-tool subcommand.

* ab/test-env-helper:
  env-helper: move this built-in to "test-tool env-helper"

2 years agoMerge branch 'kn/attr-from-tree'
Junio C Hamano [Mon, 23 Jan 2023 21:39:50 +0000 (13:39 -0800)] 
Merge branch 'kn/attr-from-tree'

"git check-attr" learned to take an optional tree-ish to read the
.gitattributes file from.

* kn/attr-from-tree:
  attr: add flag `--source` to work with tree-ish
  t0003: move setup for `--all` into new block

2 years agoMerge branch 'rs/ls-tree-path-expansion-fix'
Junio C Hamano [Mon, 23 Jan 2023 21:39:50 +0000 (13:39 -0800)] 
Merge branch 'rs/ls-tree-path-expansion-fix'

"git ls-tree --format='%(path) %(path)' $tree $path" showed the
path three times, which has been corrected.

* rs/ls-tree-path-expansion-fix:
  ls-tree: remove dead store and strbuf for quote_c_style()
  ls-tree: fix expansion of repeated %(path)

2 years agoMerge branch 'en/t6426-todo-cleanup'
Junio C Hamano [Mon, 23 Jan 2023 21:39:49 +0000 (13:39 -0800)] 
Merge branch 'en/t6426-todo-cleanup'

Test clean-up.

* en/t6426-todo-cleanup:
  t6426: fix TODO about making test more comprehensive

2 years agoMerge branch 'ab/cache-api-cleanup'
Junio C Hamano [Mon, 23 Jan 2023 21:39:49 +0000 (13:39 -0800)] 
Merge branch 'ab/cache-api-cleanup'

Code clean-up to tighten the use of in-core index in the API.

* ab/cache-api-cleanup:
  cache API: add a "INDEX_STATE_INIT" macro/function, add release_index()
  read-cache.c: refactor set_new_index_sparsity() for subsequent commit
  sparse-index API: BUG() out on NULL ensure_full_index()
  sparse-index.c: expand_to_path() can assume non-NULL "istate"
  builtin/difftool.c: { 0 }-initialize rather than using memset()

2 years agoDocumentation: render dash correctly
Andrei Rybak [Mon, 23 Jan 2023 09:01:14 +0000 (10:01 +0100)] 
Documentation: render dash correctly

Three hyphens are rendered verbatim in documentation, so "--" has to be
used to produce a dash.  Fix asciidoc output for dashes.  This is
similar to previous commits f0b922473e (Documentation: render special
characters correctly, 2021-07-29) and de82095a95 (doc
hash-function-transition: fix asciidoc output, 2021-02-05).

Signed-off-by: Andrei Rybak <rybak.a.v@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agot0003: call dd with portable blocksize
Torsten Bögershausen [Sun, 22 Jan 2023 06:28:39 +0000 (07:28 +0100)] 
t0003: call dd with portable blocksize

The command `dd bs=101M count=1` is not portable,
e.g. dd shipped with MacOs does not understand the 'M'.

Use `dd bs=1048576 count=101`, which achives the same, instead.

Signed-off-by: Torsten Bögershausen <tboegi@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agoThe ninth batch
Junio C Hamano [Sun, 22 Jan 2023 00:35:14 +0000 (16:35 -0800)] 
The ninth batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agoMerge branch 'yc/doc-fetch-fix'
Junio C Hamano [Sun, 22 Jan 2023 01:22:01 +0000 (17:22 -0800)] 
Merge branch 'yc/doc-fetch-fix'

Doc fix.

* yc/doc-fetch-fix:
  doc: fix non-existent config name

2 years agoMerge branch 'ab/bisect-cleanup'
Junio C Hamano [Sun, 22 Jan 2023 01:22:00 +0000 (17:22 -0800)] 
Merge branch 'ab/bisect-cleanup'

Code clean-up.

* ab/bisect-cleanup:
  bisect: no longer try to clean up left-over `.git/head-name` files
  bisect: remove Cogito-related code
  bisect run: fix the error message
  bisect: verify that a bogus option won't try to start a bisection
  bisect--helper: make the order consistently `argc, argv`
  bisect--helper: simplify exit code computation

2 years agoMerge branch 'tl/ls-tree-code-clean-up'
Junio C Hamano [Sun, 22 Jan 2023 01:22:00 +0000 (17:22 -0800)] 
Merge branch 'tl/ls-tree-code-clean-up'

Code clean-up.

* tl/ls-tree-code-clean-up:
  t3104: remove shift code in 'test_ls_tree_format'
  ls-tree: cleanup the redundant SPACE
  ls-tree: make "line_termination" less generic
  ls-tree: fold "show_tree_data" into "cb" struct
  ls-tree: use a "struct options"
  ls-tree: don't use "show_tree_data" for "fast" callbacks

2 years agoMerge branch 'ph/parse-date-reduced-precision'
Junio C Hamano [Sun, 22 Jan 2023 01:22:00 +0000 (17:22 -0800)] 
Merge branch 'ph/parse-date-reduced-precision'

Loosen date parsing heuristics.

* ph/parse-date-reduced-precision:
  date.c: allow ISO 8601 reduced precision times

2 years agoMerge branch 'pw/rebase-exec-cleanup'
Junio C Hamano [Sun, 22 Jan 2023 01:22:00 +0000 (17:22 -0800)] 
Merge branch 'pw/rebase-exec-cleanup'

Code clean-up.

* pw/rebase-exec-cleanup:
  rebase: cleanup "--exec" option handling

2 years agoMerge branch 'pb/doc-orig-head'
Junio C Hamano [Sun, 22 Jan 2023 01:22:00 +0000 (17:22 -0800)] 
Merge branch 'pb/doc-orig-head'

Document ORIG_HEAD a bit more.

* pb/doc-orig-head:
  git-rebase.txt: add a note about 'ORIG_HEAD' being overwritten
  revisions.txt: be explicit about commands writing 'ORIG_HEAD'
  git-merge.txt: mention 'ORIG_HEAD' in the Description
  git-reset.txt: mention 'ORIG_HEAD' in the Description
  git-cherry-pick.txt: do not use 'ORIG_HEAD' in example

2 years agoMerge branch 'yo/doc-use-more-switch-c'
Junio C Hamano [Sun, 22 Jan 2023 01:21:59 +0000 (17:21 -0800)] 
Merge branch 'yo/doc-use-more-switch-c'

Doc update.

* yo/doc-use-more-switch-c:
  doc: add "git switch -c" as another option on detached HEAD

2 years agoMerge branch 'sk/merge-filtering-strategies-micro-optim'
Junio C Hamano [Sun, 22 Jan 2023 01:21:59 +0000 (17:21 -0800)] 
Merge branch 'sk/merge-filtering-strategies-micro-optim'

Micro optimization.

* sk/merge-filtering-strategies-micro-optim:
  merge: break out of all_strategy loop when strategy is found

2 years agoMerge branch 'jk/interop-error'
Junio C Hamano [Sun, 22 Jan 2023 01:21:59 +0000 (17:21 -0800)] 
Merge branch 'jk/interop-error'

Test helper improvement.

* jk/interop-error:
  t/interop: report which vanilla git command failed

2 years agoMerge branch 'ar/bisect-doc-update'
Junio C Hamano [Sun, 22 Jan 2023 01:21:59 +0000 (17:21 -0800)] 
Merge branch 'ar/bisect-doc-update'

Doc update.

* ar/bisect-doc-update:
  git-bisect-lk2009: update nist report link
  git-bisect-lk2009: update java code conventions link

2 years agoMerge branch 'ar/test-cleanup'
Junio C Hamano [Sun, 22 Jan 2023 01:21:59 +0000 (17:21 -0800)] 
Merge branch 'ar/test-cleanup'

Test clean-up.

* ar/test-cleanup:
  t7527: use test_when_finished in 'case insensitive+preserving'
  t6422: drop commented out code
  t6003: uncomment test '--max-age=c3, --topo-order'

2 years agoMerge branch 'jc/doc-diff-patch.txt'
Junio C Hamano [Sun, 22 Jan 2023 01:21:58 +0000 (17:21 -0800)] 
Merge branch 'jc/doc-diff-patch.txt'

Doc update.

* jc/doc-diff-patch.txt:
  docs: link generating patch sections

2 years agoMerge branch 'es/hooks-and-local-env'
Junio C Hamano [Sun, 22 Jan 2023 01:21:58 +0000 (17:21 -0800)] 
Merge branch 'es/hooks-and-local-env'

Doc update for environment variables set when hooks are invoked.

* es/hooks-and-local-env:
  githooks: discuss Git operations in foreign repositories

2 years agoMerge branch 'rs/dup-array'
Junio C Hamano [Sun, 22 Jan 2023 01:21:58 +0000 (17:21 -0800)] 
Merge branch 'rs/dup-array'

Code cleaning.

* rs/dup-array:
  use DUP_ARRAY
  add DUP_ARRAY
  do full type check in BARF_UNLESS_COPYABLE
  factor out BARF_UNLESS_COPYABLE
  mingw: make argv2 in try_shell_exec() non-const

2 years agoMerge branch 'jx/t1301-updates'
Junio C Hamano [Sun, 22 Jan 2023 01:21:58 +0000 (17:21 -0800)] 
Merge branch 'jx/t1301-updates'

Test updates.

* jx/t1301-updates:
  t1301: do not change $CWD in "shared=all" test case
  t1301: use test_when_finished for cleanup
  t1301: fix wrong template dir for git-init

2 years agoThe eighth batch
Junio C Hamano [Fri, 20 Jan 2023 21:48:44 +0000 (13:48 -0800)] 
The eighth batch

The cURL one hasn't cooked for a week in 'next', but let's fast
track it so that linux-musl CI job would be happy.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agoMerge branch 'jk/read-object-cleanup'
Junio C Hamano [Fri, 20 Jan 2023 23:36:21 +0000 (15:36 -0800)] 
Merge branch 'jk/read-object-cleanup'

Code clean-up.

* jk/read-object-cleanup:
  object-file: fix indent-with-space
  packfile: inline custom read_object()
  repo_read_object_file(): stop wrapping read_object_file_extended()
  read_object_file_extended(): drop lookup_replace option
  streaming: inline call to read_object_file_extended()
  object-file: inline calls to read_object()

2 years agoMerge branch 'jk/curl-avoid-deprecated-api'
Junio C Hamano [Fri, 20 Jan 2023 23:36:21 +0000 (15:36 -0800)] 
Merge branch 'jk/curl-avoid-deprecated-api'

Deal with a few deprecation warning from cURL library.

* jk/curl-avoid-deprecated-api:
  http: support CURLOPT_PROTOCOLS_STR
  http: prefer CURLOPT_SEEKFUNCTION to CURLOPT_IOCTLFUNCTION
  http-push: prefer CURLOPT_UPLOAD to CURLOPT_PUT

2 years agofsck: do not assume NUL-termination of buffers
Jeff King [Thu, 19 Jan 2023 23:13:29 +0000 (18:13 -0500)] 
fsck: do not assume NUL-termination of buffers

The fsck code operates on an object buffer represented as a pointer/len
combination. However, the parsing of commits and tags is a little bit
loose; we mostly scan left-to-right through the buffer, without checking
whether we've gone past the length we were given.

This has traditionally been OK because the buffers we feed to fsck
always have an extra NUL after the end of the object content, which ends
any left-to-right scan. That has always been true for objects we read
from the odb, and we made it true for incoming index-pack/unpack-objects
checks in a1e920a0a7 (index-pack: terminate object buffers with NUL,
2014-12-08).

However, we recently added an exception: hash-object asks index_fd() to
do fsck checks. That _may_ have an extra NUL (if we read from a pipe
into a strbuf), but it might not (if we read the contents from the
file). Nor can we just teach it to always add a NUL. We may mmap the
on-disk file, which will not have any extra bytes (if it's a multiple of
the page size). Not to mention that this is a rather subtle assumption
for the fsck code to make.

Instead, let's make sure that the fsck parsers don't ever look past the
size of the buffer they've been given. This _almost_ works already,
thanks to earlier work in 4d0d89755e (Make sure fsck_commit_buffer()
does not run out of the buffer, 2014-09-11). The theory there is that we
check up front whether we have the end of header double-newline
separator. And then any left-to-right scanning we do is OK as long as it
stops when it hits that boundary.

However, we later softened that in 84d18c0bcf (fsck: it is OK for a tag
and a commit to lack the body, 2015-06-28), which allows the
double-newline header to be missing, but does require that the header
ends in a newline. That was OK back then, because of the NUL-termination
guarantees (including the one from a1e920a0a7 mentioned above).

Because 84d18c0bcf guarantees that any header line does end in a
newline, we are still OK with most of the left-to-right scanning. We
only need to take care after completing a line, to check that there is
another line (and we didn't run out of buffer).

Most of these checks are just need to check "buffer < buffer_end" (where
buffer is advanced as we parse) before scanning for the next header
line. But here are a few notes:

  - we don't technically need to check for remaining buffer before
    parsing the very first line ("tree" for a commit, or "object" for a
    tag), because verify_headers() rejects a totally empty buffer. But
    we'll do so in the name of consistency and defensiveness.

  - there are some calls to strchr('\n'). These are actually OK by the
    "the final header line must end in a newline" guarantee from
    verify_headers(). They will always find that rather than run off the
    end of the buffer. Curiously, they do check for a NULL return and
    complain, but I believe that condition can never be reached.

    However, I converted them to use memchr() with a proper size and
    retained the NULL checks. Using memchr() is not much longer and
    makes it more obvious what is going on. Likewise, retaining the NULL
    checks serves as a defensive measure in case my analysis is wrong.

  - commit 9a1a3a4d4c (mktag: allow omitting the header/body \n
    separator, 2021-01-05), does check for the end-of-buffer condition,
    but does so with "!*buffer", relying explicitly on the NUL
    termination. We can accomplish the same thing with a pointer
    comparison. I also folded it into the follow-on conditional that
    checks the contents of the buffer, for consistency with the other
    checks.

  - fsck_ident() uses parse_timestamp(), which is based on strtoumax().
    That function will happily skip past leading whitespace, including
    newlines, which makes it a risk. We can fix this by scanning to the
    first digit ourselves, and then using parse_timestamp() to do the
    actual numeric conversion.

    Note that as a side effect this fixes the fact that we missed
    zero-padded timestamps like "<email>   0123" (whereas we would
    complain about "<email> 0123"). I doubt anybody cares, but I
    mention it here for completeness.

  - fsck_tree() does not need any modifications. It relies on
    decode_tree_entry() to do the actual parsing, and that function
    checks both that there are enough bytes in the buffer to represent
    an entry, and that there is a NUL at the appropriate spot (one
    hash-length from the end; this may not be the NUL for the entry we
    are parsing, but we know that in the worst case, everything from our
    current position to that NUL is a filename, so we won't run out of
    bytes).

In addition to fixing the code itself, we'd like to make sure our rather
subtle assumptions are not violated in the future. So this patch does
two more things:

  - add comments around verify_headers() documenting the link between
    what it checks and the memory safety of the callers. I don't expect
    this code to be modified frequently, but this may help somebody from
    accidentally breaking things.

  - add a thorough set of tests covering truncations at various key
    spots (e.g., for a "tree $oid" line, in the middle of the word
    "tree", right after it, after the space, in the middle of the $oid,
    and right at the end of the line. Most of these are fine already (it
    is only truncating right at the end of the line that is currently
    broken). And some of them are not even possible with the current
    code (we parse "tree " as a unit, so truncating before the space is
    equivalent). But I aimed here to consider the code a black box and
    look for any truncations that would be a problem for a left-to-right
    parser.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agofetch: fix duplicate remote parallel fetch bug
Calvin Wan [Thu, 19 Jan 2023 22:05:38 +0000 (22:05 +0000)] 
fetch: fix duplicate remote parallel fetch bug

Fetching in parallel from a remote group with a duplicated remote results
in the following:

error: cannot lock ref '<ref>': is at <oid> but expected <oid>

This doesn't happen in serial since fetching from the same remote that
has already been fetched from is a noop. Therefore, remove any duplicated
remotes after remote groups are parsed.

Signed-off-by: Calvin Wan <calvinwan@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agodoc: pretty-formats note wide char limitations, and add tests
Philip Oakley [Thu, 19 Jan 2023 18:18:27 +0000 (18:18 +0000)] 
doc: pretty-formats note wide char limitations, and add tests

The previous commits added clarifications to the column alignment
placeholders, note that the spaces are optional around the parameters.

Also, a proposed extension [1] to allow hard truncation (without
ellipsis '..') highlighted that the existing code does not play well
with wide characters, such as Asian fonts and emojis.

For example, N wide characters take 2N columns so won't fit an odd number
column width, causing misalignment somewhere.

Further analysis also showed that decomposed characters, e.g. separate
`a` + `umlaut` Unicode code-points may also be mis-counted, in some cases
leaving multiple loose `umlauts` all combined together.

Add some notes about these limitations, and add basic tests to demonstrate
them.

The chosen solution for the tests is to substitute any wide character
that overlaps a splitting boundary for the unicode vertical ellipsis
code point as a rare but 'obvious' substitution.

An alternative could be the substitution with a single dot '.' which
matches regular expression usage, and our two dot ellipsis, and further
in scenarios where the bulk of the text is wide characters, would be
obvious. In mainly 'ascii' scenarios a singleton emoji being substituted
by a dot could be confusing.

It is enough that the tests fail cleanly. The final choice for the
substitute character can be deferred.

[1]
https://lore.kernel.org/git/20221030185614.3842-1-philipoakley@iee.email/

Signed-off-by: Philip Oakley <philipoakley@iee.email>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agodoc: pretty-formats describe use of ellipsis in truncation
Philip Oakley [Thu, 19 Jan 2023 18:18:26 +0000 (18:18 +0000)] 
doc: pretty-formats describe use of ellipsis in truncation

Commit a7f01c6b4d (pretty: support truncating in %>, %< and %><,
2013-04-19) added the use of ellipsis when truncating placeholder
values.

Show our 'two dot' ellipsis, and examples for the left, middle and
right truncation to avoid any confusion as to which end of the string
is adjusted. (cf justification and sub-string).

Signed-off-by: Philip Oakley <philipoakley@iee.email>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agodoc: pretty-formats document negative column alignments
Philip Oakley [Thu, 19 Jan 2023 18:18:25 +0000 (18:18 +0000)] 
doc: pretty-formats document negative column alignments

Commit 066790d7cb0 (pretty.c: support <direction>|(<negative number>) forms,
2016-06-16) added the option for right justified column alignment without
updating the documentation.

Add an explanation of its use of negative column values.

Signed-off-by: Philip Oakley <philipoakley@iee.email>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agodoc: pretty-formats: delineate `%<|(` parameter values
Philip Oakley [Thu, 19 Jan 2023 18:18:24 +0000 (18:18 +0000)] 
doc: pretty-formats: delineate `%<|(` parameter values

Commit a57523428b4 (pretty: support padding placeholders, %< %> and %><,
2013-04-19) introduced column width place holders. It also added
separate column position `%<|(` placeholders for display screen based
placement.

Change the display screen parameter reference from 'N' to 'M' and
corresponding descriptives to make the distinction clearer.

Signed-off-by: Philip Oakley <philipoakley@iee.email>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agodoc: pretty-formats: separate parameters from placeholders
Philip Oakley [Thu, 19 Jan 2023 18:18:23 +0000 (18:18 +0000)] 
doc: pretty-formats: separate parameters from placeholders

Commit a57523428b4 (pretty: support padding placeholders, %< %> and %><,
2013-04-19) introduced columnated place holders. These placeholders
can be confusing as they contain `<` and `>` characters as part
of their placeholders adjacent to the `<N>` parameters.

Add spaces either side of the `<N>` parameters in the title line.
The code (strtol) will consume any spaces around the number values
(assuming they are passed as a quoted string with spaces).
Note that the spaces are optional.

Subsequent commits will clarify other confusions.

Signed-off-by: Philip Oakley <philipoakley@iee.email>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agoSync with 'maint'
Junio C Hamano [Thu, 19 Jan 2023 21:49:38 +0000 (13:49 -0800)] 
Sync with 'maint'

2 years agoSync with maint-2.38
Junio C Hamano [Thu, 19 Jan 2023 21:49:08 +0000 (13:49 -0800)] 
Sync with maint-2.38

* maint-2.38:
  attr: adjust a mismatched data type

2 years agoSync with maint-2.37
Junio C Hamano [Thu, 19 Jan 2023 21:48:26 +0000 (13:48 -0800)] 
Sync with maint-2.37

* maint-2.37:
  attr: adjust a mismatched data type

2 years agoSync with maint-2.36
Junio C Hamano [Thu, 19 Jan 2023 21:48:17 +0000 (13:48 -0800)] 
Sync with maint-2.36

* maint-2.36:
  attr: adjust a mismatched data type

2 years agoSync with maint-2.35
Junio C Hamano [Thu, 19 Jan 2023 21:48:08 +0000 (13:48 -0800)] 
Sync with maint-2.35

* maint-2.35:
  attr: adjust a mismatched data type

2 years agoSync with maint-2.34
Junio C Hamano [Thu, 19 Jan 2023 21:48:00 +0000 (13:48 -0800)] 
Sync with maint-2.34

* maint-2.34:
  attr: adjust a mismatched data type

2 years agoSync with maint-2.33
Junio C Hamano [Thu, 19 Jan 2023 21:47:42 +0000 (13:47 -0800)] 
Sync with maint-2.33

* maint-2.33:
  attr: adjust a mismatched data type

2 years agoSync with maint-2.32
Junio C Hamano [Thu, 19 Jan 2023 21:46:04 +0000 (13:46 -0800)] 
Sync with maint-2.32

* maint-2.32:
  attr: adjust a mismatched data type

2 years agoSync with maint-2.31
Junio C Hamano [Thu, 19 Jan 2023 21:45:37 +0000 (13:45 -0800)] 
Sync with maint-2.31

* maint-2.31:
  attr: adjust a mismatched data type

2 years agoSync with maint-2.30
Junio C Hamano [Thu, 19 Jan 2023 21:45:23 +0000 (13:45 -0800)] 
Sync with maint-2.30

* maint-2.30:
  attr: adjust a mismatched data type

2 years agoattr: adjust a mismatched data type
Johannes Schindelin [Thu, 12 Jan 2023 00:05:02 +0000 (01:05 +0100)] 
attr: adjust a mismatched data type

On platforms where `size_t` does not have the same width as `unsigned
long`, passing a pointer to the former when a pointer to the latter is
expected can lead to problems.

Windows and 32-bit Linux are among the affected platforms.

In this instance, we want to store the size of the blob that was read in
that variable. However, `read_blob_data_from_index()` passes that
pointer to `read_object_file()` which expects an `unsigned long *`.
Which means that on affected platforms, the variable is not fully
populated and part of its value is left uninitialized. (On Big-Endian
platforms, this problem would be even worse.)

The consequence is that depending on the uninitialized memory's
contents, we may erroneously reject perfectly fine attributes.

Let's address this by passing a pointer to a variable of the expected
data type.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agocheckout: document -b/-B to highlight the differences from "git branch"
Junio C Hamano [Thu, 19 Jan 2023 17:12:41 +0000 (09:12 -0800)] 
checkout: document -b/-B to highlight the differences from "git branch"

The existing text read as if "git checkout -b/-B name" were
equivalent to "git branch [-f] name", which clearly was not
what we wanted to say.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agohash-object: fix descriptor leak with --literally
Jeff King [Thu, 19 Jan 2023 01:57:56 +0000 (20:57 -0500)] 
hash-object: fix descriptor leak with --literally

In hash_object(), we open a descriptor for each file to hash (whether we
got the filename from the command line or --stdin-paths), but never
close it. For the traditional code path, which feeds the result to
index_fd(), this is OK; it closes the descriptor for us.

But 5ba9a93b39 (hash-object: add --literally option, 2014-09-11) added a
second code path, which does not close the descriptor. There we need to
do so ourselves.

You can see the problem in a clone of git.git like this:

  $ git ls-files -s | grep ^100644 | cut -f2 |
    git hash-object --stdin-paths --literally >/dev/null
  fatal: could not open 'builtin/var.c' for reading: Too many open files

After this patch, it completes successfully. I didn't bother with a
test, as it's a pain to deal with descriptor limits portably, and the
fix is so trivial.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agobranch: document `-f` and linked worktree behaviour
Junio C Hamano [Thu, 19 Jan 2023 07:23:46 +0000 (23:23 -0800)] 
branch: document `-f` and linked worktree behaviour

"git branch -f name start" forces to recreate the named branch, but
the forcing does not defeat the "do not touch a branch that is
checked out elsewhere" safety valve.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agogrep: correctly identify utf-8 characters with \{b,w} in -P
Carlo Marcelo Arenas Belón [Sun, 8 Jan 2023 15:52:17 +0000 (07:52 -0800)] 
grep: correctly identify utf-8 characters with \{b,w} in -P

When UTF is enabled for a PCRE match, the corresponding flags are
added to the pcre2_compile() call, but PCRE2_UCP wasn't included.

This prevents extending the meaning of the character classes to
include those new valid characters and therefore result in failed
matches for expressions that rely on that extention, for ex:

  $ git grep -P '\bÆvar'

Add PCRE2_UCP so that \w will include Æ and therefore \b could
correctly match the beginning of that word.

This has an impact on performance that has been estimated to be
between 20% to 40% and that is shown through the added performance
test.

Signed-off-by: Carlo Marcelo Arenas Belón <carenas@gmail.com>
Acked-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agobranch: improve advice when --recurse-submodules fails
Philippe Blain [Mon, 16 Jan 2023 17:41:48 +0000 (17:41 +0000)] 
branch: improve advice when --recurse-submodules fails

'git branch --recurse-submodules start from-here' fails if any submodule
present in 'from-here' is not yet cloned (under
submodule.propagateBranches=true). We then give this advice:

   "You may try updating the submodules using 'git checkout from-here && git submodule update --init'"

If 'submodule.recurse' is set, 'git checkout from-here' will also fail since
it will try to recursively checkout the submodules.

Improve the advice by adding '--no-recurse-submodules' to the checkout
command.

Signed-off-by: Philippe Blain <levraiphilippeblain@gmail.com>
Reviewed-by: Glen Choo <chooglen@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agohash-object: use fsck for object checks
Jeff King [Wed, 18 Jan 2023 20:44:12 +0000 (15:44 -0500)] 
hash-object: use fsck for object checks

Since c879daa237 (Make hash-object more robust against malformed
objects, 2011-02-05), we've done some rudimentary checks against objects
we're about to write by running them through our usual parsers for
trees, commits, and tags.

These parsers catch some problems, but they are not nearly as careful as
the fsck functions (which make sense; the parsers are designed to be
fast and forgiving, bailing only when the input is unintelligible). We
are better off doing the more thorough fsck checks when writing objects.
Doing so at write time is much better than writing garbage only to find
out later (after building more history atop it!) that fsck complains
about it, or hosts with transfer.fsckObjects reject it.

This is obviously going to be a user-visible behavior change, and the
test changes earlier in this series show the scope of the impact. But
I'd argue that this is OK:

  - the documentation for hash-object is already vague about which
    checks we might do, saying that --literally will allow "any
    garbage[...] which might not otherwise pass standard object parsing
    or git-fsck checks". So we are already covered under the documented
    behavior.

  - users don't generally run hash-object anyway. There are a lot of
    spots in the tests that needed to be updated because creating
    garbage objects is something that Git's tests disproportionately do.

  - it's hard to imagine anyone thinking the new behavior is worse. Any
    object we reject would be a potential problem down the road for the
    user. And if they really want to create garbage, --literally is
    already the escape hatch they need.

Note that the change here is actually in index_mem(), which handles the
HASH_FORMAT_CHECK flag passed by hash-object. That flag is also used by
"git-replace --edit" to sanity-check the result. Covering that with more
thorough checks likewise seems like a good thing.

Besides being more thorough, there are a few other bonuses:

  - we get rid of some questionable stack allocations of object structs.
    These don't seem to currently cause any problems in practice, but
    they subtly violate some of the assumptions made by the rest of the
    code (e.g., the "struct commit" we put on the stack and
    zero-initialize will not have a proper index from
    alloc_comit_index().

  - likewise, those parsed object structs are the source of some small
    memory leaks

  - the resulting messages are much better. For example:

      [before]
      $ echo 'tree 123' | git hash-object -t commit --stdin
      error: bogus commit object 0000000000000000000000000000000000000000
      fatal: corrupt commit

      [after]
      $ echo 'tree 123' | git.compile hash-object -t commit --stdin
      error: object fails fsck: badTreeSha1: invalid 'tree' line format - bad sha1
      fatal: refusing to create malformed object

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agofsck: provide a function to fsck buffer without object struct
Jeff King [Wed, 18 Jan 2023 20:43:53 +0000 (15:43 -0500)] 
fsck: provide a function to fsck buffer without object struct

The fsck code has been slowly moving away from requiring an object
struct in commits like 103fb6d43b (fsck: accept an oid instead of a
"struct tag" for fsck_tag(), 2019-10-18), c5b4269b57 (fsck: accept an
oid instead of a "struct commit" for fsck_commit(), 2019-10-18), etc.

However, the only external interface that fsck.c provides is
fsck_object(), which requires an object struct, then promptly discards
everything except its oid and type. Let's factor out the post-discard
part of that function as fsck_buffer(), leaving fsck_object() as a thin
wrapper around it. That will provide more flexibility for callers which
may not have a struct.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agot: use hash-object --literally when created malformed objects
Jeff King [Wed, 18 Jan 2023 20:41:56 +0000 (15:41 -0500)] 
t: use hash-object --literally when created malformed objects

Many test scripts use hash-object to create malformed objects to see how
we handle the results in various commands. In some cases we already have
to use "hash-object --literally", because it does some rudimentary
quality checks. But let's use "--literally" more consistently to
future-proof these tests against hash-object learning to be more
careful.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>