]> Kevux Git Server - rit/log
rit
3 years agoSync with Git 2.39.2
Junio C Hamano [Tue, 14 Feb 2023 01:03:24 +0000 (17:03 -0800)]
Sync with Git 2.39.2

3 years agoThe fifteenth batch
Junio C Hamano [Thu, 9 Feb 2023 22:40:34 +0000 (14:40 -0800)]
The fifteenth batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoMerge branch 'ew/free-island-marks'
Junio C Hamano [Thu, 9 Feb 2023 22:40:47 +0000 (14:40 -0800)]
Merge branch 'ew/free-island-marks'

"git pack-objects" learned to release delta-island bitmap data when
it is done using it, saving peak heap memory usage.

* ew/free-island-marks:
  delta-islands: free island_marks and bitmaps

3 years agoMerge branch 'sk/winansi-createthread-fix'
Junio C Hamano [Thu, 9 Feb 2023 22:40:47 +0000 (14:40 -0800)]
Merge branch 'sk/winansi-createthread-fix'

Fix use of CreateThread() API call made early in the windows
start-up code.

* sk/winansi-createthread-fix:
  compat/winansi: check for errors of CreateThread() correctly

3 years agoMerge branch 'hj/remove-msys-support'
Junio C Hamano [Thu, 9 Feb 2023 22:40:47 +0000 (14:40 -0800)]
Merge branch 'hj/remove-msys-support'

Remove support for MSys, which now lags way behind MSys2.

* hj/remove-msys-support:
  mingw: remove msysGit/MSYS1 support
  mingw: remove duplicate `USE_NED_ALLOCATOR` directive

3 years agoMerge branch 'jk/httpd-test-updates'
Junio C Hamano [Thu, 9 Feb 2023 22:40:46 +0000 (14:40 -0800)]
Merge branch 'jk/httpd-test-updates'

Test update.

* jk/httpd-test-updates:
  t/lib-httpd: increase ssl key size to 2048 bits
  t/lib-httpd: drop SSLMutex config
  t/lib-httpd: bump required apache version to 2.4
  t/lib-httpd: bump required apache version to 2.2

3 years agoMerge branch 'gc/index-format-doc'
Junio C Hamano [Thu, 9 Feb 2023 22:40:46 +0000 (14:40 -0800)]
Merge branch 'gc/index-format-doc'

Doc update.

* gc/index-format-doc:
  docs: document zero bits in index "mode"

3 years agoThe fourteenth batch
Junio C Hamano [Wed, 8 Feb 2023 17:14:51 +0000 (09:14 -0800)]
The fourteenth batch

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

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

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

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

Documentation clarification.

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

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

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

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

3 years agoGit 2.39.2
Johannes Schindelin [Mon, 6 Feb 2023 08:43:41 +0000 (09:43 +0100)]
Git 2.39.2

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
3 years agoSync with 2.38.4
Johannes Schindelin [Mon, 6 Feb 2023 08:43:39 +0000 (09:43 +0100)]
Sync with 2.38.4

* maint-2.38:
  Git 2.38.4
  Git 2.37.6
  Git 2.36.5
  Git 2.35.7
  Git 2.34.7
  http: support CURLOPT_PROTOCOLS_STR
  http: prefer CURLOPT_SEEKFUNCTION to CURLOPT_IOCTLFUNCTION
  http-push: prefer CURLOPT_UPLOAD to CURLOPT_PUT
  Git 2.33.7
  Git 2.32.6
  Git 2.31.7
  Git 2.30.8
  apply: fix writing behind newly created symbolic links
  dir-iterator: prevent top-level symlinks without FOLLOW_SYMLINKS
  clone: delay picking a transport until after get_repo_path()
  t5619: demonstrate clone_local() with ambiguous transport

3 years agoGit 2.38.4
Johannes Schindelin [Mon, 6 Feb 2023 08:43:30 +0000 (09:43 +0100)]
Git 2.38.4

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
3 years agoSync with 2.37.6
Johannes Schindelin [Mon, 6 Feb 2023 08:43:28 +0000 (09:43 +0100)]
Sync with 2.37.6

