]> git.ipfire.org Git - thirdparty/git.git/log
thirdparty/git.git
15 months agoMerge branch 'gm/signature-format-doc'
Junio C Hamano [Tue, 7 Mar 2023 05:51:56 +0000 (21:51 -0800)] 
Merge branch 'gm/signature-format-doc'

Doc update.

* gm/signature-format-doc:
  signature-format.txt: note SSH and X.509 signature delimiters

15 months agoMerge branch 'rs/range-diff-custom-abbrev-fix'
Junio C Hamano [Wed, 1 Mar 2023 21:25:24 +0000 (13:25 -0800)] 
Merge branch 'rs/range-diff-custom-abbrev-fix'

Hotfix for a topic that is already in 'master'.

* rs/range-diff-custom-abbrev-fix:
  range-diff: avoid compiler warning when char is unsigned

15 months agoGit 2.40-rc1 v2.40.0-rc1
Junio C Hamano [Wed, 1 Mar 2023 16:13:35 +0000 (08:13 -0800)] 
Git 2.40-rc1

Signed-off-by: Junio C Hamano <gitster@pobox.com>
15 months agoA bit more before 2.40-rc1
Junio C Hamano [Tue, 28 Feb 2023 23:42:20 +0000 (15:42 -0800)] 
A bit more before 2.40-rc1

Signed-off-by: Junio C Hamano <gitster@pobox.com>
15 months agoMerge branch 'ar/test-lib-remove-stale-comment'
Junio C Hamano [Wed, 1 Mar 2023 00:38:47 +0000 (16:38 -0800)] 
Merge branch 'ar/test-lib-remove-stale-comment'

Test library clean-up.

* ar/test-lib-remove-stale-comment:
  test-lib: drop comment about test_description

15 months agoMerge branch 'zy/t9700-style'
Junio C Hamano [Wed, 1 Mar 2023 00:38:47 +0000 (16:38 -0800)] 
Merge branch 'zy/t9700-style'

Test style fixes.

* zy/t9700-style:
  t9700: modernize test scripts

15 months agoMerge branch 'pw/rebase-i-parse-fix'
Junio C Hamano [Wed, 1 Mar 2023 00:38:47 +0000 (16:38 -0800)] 
Merge branch 'pw/rebase-i-parse-fix'

Fixes to code that parses the todo file used in "rebase -i".

* pw/rebase-i-parse-fix:
  rebase -i: fix parsing of "fixup -C<commit>"
  rebase -i: match whole word in is_command()

15 months agoMerge branch 'jk/http-test-fixes'
Junio C Hamano [Wed, 1 Mar 2023 00:38:47 +0000 (16:38 -0800)] 
Merge branch 'jk/http-test-fixes'

Various fix-ups on HTTP tests.

* jk/http-test-fixes:
  t5559: make SSL/TLS the default
  t5559: fix test failures with LIB_HTTPD_SSL
  t/lib-httpd: enable HTTP/2 "h2" protocol, not just h2c
  t/lib-httpd: respect $HTTPD_PROTO in expect_askpass()
  t5551: drop curl trace lines without headers
  t5551: handle v2 protocol in cookie test
  t5551: simplify expected cookie file
  t5551: handle v2 protocol in upload-pack service test
  t5551: handle v2 protocol when checking curl trace
  t5551: stop forcing clone to run with v0 protocol
  t5551: handle HTTP/2 when checking curl trace
  t5551: lower-case headers in expected curl trace
  t5551: drop redundant grep for Accept-Language
  t5541: simplify and move "no empty path components" test
  t5541: stop marking "used receive-pack service" test as v0 only
  t5541: run "used receive-pack service" test earlier

15 months agorange-diff: avoid compiler warning when char is unsigned
René Scharfe [Tue, 28 Feb 2023 16:13:27 +0000 (17:13 +0100)] 
range-diff: avoid compiler warning when char is unsigned

Since 2b15969f61 (range-diff: let '--abbrev' option takes effect,
2023-02-20), GCC 11.3 on Ubuntu 22.04 on aarch64 warns (and errors
out if the make variable DEVELOPER is set):

range-diff.c: In function ‘output_pair_header’:
range-diff.c:388:20: error: comparison is always false due to limited range of data type [-Werror=type-limits]
  388 |         if (abbrev < 0)
      |                    ^
cc1: all warnings being treated as errors

That's because char is unsigned on that platform.  Use int instead, just
like in struct diff_options, to copy the value faithfully.

Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
15 months agosignature-format.txt: note SSH and X.509 signature delimiters
Gwyneth Morgan [Mon, 27 Feb 2023 20:27:18 +0000 (20:27 +0000)] 
signature-format.txt: note SSH and X.509 signature delimiters

This document only explains PGP signatures, but Git now supports X.509
signatures as of 1e7adb9756 (gpg-interface: introduce new signature
format "x509" using gpgsm, 2018-07-17), and SSH signatures as of
29b315778e (ssh signing: add ssh key format and signing code,
2021-09-10).

Additionally, explain that these signature formats are controlled
`gpg.format`, linking to its documentation, and explain in said
`gpg.format` documentation that the underlying signature format is
documented in signature-format.txt.

Signed-off-by: Gwyneth Morgan <gwymor@tilde.club>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
15 months agoA bit more before 2.40-rc1
Junio C Hamano [Mon, 27 Feb 2023 18:06:20 +0000 (10:06 -0800)] 
A bit more before 2.40-rc1

Signed-off-by: Junio C Hamano <gitster@pobox.com>
15 months agoMerge branch 'if/simplify-trace-setup'
Junio C Hamano [Mon, 27 Feb 2023 18:08:57 +0000 (10:08 -0800)] 
Merge branch 'if/simplify-trace-setup'

Code clean-up.

* if/simplify-trace-setup:
  trace.c, git.c: remove unnecessary parameter to trace_repo_setup()

15 months agoMerge branch 'jc/countermand-format-attach'
Junio C Hamano [Mon, 27 Feb 2023 18:08:57 +0000 (10:08 -0800)] 
Merge branch 'jc/countermand-format-attach'

The format.attach configuration variable lacked a way to override a
value defined in a lower-priority configuration file (e.g. the
system one) by redefining it in a higher-priority configuration
file.  Now, setting format.attach to an empty string means show the
patch inline in the e-mail message, without using MIME attachment.

This is a backward incompatible change.

* jc/countermand-format-attach:
  format.attach: allow empty value to disable multi-part messages

15 months agoMerge branch 'jk/shorten-unambiguous-ref-wo-sscanf'
Junio C Hamano [Mon, 27 Feb 2023 18:08:57 +0000 (10:08 -0800)] 
Merge branch 'jk/shorten-unambiguous-ref-wo-sscanf'

sscanf(3) used in "git symbolic-ref --short" implementation found
to be not working reliably on macOS in UTF-8 locales.  Rewrite the
code to avoid sscanf() altogether to work it around.

* jk/shorten-unambiguous-ref-wo-sscanf:
  shorten_unambiguous_ref(): avoid sscanf()
  shorten_unambiguous_ref(): use NUM_REV_PARSE_RULES constant
  shorten_unambiguous_ref(): avoid integer truncation

15 months agoMerge branch 'mh/credential-password-expiry'
Junio C Hamano [Mon, 27 Feb 2023 18:08:57 +0000 (10:08 -0800)] 
Merge branch 'mh/credential-password-expiry'

The credential subsystem learned that a password may have an
explicit expiration.

* mh/credential-password-expiry:
  credential: new attribute password_expiry_utc

15 months agoMerge branch 'rs/archive-mtime'
Junio C Hamano [Mon, 27 Feb 2023 18:08:57 +0000 (10:08 -0800)] 
Merge branch 'rs/archive-mtime'

"git archive HEAD^{tree}" records the paths with the current
timestamp in the archive, making it harder to obtain a stable
output.  The command learned the --mtime option to specify an
arbitrary timestamp (e.g. --mtime="@0 +0000" for the epoch).

* rs/archive-mtime:
  archive: add --mtime

15 months agoMerge branch 'tb/drop-dir-iterator-follow-symlink-bit'
Junio C Hamano [Mon, 27 Feb 2023 18:08:57 +0000 (10:08 -0800)] 
Merge branch 'tb/drop-dir-iterator-follow-symlink-bit'

Remove leftover and unused code.

* tb/drop-dir-iterator-follow-symlink-bit:
  t0066: drop setup of "dir5"
  dir-iterator: drop unused `DIR_ITERATOR_FOLLOW_SYMLINKS`

15 months agoMerge branch 'tl/range-diff-custom-abbrev'
Junio C Hamano [Mon, 27 Feb 2023 18:08:56 +0000 (10:08 -0800)] 
Merge branch 'tl/range-diff-custom-abbrev'

"git range-diff" learned --abbrev=<num> option.

* tl/range-diff-custom-abbrev:
  range-diff: let '--abbrev' option takes effect

