git
4 years agoMerge branch 'jk/use-quick-lookup-in-clone-for-tag-following'
Junio C Hamano [Wed, 22 Apr 2020 20:42:50 +0000 (13:42 -0700)] 
Merge branch 'jk/use-quick-lookup-in-clone-for-tag-following'

The logic to auto-follow tags by "git clone --single-branch" was
not careful to avoid lazy-fetching unnecessary tags, which has been
corrected.

* jk/use-quick-lookup-in-clone-for-tag-following:
  clone: use "quick" lookup while following tags

4 years agoMerge branch 'ag/rebase-merge-allow-ff-under-abbrev-command'
Junio C Hamano [Wed, 22 Apr 2020 20:42:50 +0000 (13:42 -0700)] 
Merge branch 'ag/rebase-merge-allow-ff-under-abbrev-command'

"git rebase" with the merge backend did not work well when the
rebase.abbreviateCommands configuration was set.

* ag/rebase-merge-allow-ff-under-abbrev-command:
  t3432: test `--merge' with `rebase.abbreviateCommands = true', too
  sequencer: don't abbreviate a command if it doesn't have a short form

4 years agoMerge branch 'jk/oid-array-cleanups'
Junio C Hamano [Wed, 22 Apr 2020 20:42:49 +0000 (13:42 -0700)] 
Merge branch 'jk/oid-array-cleanups'

Code cleanup.

* jk/oid-array-cleanups:
  oidset: stop referring to sha1-array
  ref-filter: stop referring to "sha1 array"
  bisect: stop referring to sha1_array
  test-tool: rename sha1-array to oid-array
  oid_array: rename source file from sha1-array
  oid_array: use size_t for iteration
  oid_array: use size_t for count and allocation

4 years agoMerge branch 'jm/gitweb-fastcgi-utf8'
Junio C Hamano [Wed, 22 Apr 2020 20:42:49 +0000 (13:42 -0700)] 
Merge branch 'jm/gitweb-fastcgi-utf8'

Gitweb update.

* jm/gitweb-fastcgi-utf8:
  gitweb: fix UTF-8 encoding when using CGI::Fast

4 years agoMerge branch 'jc/allow-strlen-substitution-in-shell-scripts'
Junio C Hamano [Wed, 22 Apr 2020 20:42:48 +0000 (13:42 -0700)] 
Merge branch 'jc/allow-strlen-substitution-in-shell-scripts'

Coding guideline update.