* maint-2.37:
  Git 2.37.6
  Git 2.36.5
  Git 2.35.7
  Git 2.34.7
  http: support CURLOPT_PROTOCOLS_STR
  http: prefer CURLOPT_SEEKFUNCTION to CURLOPT_IOCTLFUNCTION
  http-push: prefer CURLOPT_UPLOAD to CURLOPT_PUT
  Git 2.33.7
  Git 2.32.6
  Git 2.31.7
  Git 2.30.8
  apply: fix writing behind newly created symbolic links
  dir-iterator: prevent top-level symlinks without FOLLOW_SYMLINKS
  clone: delay picking a transport until after get_repo_path()
  t5619: demonstrate clone_local() with ambiguous transport

3 years agoGit 2.37.6
Johannes Schindelin [Mon, 6 Feb 2023 08:38:32 +0000 (09:38 +0100)]
Git 2.37.6

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
3 years agoSync with 2.36.5
Johannes Schindelin [Mon, 6 Feb 2023 08:38:31 +0000 (09:38 +0100)]
Sync with 2.36.5

* maint-2.36:
  Git 2.36.5
  Git 2.35.7
  Git 2.34.7
  http: support CURLOPT_PROTOCOLS_STR
  http: prefer CURLOPT_SEEKFUNCTION to CURLOPT_IOCTLFUNCTION
  http-push: prefer CURLOPT_UPLOAD to CURLOPT_PUT
  Git 2.33.7
  Git 2.32.6
  Git 2.31.7
  Git 2.30.8
  apply: fix writing behind newly created symbolic links
  dir-iterator: prevent top-level symlinks without FOLLOW_SYMLINKS
  clone: delay picking a transport until after get_repo_path()
  t5619: demonstrate clone_local() with ambiguous transport

3 years agoGit 2.36.5
Johannes Schindelin [Mon, 6 Feb 2023 08:37:53 +0000 (09:37 +0100)]
Git 2.36.5

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
3 years agoSync with 2.35.7
Johannes Schindelin [Mon, 6 Feb 2023 08:37:52 +0000 (09:37 +0100)]
Sync with 2.35.7

* maint-2.35:
  Git 2.35.7
  Git 2.34.7
  http: support CURLOPT_PROTOCOLS_STR
  http: prefer CURLOPT_SEEKFUNCTION to CURLOPT_IOCTLFUNCTION
  http-push: prefer CURLOPT_UPLOAD to CURLOPT_PUT
  Git 2.33.7
  Git 2.32.6
  Git 2.31.7
  Git 2.30.8
  apply: fix writing behind newly created symbolic links
  dir-iterator: prevent top-level symlinks without FOLLOW_SYMLINKS
  clone: delay picking a transport until after get_repo_path()
  t5619: demonstrate clone_local() with ambiguous transport

3 years agoGit 2.35.7
Johannes Schindelin [Mon, 6 Feb 2023 08:29:45 +0000 (09:29 +0100)]
Git 2.35.7

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
3 years agoSync with 2.34.7
Johannes Schindelin [Mon, 6 Feb 2023 08:29:44 +0000 (09:29 +0100)]
Sync with 2.34.7

* maint-2.34:
  Git 2.34.7
  http: support CURLOPT_PROTOCOLS_STR
  http: prefer CURLOPT_SEEKFUNCTION to CURLOPT_IOCTLFUNCTION
  http-push: prefer CURLOPT_UPLOAD to CURLOPT_PUT
  Git 2.33.7
  Git 2.32.6
  Git 2.31.7
  Git 2.30.8
  apply: fix writing behind newly created symbolic links
  dir-iterator: prevent top-level symlinks without FOLLOW_SYMLINKS
  clone: delay picking a transport until after get_repo_path()
  t5619: demonstrate clone_local() with ambiguous transport

3 years agoGit 2.34.7
Johannes Schindelin [Mon, 6 Feb 2023 08:29:17 +0000 (09:29 +0100)]
Git 2.34.7

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
3 years agoSync with 2.33.7
Johannes Schindelin [Mon, 6 Feb 2023 08:29:16 +0000 (09:29 +0100)]
Sync with 2.33.7