15 months agoMerge branch 'ap/t2015-style-update'
Junio C Hamano [Mon, 27 Feb 2023 18:08:56 +0000 (10:08 -0800)] 
Merge branch 'ap/t2015-style-update'

Test clean-up.

* ap/t2015-style-update:
  t2015-checkout-unborn.sh: changes the style for cd

15 months agoMerge branch 'jc/diff-algo-attribute'
Junio C Hamano [Mon, 27 Feb 2023 18:08:56 +0000 (10:08 -0800)] 
Merge branch 'jc/diff-algo-attribute'

The "diff" drivers specified by the "diff" attribute attached to
paths can now specify which algorithm (e.g. histogram) to use.

* jc/diff-algo-attribute:
  diff: teach diff to read algorithm from diff driver
  diff: consolidate diff algorithm option parsing

15 months agoMerge branch 'pw/rebase-i-validate-labels-early'
Junio C Hamano [Mon, 27 Feb 2023 18:08:56 +0000 (10:08 -0800)] 
Merge branch 'pw/rebase-i-validate-labels-early'

An invalid label or ref in the "rebase -i" todo file used to
trigger an runtime error. SUch an error is now diagnosed while the
todo file is parsed.

* pw/rebase-i-validate-labels-early:
  rebase -i: check labels and refs when parsing todo list

15 months agotest-lib: drop comment about test_description
Andrei Rybak [Sun, 26 Feb 2023 10:53:03 +0000 (11:53 +0100)] 
test-lib: drop comment about test_description

When a comment describing how each test file should start was added in
commit [1], it was the second comment of t/test-lib.sh.  The comment
describes how variable "test_description" is supposed to be assigned at
the top of each test file and how "test-lib.sh" should be used by
sourcing it.  However, even in [1], the comment was ten lines away from
the usage of the variable by test-lib.sh.  Since then, the comment has
drifted away both from the top of the file and from the usage of the
variable.  The comment just sits in the middle of the initialization of
the test library, surrounded by unrelated code, almost one hundred lines
away from the usage of "test_description".

Nobody has noticed this drift during evolution of test-lib.sh, which
suggests that this comment has outlived its usefulness.  The assignment
of "test_description", sourcing of "test-lib.sh" by tests, and the
process of writing tests in general are described in detail in
"t/README".  So drop the obsolete comment.

An alternative solution could be to move the comment either to the top
of the file, or down to the usage of variable "test_description".

[1] e1970ce43a ("[PATCH 1/2] Test framework take two.", 2005-05-13)

Signed-off-by: Andrei Rybak <rybak.a.v@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
15 months agot9700: modernize test scripts
Zhang Yi [Sat, 25 Feb 2023 01:30:03 +0000 (09:30 +0800)] 
t9700: modernize test scripts

The style of t9700-perl-git.sh is old. There are 3 problems:
* A title is not on the same line with test_expect_success command.
* A test body is indented by whitespaces.
* There are whitespaces after redirect operators.

Modernize test scripts by:
* Combine the title with test_expect_success command.
* Replace whitespace indents with TAB.
* Delete whitespaces after redirect operators.

Signed-off-by: Zhang Yi <18994118902@163.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
15 months agoA few more topics post 2.40-rc0
Junio C Hamano [Sat, 25 Feb 2023 06:53:08 +0000 (22:53 -0800)] 
A few more topics post 2.40-rc0

Signed-off-by: Junio C Hamano <gitster@pobox.com>
15 months agoMerge branch 'ps/free-island-marks'
Junio C Hamano [Sat, 25 Feb 2023 06:54:01 +0000 (22:54 -0800)] 
Merge branch 'ps/free-island-marks'

Fix on a previous fix already in 'master'.

* ps/free-island-marks:
  delta-islands: fix segfault when freeing island marks

15 months agoMerge branch 'jk/http-proxy-tests'
Junio C Hamano [Sat, 25 Feb 2023 06:54:01 +0000 (22:54 -0800)] 
Merge branch 'jk/http-proxy-tests'

Test updates.

* jk/http-proxy-tests:
  add basic http proxy tests

15 months agoMerge branch 'ma/fetch-parallel-use-online-cpus'
Junio C Hamano [Sat, 25 Feb 2023 06:54:00 +0000 (22:54 -0800)] 
Merge branch 'ma/fetch-parallel-use-online-cpus'

"git fetch --jobs=0" used to hit a BUG(), which has been corrected
to use the available CPUs.

* ma/fetch-parallel-use-online-cpus:
  fetch: choose a sensible default with --jobs=0 again

15 months agoGit 2.40-rc0 v2.40.0-rc0
Junio C Hamano [Fri, 24 Feb 2023 19:32:40 +0000 (11:32 -0800)] 
Git 2.40-rc0

Signed-off-by: Junio C Hamano <gitster@pobox.com>
15 months agoMerge branch 'jc/genzeros-avoid-raw-write'
Junio C Hamano [Fri, 24 Feb 2023 19:32:30 +0000 (11:32 -0800)] 
Merge branch 'jc/genzeros-avoid-raw-write'

A test helper had a single write(2) of 256kB, which was too big for
some platforms (e.g. NonStop), which has been corrected by using
xwrite() wrapper appropriately.

* jc/genzeros-avoid-raw-write:
  test-genzeros: avoid raw write(2)

15 months agoMerge branch 'rd/doc-default-date-format'
Junio C Hamano [Fri, 24 Feb 2023 19:32:29 +0000 (11:32 -0800)] 
Merge branch 'rd/doc-default-date-format'

Update --date=default documentation.

* rd/doc-default-date-format:
  rev-list: clarify git-log default date format

15 months agoMerge branch 'js/gpg-errors'
Junio C Hamano [Fri, 24 Feb 2023 19:32:29 +0000 (11:32 -0800)] 
Merge branch 'js/gpg-errors'

Error messages given upon a signature verification failure used to
discard the errors from underlying gpg program, which has been
corrected.

* js/gpg-errors:
  gpg: do show gpg's error message upon failure
  t7510: add a test case that does not need gpg

15 months agoMerge branch 'rs/ctype-test'
Junio C Hamano [Fri, 24 Feb 2023 19:32:29 +0000 (11:32 -0800)] 
Merge branch 'rs/ctype-test'

Test safe_ctype

* rs/ctype-test:
  test-ctype: test iscntrl, ispunct, isxdigit and isprint
  test-ctype: test islower and isupper
  test-ctype: test isascii

15 months agorebase -i: fix parsing of "fixup -C<commit>"
Phillip Wood [Thu, 23 Feb 2023 20:55:01 +0000 (20:55 +0000)] 
rebase -i: fix parsing of "fixup -C<commit>"

If the user omits the space between "-C" and the commit in a fixup
command then it is parsed as an ordinary fixup and the commit message is
not updated as it should be. Fix this by making the space between "-C"
and "<commit>" optional as it is for the "merge" command.

Note that set_replace_editor() is changed to set $GIT_SEQUENCE_EDITOR
instead of $EDITOR in order to be able to replace the todo list and
reword commits with $FAKE_COMMIT_MESSAGE. This is safe as all the
existing users are using set_replace_editor() to replace the todo list.

Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
15 months agorebase -i: match whole word in is_command()
Phillip Wood [Thu, 23 Feb 2023 20:55:00 +0000 (20:55 +0000)] 
rebase -i: match whole word in is_command()

When matching an unabbreviated command is_command() only does a prefix
match which means it parses "pickled" as TODO_PICK. parse_insn_line()
does error out because is_command() only advances as far as the end of
"pick" so it looks like the command name is not followed by a space but
the error message is "missing arguments for pick" rather than telling
the user that the "pickled" is not a valid command.

Fix this by ensuring the match is follow by whitespace or the end of the
string as we already do for abbreviated commands. The (*bol = p) at the
end of the condition is a bit cute for my taste but I decided to leave
it be for now. Rather than add new tests the existing tests for bad
commands are adapted to use a bad command name that triggers the prefix
matching bug.

Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
15 months agot5559: make SSL/TLS the default
Jeff King [Thu, 23 Feb 2023 11:08:41 +0000 (06:08 -0500)] 
t5559: make SSL/TLS the default

The point of t5559 is run the regular t5551 tests with HTTP/2. But it
does so with the "h2c" protocol, which uses cleartext upgrades from
HTTP/1.1 to HTTP/2 (rather than learning about HTTP/2 support during the
TLS negotiation).

This has a few problems:

 - it's not very indicative of the real world. In practice, most servers
   that support HTTP/2 will also support TLS.

 - support for upgrading does not seem as robust. In particular, we've
   run into bugs in some versions of Apache's mod_http2 that trigger
   only with the upgrade mode. See:

     https://lore.kernel.org/git/Y8ztIqYgVCPILJlO@coredump.intra.peff.net/