* jc/allow-strlen-substitution-in-shell-scripts:
  CodingGuidelines: allow ${#posix} == strlen($posix)

4 years agoMerge branch 'en/pull-do-not-rebase-after-fast-forwarding'
Junio C Hamano [Wed, 22 Apr 2020 20:42:47 +0000 (13:42 -0700)] 
Merge branch 'en/pull-do-not-rebase-after-fast-forwarding'

"git pull --rebase" tried to run a rebase even after noticing that
the pull results in a fast-forward and no rebase is needed nor
sensible, for the past few years due to a mistake nobody noticed.

* en/pull-do-not-rebase-after-fast-forwarding:
  pull: avoid running both merge and rebase

4 years agoMerge branch 'dl/wrapper-fix-indentation'
Junio C Hamano [Wed, 22 Apr 2020 20:42:46 +0000 (13:42 -0700)] 
Merge branch 'dl/wrapper-fix-indentation'

Coding style fix.

* dl/wrapper-fix-indentation:
  wrapper: indent with tabs

4 years agoMerge branch 'ag/sequencer-i18n-messages'
Junio C Hamano [Wed, 22 Apr 2020 20:42:45 +0000 (13:42 -0700)] 
Merge branch 'ag/sequencer-i18n-messages'

Message fix.

* ag/sequencer-i18n-messages:
  sequencer: mark messages for translation

4 years agoMerge branch 'rs/pull-options-sync-code-and-doc'
Junio C Hamano [Wed, 22 Apr 2020 20:42:45 +0000 (13:42 -0700)] 
Merge branch 'rs/pull-options-sync-code-and-doc'

"git pull" shares many options with underlying "git fetch", but
some of them were not documented and some of those that would make
sense to pass down were not passed down.

* rs/pull-options-sync-code-and-doc:
  pull: pass documented fetch options on
  pull: remove --update-head-ok from documentation

4 years agoMerge branch 'js/walk-doc-optim'
Junio C Hamano [Wed, 22 Apr 2020 20:42:45 +0000 (13:42 -0700)] 
Merge branch 'js/walk-doc-optim'

Code cleanup.

* js/walk-doc-optim:
  MyFirstObjectWalk: remove unnecessary conditional statement

4 years agoMerge branch 'pb/rebase-doc-typofix'
Junio C Hamano [Wed, 22 Apr 2020 20:42:44 +0000 (13:42 -0700)] 
Merge branch 'pb/rebase-doc-typofix'

Typofix.

* pb/rebase-doc-typofix:
  git-rebase.txt: fix typo

4 years agoMerge branch 'jk/p5310-drop-non-bitmap-timing'
Junio C Hamano [Wed, 22 Apr 2020 20:42:44 +0000 (13:42 -0700)] 
Merge branch 'jk/p5310-drop-non-bitmap-timing'

Perf-test update.

* jk/p5310-drop-non-bitmap-timing:
  p5310: stop timing non-bitmap pack-to-disk

4 years agoMerge branch 'jk/harden-protocol-v2-delim-handling'
Junio C Hamano [Wed, 22 Apr 2020 20:42:44 +0000 (13:42 -0700)] 
Merge branch 'jk/harden-protocol-v2-delim-handling'

The server-end of the v2 protocol to serve "git clone" and "git
fetch" was not prepared to see a delim packets at unexpected
places, which led to a crash.

* jk/harden-protocol-v2-delim-handling:
  test-lib-functions: simplify packetize() stdin code
  upload-pack: handle unexpected delim packets
  test-lib-functions: make packetize() more efficient

4 years agoMerge branch 'jk/test-cleanup'
Junio C Hamano [Wed, 22 Apr 2020 20:42:44 +0000 (13:42 -0700)] 
Merge branch 'jk/test-cleanup'

Test cleanup.

* jk/test-cleanup:
  t/lib-*.sh: drop executable bit
  t/lib-credential.sh: drop shebang line

4 years agoMerge branch 'ak/run-command-on-cygwin-fix'
Junio C Hamano [Wed, 22 Apr 2020 20:42:44 +0000 (13:42 -0700)] 
Merge branch 'ak/run-command-on-cygwin-fix'

Utitiles run via the run_command() API were not spawned correctly
on Cygwin, when the paths to them are given as a full path with
backslashes.

* ak/run-command-on-cygwin-fix:
  run-command: trigger PATH lookup properly on Cygwin

4 years agoMerge branch 'dr/midx-avoid-int-underflow'
Junio C Hamano [Wed, 22 Apr 2020 20:42:44 +0000 (13:42 -0700)] 
Merge branch 'dr/midx-avoid-int-underflow'

When fed a midx that records no objects, some codepaths tried to
loop from 0 through (num_objects-1), which, due to integer
arithmetic wrapping around, made it nonsense operation with out of
bounds array accesses.  The code has been corrected to reject such
an midx file.

* dr/midx-avoid-int-underflow:
  midx.c: fix an integer underflow

4 years agoMerge branch 'dl/test-must-fail-fixes-3'
Junio C Hamano [Wed, 22 Apr 2020 20:42:44 +0000 (13:42 -0700)] 
Merge branch 'dl/test-must-fail-fixes-3'

Test clean-up continues.

* dl/test-must-fail-fixes-3:
  t5801: teach compare_refs() to accept !
  t5612: stop losing return codes of git commands
  t5612: don't use `test_must_fail test_cmp`
  t5607: reorder `nongit test_must_fail`
  t5550: simplify no matching line check
  t5512: stop losing return codes of git commands
  t5512: stop losing git exit code in here-docs
  t5512: don't use `test_must_fail test_cmp`

4 years agoMerge branch 'js/trace2-env-vars'
Junio C Hamano [Wed, 22 Apr 2020 20:42:43 +0000 (13:42 -0700)] 
Merge branch 'js/trace2-env-vars'

Trace2 enhancement to allow logging of the environment variables.

* js/trace2-env-vars:
  trace2: teach Git to log environment variables

4 years agoMerge branch 'jt/connectivity-check-optim-in-partial-clone'
Junio C Hamano [Wed, 22 Apr 2020 20:42:43 +0000 (13:42 -0700)] 
Merge branch 'jt/connectivity-check-optim-in-partial-clone'

Simplify the commit ancestry connectedness check in a partial clone
repository in which "promised" objects are assumed to be obtainable
lazily on-demand from promisor remote repositories.

* jt/connectivity-check-optim-in-partial-clone:
  connected: always use partial clone optimization

4 years agoMerge branch 'bc/faq'
Junio C Hamano [Wed, 22 Apr 2020 20:42:43 +0000 (13:42 -0700)] 
Merge branch 'bc/faq'

Doc update.

* bc/faq:
  docs: add a FAQ

4 years agoMerge branch 'bk/p4-pre-edit-changelist'
Junio C Hamano [Wed, 22 Apr 2020 20:42:43 +0000 (13:42 -0700)] 
Merge branch 'bk/p4-pre-edit-changelist'

"git p4" learned four new hooks and also "--no-verify" option to
bypass them (and the existing "p4-pre-submit" hook).

* bk/p4-pre-edit-changelist:
  git-p4: add RCS keyword status message
  git-p4: add p4 submit hooks
  git-p4: restructure code in submit
  git-p4: add --no-verify option
  git-p4: add p4-pre-submit exit text
  git-p4: create new function run_git_hook
  git-p4: rewrite prompt to be Windows compatible

4 years agoMerge branch 'mt/test-lib-bundled-short-options'
Junio C Hamano [Wed, 22 Apr 2020 20:42:43 +0000 (13:42 -0700)] 
Merge branch 'mt/test-lib-bundled-short-options'

Minor test usability improvement.

* mt/test-lib-bundled-short-options:
  test-lib: allow short options to be bundled

4 years agoMerge branch 'js/import-tars-do-not-make-phony-files-from-pax-headers'
Junio C Hamano [Wed, 22 Apr 2020 20:42:43 +0000 (13:42 -0700)] 
Merge branch 'js/import-tars-do-not-make-phony-files-from-pax-headers'

The import-tars importer (in contrib/fast-import/) used to create
phony files at the top-level of the repository when the archive
contains global PAX headers, which made its own logic to detect and
omit the common leading directory ineffective, which has been
corrected.

* js/import-tars-do-not-make-phony-files-from-pax-headers:
  import-tars: ignore the global PAX header

4 years agoMerge branch 'js/test-junit-finalization-fix'
Junio C Hamano [Wed, 22 Apr 2020 20:42:43 +0000 (13:42 -0700)] 
Merge branch 'js/test-junit-finalization-fix'

Test fix.

* js/test-junit-finalization-fix:
  tests(junit-xml): avoid invalid XML

4 years agoMerge branch 'js/tests-gpg-integration-on-windows'
Junio C Hamano [Wed, 22 Apr 2020 20:42:42 +0000 (13:42 -0700)] 
Merge branch 'js/tests-gpg-integration-on-windows'

Enable tests that require GnuPG on Windows.

* js/tests-gpg-integration-on-windows:
  tests: increase the verbosity of the GPG-related prereqs
  tests: turn GPG, GPGSM and RFC1991 into lazy prereqs
  tests: do not let lazy prereqs inside `test_expect_*` turn off tracing
  t/lib-gpg.sh: stop pretending to be a stand-alone script
  tests(gpg): allow the gpg-agent to start on Windows

4 years agoMerge branch 'jk/t3419-drop-expensive-tests'
Junio C Hamano [Wed, 22 Apr 2020 20:42:42 +0000 (13:42 -0700)] 
Merge branch 'jk/t3419-drop-expensive-tests'

Test update.

* jk/t3419-drop-expensive-tests:
  t3419: drop EXPENSIVE tests

4 years agoMerge branch 'ds/doc-clone-filter'
Junio C Hamano [Wed, 22 Apr 2020 20:42:42 +0000 (13:42 -0700)] 
Merge branch 'ds/doc-clone-filter'

Doc update.

* ds/doc-clone-filter:
  clone: document --filter options

4 years agoMerge branch 'ar/test-style-fixes'
Junio C Hamano [Wed, 22 Apr 2020 20:42:42 +0000 (13:42 -0700)] 
Merge branch 'ar/test-style-fixes'

Style fixes.

* ar/test-style-fixes:
  t: fix whitespace around &&
  t9500: remove spaces after redirect operators

4 years agoSync with 2.26.2
Junio C Hamano [Mon, 20 Apr 2020 05:05:56 +0000 (22:05 -0700)] 
Sync with 2.26.2

4 years agoGit 2.26.2 v2.26.2
Jonathan Nieder [Sun, 19 Apr 2020 23:32:24 +0000 (16:32 -0700)] 
Git 2.26.2

This merges up the security fix from v2.17.5.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
4 years agoGit 2.25.4 v2.25.4
Jonathan Nieder [Sun, 19 Apr 2020 23:31:07 +0000 (16:31 -0700)] 
Git 2.25.4

This merges up the security fix from v2.17.5.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
4 years agoGit 2.24.3 v2.24.3
Jonathan Nieder [Sun, 19 Apr 2020 23:30:34 +0000 (16:30 -0700)] 
Git 2.24.3

This merges up the security fix from v2.17.5.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
4 years agoGit 2.23.3 v2.23.3
Jonathan Nieder [Sun, 19 Apr 2020 23:30:27 +0000 (16:30 -0700)] 
Git 2.23.3

This merges up the security fix from v2.17.5.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
4 years agoGit 2.22.4 v2.22.4
Jonathan Nieder [Sun, 19 Apr 2020 23:30:19 +0000 (16:30 -0700)] 
Git 2.22.4

This merges up the security fix from v2.17.5.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
4 years agoGit 2.21.3 v2.21.3
Jonathan Nieder [Sun, 19 Apr 2020 23:30:08 +0000 (16:30 -0700)] 
Git 2.21.3

This merges up the security fix from v2.17.5.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
4 years agoGit 2.20.4 v2.20.4
Jonathan Nieder [Sun, 19 Apr 2020 23:28:57 +0000 (16:28 -0700)] 
Git 2.20.4

This merges up the security fix from v2.17.5.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
4 years agoGit 2.19.5 v2.19.5
Jonathan Nieder [Sun, 19 Apr 2020 23:26:41 +0000 (16:26 -0700)] 
Git 2.19.5

This merges up the security fix from v2.17.5.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
4 years agoGit 2.18.4 v2.18.4
Jonathan Nieder [Sun, 19 Apr 2020 23:24:14 +0000 (16:24 -0700)] 
Git 2.18.4

This merges up the security fix from v2.17.5.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
4 years agoGit 2.17.5 v2.17.5
Jeff King [Sun, 19 Apr 2020 06:34:55 +0000 (02:34 -0400)] 
Git 2.17.5

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
4 years agofsck: reject URL with empty host in .gitmodules
Jonathan Nieder [Sun, 19 Apr 2020 03:57:22 +0000 (20:57 -0700)] 
fsck: reject URL with empty host in .gitmodules

Git's URL parser interprets

https:///example.com/repo.git

to have no host and a path of "example.com/repo.git".  Curl, on the
other hand, internally redirects it to https://example.com/repo.git.  As
a result, until "credential: parse URL without host as empty host, not
unset", tricking a user into fetching from such a URL would cause Git to
send credentials for another host to example.com.

Teach fsck to block and detect .gitmodules files using such a URL to
prevent sharing them with Git versions that are not yet protected.

A relative URL in a .gitmodules file could also be used to trigger this.
The relative URL resolver used for .gitmodules does not normalize
sequences of slashes and can follow ".." components out of the path part
and to the host part of a URL, meaning that such a relative URL can be
used to traverse from a https://foo.example.com/innocent superproject to
a https:///attacker.example.com/exploit submodule. Fortunately,
redundant extra slashes in .gitmodules are rare, so we can catch this by
detecting one after a leading sequence of "./" and "../" components.

Helped-by: Jeff King <peff@peff.net>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Reviewed-by: Jeff King <peff@peff.net>
4 years agocredential: treat URL with empty scheme as invalid
Jonathan Nieder [Sun, 19 Apr 2020 03:54:57 +0000 (20:54 -0700)] 
credential: treat URL with empty scheme as invalid

Until "credential: refuse to operate when missing host or protocol",
Git's credential handling code interpreted URLs with empty scheme to
mean "give me credentials matching this host for any protocol".

Luckily libcurl does not recognize such URLs (it tries to look for a
protocol named "" and fails). Just in case that changes, let's reject
them within Git as well. This way, credential_from_url is guaranteed to
always produce a "struct credential" with protocol and host set.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
4 years agocredential: treat URL without scheme as invalid
Jonathan Nieder [Sun, 19 Apr 2020 03:54:13 +0000 (20:54 -0700)] 
credential: treat URL without scheme as invalid

libcurl permits making requests without a URL scheme specified.  In
this case, it guesses the URL from the hostname, so I can run

git ls-remote http::ftp.example.com/path/to/repo

and it would make an FTP request.

Any user intentionally using such a URL is likely to have made a typo.
Unfortunately, credential_from_url is not able to determine the host and
protocol in order to determine appropriate credentials to send, and
until "credential: refuse to operate when missing host or protocol",
this resulted in another host's credentials being leaked to the named
host.

Teach credential_from_url_gently to consider such a URL to be invalid
so that fsck can detect and block gitmodules files with such URLs,
allowing server operators to avoid serving them to downstream users
running older versions of Git.

This also means that when such URLs are passed on the command line, Git
will print a clearer error so affected users can switch to the simpler
URL that explicitly specifies the host and protocol they intend.

One subtlety: .gitmodules files can contain relative URLs, representing
a URL relative to the URL they were cloned from.  The relative URL
resolver used for .gitmodules can follow ".." components out of the path
part and past the host part of a URL, meaning that such a relative URL
can be used to traverse from a https://foo.example.com/innocent
superproject to a https::attacker.example.com/exploit submodule.
Fortunately a leading ':' in the first path component after a series of
leading './' and '../' components is unlikely to show up in other
contexts, so we can catch this by detecting that pattern.

Reported-by: Jeff King <peff@peff.net>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Reviewed-by: Jeff King <peff@peff.net>
4 years agocredential: die() when parsing invalid urls
Jeff King [Sun, 19 Apr 2020 03:53:09 +0000 (20:53 -0700)] 
credential: die() when parsing invalid urls

When we try to initialize credential loading by URL and find that the
URL is invalid, we set all fields to NULL in order to avoid acting on
malicious input. Later when we request credentials, we diagonse the
erroneous input:

fatal: refusing to work with credential missing host field

This is problematic in two ways:

- The message doesn't tell the user *why* we are missing the host
  field, so they can't tell from this message alone how to recover.
  There can be intervening messages after the original warning of
  bad input, so the user may not have the context to put two and two
  together.

- The error only occurs when we actually need to get a credential.  If
  the URL permits anonymous access, the only encouragement the user gets
  to correct their bogus URL is a quiet warning.

  This is inconsistent with the check we perform in fsck, where any use
  of such a URL as a submodule is an error.

When we see such a bogus URL, let's not try to be nice and continue
without helpers. Instead, die() immediately. This is simpler and
obviously safe. And there's very little chance of disrupting a normal
workflow.

It's _possible_ that somebody has a legitimate URL with a raw newline in
it. It already wouldn't work with credential helpers, so this patch
steps that up from an inconvenience to "we will refuse to work with it
at all". If such a case does exist, we should figure out a way to work
with it (especially if the newline is only in the path component, which
we normally don't even pass to helpers). But until we see a real report,
we're better off being defensive.

Reported-by: Carlo Arenas <carenas@gmail.com>
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
4 years agofsck: convert gitmodules url to URL passed to curl
Jonathan Nieder [Sun, 19 Apr 2020 03:52:34 +0000 (20:52 -0700)] 
fsck: convert gitmodules url to URL passed to curl

In 07259e74ec1 (fsck: detect gitmodules URLs with embedded newlines,
2020-03-11), git fsck learned to check whether URLs in .gitmodules could
be understood by the credential machinery when they are handled by
git-remote-curl.

However, the check is overbroad: it checks all URLs instead of only
URLs that would be passed to git-remote-curl. In principle a git:// or
file:/// URL does not need to follow the same conventions as an http://
URL; in particular, git:// and file:// protocols are not succeptible to
issues in the credential API because they do not support attaching
credentials.

In the HTTP case, the URL in .gitmodules does not always match the URL
that would be passed to git-remote-curl and the credential machinery:
Git's URL syntax allows specifying a remote helper followed by a "::"
delimiter and a URL to be passed to it, so that

git ls-remote http::https://example.com/repo.git

invokes git-remote-http with https://example.com/repo.git as its URL
argument. With today's checks, that distinction does not make a
difference, but for a check we are about to introduce (for empty URL
schemes) it will matter.

.gitmodules files also support relative URLs. To ensure coverage for the
https based embedded-newline attack, urldecode and check them directly
for embedded newlines.

Helped-by: Jeff King <peff@peff.net>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Reviewed-by: Jeff King <peff@peff.net>
4 years agocredential: refuse to operate when missing host or protocol
Jeff King [Sun, 19 Apr 2020 03:50:48 +0000 (20:50 -0700)] 
credential: refuse to operate when missing host or protocol

The credential helper protocol was designed to be very flexible: the
fields it takes as input are treated as a pattern, and any missing
fields are taken as wildcards. This allows unusual things like:

  echo protocol=https | git credential reject

to delete all stored https credentials (assuming the helpers themselves
treat the input that way). But when helpers are invoked automatically by
Git, this flexibility works against us. If for whatever reason we don't
have a "host" field, then we'd match _any_ host. When you're filling a
credential to send to a remote server, this is almost certainly not what
you want.

Prevent this at the layer that writes to the credential helper. Add a
check to the credential API that the host and protocol are always passed
in, and add an assertion to the credential_write function that speaks
credential helper protocol to be doubly sure.

There are a few ways this can be triggered in practice:

  - the "git credential" command passes along arbitrary credential
    parameters it reads from stdin.

  - until the previous patch, when the host field of a URL is empty, we
    would leave it unset (rather than setting it to the empty string)

  - a URL like "example.com/foo.git" is treated by curl as if "http://"
    was present, but our parser sees it as a non-URL and leaves all
    fields unset

  - the recent fix for URLs with embedded newlines blanks the URL but
    otherwise continues. Rather than having the desired effect of
    looking up no credential at all, many helpers will return _any_
    credential

Our earlier test for an embedded newline didn't catch this because it
only checked that the credential was cleared, but didn't configure an
actual helper. Configuring the "verbatim" helper in the test would show
that it is invoked (it's obviously a silly helper which doesn't look at
its input, but the point is that it shouldn't be run at all). Since
we're switching this case to die(), we don't need to bother with a
helper. We can see the new behavior just by checking that the operation
fails.

We'll add new tests covering partial input as well (these can be
triggered through various means with url-parsing, but it's simpler to
just check them directly, as we know we are covered even if the url
parser changes behavior in the future).

[jn: changed to die() instead of logging and showing a manual
 username/password prompt]

Reported-by: Carlo Arenas <carenas@gmail.com>
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
4 years agocredential: parse URL without host as empty host, not unset
Jeff King [Sun, 19 Apr 2020 03:48:05 +0000 (20:48 -0700)] 
credential: parse URL without host as empty host, not unset

We may feed a URL like "cert:///path/to/cert.pem" into the credential
machinery to get the key for a client-side certificate. That
credential has no hostname field, which is about to be disallowed (to
avoid confusion with protocols where a helper _would_ expect a
hostname).

This means as of the next patch, credential helpers won't work for
unlocking certs. Let's fix that by doing two things:

  - when we parse a url with an empty host, set the host field to the
    empty string (asking only to match stored entries with an empty
    host) rather than NULL (asking to match _any_ host).

  - when we build a cert:// credential by hand, similarly assign an
    empty string

It's the latter that is more likely to impact real users in practice,
since it's what's used for http connections. But we don't have good
infrastructure to test it.

The url-parsing version will help anybody using git-credential in a
script, and is easy to test.

Signed-off-by: Jeff King <peff@peff.net>
Reviewed-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
4 years agot0300: use more realistic inputs
Jeff King [Sun, 19 Apr 2020 03:47:30 +0000 (20:47 -0700)] 
t0300: use more realistic inputs

Many of the tests in t0300 give partial inputs to git-credential,
omitting a protocol or hostname. We're checking only high-level things
like whether and how helpers are invoked at all, and we don't care about
specific hosts. However, in preparation for tightening up the rules
about when we're willing to run a helper, let's start using input that's
a bit more realistic: pretend as if http://example.com is being
examined.

This shouldn't change the point of any of the tests, but do note we have
to adjust the expected output to accommodate this (filling a credential
will repeat back the protocol/host fields to stdout, and the helper
debug messages and askpass prompt will change on stderr).

Signed-off-by: Jeff King <peff@peff.net>
Reviewed-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
4 years agot0300: make "quit" helper more realistic
Jeff King [Sun, 19 Apr 2020 05:36:02 +0000 (01:36 -0400)] 
t0300: make "quit" helper more realistic

We test a toy credential helper that writes "quit=1" and confirms that
we stop running other helpers. However, that helper is unrealistic in
that it does not bother to read its stdin at all.

For now we don't send any input to it, because we feed git-credential a
blank credential. But that will change in the next patch, which will
cause this test to racily fail, as git-credential will get SIGPIPE
writing to the helper rather than exiting because it was asked to.

Let's make this one-off helper more like our other sample helpers, and
have it source the "dump" script. That will read stdin, fixing the
SIGPIPE problem. But it will also write what it sees to stderr. We can
make the test more robust by checking that output, which confirms that
we do run the quit helper, don't run any other helpers, and exit for the
reason we expected.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
4 years agoSync with v2.26.1
Junio C Hamano [Tue, 14 Apr 2020 01:40:10 +0000 (18:40 -0700)] 
Sync with v2.26.1

4 years agoclone: use "quick" lookup while following tags
Jeff King [Wed, 1 Apr 2020 12:15:37 +0000 (08:15 -0400)] 
clone: use "quick" lookup while following tags

When cloning with --single-branch, we implement git-fetch's usual
tag-following behavior, grabbing any tag objects that point to objects
we have locally.

When we're a partial clone, though, our has_object_file() check will
actually lazy-fetch each tag. That not only defeats the purpose of
--single-branch, but it does it incredibly slowly, potentially kicking
off a new fetch for each tag. This is even worse for a shallow clone,
which implies --single-branch, because even tags which are supersets of
each other will be fetched individually.

We can fix this by passing OBJECT_INFO_SKIP_FETCH_OBJECT to the call,
which is what git-fetch does in this case.

Likewise, let's include OBJECT_INFO_QUICK, as that's what git-fetch
does. The rationale is discussed in 5827a03545 (fetch: use "quick"
has_sha1_file for tag following, 2016-10-13), but here the tradeoff
would apply even more so because clone is very unlikely to be racing
with another process repacking our newly-created repository.

This may provide a very small speedup even in the non-partial case case,
as we'd avoid calling reprepare_packed_git() for each tag (though in
practice, we'd only have a single packfile, so that reprepare should be
quite cheap).

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agot3432: test `--merge' with `rebase.abbreviateCommands = true', too
Alban Gruin [Mon, 30 Mar 2020 12:42:36 +0000 (14:42 +0200)] 
t3432: test `--merge' with `rebase.abbreviateCommands = true', too

When fast forwarding, `git --merge' should act the same whether
`rebase.abbreviateCommands' is set or not, but so far it was not the
case.  This duplicates the tests ensuring that `--merge' works when fast
forwarding to check if it also works with abbreviated commands.

Signed-off-by: Alban Gruin <alban.gruin@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agosequencer: don't abbreviate a command if it doesn't have a short form
Alban Gruin [Mon, 30 Mar 2020 12:42:35 +0000 (14:42 +0200)] 
sequencer: don't abbreviate a command if it doesn't have a short form

When the sequencer is requested to abbreviate commands, it will replace
those that do not have a short form (eg. `noop') by a comment mark.
`noop' serves no purpose, except when fast-forwarding (ie. by running
`git rebase').  Removing it will break this command when
`rebase.abbreviateCommands' is set to true.

Teach todo_list_to_strbuf() to check if a command has an actual
short form, and to ignore it if not.

Signed-off-by: Alban Gruin <alban.gruin@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agoMyFirstObjectWalk: remove unnecessary conditional statement
Johannes Schindelin [Sat, 28 Mar 2020 15:19:13 +0000 (15:19 +0000)] 
MyFirstObjectWalk: remove unnecessary conditional statement

In the given example, `commit` cannot be `NULL` (because this is the
loop condition: if it was `NULL`, the loop body would not be entered at
all). It took this developer a moment or two to see that this is
therefore dead code.

Let's remove it, to avoid puzzling future readers.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Reviewed-by: Emily Shaffer <emilyshaffer@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agooidset: stop referring to sha1-array
Jeff King [Mon, 30 Mar 2020 14:04:13 +0000 (10:04 -0400)] 
oidset: stop referring to sha1-array

Ths has been oid_array for some time, though the source only recently
moved from sha1-array.[ch] to oid-array.[ch]. In either case, we should
say "oid-array" here.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agoref-filter: stop referring to "sha1 array"
Jeff King [Mon, 30 Mar 2020 14:04:11 +0000 (10:04 -0400)] 
ref-filter: stop referring to "sha1 array"

A comment refers to the "sha1s in the given sha1 array". But this became
an oid_array along with everywhere else in 910650d2f8 (Rename sha1_array
to oid_array, 2017-03-31). Plus there's an extra line of leftover
editing cruft we can drop.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agobisect: stop referring to sha1_array
Jeff King [Mon, 30 Mar 2020 14:04:06 +0000 (10:04 -0400)] 
bisect: stop referring to sha1_array

Our join_sha1_array_hex() function long ago switched to using an
oid_array; let's change the name to match.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agotest-tool: rename sha1-array to oid-array
Jeff King [Mon, 30 Mar 2020 14:04:03 +0000 (10:04 -0400)] 
test-tool: rename sha1-array to oid-array

This matches the actual data structure name, as well as the source file
that contains the code we're testing. The test scripts need updating to
use the new name, as well.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agooid_array: rename source file from sha1-array
Jeff King [Mon, 30 Mar 2020 14:03:46 +0000 (10:03 -0400)] 
oid_array: rename source file from sha1-array

We renamed the actual data structure in 910650d2f8 (Rename sha1_array to
oid_array, 2017-03-31), but the file is still called sha1-array. Besides
being slightly confusing, it makes it more annoying to grep for leftover
occurrences of "sha1" in various files, because the header is included
in so many places.

Let's complete the transition by renaming the source and header files
(and fixing up a few comment references).

I kept the "-" in the name, as that seems to be our style; cf.
fc1395f4a4 (sha1_file.c: rename to use dash in file name, 2018-04-10).
We also have oidmap.h and oidset.h without any punctuation, but those
are "struct oidmap" and "struct oidset" in the code. We _could_ make
this "oidarray" to match, but somehow it looks uglier to me because of
the length of "array" (plus it would be a very invasive patch for little
gain).

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agooid_array: use size_t for iteration
Jeff King [Mon, 30 Mar 2020 14:03:20 +0000 (10:03 -0400)] 
oid_array: use size_t for iteration

The previous commit started using size_t for our allocations. There are
some iterations that use int or unsigned, though. These aren't dangerous
with respect to memory, but they could produce incorrect results.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agooid_array: use size_t for count and allocation
Jeff King [Mon, 30 Mar 2020 14:03:09 +0000 (10:03 -0400)] 
oid_array: use size_t for count and allocation

The oid_array object uses an "int" to store the number of items and the
allocated size. It's rather unlikely for somebody to have more than 2^31
objects in a repository (the sha1's alone would be 40GB!), but if they
do, we'd overflow our alloc variable.

You can reproduce this case with something like:

  git init repo
  cd repo

  # make a pack with 2^24 objects
  perl -e '
    my $nr = 2**24;

    for (my $i = 0; $i < $nr; $i++) {
    print "blob\n";
    print "data 4\n";
    print pack("N", $i);
    }
  ' | git fast-import

  # now make 256 copies of it; most of these objects will be duplicates,
  # but oid_array doesn't de-dup until all values are read and it can
  # sort the result.
  cd .git/objects/pack/
  pack=$(echo *.pack)
  idx=$(echo *.idx)
  for i in $(seq 0 255); do
    # no need to waste disk space
    ln "$pack" "pack-extra-$i.pack"
    ln "$idx" "pack-extra-$i.idx"
  done

  # and now force an oid_array to store all of it
  git cat-file --batch-all-objects --batch-check

which results in:

  fatal: size_t overflow: 32 * 18446744071562067968

So the good news is that st_mult() sees the problem (the large number is
because our int wraps negative, and then that gets cast to a size_t),
doing the job it was meant to: bailing in crazy situations rather than
causing an undersized buffer.

But we should avoid hitting this case at all, and instead limit
ourselves based on what malloc() is willing to give us. We can easily do
that by switching to size_t.

The cat-file process above made it to ~120GB virtual set size before the
integer overflow (our internal hash storage is 32-bytes now in
preparation for sha256, so we'd expect ~128GB total needed, plus
potentially more to copy from one realloc'd block to another)). After
this patch (and about 130GB of RAM+swap), it does eventually read in the
whole set. No test for obvious reasons.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agodocs: add a FAQ
brian m. carlson [Mon, 30 Mar 2020 11:55:18 +0000 (11:55 +0000)] 
docs: add a FAQ

Git is an enormously flexible and powerful piece of software.  However,
it can be intimidating for many users and there are a set of common
questions that users often ask.  While we already have some new user
documentation, it's worth adding a FAQ to address common questions that
users often have.  Even though some of this is addressed elsewhere in
the documentation, experience has shown that it is difficult for users
to find, so a centralized location is helpful.

Add such a FAQ and fill it with some common questions and answers.
While there are few entries now, we can expand it in the future to cover
more things as we find new questions that users have.  Let's also add
section markers so that people answering questions can directly link
users to the proper answer.

The FAQ also addresses common configuration questions that apply not
only to Git as an independent piece of software but also the ecosystem
of CI tools and hosting providers that people use, since these are the
source of common questions.  An attempt has been made to avoid
mentioning any particular provider or tool, but to nevertheless cover
common configurations that apply to a wide variety of such tools.

Note that the long lines for certain questions are required, since
Asciidoctor does not permit broken lines there.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agoconnected: always use partial clone optimization
Jonathan Tan [Fri, 20 Mar 2020 22:00:45 +0000 (15:00 -0700)] 
connected: always use partial clone optimization

With 50033772d5 ("connected: verify promisor-ness of partial clone",
2020-01-30), the fast path (checking promisor packs) in
check_connected() now passes a subset of the slow path (rev-list) - if
all objects to be checked are found in promisor packs, both the fast
path and the slow path will pass; otherwise, the fast path will
definitely not pass. This means that we can always attempt the fast path
whenever we need to do the slow path.

The fast path is currently guarded by a flag; therefore, remove that
flag. Also, make the fast path fallback to the slow path - if the fast
path fails, the failing OID and all remaining OIDs will be passed to
rev-list.

The main user-visible benefit is the performance of fetch from a partial
clone - specifically, the speedup of the connectivity check done before
the fetch. In particular, a no-op fetch into a partial clone on my
computer was sped up from 7 seconds to 0.01 seconds. This is a
complement to the work in 2df1aa239c ("fetch: forgo full
connectivity check if --filter", 2020-01-30), which is the child of the
aforementioned 50033772d5. In that commit, the connectivity check
*after* the fetch was sped up.

The addition of the fast path might cause performance reductions in
these cases:

 - If a partial clone or a fetch into a partial clone fails, Git will
   fruitlessly run rev-list (it is expected that everything fetched
   would go into promisor packs, so if that didn't happen, it is most
   likely that rev-list will fail too).

 - Any connectivity checks done by receive-pack, in the (in my opinion,
   unlikely) event that a partial clone serves receive-pack.

I think that these cases are rare enough, and the performance reduction
in this case minor enough (additional object DB access), that the
benefit of avoiding a flag outweighs these.

Signed-off-by: Jonathan Tan <jonathantanmy@google.com>
Reviewed-by: Josh Steadmon <steadmon@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agoMerge branch 'ds/default-pack-use-sparse-to-true'
Junio C Hamano [Sun, 29 Mar 2020 16:32:51 +0000 (09:32 -0700)] 
Merge branch 'ds/default-pack-use-sparse-to-true'

The 'pack.useSparse' configuration variable now defaults to 'true',
enabling an optimization that has been experimental since Git 2.21.

* ds/default-pack-use-sparse-to-true:
  pack-objects: flip the use of GIT_TEST_PACK_SPARSE
  config: set pack.useSparse=true by default

4 years agogitweb: fix UTF-8 encoding when using CGI::Fast
Julien Moutinho [Sun, 29 Mar 2020 00:20:28 +0000 (01:20 +0100)] 
gitweb: fix UTF-8 encoding when using CGI::Fast

FCGI streams are implemented using the older stream API: TIEHANDLE,
therefore applying PerlIO layers using binmode() has no effect to them.
The solution in this patch is to redefine the FCGI::Stream::PRINT function
to use UTF-8 as output encoding, except within git_blob_plain() and git_snapshot()
which must still output in raw binary mode.

This problem and solution were previously reported back in 2012:
- http://git.661346.n2.nabble.com/Gitweb-running-as-FCGI-does-not-print-its-output-in-UTF-8-td7573415.html
- http://stackoverflow.com/questions/5005104

Signed-off-by: Julien Moutinho <julm+git@sourcephile.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agotest-lib-functions: simplify packetize() stdin code
Jeff King [Sun, 29 Mar 2020 15:02:26 +0000 (11:02 -0400)] 
test-lib-functions: simplify packetize() stdin code

The code path in packetize() for reading stdin needs to handle NUL
bytes, so we can't rely on shell variables. However, the current code
takes a whopping 4 processes and uses a temporary file. We can do this
much more simply and efficiently by using a single perl invocation (and
we already rely on perl in the matching depacketize() function).

We'll keep the non-stdin code path as it is, since that uses zero extra
processes.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agoCodingGuidelines: allow ${#posix} == strlen($posix)
Junio C Hamano [Sun, 29 Mar 2020 03:06:53 +0000 (20:06 -0700)] 
CodingGuidelines: allow ${#posix} == strlen($posix)

The construct has been in POSIX for the past 10+ years, and we have
used in t9xxx (subversion) series of the tests, so we know it is at
portable across systems that people have run those tests, which is
almost everything we'd care about.

Let's loosen the rule; luckily, the check-non-portable-shell script
does not have any rule to find its use, so the only change needed is
a removal of one paragraph from the documentation.

Helped-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agogit-rebase.txt: fix typo
Philippe Blain [Sat, 28 Mar 2020 19:12:00 +0000 (19:12 +0000)] 
git-rebase.txt: fix typo

Signed-off-by: Philippe Blain <levraiphilippeblain@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agopull: pass documented fetch options on
RenĂ© Scharfe [Sat, 28 Mar 2020 14:48:41 +0000 (15:48 +0100)] 
pull: pass documented fetch options on

The fetch options --deepen, --negotiation-tip, --server-option,
--shallow-exclude, and --shallow-since are documented for git pull as
well, but are not actually accepted by that command.  Pass them on to
make the code match its documentation.

Reported-by: 天几 <muzimuzhi@gmail.com>
Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agopull: remove --update-head-ok from documentation
RenĂ© Scharfe [Sat, 28 Mar 2020 14:48:33 +0000 (15:48 +0100)] 
pull: remove --update-head-ok from documentation

'git pull' implicitly passes --update-head-ok to 'git fetch', but
doesn't itself accept that option from users.  That makes sense, as it
wouldn't work without the possibility to update HEAD.  Remove the option
from the command's documentation to match its actual behavior.

Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agosequencer: mark messages for translation
Alban Gruin [Sat, 28 Mar 2020 13:05:15 +0000 (14:05 +0100)] 
sequencer: mark messages for translation

Signed-off-by: Alban Gruin <alban.gruin@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agowrapper: indent with tabs
Denton Liu [Sat, 28 Mar 2020 02:57:34 +0000 (22:57 -0400)] 
wrapper: indent with tabs

The codebase uses tabs for indentation. Convert an erroneous space
indent into a tab indent.

Signed-off-by: Denton Liu <liu.denton@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agomidx.c: fix an integer underflow
Damien Robert [Sat, 28 Mar 2020 22:18:22 +0000 (23:18 +0100)] 
midx.c: fix an integer underflow

When verifying a midx index with 0 objects, the
    m->num_objects - 1
underflows and wraps around to 4294967295.

Fix this both by checking that the midx contains at least one oid,
and also that we don't write any midx when there is no packfiles.

Update the tests to check that `git multi-pack-index write` does
not write an midx when there is no objects, and another to check
that `git multi-pack-index verify` warns when it verifies an midx with no
objects. For this last test, use t5319/no-objects.midx which was
generated by an older version of git.

Signed-off-by: Damien Robert <damien.olivier.robert+git@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agopull: avoid running both merge and rebase
Elijah Newren [Fri, 27 Mar 2020 21:51:40 +0000 (21:51 +0000)] 
pull: avoid running both merge and rebase

When opt_rebase is true, we still first check if we can fast-forward.
If the branch is fast-forwardable, then we can avoid the rebase and just
use merge to do the fast-forward logic.  However, when commit a6d7eb2c7a
("pull: optionally rebase submodules (remote submodule changes only)",
2017-06-23) added the ability to rebase submodules it accidentally
caused us to run BOTH a merge and a rebase.  Add a flag to avoid doing
both.

This was found when a user had both pull.rebase and rebase.autosquash
set to true.  In such a case, the running of both merge and rebase would
cause ORIG_HEAD to be updated twice (and match HEAD at the end instead
of the commit before the rebase started), against expectation.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agop5310: stop timing non-bitmap pack-to-disk
Jeff King [Thu, 26 Mar 2020 07:54:36 +0000 (03:54 -0400)] 
p5310: stop timing non-bitmap pack-to-disk

Commit 645c432d61 (pack-objects: use reachability bitmap index when
generating non-stdout pack, 2016-09-10) added two timing tests for
packing to an on-disk file, both with and without bitmaps. However, the
non-bitmap one isn't interesting to have as part of p5310's regression
suite. It _could_ be used as a baseline to show off the improvement in
the bitmap case, but:

  - the point of the t/perf suite is to find performance regressions,
    and it won't help with that. We don't compare the numbers between
    two tests (which the perf suite has no idea are even related), and
    any change in its numbers would have nothing to do with bitmaps.

  - it did show off the improvement in the commit message of 645c432d61,
    but it wasn't even necessary there. The bitmap case already shows an
    improvement (because before the patch, it behaved the same as the
    non-bitmap case), and the perf suite is even able to show the
    difference between the before and after measurements.

On top of that, it's one of the most expensive tests in the suite,
clocking in around 60s for linux.git on my machine (as compared to 16s
for the bitmapped version). And by default when using "./run", we'd run
it three times!

So let's just drop it. It's not useful and is adding minutes to perf
runs.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agoupload-pack: handle unexpected delim packets
Jeff King [Fri, 27 Mar 2020 08:03:38 +0000 (04:03 -0400)] 
upload-pack: handle unexpected delim packets

When processing the arguments list for a v2 ls-refs or fetch command, we
loop like this:

  while (packet_reader_read(request) != PACKET_READ_FLUSH) {
          const char *arg = request->line;
  ...handle arg...
  }

to read and handle packets until we see a flush. The hidden assumption
here is that anything except PACKET_READ_FLUSH will give us valid packet
data to read. But that's not true; PACKET_READ_DELIM or PACKET_READ_EOF
will leave packet->line as NULL, and we'll segfault trying to look at
it.

Instead, we should follow the more careful model demonstrated on the
client side (e.g., in process_capabilities_v2): keep looping as long
as we get normal packets, and then make sure that we broke out of the
loop due to a real flush. That fixes the segfault and correctly
diagnoses any unexpected input from the client.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agotest-lib-functions: make packetize() more efficient
Jeff King [Fri, 27 Mar 2020 08:03:00 +0000 (04:03 -0400)] 
test-lib-functions: make packetize() more efficient

The packetize() function takes its input on stdin, and requires 4
separate sub-processes to format a simple string. We can do much better
by getting the length via the shell's "${#packet}" construct. The one
caveat is that the shell can't put a NUL into a variable, so we'll have
to continue to provide the stdin form for a few calls.

There are a few other cleanups here in the touched code:

 - the stdin form of packetize() had an extra stray "%s" when printing
   the packet

 - the converted calls in t5562 can be made simpler by redirecting
   output as a block, rather than repeated appending

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agot/lib-*.sh: drop executable bit
Jeff King [Thu, 26 Mar 2020 08:25:53 +0000 (04:25 -0400)] 
t/lib-*.sh: drop executable bit

There's no need for shell libraries to have the executable bit. They're
meant to be sourced, and running them stand-alone is pointless. Let's
reduce any possible confusion by making it more clear they're not meant
to be run this way.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agot/lib-credential.sh: drop shebang line
Jeff King [Thu, 26 Mar 2020 08:25:27 +0000 (04:25 -0400)] 
t/lib-credential.sh: drop shebang line

The purpose of lib-credential.sh is to be sourced into other test
scripts. It doesn't need a "#!/bin/sh" line, as running it directly
makes no sense. Nor does it serve any real filetype documentation
purpose, as the file is clearly named with a ".sh" extension.

In the spirit of c74c72034f (test: replace shebangs with descriptions in
shell libraries, 2013-11-25), let's replace it with a human-readable
description.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agorun-command: trigger PATH lookup properly on Cygwin
Andras Kucsma [Fri, 27 Mar 2020 00:36:43 +0000 (00:36 +0000)] 
run-command: trigger PATH lookup properly on Cygwin

On Cygwin, the codepath for POSIX-like systems is taken in
run-command.c::start_command(). The prepare_cmd() helper
function is called to decide if the command needs to be looked
up in the PATH. The logic there is to do the PATH-lookup if
and only if it does not have any slash '/' in it. If this test
passes we end up attempting to run the command by appending the
string after each colon-separated component of PATH.

The Cygwin environment supports both Windows and POSIX style
paths, so both forwardslahes '/' and back slashes '\' can be
used as directory separators for any external program the user
supplies.

Examples for path strings which are being incorrectly searched
for in the PATH instead of being executed as is:

- "C:\Program Files\some-program.exe"
- "a\b\c.exe"

To handle these, the PATH lookup detection logic in prepare_cmd()
is taught to know about this Cygwin quirk, by introducing
has_dir_sep(path) helper function to abstract away the difference
between true POSIX and Cygwin systems.

Signed-off-by: Andras Kucsma <r0maikx02b@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agot5801: teach compare_refs() to accept !
Denton Liu [Thu, 26 Mar 2020 08:27:55 +0000 (04:27 -0400)] 
t5801: teach compare_refs() to accept !

Before, testing if two refs weren't equal with compare_refs() was done
with `test_must_fail compare_refs`. This was wrong for two reasons.
First, test_must_fail should only be used on git commands. Second,
negating the error code is a little heavy-handed since in the case where
one of the git invocations within compare_refs() fails, we will report
success, even though it failed at an unexpected point.

Teach compare_refs() to accept `!` as the first argument which would
_only_ negate the test_cmp()'s return code.

Signed-off-by: Denton Liu <liu.denton@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agot5612: stop losing return codes of git commands
Denton Liu [Thu, 26 Mar 2020 08:27:54 +0000 (04:27 -0400)] 
t5612: stop losing return codes of git commands

In a pipe, only the return code of the last command is used. Thus, all
other commands will have their return codes masked. Rewrite pipes so
that there are no git commands upstream so that their failure is
reported.

Signed-off-by: Denton Liu <liu.denton@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agot5612: don't use `test_must_fail test_cmp`
Denton Liu [Thu, 26 Mar 2020 08:27:53 +0000 (04:27 -0400)] 
t5612: don't use `test_must_fail test_cmp`

The test_must_fail function should only be used for git commands since
we should assume that external commands work sanely. Since test_cmp() just
wraps an external command, replace `test_must_fail test_cmp` with
`! test_cmp`.

Signed-off-by: Denton Liu <liu.denton@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agot5607: reorder `nongit test_must_fail`
Denton Liu [Thu, 26 Mar 2020 08:27:52 +0000 (04:27 -0400)] 
t5607: reorder `nongit test_must_fail`

In the future, we plan on only allowing `test_must_fail` to work on a
restricted subset of commands, including `git`. Reorder the commands so
that `nongit` comes before `test_must_fail`. This way, `test_must_fail`
operates on a git command.

Signed-off-by: Denton Liu <liu.denton@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agot5550: simplify no matching line check
Denton Liu [Thu, 26 Mar 2020 08:27:51 +0000 (04:27 -0400)] 
t5550: simplify no matching line check

In the 'did not use upload-pack service' test, we have a complicated
song-and-dance to ensure that there are no "/git-upload-pack" lines in
"$HTTPD_ROOT_PATH/access.log". Simplify this by just checking that grep
returns a non-zero exit code.

Helped-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Denton Liu <liu.denton@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agot5512: stop losing return codes of git commands
Denton Liu [Thu, 26 Mar 2020 08:27:50 +0000 (04:27 -0400)] 
t5512: stop losing return codes of git commands

In a pipe, only the return code of the last command is used. Thus, all
other commands will have their return codes masked. Rewrite pipes so
that there are no git commands upstream so that their failure is
reported.

Signed-off-by: Denton Liu <liu.denton@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agot5512: stop losing git exit code in here-docs
Denton Liu [Thu, 26 Mar 2020 08:27:49 +0000 (04:27 -0400)] 
t5512: stop losing git exit code in here-docs

The expected references are generated using a here-doc with some inline
command substitutions. If one of the `git rev-parse` invocations within
the command substitutions fails, its return code is swallowed and we
won't know about it. Replace these command substitutions with
generate_references(), which actually reports when `git rev-parse`
fails.

Signed-off-by: Denton Liu <liu.denton@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agoThe second batch post 2.26 cycle
Junio C Hamano [Fri, 27 Mar 2020 00:00:57 +0000 (17:00 -0700)] 
The second batch post 2.26 cycle

Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agoMerge branch 'ah/force-pull-rebase-configuration'
Junio C Hamano [Fri, 27 Mar 2020 00:11:21 +0000 (17:11 -0700)] 
Merge branch 'ah/force-pull-rebase-configuration'

"git pull" learned to warn when no pull.rebase configuration
exists, and neither --[no-]rebase nor --ff-only is given (which
would result a merge).

* ah/force-pull-rebase-configuration:
  pull: warn if the user didn't say whether to rebase or to merge

4 years agoMerge branch 'tg/retire-scripted-stash'
Junio C Hamano [Fri, 27 Mar 2020 00:11:21 +0000 (17:11 -0700)] 
Merge branch 'tg/retire-scripted-stash'

"git stash" has kept an escape hatch to use the scripted version
for a few releases, which got stale.  It has been removed.

* tg/retire-scripted-stash:
  stash: remove the stash.useBuiltin setting
  stash: get git_stash_config at the top level

4 years agoMerge branch 'jc/describe-misnamed-annotated-tag'
Junio C Hamano [Fri, 27 Mar 2020 00:11:21 +0000 (17:11 -0700)] 
Merge branch 'jc/describe-misnamed-annotated-tag'

When "git describe C" finds an annotated tag with tagname A to be
the best name to explain commit C, and the tag is stored in a
"wrong" place in the refs/tags hierarchy, e.g. refs/tags/B, the
command gave a warning message but used A (not B) to describe C.
If C is exactly at the tag, the describe output would be "A", but
"git rev-parse A^0" would not be equal as "git rev-parse C^0".  The
behavior of the command has been changed to use the "long" form
i.e. A-0-gOBJECTNAME, which is correctly interpreted by rev-parse.

* jc/describe-misnamed-annotated-tag:
  describe: force long format for a name based on a mislocated tag

4 years agoMerge branch 'at/rebase-fork-point-regression-fix'
Junio C Hamano [Fri, 27 Mar 2020 00:11:21 +0000 (17:11 -0700)] 
Merge branch 'at/rebase-fork-point-regression-fix'

The "--fork-point" mode of "git rebase" regressed when the command
was rewritten in C back in 2.20 era, which has been corrected.

* at/rebase-fork-point-regression-fix:
  rebase: --fork-point regression fix

4 years agoMerge branch 'bc/filter-process'
Junio C Hamano [Fri, 27 Mar 2020 00:11:20 +0000 (17:11 -0700)] 
Merge branch 'bc/filter-process'

Provide more information (e.g. the object of the tree-ish in which
the blob being converted appears, in addition to its path, which
has already been given) to smudge/clean conversion filters.

* bc/filter-process:
  t0021: test filter metadata for additional cases
  builtin/reset: compute checkout metadata for reset
  builtin/rebase: compute checkout metadata for rebases
  builtin/clone: compute checkout metadata for clones
  builtin/checkout: compute checkout metadata for checkouts
  convert: provide additional metadata to filters
  convert: permit passing additional metadata to filter processes
  builtin/checkout: pass branch info down to checkout_worktree

4 years agoMerge branch 'hi/gpg-prefer-check-signature'
Junio C Hamano [Fri, 27 Mar 2020 00:11:20 +0000 (17:11 -0700)] 
Merge branch 'hi/gpg-prefer-check-signature'

The code to interface with GnuPG has been refactored.

* hi/gpg-prefer-check-signature:
  gpg-interface: prefer check_signature() for GPG verification
  t: increase test coverage of signature verification output

4 years agoMerge branch 'bc/sha-256-part-1-of-4'
Junio C Hamano [Fri, 27 Mar 2020 00:11:20 +0000 (17:11 -0700)] 
Merge branch 'bc/sha-256-part-1-of-4'

SHA-256 transition continues.

* bc/sha-256-part-1-of-4: (22 commits)
  fast-import: add options for rewriting submodules
  fast-import: add a generic function to iterate over marks
  fast-import: make find_marks work on any mark set
  fast-import: add helper function for inserting mark object entries
  fast-import: permit reading multiple marks files
  commit: use expected signature header for SHA-256
  worktree: allow repository version 1
  init-db: move writing repo version into a function
  builtin/init-db: add environment variable for new repo hash
  builtin/init-db: allow specifying hash algorithm on command line
  setup: allow check_repository_format to read repository format
  t/helper: make repository tests hash independent
  t/helper: initialize repository if necessary
  t/helper/test-dump-split-index: initialize git repository
  t6300: make hash algorithm independent
  t6300: abstract away SHA-1-specific constants
  t: use hash-specific lookup tables to define test constants
  repository: require a build flag to use SHA-256
  hex: add functions to parse hex object IDs in any algorithm
  hex: introduce parsing variants taking hash algorithms
  ...

4 years agoMerge branch 'pb/recurse-submodules-fix'
Junio C Hamano [Fri, 27 Mar 2020 00:11:20 +0000 (17:11 -0700)] 
Merge branch 'pb/recurse-submodules-fix'

Fix "git checkout --recurse-submodules" of a nested submodule
hierarchy.

* pb/recurse-submodules-fix:
  t/lib-submodule-update: add test removing nested submodules
  unpack-trees: check for missing submodule directory in merged_entry
  unpack-trees: remove outdated description for verify_clean_submodule
  t/lib-submodule-update: move a test to the right section
  t/lib-submodule-update: remove outdated test description
  t7112: remove mention of KNOWN_FAILURE_SUBMODULE_RECURSIVE_NESTED

4 years agotests: increase the verbosity of the GPG-related prereqs
Johannes Schindelin [Thu, 26 Mar 2020 15:35:28 +0000 (15:35 +0000)] 
tests: increase the verbosity of the GPG-related prereqs

Especially when debugging a test failure that can only be reproduced in
the CI build (e.g. when the developer has no access to a macOS machine
other than running the tests on a macOS build agent), output should not
be suppressed.

In the instance of `hi/gpg-prefer-check-signature`, where one
GPG-related test failed for no apparent reason, the entire output of
`gpg` and `gpgsm` was suppressed, even in verbose mode, leaving
interested readers no clue what was going wrong.

Let's fix this by no longer redirecting the output not to `/dev/null`.
This is now possible because the affected prereqs were turned into lazy
ones (and are therefore evaluated via `test_eval_` which respects the
`--verbose` option).

Note that we _still_ redirect `stdout` to `/dev/null` for those commands
that sign their `stdin`, as the output would be binary (and useless
anyway, because the reader would not have anything against which to
compare the output).

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agotests: turn GPG, GPGSM and RFC1991 into lazy prereqs
Johannes Schindelin [Thu, 26 Mar 2020 15:35:27 +0000 (15:35 +0000)] 
tests: turn GPG, GPGSM and RFC1991 into lazy prereqs

The code to set those prereqs is executed completely outside of any
`test_eval_` block. As a consequence, its output had to be suppressed so
that it does not clutter the output of a regular test script run.

Unfortunately, the output *stays* suppressed even when the `--verbose`
option is in effect.

This hid important output when debugging why the GPG prereq was not
enabled in the Windows part of our CI builds.

In preparation for fixing that, let's move all of this code into lazy
prereqs.

The only slightly tricky part is the global environment variable
`GNUPGHOME`. Originally, it was configured only when we verified that
there is a `gpg` in the `PATH` that we can use. This is now no longer
possible, as lazy prereqs are evaluated in a subshell that changes the
working directory to a temporary one. Therefore, we simply _always_ set
that environment variable: it does not hurt anything because it does not
indicate the presence of a working GPG.

Side note: it was quite tempting to use a hack that is possible because
we do not validate what is passed to `test_lazy_prereq` (and it is
therefore possible to "break out" of the lazy_prereq subshell:

test_lazy_prereq GPG '...) && GNUPGHOME=... && (...'

However, this is rather tricksy hobbitses code, and the current patch is
_much_ easier to understand.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agotests: do not let lazy prereqs inside `test_expect_*` turn off tracing
Johannes Schindelin [Thu, 26 Mar 2020 15:35:26 +0000 (15:35 +0000)] 
tests: do not let lazy prereqs inside `test_expect_*` turn off tracing

The `test_expect_*` functions use `test_eval_` and so does
`test_run_lazy_prereq_`. If tracing is enabled via the `-x` option,
`test_eval_` turns on tracing while evaluating the code block, and turns
it off directly after it.

This is unwanted for nested invocations.

One somewhat surprising example of this is when running a test that
calls `test_i18ngrep`: that function requires the `C_LOCALE_OUTPUT`
prereq, and that prereq is a lazy one, so it is evaluated via
`test_eval_`, the command tracing is turned off, and the test case
continues to run _without tracing the commands_.

Another somewhat surprising example is when one lazy prereq depends on
another lazy prereq: the former will call `test_have_prereq` with the
latter one, which in turn calls `test_eval_` and -- you guessed it --
tracing (if enabled) will be turned off _before_ returning to evaluating
the other lazy prereq.

As we will introduce just such a scenario with the GPG, GPGSM and
RFC1991 prereqs, let's fix that by introducing a variable that keeps
track of the current trace level: nested `test_eval_` calls will
increment and then decrement the level, and only when it reaches 0, the
tracing will _actually_ be turned off.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agot/lib-gpg.sh: stop pretending to be a stand-alone script
Johannes Schindelin [Thu, 26 Mar 2020 15:35:25 +0000 (15:35 +0000)] 
t/lib-gpg.sh: stop pretending to be a stand-alone script

It makes no sense to call `./lib-gpg.sh`. Therefore the hash-bang line
is unnecessary.

There are other similar instances in `t/`, but they are too far from the
context of the enclosing patch series, so they will be addressed
separately.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agoThe first batch post 2.26 cycle
Junio C Hamano [Wed, 25 Mar 2020 20:37:05 +0000 (13:37 -0700)] 
The first batch post 2.26 cycle

Signed-off-by: Junio C Hamano <gitster@pobox.com>