* maint-2.33:
  Git 2.33.7
  Git 2.32.6
  Git 2.31.7
  Git 2.30.8
  apply: fix writing behind newly created symbolic links
  dir-iterator: prevent top-level symlinks without FOLLOW_SYMLINKS
  clone: delay picking a transport until after get_repo_path()
  t5619: demonstrate clone_local() with ambiguous transport

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

Deal with a few deprecation warning from cURL library.

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

3 years agohttp: support CURLOPT_PROTOCOLS_STR
Jeff King [Tue, 17 Jan 2023 03:04:48 +0000 (22:04 -0500)]
http: support CURLOPT_PROTOCOLS_STR

The CURLOPT_PROTOCOLS (and matching CURLOPT_REDIR_PROTOCOLS) flag was
deprecated in curl 7.85.0, and using it generate compiler warnings as of
curl 7.87.0. The path forward is to use CURLOPT_PROTOCOLS_STR, but we
can't just do so unilaterally, as it was only introduced less than a
year ago in 7.85.0.

Until that version becomes ubiquitous, we have to either disable the
deprecation warning or conditionally use the "STR" variant on newer
versions of libcurl. This patch switches to the new variant, which is
nice for two reasons:

  - we don't have to worry that silencing curl's deprecation warnings
    might cause us to miss other more useful ones

  - we'd eventually want to move to the new variant anyway, so this gets
    us set up (albeit with some extra ugly boilerplate for the
    conditional)

There are a lot of ways to split up the two cases. One way would be to
abstract the storage type (strbuf versus a long), how to append
(strbuf_addstr vs bitwise OR), how to initialize, which CURLOPT to use,
and so on. But the resulting code looks pretty magical:

  GIT_CURL_PROTOCOL_TYPE allowed = GIT_CURL_PROTOCOL_TYPE_INIT;
  if (...http is allowed...)
GIT_CURL_PROTOCOL_APPEND(&allowed, "http", CURLOPT_HTTP);

and you end up with more "#define GIT_CURL_PROTOCOL_TYPE" macros than
actual code.

On the other end of the spectrum, we could just implement two separate
functions, one that handles a string list and one that handles bits. But
then we end up repeating our list of protocols (http, https, ftp, ftp).

This patch takes the middle ground. The run-time code is always there to
handle both types, and we just choose which one to feed to curl.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
3 years agohttp: prefer CURLOPT_SEEKFUNCTION to CURLOPT_IOCTLFUNCTION
Jeff King [Tue, 17 Jan 2023 03:04:44 +0000 (22:04 -0500)]
http: prefer CURLOPT_SEEKFUNCTION to CURLOPT_IOCTLFUNCTION

The IOCTLFUNCTION option has been deprecated, and generates a compiler
warning in recent versions of curl. We can switch to using SEEKFUNCTION
instead. It was added in 2008 via curl 7.18.0; our INSTALL file already
indicates we require at least curl 7.19.4.

But there's one catch: curl says we should use CURL_SEEKFUNC_{OK,FAIL},
and those didn't arrive until 7.19.5. One workaround would be to use a
bare 0/1 here (or define our own macros).  But let's just bump the
minimum required version to 7.19.5. That version is only a minor version
bump from our existing requirement, and is only a 2 month time bump for
versions that are almost 13 years old. So it's not likely that anybody
cares about the distinction.

Switching means we have to rewrite the ioctl functions into seek
functions. In some ways they are simpler (seeking is the only
operation), but in some ways more complex (the ioctl allowed only a full
rewind, but now we can seek to arbitrary offsets).

Curl will only ever use SEEK_SET (per their documentation), so I didn't
bother implementing anything else, since it would naturally be
completely untested. This seems unlikely to change, but I added an
assertion just in case.

Likewise, I doubt curl will ever try to seek outside of the buffer sizes
we've told it, but I erred on the defensive side here, rather than do an
out-of-bounds read.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
3 years agohttp-push: prefer CURLOPT_UPLOAD to CURLOPT_PUT
Jeff King [Tue, 17 Jan 2023 03:04:38 +0000 (22:04 -0500)]
http-push: prefer CURLOPT_UPLOAD to CURLOPT_PUT