So the upside is that this change makes our HTTP/2 tests more robust and
more realistic. The downside is that if we can't set up SSL for any
reason, we'll skip the tests (even though you _might_ have been able to
run the HTTP/2 tests the old way). We could probably have a conditional
fallback, but it would be complicated for little gain, and it's not even
clear it would help (i.e., would any test environment even have HTTP/2
but not SSL support?).

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
15 months agot5559: fix test failures with LIB_HTTPD_SSL
Jeff King [Thu, 23 Feb 2023 11:07:29 +0000 (06:07 -0500)] 
t5559: fix test failures with LIB_HTTPD_SSL

One test needs to be tweaked in order for t5559 to pass with SSL/TLS set
up. When we make our initial clone, we check that the curl trace of
requests is what we expected. But we need to fix two things:

  - along with ignoring "data" lines from the trace, we need to ignore
    "SSL data" lines

  - when TLS is used, the server is able to tell the client (via ALPN)
    that it supports HTTP/2 before the first HTTP request is made. So
    rather than request an upgrade using an HTTP header, it can just
    speak HTTP/2 immediately

With this patch, running:

  LIB_HTTPD_SSL=1 ./t5559-http-fetch-smart-http2.sh

works, whereas it did not before.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
15 months agot/lib-httpd: enable HTTP/2 "h2" protocol, not just h2c
Jeff King [Thu, 23 Feb 2023 11:06:44 +0000 (06:06 -0500)] 
t/lib-httpd: enable HTTP/2 "h2" protocol, not just h2c

Commit 73c49a4474 (t: run t5551 tests with both HTTP and HTTP/2,
2022-11-11) added Apache config to enable HTTP/2. However, it only
enabled the "h2c" protocol, which allows cleartext HTTP/2 (generally
based on an upgrade header during an HTTP/1.1 request). This is what
t5559 is generally testing, since by default we don't set up SSL/TLS.