The two options do exactly the same thing, but the latter has been
deprecated and in recent versions of curl may produce a compiler
warning. Since the UPLOAD form is available everywhere (it was
introduced in the year 2000 by curl 7.1), we can just switch to it.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
3 years agoGit 2.33.7
Johannes Schindelin [Mon, 6 Feb 2023 08:25:58 +0000 (09:25 +0100)]
Git 2.33.7

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
3 years agoSync with 2.32.6
Johannes Schindelin [Mon, 6 Feb 2023 08:25:56 +0000 (09:25 +0100)]
Sync with 2.32.6

* maint-2.32:
  Git 2.32.6
  Git 2.31.7
  Git 2.30.8
  apply: fix writing behind newly created symbolic links
  dir-iterator: prevent top-level symlinks without FOLLOW_SYMLINKS
  clone: delay picking a transport until after get_repo_path()
  t5619: demonstrate clone_local() with ambiguous transport

3 years agoGit 2.32.6
Johannes Schindelin [Mon, 6 Feb 2023 08:25:09 +0000 (09:25 +0100)]
Git 2.32.6

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
3 years agoSync with 2.31.7
Johannes Schindelin [Mon, 6 Feb 2023 08:25:08 +0000 (09:25 +0100)]
Sync with 2.31.7

* maint-2.31:
  Git 2.31.7
  Git 2.30.8
  apply: fix writing behind newly created symbolic links
  dir-iterator: prevent top-level symlinks without FOLLOW_SYMLINKS
  clone: delay picking a transport until after get_repo_path()
  t5619: demonstrate clone_local() with ambiguous transport

3 years agoGit 2.31.7
Johannes Schindelin [Mon, 6 Feb 2023 08:24:07 +0000 (09:24 +0100)]
Git 2.31.7

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
3 years agoSync with 2.30.8
Johannes Schindelin [Mon, 6 Feb 2023 08:24:06 +0000 (09:24 +0100)]
Sync with 2.30.8

* maint-2.30:
  Git 2.30.8
  apply: fix writing behind newly created symbolic links
  dir-iterator: prevent top-level symlinks without FOLLOW_SYMLINKS
  clone: delay picking a transport until after get_repo_path()
  t5619: demonstrate clone_local() with ambiguous transport

3 years agoGit 2.30.8
Junio C Hamano [Fri, 3 Feb 2023 22:58:10 +0000 (14:58 -0800)]
Git 2.30.8

Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoMerge branch 'ps/apply-beyond-symlink' into maint-2.30
Junio C Hamano [Fri, 3 Feb 2023 22:57:27 +0000 (14:57 -0800)]
Merge branch 'ps/apply-beyond-symlink' into maint-2.30

Fix a vulnerability (CVE-2023-23946) that allows crafted input to trick
`git apply` into writing files outside of the working tree.

* ps/apply-beyond-symlink:
  dir-iterator: prevent top-level symlinks without FOLLOW_SYMLINKS

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
3 years agoMerge branch 'tb/clone-local-symlinks' into maint-2.30
Taylor Blau [Wed, 25 Jan 2023 19:58:38 +0000 (14:58 -0500)]
Merge branch 'tb/clone-local-symlinks' into maint-2.30

Resolve a security vulnerability (CVE-2023-22490) where `clone_local()`
is used in conjunction with non-local transports, leading to arbitrary
path exfiltration.

* tb/clone-local-symlinks:
  dir-iterator: prevent top-level symlinks without FOLLOW_SYMLINKS
  clone: delay picking a transport until after get_repo_path()
  t5619: demonstrate clone_local() with ambiguous transport

3 years agodelta-islands: free island_marks and bitmaps
Eric Wong [Fri, 3 Feb 2023 23:44:30 +0000 (23:44 +0000)]
delta-islands: free island_marks and bitmaps

On my mirror of linux.git forkgroup with 780 islands, this saves
nearly 4G of heap memory in pack-objects.  This savings only
benefits delta island users of pack bitmaps, as the process
would otherwise be exiting anyways.

However, there's probably not many delta island users, but the
majority of delta island users would also be pack bitmaps users.

Signed-off-by: Eric Wong <e@80x24.org>
Helped-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Helped-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoThe thirteenth batch
Junio C Hamano [Fri, 3 Feb 2023 22:31:25 +0000 (14:31 -0800)]
The thirteenth batch

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

Doc update to ls-files.

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

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

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

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

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

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

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

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

Comment fix.

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

3 years agoapply: fix writing behind newly created symbolic links
Patrick Steinhardt [Thu, 2 Feb 2023 10:54:34 +0000 (11:54 +0100)]
apply: fix writing behind newly created symbolic links

When writing files git-apply(1) initially makes sure that none of the
files it is about to create are behind a symlink:

```
 $ git init repo
 Initialized empty Git repository in /tmp/repo/.git/
 $ cd repo/
 $ ln -s dir symlink
 $ git apply - <<EOF
 diff --git a/symlink/file b/symlink/file
 new file mode 100644
 index 0000000..e69de29
 EOF
 error: affected file 'symlink/file' is beyond a symbolic link
```

This safety mechanism is crucial to ensure that we don't write outside
of the repository's working directory. It can be fooled though when the
patch that is being applied creates the symbolic link in the first
place, which can lead to writing files in arbitrary locations.

Fix this by checking whether the path we're about to create is
beyond a symlink or not. Tightening these checks like this should be
fine as we already have these precautions in Git as explained
above. Ideally, we should update the check we do up-front before
starting to reflect the computed changes to the working tree so that
we catch this case as well, but as part of embargoed security work,
adding an equivalent check just before we try to write out a file
should serve us well as a reasonable first step.

Digging back into history shows that this vulnerability has existed
since at least Git v2.9.0. As Git v2.8.0 and older don't build on my
system anymore I cannot tell whether older versions are affected, as
well.

Reported-by: Joern Schneeweisz <jschneeweisz@gitlab.com>
Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agomingw: remove msysGit/MSYS1 support
Harshil-Jani [Thu, 2 Feb 2023 03:51:38 +0000 (03:51 +0000)]
mingw: remove msysGit/MSYS1 support

MSys has long fallen behind MSYS2 in features like Unicode or
x86_64 support or even security bug fixes, and is therefore no
longer used by anyone in the Git developer community. The Git for
Windows project itself started switching from MSys to MSYS2 early
in 2015, i.e. about eight years ago. Let's drop supporting MSys as
a development platform.

Signed-off-by: Harshil-Jani <harshiljani2002@gmail.com>
Acked-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agomingw: remove duplicate `USE_NED_ALLOCATOR` directive
Harshil-Jani [Thu, 2 Feb 2023 03:51:37 +0000 (03:51 +0000)]
mingw: remove duplicate `USE_NED_ALLOCATOR` directive

nedalloc was added to fix the slowness of memory allocator. Here
specifically for the MSys2 build there seems to be a duplication of
USE_NED_ALLOCATOR directive. So this patch intends to remove the
duplicate USE_NED_ALLOCATOR and keeping it only into the MSys2 config
section so it still uses the nedalloc.

Signed-off-by: Harshil-Jani <harshiljani2002@gmail.com>
Acked-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agocompat/winansi: check for errors of CreateThread() correctly
Seija Kijin [Wed, 1 Feb 2023 22:20:33 +0000 (22:20 +0000)]
compat/winansi: check for errors of CreateThread() correctly

The return value for failed thread creation is NULL,
not INVALID_HANDLE_VALUE, unlike other Windows API functions.

Signed-off-by: Seija Kijin <doremylover123@gmail.com>
Acked-by: Johannes Sixt <j6t@kdbg.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agot/lib-httpd: increase ssl key size to 2048 bits
Jeff King [Wed, 1 Feb 2023 11:39:26 +0000 (06:39 -0500)]
t/lib-httpd: increase ssl key size to 2048 bits