However, it should be possible to run t5559 with LIB_HTTPD_SSL set. In
that case, Apache will advertise support for HTTP/2 via ALPN during the
TLS handshake. But we need to tell it support "h2" (the non-cleartext
version) to do so. Without that, then curl does not even try to do the
HTTP/1.1 upgrade (presumably because after seeing that we did TLS but
didn't get the ALPN indicator, it assumes it would be fruitless).

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
15 months agot/lib-httpd: respect $HTTPD_PROTO in expect_askpass()
Jeff King [Thu, 23 Feb 2023 11:05:55 +0000 (06:05 -0500)] 
t/lib-httpd: respect $HTTPD_PROTO in expect_askpass()

When the HTTP tests are run with LIB_HTTPD_SSL in the environment, then
we access the test server as https://. This causes expect_askpass to
complain, because it tries to blindly match "http://" in the prompt
shown to the user. We can adjust this to use $HTTPD_PROTO, which is set
during the setup phase.

Note that this is enough for t5551 and t5559 to pass when run with
https, but there are similar problems in other scripts that will need to
be fixed before the whole suite can run with LIB_HTTPD_SSL.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
15 months agot5551: drop curl trace lines without headers
Jeff King [Thu, 23 Feb 2023 11:05:07 +0000 (06:05 -0500)] 
t5551: drop curl trace lines without headers

We pick apart a curl trace, looking for "=> Send header:" and so on, and
matching against an expected set of requests and responses. We remove
"== Info" lines entirely. However, our parser is fooled when running the
test with LIB_HTTPD_SSL on Ubuntu 20.04 (as found in our linux-gcc CI
job), as curl hands us an "Info" buffer with a newline, and we get:

  == Info: successfully set certificate verify locations:
  == Info:   CAfile: /etc/ssl/certs/ca-certificates.crt
    CApath: /etc/ssl/certs
  => Send SSL data[...]

which results in the "CApath" line ending up in the cleaned-up output,
causing the test to fail.

Arguably the tracing code should detect this and put it on two separate
"== Info" lines. But this is actually a curl bug, fixed by their
80d73bcca (tls: provide the CApath verbose log on its own line,
2020-08-18). It's simpler to just work around it here.

Since we are using GIT_TRACE_CURL, every line should just start with one
of "<=", "==", or "=>", and we can throw away anything else. In fact, we
can just replace the pattern for deleting "*" lines. Those were from the
old GIT_CURL_VERBOSE output, but we switched over in 14e24114d9
(t5551-http-fetch-smart.sh: use the GIT_TRACE_CURL environment var,
2016-09-05).

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
15 months agot5551: handle v2 protocol in cookie test
Jeff King [Thu, 23 Feb 2023 11:02:31 +0000 (06:02 -0500)] 
t5551: handle v2 protocol in cookie test

After making a request, we check that it stored the expected cookies.
This depends on the protocol version, because the cookies we store
depend on the exact requests we made (and for ls-remote, v2 will always
hit /git-upload-pack to get the refs, whereas v0 is happy with the
initial ref advertisement).

As a result, hardly anybody runs this test, as you'd have to manually
set GIT_TEST_PROTOCOL_VERSION=0 to do so.

Let's teach it to handle both protocol versions. One way to do this
would be to make the expectation conditional on the protocol used. But
there's a simpler solution. The reason that v0 doesn't hit
/git-upload-pack is that ls-remote doesn't fetch any objects. If we
instead do a fetch (making sure there's an actual object to grab), then
both v0 and v2 will hit the same endpoints and set the same cookies.

Note that we do have to clean up our new tag here; otherwise it confuses
the later "clone 2,000 tags" test.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
15 months agot5551: simplify expected cookie file
Jeff King [Thu, 23 Feb 2023 11:01:31 +0000 (06:01 -0500)] 
t5551: simplify expected cookie file

After making an HTTP request that should store cookies, we check that
the expected values are in the cookie file. We don't want to look at the
whole file, because it has noisy comments at the top that we shouldn't
depend on. But we strip out the interesting bits using "tail -3", which
is brittle. It requires us to put an extra blank line in our expected
output, and it would fail to notice any reordering or extra content in
the cookie file.

Instead, let's just grep for non-blank lines that are not comments,
which more directly describes what we're interested in.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
15 months agot5551: handle v2 protocol in upload-pack service test
Jeff King [Thu, 23 Feb 2023 11:00:38 +0000 (06:00 -0500)] 
t5551: handle v2 protocol in upload-pack service test

We perform a clone and a fetch, and then check that we saw the expected
requests in Apache's access log. In the v2 protocol, there will be one
extra request to /git-upload-pack for each operation (since the initial
/info/refs probe is just used to upgrade the protocol).

As a result, this test is a noop unless the use of the v0 protocol is
forced. Which means that hardly anybody runs it, since you have to do so
manually.

Let's update it to handle v2 and run it always. We could do this by just
conditionally adding in the extra POST lines. But if we look at the
origin of the test in 7da4e2280c (test smart http fetch and push,
2009-10-30), the point is really just to make sure that the smart
git-upload-pack service was used at all. So rather than counting up the
individual requests, let's just make sure we saw each of the expected
types. This is a bit looser, but makes maintenance easier.

Since we're now matching with grep, we can also loosen the HTTP/1.1
match, which allows this test to pass when run with HTTP/2 via t5559.
That lets:

  GIT_TEST_PROTOCOL_VERSION=0 ./t5559-http-fetch-smart-http2.sh

run to completion, which previously failed (and of course it works if
you use v2, as well).

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
15 months agot5551: handle v2 protocol when checking curl trace
Jeff King [Thu, 23 Feb 2023 10:59:00 +0000 (05:59 -0500)] 
t5551: handle v2 protocol when checking curl trace

After cloning an http repository, we check the curl trace to make sure
the expected requests were made. But since the expected trace was never
updated to handle v2, it is only run when you ask the test suite to run
in v0 mode (which hardly anybody does).

Let's update it to handle both protocols. This isn't too hard since v2
just sends an extra header and an extra request. So we can just annotate
those extra lines and strip them out for v0 (and drop the annotations
for v2). I didn't bother handling v1 here, as it's not really of
practical interest (it would drop the extra v2 request, but still have
the "git-protocol" lines).

There's a similar tweak needed at the end. Since we check the
"accept-encoding" value loosely, we grep for it rather than finding it
in the verbatim trace. This grep insists that there are exactly 2
matches, but of course in v2 with the extra request there are 3. We
could tweak the number, but it's simpler still to just check that we saw
at least one match. The verbatim check already confirmed how many
instances of the header we have; we're really just checking here that
"gzip" is in the value (it's possible, of course, that the headers could
have different values, but that seems like an unlikely bug).

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
15 months agot5551: stop forcing clone to run with v0 protocol
Jeff King [Thu, 23 Feb 2023 10:57:27 +0000 (05:57 -0500)] 
t5551: stop forcing clone to run with v0 protocol

In the "clone http repository" test, we check the curl trace to make
sure the expected requests were made. This whole script was marked to
handle only the v0 protocol in d790ee1707 (tests: fix protocol version
for overspecifications, 2019-02-25). That makes sense, since v2 requires
an extra request, so tests as specific as this would fail unless
modified.

Later, in preparation for v2 becoming the default, this was tweaked by
8a1b0978ab (test: request GIT_TEST_PROTOCOL_VERSION=0 when appropriate,
2019-12-23). There we run the trace check only if the user has
explicitly asked to test protocol version 0. But it also forced the
clone itself to run with the v0 protocol.

This makes the check for "can we expect a v0 trace" silly; it will
always be v0. But much worse, it means that the clone we are testing is
not like the one that normal users would run. They would use the
defaults, which are now v2.  And since this is supposed to be a basic
check of clone-over-http, we should do the same.

Let's fix this by dropping the extra v0 override. The test still passes
because the trace checking only kicks in if we asked to use v0
explicitly (this is the same as before; even though we were running a v0
clone, unless you specifically set GIT_TEST_PROTOCOL_VERSION=0, the
trace check was always skipped).

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
15 months agot5551: handle HTTP/2 when checking curl trace
Jeff King [Thu, 23 Feb 2023 10:56:17 +0000 (05:56 -0500)] 
t5551: handle HTTP/2 when checking curl trace

We check that the curl trace of a clone has the lines we expect, but
this won't work when we run the test under t5559, because a few details
are different under HTTP/2 (but nobody noticed because it only happens
when you manually set GIT_TEST_PROTOCOL_VERSION to "0").

We can handle both HTTP protocols with a few tweaks:

  - we'll drop the HTTP "101 Switching Protocols" response, as well as
    various protocol upgrade headers. These details aren't interesting
    to us. We just want to make sure the correct protocol was used (and
    we do in the main request/response lines).

  - successful HTTP/2 responses just say "200" and not "200 OK"; we can
    normalize these

  - replace HTTP/1.1 with a variable in the request/response lines. We
    can use the existing $HTTP_PROTO for this, as it's already set to
    "HTTP/2" when appropriate. We do need to tweak the fallback value to
    "HTTP/1.1" to match what curl will write (prior to this patch, the
    fallback value didn't matter at all; we only checked if it was the
    literal string "HTTP/2").

Note that several lines still expect HTTP/1.1 unconditionally. The first
request does so because the client requests an upgrade during the
request. The POST request and response do so because you can't do an
upgrade if there is a request body. (This will all be different if we
trigger HTTP/2 via ALPN, but the tests aren't yet capable of that).

This is enough to let:

  GIT_TEST_PROTOCOL_VERSION=0 ./t5559-http-fetch-smart-http2.sh

pass the "clone http repository" test (but there are some other failures
later on).

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
15 months agot5551: lower-case headers in expected curl trace
Jeff King [Thu, 23 Feb 2023 10:54:02 +0000 (05:54 -0500)] 
t5551: lower-case headers in expected curl trace

There's a test in t5551 which checks the curl trace (after simplifying
it a bit). It doesn't work with HTTP/2, because in that case curl
outputs all of the headers in lower-case. Even though this test is run
with HTTP/2 by t5559, nobody has noticed because checking the trace only
happens if GIT_TEST_PROTOCOL_VERSION is manually set to "0".

Let's fix this by lower-casing all of the header names in the trace, and
then checking for those in our expected code (this is easier than making
HTTP/2 traces look like HTTP/1.1, since HTTP/1.1 uses title-casing).

Sadly, we can't quite do this in our existing sed script. This works if
you have GNU sed:

  s/^\\([><]\\) \\([A-Za-z0-9-]*:\\)/\1 \L\2\E/

but \L is a GNU-ism, and I don't think there's a portable solution. We
could just "tr A-Z a-z" on the way in, of course, but that makes the
non-header parts harder to read (e.g., lowercase "post" requests). But
to paraphrase Baron Munchausen, I have learned from experience that a
modicum of Perl can be most efficacious.

Note that this doesn't quite get the test passing with t5559; there are
more fixes needed on top.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
15 months agot5551: drop redundant grep for Accept-Language
Jeff King [Thu, 23 Feb 2023 10:52:10 +0000 (05:52 -0500)] 
t5551: drop redundant grep for Accept-Language

Commit b0c4adcdd7 (remote-curl: send Accept-Language header to server,
2022-07-11) added tests to make sure the header is sent via HTTP.
However, it checks in two places:

  1. In the expected trace output, we check verbatim for the header and
     its value.

  2. Afterwards, we grep for the header again in the trace file.

This (2) is probably cargo-culted from the earlier grep for
Accept-Encoding. It is needed for the encoding because we smudge the
value of that header when doing the verbatim check; see 1a53e692af
(remote-curl: accept all encodings supported by curl, 2018-05-22).

But we don't do so for the language header, so any problem that the
"grep" would catch in (2) would already have been caught by (1).

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
15 months agot5541: simplify and move "no empty path components" test
Jeff King [Thu, 23 Feb 2023 10:51:35 +0000 (05:51 -0500)] 
t5541: simplify and move "no empty path components" test

Commit 9ee6bcd398 (t5541-http-push: add test for URLs with trailing
slash, 2010-04-08) added a test that clones a URL with a trailing slash,
and confirms that we don't send a doubled slash (like "$url//info/refs")
to the server.

But this test makes no sense in t5541, which is about pushing. It should
have been added in t5551. Let's move it there.

But putting it at the end is tricky, since it checks the entire contents
of the Apache access log. We could get around this by clearing the log
before our test. But there's an even simpler solution: just make sure no
doubled slashes appear in the log (fortunately, "http://" does not
appear in the log itself).

As a bonus, this also lets us drop the check for the v0 protocol (which
is otherwise necessary since v2 makes multiple requests, and
check_access_log insists on exactly matching the number of requests,
even though we don't care about that here).

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
15 months agot5541: stop marking "used receive-pack service" test as v0 only
Jeff King [Thu, 23 Feb 2023 10:50:36 +0000 (05:50 -0500)] 
t5541: stop marking "used receive-pack service" test as v0 only

We have a test which checks to see if a request to git-receive-pack was
made. Originally, it was checking the entire set of requests made in the
script so far, including clones, and thus it would break when run with
the v2 protocol (since that implies an extra request for fetches).

Since the previous commit, though, we are only checking the requests
made by a single push. And since there is no v2 push protocol, the test
now passes no matter what's in GIT_TEST_PROTOCOL_VERSION. We can just
run it all the time.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
15 months agot5541: run "used receive-pack service" test earlier
Jeff King [Thu, 23 Feb 2023 10:49:47 +0000 (05:49 -0500)] 
t5541: run "used receive-pack service" test earlier

There's a test in t5541 that confirms that "git push" makes two requests
(a GET to /info/refs, and a POST to /git-receive-pack). However, it's a
noop unless GIT_TEST_PROTOCOL_VERSION is set to "0", due to 8a1b0978ab
(test: request GIT_TEST_PROTOCOL_VERSION=0 when appropriate,
2019-12-23).

This means that almost nobody runs it. And indeed, it has been broken
since b0c4adcdd7 (remote-curl: send Accept-Language header to server,
2022-07-11). But the fault is not in that commit, but in how brittle the
test is. It runs after several operations have been performed, which
means that it expects to see the complete set of requests made so far in
the script. Commit b0c4adcdd7 added a new test, which means that the
"used receive-pack service" test must be updated, too.

Let's fix this by making the test less brittle. We'll move it higher in
the script, right after the first push has completed. And we'll clear
the access log right before doing the push, so we'll see only the
requests from that command.

This is technically testing less, in that we won't check that all of
those other requests also correctly used smart http. But there's no
particular reason think that if the first one did, the others wouldn't.

After this patch, running:

  GIT_TEST_PROTOCOL_VERSION=0 ./t5541-http-push-smart.sh

passes, whereas it did not before.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
15 months agocredential: new attribute password_expiry_utc
M Hickford [Sat, 18 Feb 2023 06:32:57 +0000 (06:32 +0000)] 
credential: new attribute password_expiry_utc

Some passwords have an expiry date known at generation. This may be
years away for a personal access token or hours for an OAuth access
token.

When multiple credential helpers are configured, `credential fill` tries
each helper in turn until it has a username and password, returning
early. If Git authentication succeeds, `credential approve`
stores the successful credential in all helpers. If authentication
fails, `credential reject` erases matching credentials in all helpers.
Helpers implement corresponding operations: get, store, erase.

The credential protocol has no expiry attribute, so helpers cannot
store expiry information. Even if a helper returned an improvised
expiry attribute, git credential discards unrecognised attributes
between operations and between helpers.

This is a particular issue when a storage helper and a
credential-generating helper are configured together:

[credential]
helper = storage  # eg. cache or osxkeychain
helper = generate  # eg. oauth

`credential approve` stores the generated credential in both helpers
without expiry information. Later `credential fill` may return an
expired credential from storage. There is no workaround, no matter how
clever the second helper. The user sees authentication fail (a retry
will succeed).

Introduce a password expiry attribute. In `credential fill`, ignore
expired passwords and continue to query subsequent helpers.

In the example above, `credential fill` ignores the expired password
and a fresh credential is generated. If authentication succeeds,
`credential approve` replaces the expired password in storage.
If authentication fails, the expired credential is erased by
`credential reject`. It is unnecessary but harmless for storage
helpers to self prune expired credentials.

Add support for the new attribute to credential-cache.
Eventually, I hope to see support in other popular storage helpers.

Example usage in a credential-generating helper
https://github.com/hickford/git-credential-oauth/pull/16

Signed-off-by: M Hickford <mirth.hickford@gmail.com>
Reviewed-by: Calvin Wan <calvinwan@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
15 months agoThe seventeenth batch
Junio C Hamano [Wed, 22 Feb 2023 22:55:59 +0000 (14:55 -0800)] 
The seventeenth batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
15 months agoMerge branch 'ab/hook-api-with-stdin'
Junio C Hamano [Wed, 22 Feb 2023 22:55:45 +0000 (14:55 -0800)] 
Merge branch 'ab/hook-api-with-stdin'

Extend the run-hooks API to allow feeding data from the standard
input when running the hook script(s).

* ab/hook-api-with-stdin:
  hook: support a --to-stdin=<path> option
  sequencer: use the new hook API for the simpler "post-rewrite" call
  hook API: support passing stdin to hooks, convert am's 'post-rewrite'
  run-command: allow stdin for run_processes_parallel
  run-command.c: remove dead assignment in while-loop

15 months agoMerge branch 'ab/various-leak-fixes'
Junio C Hamano [Wed, 22 Feb 2023 22:55:45 +0000 (14:55 -0800)] 
Merge branch 'ab/various-leak-fixes'

Leak fixes.

* ab/various-leak-fixes:
  push: free_refs() the "local_refs" in set_refspecs()
  push: refactor refspec_append_mapped() for subsequent leak-fix
  receive-pack: release the linked "struct command *" list
  grep API: plug memory leaks by freeing "header_list"
  grep.c: refactor free_grep_patterns()
  builtin/merge.c: free "&buf" on "Your local changes..." error
  builtin/merge.c: use fixed strings, not "strbuf", fix leak
  show-branch: free() allocated "head" before return
  commit-graph: fix a parse_options_concat() leak
  http-backend.c: fix cmd_main() memory leak, refactor reg{exec,free}()
  http-backend.c: fix "dir" and "cmd_arg" leaks in cmd_main()
  worktree: fix a trivial leak in prune_worktrees()
  repack: fix leaks on error with "goto cleanup"
  name-rev: don't xstrdup() an already dup'd string
  various: add missing clear_pathspec(), fix leaks
  clone: use free() instead of UNLEAK()
  commit-graph: use free_commit_graph() instead of UNLEAK()
  bundle.c: don't leak the "args" in the "struct child_process"
  tests: mark tests as passing with SANITIZE=leak

15 months agoMerge branch 'jk/doc-ls-remote-matching'
Junio C Hamano [Wed, 22 Feb 2023 22:55:45 +0000 (14:55 -0800)] 
Merge branch 'jk/doc-ls-remote-matching'

Doc update.

* jk/doc-ls-remote-matching:
  doc/ls-remote: clarify pattern format
  doc/ls-remote: cosmetic cleanups for examples

15 months agoMerge branch 'rs/cache-tree-strbuf-growth-fix'
Junio C Hamano [Wed, 22 Feb 2023 22:55:44 +0000 (14:55 -0800)] 
Merge branch 'rs/cache-tree-strbuf-growth-fix'

Remove unnecessary explicit sizing of strbuf.

* rs/cache-tree-strbuf-growth-fix:
  cache-tree: fix strbuf growth in prime_cache_tree_rec()

15 months agoMerge branch 'ab/the-index-compatibility'
Junio C Hamano [Wed, 22 Feb 2023 22:55:44 +0000 (14:55 -0800)] 
Merge branch 'ab/the-index-compatibility'

Remove more remaining uses of macros that relies on the_index
singleton instance without explicitly spelling it out.

* ab/the-index-compatibility:
  cocci & cache.h: remove "USE_THE_INDEX_COMPATIBILITY_MACROS"
  cache-tree API: remove redundant update_main_cache_tree()
  cocci & cache-tree.h: migrate "write_cache_as_tree" to "*_index_*"
  cocci & cache.h: apply pending "index_cache_pos" rule
  cocci & cache.h: fully apply "active_nr" part of index-compatibility
  builtin/rm.c: use narrower "USE_THE_INDEX_VARIABLE"

15 months agoMerge branch 'en/name-rev-make-taggerdate-much-less-important'
Junio C Hamano [Wed, 22 Feb 2023 22:55:44 +0000 (14:55 -0800)] 
Merge branch 'en/name-rev-make-taggerdate-much-less-important'

"git name-rev" heuristics update.

* en/name-rev-make-taggerdate-much-less-important:
  name-rev: fix names by dropping taggerdate workaround

15 months agorange-diff: let '--abbrev' option takes effect
Teng Long [Mon, 20 Feb 2023 14:24:44 +0000 (22:24 +0800)] 
range-diff: let '--abbrev' option takes effect

As mentioned in 'git-range-diff.txt': "`git range-diff` also accepts the
regular diff options (see linkgit:git-diff[1])...", but '--abbrev' is not
in the "regular" scope.

In Git, the "abbrev" of an object may not be a fixed value in different
repositories, depending on the needs of the them(Linus mentioned in
e6c587c7 in 2016: "the Linux kernel project needs 11 to 12 hexdigits"
at that time ), that's why a user may want to display abbrev according
to a specified length.

Although a similar effect can be achieved through configuration (like:
git -c core.abbrev=<abbrev>), but based on ease of use (many users may not
know that the -c option can be specified) and the description in existing
document, supporting users to directly use '--abbrev', could be a good way.

Signed-off-by: Teng Long <dyroneteng@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
15 months agofetch: choose a sensible default with --jobs=0 again
Matthias Aßhauer [Mon, 20 Feb 2023 21:33:25 +0000 (21:33 +0000)] 
fetch: choose a sensible default with --jobs=0 again

prior to 51243f9 (run-command API: don't fall back on online_cpus(),
2022-10-12) `git fetch --multiple --jobs=0` would choose some default amount
of jobs, similar to `git -c fetch.parallel=0 fetch --multiple`. While our
documentation only ever promised that `fetch.parallel` would fall back to a
"sensible default", it makes sense to do the same for `--jobs`. So fall back
to online_cpus() and not BUG() out.

This fixes https://github.com/git-for-windows/git/issues/4302

Reported-by: Drew Noakes <drnoakes@microsoft.com>
Signed-off-by: Matthias Aßhauer <mha1993@live.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
15 months agotrace.c, git.c: remove unnecessary parameter to trace_repo_setup()
idriss fekir [Sun, 19 Feb 2023 00:25:27 +0000 (01:25 +0100)] 
trace.c, git.c: remove unnecessary parameter to trace_repo_setup()

trace_repo_setup() of trace.c is called with the argument 'prefix' from
only one location, run_builtin of git.c, which sets 'prefix' to the return
value of setup_git_directory() or setup_git_directory_gently() (a wrapper
of the former).

Now that "prefix" is in startup_info there is no need for the parameter
of trace_repo_setup() because setup_git_directory() sets "startup_info->prefix"
to the same value it returns. It would be less confusing to use "prefix"
from startup_info instead of passing it as an argument.

Signed-off-by: Idriss Fekir <mcsm224@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
15 months agot2015-checkout-unborn.sh: changes the style for cd
Ashutosh Pandey [Sat, 18 Feb 2023 19:21:28 +0000 (00:51 +0530)] 
t2015-checkout-unborn.sh: changes the style for cd

the `cd` followed the old style which wasn't consistent with the rest of
the test suite, so this commit makes it consistent with the current
style of the test suite for `cd` in  subshell.

Signed-off-by: Ashutosh Pandey <ashutosh.pandeyhlr007@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
15 months agodiff: teach diff to read algorithm from diff driver
John Cai [Mon, 20 Feb 2023 21:04:42 +0000 (21:04 +0000)] 
diff: teach diff to read algorithm from diff driver

It can be useful to specify diff algorithms per file type. For example,
one may want to use the minimal diff algorithm for .json files, another
for .c files, etc.

The diff machinery already checks attributes for a diff driver. Teach
the diff driver parser a new type "algorithm" to look for in the
config, which will be used if a driver has been specified through the
attributes.

Enforce precedence of the diff algorithm by favoring the command line
option, then looking at the driver attributes & config combination, then
finally the diff.algorithm config.

To enforce precedence order, use a new `ignore_driver_algorithm` member
during options parsing to indicate the diff algorithm was set via command
line args.

Signed-off-by: John Cai <johncai86@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
15 months agodiff: consolidate diff algorithm option parsing
John Cai [Mon, 20 Feb 2023 21:04:41 +0000 (21:04 +0000)] 
diff: consolidate diff algorithm option parsing

A subsequent commit will need the ability to tell if the diff algorithm
was set through the command line through setting a new member of
diff_options. While this logic can be added to the
diff_opt_diff_algorithm() callback, the `--minimal` and `--histogram`
options are handled via OPT_BIT without a callback.

Remedy this by consolidating the options parsing logic for --minimal and
--histogram into one callback. This way we can modify `diff_options` in
that function.

As an additional refactor, the logic that sets the diff algorithm in
diff_opt_diff_algorithm() can be refactored into a helper that will
allow multiple callsites to set the diff algorithm.

Signed-off-by: John Cai <johncai86@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
15 months agorebase -i: check labels and refs when parsing todo list
Phillip Wood [Mon, 20 Feb 2023 14:19:34 +0000 (14:19 +0000)] 
rebase -i: check labels and refs when parsing todo list

Check that the argument to the "label" and "update-ref" commands is a
valid refname when the todo list is parsed rather than waiting until the
command is executed. This means that the user can deal with any errors
at the beginning of the rebase rather than having it stop halfway
through due to a typo in a label name. The "update-ref" command is
changed to reject single level refs as it is all to easy to type
"update-ref branch" which is incorrect rather than "update-ref
refs/heads/branch"

Note that it is not straight forward to check the arguments to "reset"
and "merge" commands as they may be any revision, not just a refname and
we do not have an equivalent of check_refname_format() for revisions.

Helped-by: Derrick Stolee <derrickstolee@github.com>
Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>
Acked-by: Derrick Stolee <derrickstolee@github.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
15 months agodelta-islands: fix segfault when freeing island marks
Patrick Steinhardt [Thu, 16 Feb 2023 10:29:48 +0000 (11:29 +0100)] 
delta-islands: fix segfault when freeing island marks

In 647982bb71 (delta-islands: free island_marks and bitmaps, 2023-02-03)
we have introduced logic to free `island_marks` in order to reduce heap
memory usage in git-pack-objects(1). This commit is causing segfaults in
the case where this Git command does not load delta islands at all, e.g.
when reading object IDs from standard input. One such crash can be hit
when using repacking multi-pack-indices with delta islands enabled.

The root cause of this bug is that we unconditionally dereference the
`island_marks` variable even in the case where it is a `NULL` pointer,
which is fixed by making it conditional. Note that we still leave the
logic in place to set the pointer to `-1` to detect use-after-free bugs
even when there are no loaded island marks at all.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Acked-by: Eric Wong <e@80x24.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
15 months agoarchive: add --mtime
René Scharfe [Sat, 18 Feb 2023 08:36:23 +0000 (09:36 +0100)] 
archive: add --mtime

Allow users to specify the modification time of archive entries.  The
new option --mtime uses approxidate() to parse a time specification and
overrides the default of using the current time for trees and the commit
time for tags and commits.  It can be used to create a reproducible
archive for a tree, or to use a specific mtime without creating a commit
with GIT_COMMITTER_DATE set.

This implementation doesn't support the negated form of the new option,
i.e. --no-mtime is not accepted.  It is not possible to have no mtime at
all.  We could use the Unix epoch or revert to the default behavior, but
since negation is not necessary for the intended use it's left undecided
for now.

Requested-by: Raul E Rangel <rrangel@chromium.org>
Suggested-by: demerphq <demerphq@gmail.com>
Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
15 months agoformat.attach: allow empty value to disable multi-part messages
Junio C Hamano [Fri, 17 Feb 2023 23:33:37 +0000 (15:33 -0800)] 
format.attach: allow empty value to disable multi-part messages

When a lower precedence configuration file (e.g. /etc/gitconfig)
defines format.attach in any way, there was no way to disable it in
a more specific configuration file (e.g. $HOME/.gitconfig).

Change the behaviour of setting it to an empty string.  It used to
mean that the result is still a multipart message with only dashes
used as a multi-part separator, but now it resets the setting to
the default (which would be to give an inline patch, unless other
command line options are in effect).

Signed-off-by: Junio C Hamano <gitster@pobox.com>
15 months agot0066: drop setup of "dir5"
Jeff King [Fri, 17 Feb 2023 00:40:29 +0000 (19:40 -0500)] 
t0066: drop setup of "dir5"

The symlink setup in t0066 makes several directories with links, dir4
through dir6. But ever since dir5 was introduced in fa1da7d2ee
(dir-iterator: add flags parameter to dir_iterator_begin, 2019-07-10),
it has never actually been used. It was left over from an earlier
iteration of the patch which tried to handle recursive symlinks
specially, as seen in:

  https://lore.kernel.org/git/20190502144829.4394-7-matheus.bernardino@usp.br/

It's not hurting any of the existing tests to be there, but the extra
setup is confusing to anybody trying to read and understand the tests.
Let's drop the extra directory, and we'll rename "dir6" to "dir5" so
nobody wonders whether the gap in naming is important.

Helped-by: Matheus Tavares Bernardino <matheus.tavb@gmail.com>
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
15 months agoadd basic http proxy tests
Jeff King [Thu, 16 Feb 2023 20:56:32 +0000 (15:56 -0500)] 
add basic http proxy tests

We do not test our http proxy functionality at all in the test suite, so
this is a pretty big blind spot. Let's at least add a basic check that
we can go through an authenticating proxy to perform a clone.

A few notes on the implementation:

  - I'm using a single apache instance to proxy to itself. This seems to
    work fine in practice, and we can check with a test that this rather
    unusual setup is doing what we expect.

  - I've put the proxy tests into their own script, and it's the only
    one which loads the apache proxy config. If any platform can't
    handle this (e.g., doesn't have the right modules), the start_httpd
    step should fail and gracefully skip the rest of the script (but all
    the other http tests in existing scripts will continue to run).

  - I used a separate passwd file to make sure we don't ever get
    confused between proxy and regular auth credentials. It's using the
    antiquated crypt() format. This is a terrible choice security-wise
    in the modern age, but it's what our existing passwd file uses, and
    should be portable. It would probably be reasonable to switch both
    of these to bcrypt, but we can do that in a separate patch.

  - On the client side, we test two situations with credentials: when
    they are present in the url, and when the username is present but we
    prompt for the password. I think we should be able to handle the
    case that _neither_ is present, but an HTTP 407 causes us to prompt
    for them. However, this doesn't seem to work. That's either a bug,
    or at the very least an opportunity for a feature, but I punted on
    it for now. The point of this patch is just getting basic coverage,
    and we can explore possible deficiencies later.

  - this doesn't work with LIB_HTTPD_SSL. This probably would be
    valuable to have, as https over an http proxy is totally different
    (it uses CONNECT to tunnel the session). But adding in
    mod_proxy_connect and some basic config didn't seem to work for me,
    so I punted for now. Much of the rest of the test suite does not
    currently work with LIB_HTTPD_SSL either, so we shouldn't be making
    anything much worse here.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
15 months agodir-iterator: drop unused `DIR_ITERATOR_FOLLOW_SYMLINKS`
Taylor Blau [Thu, 16 Feb 2023 18:27:14 +0000 (13:27 -0500)] 
dir-iterator: drop unused `DIR_ITERATOR_FOLLOW_SYMLINKS`

The `FOLLOW_SYMLINKS` flag was added to the dir-iterator API in
fa1da7d2ee (dir-iterator: add flags parameter to dir_iterator_begin,
2019-07-10) in order to follow symbolic links while traversing through a
directory.

`FOLLOW_SYMLINKS` gained its first caller in ff7ccc8c9a (clone: use
dir-iterator to avoid explicit dir traversal, 2019-07-10), but it was
subsequently removed in 6f054f9fb3 (builtin/clone.c: disallow `--local`
clones with symlinks, 2022-07-28).

Since then, we've held on to the code for `DIR_ITERATOR_FOLLOW_SYMLINKS`
in the name of making minimally invasive changes during a security
embargo.

In fact, we even changed the dir-iterator API in bffc762f87
(dir-iterator: prevent top-level symlinks without FOLLOW_SYMLINKS,
2023-01-24) without having any non-test callers of that flag.

Now that we're past those security embargo(s), let's finalize our
cleanup of the `DIR_ITERATOR_FOLLOW_SYMLINKS` code and remove its
implementation since there are no remaining callers.

Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
15 months agotest-genzeros: avoid raw write(2)
Junio C Hamano [Thu, 16 Feb 2023 02:56:14 +0000 (18:56 -0800)] 
test-genzeros: avoid raw write(2)

This test helper feeds 256kB of data at once to a single invocation
of the write(2) system call, which may be too much for some
platforms.

Call our xwrite() wrapper that knows to honor MAX_IO_SIZE limit and
cope with short writes due to EINTR instead, and die a bit more
loudly by calling die_errno() when xwrite() indicates an error.

Reported-by: Randall S. Becker <rsbecker@nexbridge.com>
Helped-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
15 months agorev-list: clarify git-log default date format
Junio C Hamano [Thu, 16 Feb 2023 00:42:25 +0000 (16:42 -0800)] 
rev-list: clarify git-log default date format

The documentation mistakenly said that the default format was
similar to RFC 2822 format and tried to specify it by enumerating
differences, which had two problems:

 * There are some more differences from the 2822 format that are not
   mentioned; worse yet

 * The default format is not modeled after RFC 2822 format at all.
   As can be seen in f80cd783 (date.c: add "show_date()" function.,
   2005-05-06), it is a derivative of ctime(3) format.

Stop saying that it is similar to RFC 2822, and rewrite the
description to explain the format without requiring the reader to
know any other format.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
15 months agoThe sixteenth batch
Junio C Hamano [Thu, 16 Feb 2023 00:08:41 +0000 (16:08 -0800)] 
The sixteenth batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
15 months agoMerge branch 'cw/doc-pushurl-vs-url'
Junio C Hamano [Thu, 16 Feb 2023 01:11:54 +0000 (17:11 -0800)] 
Merge branch 'cw/doc-pushurl-vs-url'

Doc update.

* cw/doc-pushurl-vs-url:
  Documentation: clarify multiple pushurls vs urls

15 months agoMerge branch 'ab/config-h-remove-unused'
Junio C Hamano [Thu, 16 Feb 2023 01:11:54 +0000 (17:11 -0800)] 
Merge branch 'ab/config-h-remove-unused'

Code clean-up.

* ab/config-h-remove-unused:
  config.h: remove unused git_configset_add_parameters()

15 months agoMerge branch 'ab/retire-scripted-add-p'
Junio C Hamano [Thu, 16 Feb 2023 01:11:53 +0000 (17:11 -0800)] 
Merge branch 'ab/retire-scripted-add-p'

Finally retire the scripted "git add -p/-i" implementation and have
everybody use the one reimplemented in C.

* ab/retire-scripted-add-p:
  docs & comments: replace mentions of "git-add--interactive.perl"
  add API: remove run_add_interactive() wrapper function
  add: remove "add.interactive.useBuiltin" & Perl "git add--interactive"

15 months agoMerge branch 'rs/size-t-fixes'
Junio C Hamano [Thu, 16 Feb 2023 01:11:53 +0000 (17:11 -0800)] 
Merge branch 'rs/size-t-fixes'

Type fixes.

* rs/size-t-fixes:
  pack-objects: use strcspn(3) in name_cmp_len()
  read-cache: use size_t for {base,df}_name_compare()

15 months agoMerge branch 'kf/t5000-modernise'
Junio C Hamano [Thu, 16 Feb 2023 01:11:53 +0000 (17:11 -0800)] 
Merge branch 'kf/t5000-modernise'

Test clean-up.

* kf/t5000-modernise:
  t5000: modernise archive and :(glob) test

15 months agoMerge branch 'wl/new-command-doc'
Junio C Hamano [Thu, 16 Feb 2023 01:11:53 +0000 (17:11 -0800)] 
Merge branch 'wl/new-command-doc'

Comment fix.

* wl/new-command-doc:
  new-command.txt: update reference to builtin docs

15 months agoMerge branch 'ar/userdiff-java-update'
Junio C Hamano [Thu, 16 Feb 2023 01:11:52 +0000 (17:11 -0800)] 
Merge branch 'ar/userdiff-java-update'

Userdiff regexp update for Java language.

* ar/userdiff-java-update:
  userdiff: support Java sealed classes
  userdiff: support Java record types
  userdiff: support Java type parameters

15 months agoMerge branch 'po/attributes-text'
Junio C Hamano [Thu, 16 Feb 2023 01:11:52 +0000 (17:11 -0800)] 
Merge branch 'po/attributes-text'

In-tree .gitattributes update to match the way we recommend our
users to mark a file as text.

* po/attributes-text:
  .gitattributes: include `text` attribute for eol attributes

15 months agoMerge branch 'ab/sequencer-unleak'
Junio C Hamano [Thu, 16 Feb 2023 01:11:52 +0000 (17:11 -0800)] 
Merge branch 'ab/sequencer-unleak'

Plug leaks in sequencer subsystem and its users.

* ab/sequencer-unleak:
  commit.c: free() revs.commit in get_fork_point()
  builtin/rebase.c: free() "options.strategy_opts"
  sequencer.c: always free() the "msgbuf" in do_pick_commit()
  builtin/rebase.c: fix "options.onto_name" leak
  builtin/revert.c: move free-ing of "revs" to replay_opts_release()
  sequencer API users: fix get_replay_opts() leaks
  sequencer.c: split up sequencer_remove_state()
  rebase: use "cleanup" pattern in do_interactive_rebase()

15 months agoMerge branch 'ds/bundle-uri-5'
Junio C Hamano [Thu, 16 Feb 2023 01:11:52 +0000 (17:11 -0800)] 
Merge branch 'ds/bundle-uri-5'

The bundle-URI subsystem adds support for creation-token heuristics
to help incremental fetches.

* ds/bundle-uri-5:
  bundle-uri: test missing bundles with heuristic
  bundle-uri: store fetch.bundleCreationToken
  fetch: fetch from an external bundle URI
  bundle-uri: drop bundle.flag from design doc
  clone: set fetch.bundleURI if appropriate
  bundle-uri: download in creationToken order
  bundle-uri: parse bundle.<id>.creationToken values
  bundle-uri: parse bundle.heuristic=creationToken
  t5558: add tests for creationToken heuristic
  bundle: verify using check_connected()
  bundle: test unbundling with incomplete history

15 months agoMerge branch 'cb/grep-fallback-failing-jit'
Junio C Hamano [Thu, 16 Feb 2023 01:11:51 +0000 (17:11 -0800)] 
Merge branch 'cb/grep-fallback-failing-jit'

In an environment where dynamically generated code is prohibited to
run (e.g. SELinux), failure to JIT pcre patterns is expected.  Fall
back to interpreted execution in such a case.

* cb/grep-fallback-failing-jit:
  grep: fall back to interpreter if JIT memory allocation fails

15 months agogpg: do show gpg's error message upon failure
Johannes Schindelin [Wed, 15 Feb 2023 05:58:34 +0000 (05:58 +0000)] 
gpg: do show gpg's error message upon failure

There are few things more frustrating when signing a commit fails than
reading a terse "error: gpg failed to sign the data" message followed by
the unsurprising "fatal: failed to write commit object" message.

In many cases where signing a commit or tag fails, `gpg` actually said
something helpful, on its stderr, and Git even consumed that, but then
keeps mum about it.

Teach Git to stop withholding that rather important information.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
15 months agot7510: add a test case that does not need gpg
Johannes Schindelin [Wed, 15 Feb 2023 05:58:33 +0000 (05:58 +0000)] 
t7510: add a test case that does not need gpg

This test case not only increases test coverage in setups without
working gpg, but also prepares for verifying that the error message of
`gpg.program` is shown upon failure.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
15 months agoshorten_unambiguous_ref(): avoid sscanf()
Jeff King [Wed, 15 Feb 2023 15:16:21 +0000 (10:16 -0500)] 
shorten_unambiguous_ref(): avoid sscanf()

To shorten a fully qualified ref (e.g., taking "refs/heads/foo" to just
"foo"), we munge the usual lookup rules ("refs/heads/%.*s", etc) to drop
the ".*" modifier (so "refs/heads/%s"), and then use sscanf() to match
that against the refname, pulling the "%s" content into a separate
buffer.

This has a few downsides:

  - sscanf("%s") reportedly misbehaves on macOS with some input and
    locale combinations, returning a partial or garbled string. See
    this thread:

      https://lore.kernel.org/git/CAGF3oAcCi+fG12j-1U0hcrWwkF5K_9WhOi6ZPHBzUUzfkrZDxA@mail.gmail.com/

  - scanf's matching of "%s" is greedy. So the "refs/remotes/%s/HEAD"
    rule would never pull "origin" out of "refs/remotes/origin/HEAD".
    Instead it always produced "origin/HEAD", which is redundant with
    the "refs/remotes/%s" rule.

  - scanf in general is an error-prone interface. For example, scanning
    for "%s" will copy bytes into a destination string, which must have
    been correctly sized ahead of time to avoid a buffer overflow. In
    this case, the code is OK (the buffer is pessimistically sized to
    match the original string, which should give us a maximum). But in
    general, we do not want to encourage people to use scanf at all.

So instead, let's note that our lookup rules are not arbitrary format
strings, but all contain exactly one "%.*s" placeholder. We already rely
on this, both for lookup (we feed the lookup format along with exactly
one int/ptr combo to snprintf, etc) and for shortening (we munge "%.*s"
to "%s", and then insist that sscanf() finds exactly one result).

We can parse this manually by just matching the bytes that occur before
and after the "%.*s" placeholder. While we have a few extra lines of
parsing code, the result is arguably simpler, as can skip the
preprocessing step and its tricky memory management entirely.

The in-code comments should explain the parsing strategy, but there's
one subtle change here. The original code allocated a single buffer, and
then overwrote it in each loop iteration, since that's the only option
sscanf() gives us. But our parser can actually return a ptr/len combo
for the matched string, which is all we need (since we just feed it back
to the lookup rules with "%.*s"), and then copy it only when returning
to the caller.

There are a few new tests here, all using symbolic-ref (the code can be
triggered in many ways, but symrefs are convenient in that we don't need
to create a real ref, which avoids any complications from the filesystem
munging the name):

  - the first covers the real-world case which misbehaved on macOS.
    Setting LC_ALL is required to trigger the problem there (since
    otherwise our tests use LC_ALL=C), and hopefully is at worst simply
    ignored on other systems (and doesn't cause libc to complain, etc,
    on systems without that locale).

  - the second covers the "origin/HEAD" case as discussed above, which
    is now fixed

  - the remainder are for "weird" cases that work both before and after
    this patch, but would be easy to get wrong with off-by-one problems
    in the parsing (and came out of discussions and earlier iterations
    of the patch that did get them wrong).

  - absent here are tests of boring, expected-to-work cases like
    "refs/heads/foo", etc. Those are covered all over the test suite
    both explicitly (for-each-ref's refname:short) and implicitly (in
    the output of git-status, etc).

Reported-by: 孟子易 <mengziyi540841@gmail.com>
Helped-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
15 months agoshorten_unambiguous_ref(): use NUM_REV_PARSE_RULES constant
Jeff King [Wed, 15 Feb 2023 15:16:18 +0000 (10:16 -0500)] 
shorten_unambiguous_ref(): use NUM_REV_PARSE_RULES constant

The ref_rev_parse_rules[] array is terminated with a NULL entry, and we
count it and store the result in the local nr_rules variable. But we
don't need to do so; since the array is a constant, we can compute its
size directly. The original code probably didn't do that because it was
written as part of for-each-ref, and saw the array only as a pointer. It
was migrated in 7c2b3029df (make get_short_ref a public function,
2009-04-07) and could have been updated then, but that subtlety was not
noticed.

We even have a constant that represents this value already, courtesy of
60650a48c0 (remote: make refspec follow the same disambiguation rule as
local refs, 2018-08-01), though again, nobody noticed at the time that
it could be used here, too.

The current count-up isn't a big deal, as we need to preprocess that
array anyway. But it will become more cumbersome as we refactor the
shortening code. So let's get rid of it and just use the constant
everywhere.

Note that there are two things here that aren't just simple text
replacements:

  1. We also use nr_rules to see if a previous call has initialized the
     static pre-processing variables. We can just use the scanf_fmts
     pointer to do the same thing, as it is non-NULL only after we've
     done that initialization.

  2. If nr_rules is zero after we've counted it up, we bail from the
     function. This code is unreachable, though, as the set of rules is
     hard-coded and non-empty. And that becomes even more apparent now
     that we are using the constant. So we can drop this conditional
     completely (and ironically, the code would have the same output if
     it _did_ trigger, as we'd simply skip the loop entirely and return
     the whole refname).

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
15 months agoshorten_unambiguous_ref(): avoid integer truncation
Jeff King [Wed, 15 Feb 2023 15:16:14 +0000 (10:16 -0500)] 
shorten_unambiguous_ref(): avoid integer truncation

We parse the shortened name "foo" out of the full refname
"refs/heads/foo", and then assign the result of strlen(short_name) to an
int, which may truncate or wrap to negative.

In practice, this should never happen, as it requires a 2GB refname. And
even somebody trying to do something malicious should at worst end up
with a confused answer (we use the size only to feed back as a
placeholder length to strbuf_addf() to see if there are any collisions
in the lookup rules).

And it may even be impossible to trigger this, as we parse the string
with sscanf(), and stdio formatting functions are not known for handling
large strings well. I didn't test, but I wouldn't be surprised if
sscanf() on many platforms simply reports no match here.

But even if it is not a problem in practice so far, it is worth fixing
for two reasons:

  1. We'll shortly be replacing the sscanf() call with a real parser
     which will handle arbitrary-sized strings.

  2. Assigning strlen() to an int is an anti-pattern that requires
     people to look twice when auditing for real overflow problems.

So we'll make this a size_t. Unfortunately we still have to cast to int
eventually for the strbuf_addf() call, but at least we can localize the
cast there, and check that it will be valid. I used our new cast helper
here, which will just bail completely. That should be OK, as anybody
with a 2GB refname is up to no good, but if we really wanted to, we
could detect it manually and just refuse to shorten the refname.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
15 months agoSync with 'maint'
Junio C Hamano [Tue, 14 Feb 2023 22:17:35 +0000 (14:17 -0800)] 
Sync with 'maint'

15 months agoPrepare for 2.39.3 just in case
Junio C Hamano [Tue, 14 Feb 2023 22:15:23 +0000 (14:15 -0800)] 
Prepare for 2.39.3 just in case

Signed-off-by: Junio C Hamano <gitster@pobox.com>
15 months agoMerge branch 'sk/remove-duplicate-includes' into maint-2.39
Junio C Hamano [Tue, 14 Feb 2023 22:15:57 +0000 (14:15 -0800)] 
Merge branch 'sk/remove-duplicate-includes' into maint-2.39

Code clean-up.

* sk/remove-duplicate-includes:
  git: remove duplicate includes

15 months agoMerge branch 'rs/clarify-error-in-write-loose-object' into maint-2.39
Junio C Hamano [Tue, 14 Feb 2023 22:15:57 +0000 (14:15 -0800)] 
Merge branch 'rs/clarify-error-in-write-loose-object' into maint-2.39

Code clean-up.

* rs/clarify-error-in-write-loose-object:
  object-file: inline write_buffer()

15 months agoMerge branch 'rs/reflog-expiry-cleanup' into maint-2.39
Junio C Hamano [Tue, 14 Feb 2023 22:15:56 +0000 (14:15 -0800)] 
Merge branch 'rs/reflog-expiry-cleanup' into maint-2.39

Code clean-up.

* rs/reflog-expiry-cleanup:
  reflog: clear leftovers in reflog_expiry_cleanup()

15 months agoMerge branch 'rs/clear-commit-marks-cleanup' into maint-2.39
Junio C Hamano [Tue, 14 Feb 2023 22:15:56 +0000 (14:15 -0800)] 
Merge branch 'rs/clear-commit-marks-cleanup' into maint-2.39

Code clean-up.

* rs/clear-commit-marks-cleanup:
  commit: skip already cleared parents in clear_commit_marks_1()

15 months agoMerge branch 'rs/am-parse-options-cleanup' into maint-2.39
Junio C Hamano [Tue, 14 Feb 2023 22:15:56 +0000 (14:15 -0800)] 
Merge branch 'rs/am-parse-options-cleanup' into maint-2.39

Code clean-up.

* rs/am-parse-options-cleanup:
  am: don't pass strvec to apply_parse_options()

15 months agoMerge branch 'jk/server-supports-v2-cleanup' into maint-2.39
Junio C Hamano [Tue, 14 Feb 2023 22:15:55 +0000 (14:15 -0800)] 
Merge branch 'jk/server-supports-v2-cleanup' into maint-2.39

Code clean-up.

* jk/server-supports-v2-cleanup:
  server_supports_v2(): use a separate function for die_on_error

15 months agoMerge branch 'jk/unused-post-2.39' into maint-2.39
Junio C Hamano [Tue, 14 Feb 2023 22:15:55 +0000 (14:15 -0800)] 
Merge branch 'jk/unused-post-2.39' into maint-2.39

Code clean-up around unused function parameters.

* jk/unused-post-2.39:
  userdiff: mark unused parameter in internal callback
  list-objects-filter: mark unused parameters in virtual functions
  diff: mark unused parameters in callbacks
  xdiff: mark unused parameter in xdl_call_hunk_func()
  xdiff: drop unused parameter in def_ff()
  ws: drop unused parameter from ws_blank_line()
  list-objects: drop process_gitlink() function
  blob: drop unused parts of parse_blob_buffer()
  ls-refs: use repository parameter to iterate refs

15 months agoMerge branch 'rj/branch-copy-and-rename' into maint-2.39
Junio C Hamano [Tue, 14 Feb 2023 22:15:55 +0000 (14:15 -0800)] 
Merge branch 'rj/branch-copy-and-rename' into maint-2.39

Fix a pair of bugs in 'git branch'.

* rj/branch-copy-and-rename:
  branch: force-copy a branch to itself via @{-1} is a no-op