Recent versions of openssl will refuse to work with 1024-bit RSA keys,
as they are considered insecure. I didn't track down the exact version
in which the defaults were tightened, but the Debian-package openssl 3.0
on my system yields:

  $ LIB_HTTPD_SSL=1 ./t5551-http-fetch-smart.sh -v -i
  [...]
  SSL Library Error: error:0A00018F:SSL routines::ee key too small
  1..0 # SKIP web server setup failed

This could probably be overcome with configuration, but that's likely
to be a headache (especially if it requires touching /etc/openssl).
Let's just pick a key size that's less outrageously out of date.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agot/lib-httpd: drop SSLMutex config
Jeff King [Wed, 1 Feb 2023 11:39:06 +0000 (06:39 -0500)]
t/lib-httpd: drop SSLMutex config

The SSL config enabled by setting LIB_HTTPD_SSL does not work with
Apache versions greater than 2.2, as more recent versions complain about
the SSLMutex directive. According to
https://httpd.apache.org/docs/current/upgrading.html:

  Directives AcceptMutex, LockFile, RewriteLock, SSLMutex,
  SSLStaplingMutex, and WatchdogMutexPath have been replaced with a
  single Mutex directive. You will need to evaluate any use of these
  removed directives in your 2.2 configuration to determine if they can
  just be deleted or will need to be replaced using Mutex.

Deleting this line will just use the system default, which seems
sensible. The original came as part of faa4bc35a0 (http-push: add
regression tests, 2008-02-27), but no specific reason is given there (or
on the mailing list) for its presence.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agot/lib-httpd: bump required apache version to 2.4
Jeff King [Wed, 1 Feb 2023 11:38:24 +0000 (06:38 -0500)]
t/lib-httpd: bump required apache version to 2.4

Apache 2.4 has been out since early 2012, almost 11 years. And its
predecessor, 2.2, has been out of support since its last release in
2017, over 5 years ago. The last mention on the mailing list was from
around the same time, in this thread:

  https://lore.kernel.org/git/20171231023234.21215-1-tmz@pobox.com/

We can probably assume that 2.4 is available everywhere. And the stakes
are fairly low, as the worst case is that such a platform would skip the
http tests.

This lets us clean up a few minor version checks in the config file, but
also revert f1f2b45be0 (tests: adjust the configuration for Apache 2.2,
2016-05-09). Its technique isn't _too_ bad, but certainly required a bit
more explanation than the 2.4 version it replaced. I manually confirmed
that the test in t5551 still behaves as expected (if you replace
"cadabra" with "foo", the server correctly rejects the request).

It will also help future patches which will no longer have to deal with
conditional config for this old version.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agot/lib-httpd: bump required apache version to 2.2
Jeff King [Wed, 1 Feb 2023 11:37:21 +0000 (06:37 -0500)]
t/lib-httpd: bump required apache version to 2.2

Apache 2.2 was released in 2005, almost 18 years ago. We can probably
assume that people are running a version at least that old (and the
stakes for removing it are fairly low, as the worst case is that they
would not run the http tests against their ancient version).

Dropping support for the older versions cleans up the config file a
little, and will also enable us to bump the required version further
(with more cleanups) in a future patch.

Note that the file actually checks for version 2.1. In apache's
versioning scheme, odd numbered versions are for development and even
numbers are for stable releases. So 2.1 and 2.2 are effectively the same
from our perspective.

Older versions would just fail to start, which would generally cause us
to skip the tests. However, we do have version detection code in
lib-httpd.sh which produces a nicer error message, so let's update that,
too. I didn't bother handling the case of "3.0", etc. Apache has been on
2.x for 21 years, with no signs of bumping the major version.  And if
they eventually do, I suspect there will be enough breaking changes that
we'd need to update more than just the numeric version check. We can
worry about that hypothetical when it happens.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agodocs: document zero bits in index "mode"
Glen Choo [Wed, 1 Feb 2023 02:40:41 +0000 (10:40 +0800)]
docs: document zero bits in index "mode"

Documentation/gitformat-index.txt describes the "mode" as 32 bits, but
only documents 16 bits. Document the missing 16 bits and specify that
'unused' bits must be zero.

Signed-off-by: Glen Choo <chooglen@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoThe twelfth batch
Junio C Hamano [Mon, 30 Jan 2023 22:24:32 +0000 (14:24 -0800)]
The twelfth batch

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

Doc mark-up updates.

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

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

Test portability fix.

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

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

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

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

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

Clarify column-padding operators in the pretty format string.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Leakfix.

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

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

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

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

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

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

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

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

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

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

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

Docfix.

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

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

Updates the users of the cache API.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    error: Couldn't find key in agent

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

Signed-off-by: Adam Szkoda <adaszko@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agodir-iterator: prevent top-level symlinks without FOLLOW_SYMLINKS
Taylor Blau [Wed, 25 Jan 2023 00:43:51 +0000 (19:43 -0500)]
dir-iterator: prevent top-level symlinks without FOLLOW_SYMLINKS

When using the dir_iterator API, we first stat(2) the base path, and
then use that as a starting point to enumerate the directory's contents.

If the directory contains symbolic links, we will immediately die() upon
encountering them without the `FOLLOW_SYMLINKS` flag. The same is not
true when resolving the top-level directory, though.

As explained in a previous commit, this oversight in 6f054f9fb3
(builtin/clone.c: disallow `--local` clones with symlinks, 2022-07-28)
can be used as an attack vector to include arbitrary files on a victim's
filesystem from outside of the repository.

Prevent resolving top-level symlinks unless the FOLLOW_SYMLINKS flag is
given, which will cause clones of a repository with a symlink'd
"$GIT_DIR/objects" directory to fail.

Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoclone: delay picking a transport until after get_repo_path()
Taylor Blau [Wed, 25 Jan 2023 00:43:48 +0000 (19:43 -0500)]
clone: delay picking a transport until after get_repo_path()

In the previous commit, t5619 demonstrates an issue where two calls to
`get_repo_path()` could trick Git into using its local clone mechanism
in conjunction with a non-local transport.

That sequence is:

 - the starting state is that the local path https:/example.com/foo is a
   symlink that points to ../../../.git/modules/foo. So it's dangling.

 - get_repo_path() sees that no such path exists (because it's
   dangling), and thus we do not canonicalize it into an absolute path

 - because we're using --separate-git-dir, we create .git/modules/foo.
   Now our symlink is no longer dangling!

 - we pass the url to transport_get(), which sees it as an https URL.

 - we call get_repo_path() again, on the url. This second call was
   introduced by f38aa83f9a (use local cloning if insteadOf makes a
   local URL, 2014-07-17). The idea is that we want to pull the url
   fresh from the remote.c API, because it will apply any aliases.

And of course now it sees that there is a local file, which is a
mismatch with the transport we already selected.

The issue in the above sequence is calling `transport_get()` before
deciding whether or not the repository is indeed local, and not passing
in an absolute path if it is local.

This is reminiscent of a similar bug report in [1], where it was
suggested to perform the `insteadOf` lookup earlier. Taking that
approach may not be as straightforward, since the intent is to store the
original URL in the config, but to actually fetch from the insteadOf
one, so conflating the two early on is a non-starter.

Note: we pass the path returned by `get_repo_path(remote->url[0])`,
which should be the same as `repo_name` (aside from any `insteadOf`
rewrites).

We *could* pass `absolute_pathdup()` of the same argument, which
86521acaca (Bring local clone's origin URL in line with that of a remote
clone, 2008-09-01) indicates may differ depending on the presence of
".git/" for a non-bare repo. That matters for forming relative submodule
paths, but doesn't matter for the second call, since we're just feeding
it to the transport code, which is fine either way.

[1]: https://lore.kernel.org/git/CAMoD=Bi41mB3QRn3JdZL-FGHs4w3C2jGpnJB-CqSndO7FMtfzA@mail.gmail.com/

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agot5619: demonstrate clone_local() with ambiguous transport
Taylor Blau [Wed, 25 Jan 2023 00:43:45 +0000 (19:43 -0500)]
t5619: demonstrate clone_local() with ambiguous transport

When cloning a repository, Git must determine (a) what transport
mechanism to use, and (b) whether or not the clone is local.

Since f38aa83f9a (use local cloning if insteadOf makes a local URL,
2014-07-17), the latter check happens after the remote has been
initialized, and references the remote's URL instead of the local path.
This is done to make it possible for a `url.<base>.insteadOf` rule to
convert a remote URL into a local one, in which case the `clone_local()`
mechanism should be used.

However, with a specially crafted repository, Git can be tricked into
using a non-local transport while still setting `is_local` to "1" and
using the `clone_local()` optimization. The below test case
demonstrates such an instance, and shows that it can be used to include
arbitrary (known) paths in the working copy of a cloned repository on a
victim's machine[^1], even if local file clones are forbidden by
`protocol.file.allow`.

This happens in a few parts:

 1. We first call `get_repo_path()` to see if the remote is a local
    path. If it is, we replace the repo name with its absolute path.

 2. We then call `transport_get()` on the repo name and decide how to
    access it. If it was turned into an absolute path in the previous
    step, then we should always treat it like a file.

 3. We use `get_repo_path()` again, and set `is_local` as appropriate.
    But it's already too late to rewrite the repo name as an absolute
    path, since we've already fed it to the transport code.

The attack works by including a submodule whose URL corresponds to a
path on disk. In the below example, the repository "sub" is reachable
via the dumb HTTP protocol at (something like):

    http://127.0.0.1:NNNN/dumb/sub.git

However, the path "http:/127.0.0.1:NNNN/dumb" (that is, a top-level
directory called "http:", then nested directories "127.0.0.1:NNNN", and
"dumb") exists within the repository, too.

To determine this, it first picks the appropriate transport, which is
dumb HTTP. It then uses the remote's URL in order to determine whether
the repository exists locally on disk. However, the malicious repository
also contains an embedded stub repository which is the target of a
symbolic link at the local path corresponding to the "sub" repository on
disk (i.e., there is a symbolic link at "http:/127.0.0.1/dumb/sub.git",
pointing to the stub repository via ".git/modules/sub/../../../repo").

This stub repository fools Git into thinking that a local repository
exists at that URL and thus can be cloned locally. The affected call is
in `get_repo_path()`, which in turn calls `get_repo_path_1()`, which
locates a valid repository at that target.

This then causes Git to set the `is_local` variable to "1", and in turn
instructs Git to clone the repository using its local clone optimization
via the `clone_local()` function.

The exploit comes into play because the stub repository's top-level
"$GIT_DIR/objects" directory is a symbolic link which can point to an
arbitrary path on the victim's machine. `clone_local()` resolves the
top-level "objects" directory through a `stat(2)` call, meaning that we
read through the symbolic link and copy or hardlink the directory
contents at the destination of the link.

In other words, we can get steps (1) and (3) to disagree by leveraging
the dangling symlink to pick a non-local transport in the first step,
and then set is_local to "1" in the third step when cloning with
`--separate-git-dir`, which makes the symlink non-dangling.

This can result in data-exfiltration on the victim's machine when
sensitive data is at a known path (e.g., "/home/$USER/.ssh").

The appropriate fix is two-fold:

 - Resolve the transport later on (to avoid using the local
   clone optimization with a non-local transport).

 - Avoid reading through the top-level "objects" directory when
   (correctly) using the clone_local() optimization.

This patch merely demonstrates the issue. The following two patches will
implement each part of the above fix, respectively.

[^1]: Provided that any target directory does not contain symbolic
  links, in which case the changes from 6f054f9fb3 (builtin/clone.c:
  disallow `--local` clones with symlinks, 2022-07-28) will abort the
  clone.

Reported-by: yvvdwf <yvvdwf@gmail.com>
Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoThe tenth batch
Junio C Hamano [Mon, 23 Jan 2023 21:39:26 +0000 (13:39 -0800)]
The tenth batch

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

"scalar" learned to give progress bar.

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

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

Quickfix for a topic already in 'master'.

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

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

Plug a small leak.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Test clean-up.

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

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

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

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

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

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

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

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

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

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

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