Commit Graph

162984 Commits

Author SHA1 Message Date
Johannes Schindelin
f04024b5e9 Merge branch 'disallow-control-characters-in-credential-urls-by-default'
This addresses two vulnerabilities:

- CVE-2024-50349:

	Printing unsanitized URLs when asking for credentials made the
	user susceptible to crafted URLs (e.g. in recursive clones) that
	mislead the user into typing in passwords for trusted sites that
	would then be sent to untrusted sites instead.

- CVE-2024-52006

	Git may pass on Carriage Returns via the credential protocol to
	credential helpers which use line-reading functions that
	interpret said Carriage Returns as line endings, even though Git
	did not intend that.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2025-02-06 16:25:22 +01:00
Johannes Schindelin
ee1479b3d9 unix-socket: avoid leak when initialization fails
When a Unix socket is initialized, the current directory's path is
stored so that the cleanup code can `chdir()` back to where it was
before exit.

If the path that needs to be stored exceeds the default size of the
`sun_path` attribute of `struct sockaddr_un` (which is defined as a
108-sized byte array on Linux), a larger buffer needs to be allocated so
that it can hold the path, and it is the responsibility of the
`unix_sockaddr_cleanup()` function to release that allocated memory.

In Git's CI, this stack allocation is not necessary because the code is
checked out to `/home/runner/work/git/git`. Concatenate the path
`t/trash directory.t0301-credential-cache/.cache/git/credential/socket`
and a terminating NUL, and you end up with 96 bytes, 12 shy of the
default `sun_path` size.

However, I use worktrees with slightly longer paths:
`/home/me/projects/git/yes/i/nest/worktrees/to/organize/them/` is more
in line with what I have. When I recently tried to locally reproduce a
failure of the `linux-leaks` CI job, this t0301 test failed (where it
had not failed in CI).

The reason: When `credential-cache` tries to reach its daemon initially
by calling `unix_sockaddr_init()`, it is expected that the daemon cannot
be reached (the idea is to spin up the daemon in that case and try
again). However, when this first call to `unix_sockaddr_init()` fails,
the code returns early from the `unix_stream_connect()` function
_without_ giving the cleanup code a chance to run, skipping the
deallocation of above-mentioned path.

The fix is easy: do not return early but instead go directly to the
cleanup code.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2025-02-06 16:25:22 +01:00
Johannes Schindelin
429023c8d2 credential: disallow Carriage Returns in the protocol by default
While Git has documented that the credential protocol is line-based,
with newlines as terminators, the exact shape of a newline has not been
documented.

From Git's perspective, which is firmly rooted in the Linux ecosystem,
it is clear that "a newline" means a Line Feed character.

However, even Git's credential protocol respects Windows line endings
(a Carriage Return character followed by a Line Feed character, "CR/LF")
by virtue of using `strbuf_getline()`.

There is a third category of line endings that has been used originally
by MacOS, and that is respected by the default line readers of .NET and
node.js: bare Carriage Returns.

Git cannot handle those, and what is worse: Git's remedy against
CVE-2020-5260 does not catch when credential helpers are used that
interpret bare Carriage Returns as newlines.

Git Credential Manager addressed this as CVE-2024-50338, but other
credential helpers may still be vulnerable. So let's not only disallow
Line Feed characters as part of the values in the credential protocol,
but also disallow Carriage Return characters.

In the unlikely event that a credential helper relies on Carriage
Returns in the protocol, introduce an escape hatch via the
`credential.protectProtocol` config setting.

This addresses CVE-2024-52006.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2025-02-06 16:25:21 +01:00
Johannes Schindelin
db58126452 credential: sanitize the user prompt
When asking the user interactively for credentials, we want to avoid
misleading them e.g. via control sequences that pretend that the URL
targets a trusted host when it does not.

While Git learned, over the course of the preceding commits, to disallow
URLs containing URL-encoded control characters by default, credential
helpers are still allowed to specify values very freely (apart from Line
Feed and NUL characters, anything is allowed), and this would allow,
say, a username containing control characters to be specified that would
then be displayed in the interactive terminal prompt asking the user for
the password, potentially sending those control characters directly to
the terminal. This is undesirable because control characters can be used
to mislead users to divulge secret information to untrusted sites.

To prevent such an attack vector, let's add a `git_prompt()` that forces
the displayed text to be sanitized, i.e. displaying question marks
instead of control characters.

Note: While this commit's diff changes a lot of `user@host` strings to
`user%40host`, which may look suspicious on the surface, there is a good
reason for that: this string specifies a user name, not a
<username>@<hostname> combination! In the context of t5541, the actual
combination looks like this: `user%40@127.0.0.1:5541`. Therefore, these
string replacements document a net improvement introduced by this
commit, as `user@host@127.0.0.1` could have left readers wondering where
the user name ends and where the host name begins.

Hinted-at-by: Jeff King <peff@peff.net>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2025-02-06 16:25:21 +01:00
Johannes Schindelin
501d8da34a credential_format(): also encode <host>[:<port>]
An upcoming change wants to sanitize the credential password prompt
where a URL is displayed that may potentially come from a `.gitmodules`
file. To this end, the `credential_format()` function is employed.

To sanitize the host name (and optional port) part of the URL, we need a
new mode of the `strbuf_add_percentencode()` function because the
current mode is both too strict and too lenient: too strict because it
encodes `:`, `[` and `]` (which should be left unencoded in
`<host>:<port>` and in IPv6 addresses), and too lenient because it does
not encode invalid host name characters `/`, `_` and `~`.

So let's introduce and use a new mode specifically to encode the host
name and optional port part of a URI, leaving alpha-numerical
characters, periods, colons and brackets alone and encoding all others.

This only leads to a change of behavior for URLs that contain invalid
host names.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2025-02-06 16:25:21 +01:00
Johannes Schindelin
a62f00cc8e Start the merging-rebase to v2.48.0
This commit starts the rebase of c214f36db2 to e42a29c4b399
2025-02-06 16:07:13 +01:00
Johannes Schindelin
6d3d80b5b2 SECURITY.md: use the new Git for Windows snapshots URL (#5402)
The `SECURITY.md` document mentions Git for Windows' snapshots and
helpfully provides a link.

For almost eight years, Git for Windows' snapshots were hosted [on Azure
Blobs](https://wingit.blob.core.windows.net/files/index.html).

As of a combination of PRs
(https://github.com/git-for-windows/git-for-windows-automation/pull/109,
https://github.com/git-for-windows/gfw-helper-github-app/pull/117),
snapshots are not only now built and deployed via GitHub Actions instead
of Azure Pipelines (and ARM64 artifacts are now included, too), they are
also hosted [on
GitHub](https://github.com/git-for-windows/git-snapshots/releases/),
with the main page being hosted [on GitHub
Pages](https://github.com/git-for-windows/git-snapshots/commits/gh-pages).

Therefore, the original link now redirects to a new location (which is
also a lot easier to remember): http://gitforwindows.org/git-snapshots.
Let's adjust the link to link there directly.

This is a companion PR of
https://github.com/git-for-windows/git-for-windows-automation/pull/111
and of https://github.com/git-for-windows/build-extra/pull/589.
2025-02-06 14:30:38 +01:00
Johannes Schindelin
ae03331ea7 fixup! SECURITY.md: document Git for Windows' policies
The `SECURITY.md` document mentions Git for Windows' snapshots and
helpfully provides a link.

For almost eight years, these snapshots were hosted at
https://wingit.blob.core.windows.net/files/index.html, i.e. on Azure
Blobs.

As of a combination of PRs [*1*], [*2*],
snapshots are not only now built and deployed via GitHub Actions instead
of Azure Pipelines (and ARM64 artifacts are now included, too), they are
also hosted on GitHub [*3*], with the main page being hosted on GitHub
Pages [*4*].

Therefore, the original link now redirects to a new location (which is
also a lot easier to remember): http://gitforwindows.org/git-snapshots.
Let's adjust the link to link there directly.

References:
*1*: https://github.com/git-for-windows/git-for-windows-automation/pull/109
*2*: https://github.com/git-for-windows/gfw-helper-github-app/pull/117
*3*: https://github.com/git-for-windows/git-snapshots/releases/
*4*: https://github.com/git-for-windows/git-snapshots/commits/gh-pages

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2025-02-05 13:13:21 +01:00
Johannes Schindelin
345f0bfa05 Drop support for CI builds using Azure Pipelines (#5389)
A long time ago, we used Azure Pipelines for CI builds. Eventually, when
GitHub Actions was spawned from Azure Pipelines, we moved over to that
system for CI/PR builds.

However, I've tried to keep a working Azure Pipelines definition around
for the embargoed releases, to be able to increase confidence in the
patches by running the full CI build in a private Azure DevOps project
(we cannot do the same on GitHub because even the very generous offer of
50,000 build minutes per month is no match for Git's test suite).

It took a lot of work, and it would take even more work what with
upstream's "remove stale code for Azure Pipelines" part of
`ps/ci-misc-updates`.

Time to let it go.
2025-01-30 17:19:52 +01:00
Johannes Schindelin
5732514b1b fixup! vcxproj: unclash project directories with build outputs
Now that we dropped `contrib/buildsystems/generate` to generate Visual
Studio Solution files, it is time to also drop the `vcxproj` Makefile
target that depended on that script.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2025-01-30 12:25:34 +01:00
Johannes Schindelin
e6e5b99b5c amend! vcxproj: handle GUI programs, too
contrib/buildsystems: drop support for building .vcproj/.vcxproj files

Before we had CMake support, the only way to build Git in Visual Studio
was via this hacky `generate` script.

For a while I tried to fix whenever things got broken, in particular to
allow building confidence in embargoed releases by running the CI builds
in Azure Pipelines in a private Azure DevOps project. I even carried the
patches in Git for Windows with the intention of upstreaming them,
eventually.

However, it is a lot of work with too little benefit. CMake is much
better supported by Visual Studio. So let's drop this hacky script (plus
support code).

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2025-01-30 12:15:41 +01:00
Johannes Schindelin
ae7f51e42f fixup! ci: reinstate Azure Pipelines support
Trying to reinstate support for Azure Pipelines is somewhere between
heroic and futile. I originally tried to do this because it was highly
valuable to be able to run Git's test suite in a private Azure DevOps
project when developing embargoed releases.

Now that upstream drops even more Azure Pipeline support code, it is
time to declare defeat.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2025-01-30 11:56:52 +01:00
Johannes Schindelin
0c796d3013 Apply some v2.48 regression bugfixes (#5376)
Now that most of the Git contributors are back from the holidays, there
is an influx of bug fixes. This is precisely why I held off from rushing
Git for Windows v2.48.0 out the door.

These bug fixes are mostly taken from upstream's branches; In some
cases, though, I had to apply them directly from the Git mailing list
because they did not make it into git/git yet.

I deem those bug fixes necessary to get Git for Windows into a somewhat
healthy state again.
2025-01-23 15:48:44 +01:00
Johannes Schindelin
f045ed3e30 mingw_open_existing: handle directories better (#5342)
[`CreateFileW()` requires `FILE_FLAG_BACKUP_SEMANTICS` to create a
directory
handle](https://learn.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-createfilew#directories)
and errors out with `ERROR_ACCESS_DENIED` without this flag. Fall back
to accessing Directory handles this way.

This fixes https://github.com/git-for-windows/git/issues/5068
2025-01-23 14:58:42 +01:00
Karthik Nayak
290ad15c95 fixup! reftable: write correct max_update_index to header
The original commit was missing some initializations. This lead to the
somewhat intuitive (and not reliably reproducible, until the trick was
found to use `sanitize=address,undefined`) symptom that t1400.249 and/or
t2400.171 failed with:

  Assertion failed: (ret != REFTABLE_API_ERROR), function
  reftable_be_transaction_finish, file reftable-backend.c, line 1648.

or

  Assertion failed: (ret != REFTABLE_API_ERROR), function
  write_transaction_table, file reftable-backend.c, line 1619.

Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2025-01-23 14:53:05 +01:00
Johannes Schindelin
14ed4ada3c Merge branch 'fixes-from-the-git-mailing-list'
These fixes have been sent to the Git mailing list but have not been
picked up by the Git project yet.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2025-01-22 11:39:22 +01:00
Jeff King
86d0c30426 update-ref: do set reflog's old_oid
In git 2.48.1, the `git update-ref` subcommand no longer correctly
updates the reflog in some cases. Specifically, it appears that the
`old_oid` field will not be updated when modifying a branch referenced
by another symbolic ref (e.g. HEAD). This doesn't break the `git
reflog` subcommand, but does break references like `HEAD@{1}`, which
appear to read the `old_oid` field:

  git init -b main
  git commit --allow-empty -m "A"
  git commit --allow-empty -m "B"
  git update-ref -m "reason" refs/heads/main HEAD~ HEAD

The `old_oid` field is now empty (all zeroes). This is only the case in
derived reflogs (in this case .git/logs/HEAD). The reflog for
`refs/heads/main` appears to be updated correctly.

This was broken in 297c09eabb (refs: allow multiple reflog entries for
the same refname, 2024-12-16).

The reason for that was that there was assumed the flow of
`lock_ref_for_update()` for reflog only updates was to capture the lock
only. But this is wrong since this misses the `old_oid` population. As
such this patch is the correct fix.

Reported-by: Nika Layzell <nika@thelayzells.com>
Acked-by: Karthik Nayak <karthik.188@gmail.com>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2025-01-22 11:39:21 +01:00
Jeff King
b7a9905f75 grep: prevent ^$ false match at end of file
In some implementations, `regexec_buf()` assumes that it is fed lines;
Without `REG_NOTEOL` it thinks the end of the buffer is the end of a
line. Which makes sense, but trips up this case because we are not
feeding lines, but rather a whole buffer. So the final newline is not
the start of an empty line, but the true end of the buffer.

This causes an interesting bug:

  $ echo content >file.txt
  $ git grep --no-index -n '^$' file.txt
  file.txt:2:

This bug is fixed by making the end of the buffer consistently the end
of the final line.

The patch was applied from
https://lore.kernel.org/git/20250113062601.GD767856@coredump.intra.peff.net/

Reported-by: Olly Betts <olly@survex.com>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2025-01-22 11:39:21 +01:00
Adam Murray
1edca76e80 trace2: prevent segfault on config collection where no value specified
When TRACE2 analytics is enabled, a git config option that has no value
causes a segfault.

Steps to Reproduce
GIT_TRACE2=true GIT_TRACE2_CONFIG_PARAMS=status.*
git -c status.relativePaths version
Expected Result
git version 2.46.0
Actual Result
zsh: segmentation fault GIT_TRACE2=true

This adds checks to prevent the segfault and instead return
an empty value.

Signed-off-by: Adam Murray <ad@canva.com>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2025-01-22 11:39:21 +01:00
Junio C Hamano
9b7de7e03c Merge branch 'mh/credential-cache-authtype-request-fix'
The "cache" credential back-end did not handle authtype correctly,
which has been corrected.

* mh/credential-cache-authtype-request-fix:
  credential-cache: respect authtype capability

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2025-01-22 11:05:28 +01:00
Junio C Hamano
b37dd622db Merge branch 'jc/show-index-h-update'
Doc and short-help text for "show-index" has been clarified to
stress that the command reads its data from the standard input.

* jc/show-index-h-update:
  show-index: the short help should say the command reads from its input

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2025-01-22 11:03:09 +01:00
Junio C Hamano
1804320830 Merge branch 'bf/fetch-set-head-fix' into jch
Fetching into a bare repository incorrectly assumed it always used
a mirror layout when deciding to update remote-tracking HEAD, which
has been corrected.

* bf/fetch-set-head-fix:
  fetch set_head: fix non-mirror remotes in bare repositories

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2025-01-22 10:59:03 +01:00
Junio C Hamano
120b27442a Merge branch 'rs/ref-filter-used-atoms-value-fix'
"git branch --sort=..." and "git for-each-ref --format=... --sort=..."
did not work as expected with some atoms, which has been corrected.

* rs/ref-fitler-used-atoms-value-fix:
  ref-filter: remove ref_format_clear()
  ref-filter: move is-base tip to used_atom
  ref-filter: move ahead-behind bases into used_atom

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2025-01-22 10:57:14 +01:00
Junio C Hamano
fff597de48 Merge branch 'kn/reflog-migration-fix-followup'
Code clean-up.

* kn/reflog-migration-fix-followup:
  reftable: prevent 'update_index' changes after adding records
  refs: use 'uint64_t' for 'ref_update.index'
  refs: mark `ref_transaction_update_reflog()` as static

These patches have been actually rebased onto a better base (the
`kn/reflog-migration` tip instead of the merge commit that merged this
tip).

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2025-01-22 10:55:10 +01:00
Karthik Nayak
148560f1e3 reftable: prevent 'update_index' changes after adding records
The function `reftable_writer_set_limits()` allows updating the
'min_update_index' and 'max_update_index' of a reftable writer. These
values are written to both the writer's header and footer.

Since the header is written during the first block write, any subsequent
changes to the update index would create a mismatch between the header
and footer values. The footer would contain the newer values while the
header retained the original ones.

To fix this bug, prevent callers from updating these values after any
record is written. To do this, modify the function to return an error
whenever the limits are modified after any record adds. Check for record
adds within `reftable_writer_set_limits()` by checking the `last_key`
variable, which is set whenever a new record is added.

Modify all callers of the function to anticipate a return type and
handle it accordingly.

Helped-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2025-01-22 10:54:17 +01:00
Karthik Nayak
a89e12dc16 refs: use 'uint64_t' for 'ref_update.index'
The 'ref_update.index' variable is used to store an index for a given
reference update. This index is used to order the updates in a
predetermined order, while the default ordering is alphabetical as per
the refname.

For large repositories with millions of references, it should be safer
to use 'uint64_t'. Let's do that. This also is applied for all other
code sections where we store 'index' and pass it around.

Reported-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2025-01-22 10:54:16 +01:00
Karthik Nayak
6638779367 refs: mark ref_transaction_update_reflog() as static
The `ref_transaction_update_reflog()` function is only used within
'refs.c', so mark it as static.

Reported-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2025-01-22 10:54:16 +01:00
Junio C Hamano
a5dd3491bb Merge branch 'kn/reflog-migration-fix'
"git refs migrate" for migrating reflog data was broken.

* kn/reflog-migration-fix:
  reftable: write correct max_update_index to header

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2025-01-22 10:48:44 +01:00
Junio C Hamano
369aa54ab0 Merge branch 'en/object-name-with-funny-refname-fix'
Extended SHA-1 expression parser did not work well when a branch
with an unusual name (e.g. "foo{bar") is involved.

* en/object-name-with-funny-refname-fix:
  object-name: be more strict in parsing describe-like output
  object-name: fix resolution of object names containing curly braces

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2025-01-22 10:47:59 +01:00
Junio C Hamano
7c730349a5 Merge branch 'jk/pack-header-parse-alignment-fix'
It was possible for "git unpack-objects" and "git index-pack" to
make an unaligned access, which has been corrected.

* jk/pack-header-parse-alignment-fix:
  index-pack, unpack-objects: use skip_prefix to avoid magic number
  index-pack, unpack-objects: use get_be32() for reading pack header
  parse_pack_header_option(): avoid unaligned memory writes
  packfile: factor out --pack_header argument parsing
  bswap.h: squelch potential sparse -Wcast-truncate warnings

These patches have actually been rebased onto v2.46.2 for easier
merging.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2025-01-22 10:45:57 +01:00
Jeff King
f2d9cf95f7 index-pack, unpack-objects: use skip_prefix to avoid magic number
When parsing --pack_header=, we manually skip 14 bytes to the data.
Let's use skip_prefix() to do this automatically.

Note that we overwrite our pointer to the front of the string, so we
have to add more context to the error message. We could avoid this by
declaring an extra pointer to hold the value, but I think the modified
message is actually preferable; it should give translators a bit more
context.

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>
2025-01-22 10:45:09 +01:00
Jeff King
7215d586d4 index-pack, unpack-objects: use get_be32() for reading pack header
Both of these commands read the incoming pack into a static unsigned
char buffer in BSS, and then parse it by casting the start of the buffer
to a struct pack_header. This can result in SIGBUS on some platforms if
the compiler doesn't place the buffer in a position that is properly
aligned for 4-byte integers.

This reportedly happens with unpack-objects (but not index-pack) on
sparc64 when compiled with clang (but not gcc). But we are definitely in
the wrong in both spots; since the buffer's type is unsigned char, we
can't depend on larger alignment. When it works it is only because we
are lucky.

We'll fix this by switching to get_be32() to read the headers (just like
the last few commits similarly switched us to put_be32() for writing
into the same buffer).

It would be nice to factor this out into a common helper function, but
the interface ends up quite awkward. Either the caller needs to hardcode
how many bytes we'll need, or it needs to pass us its fill()/use()
functions as pointers. So I've just fixed both spots in the same way;
this is not code that is likely to be repeated a third time (most of the
pack reading code uses an mmap'd buffer, which should be properly
aligned).

I did make one tweak to the shared code: our pack_version_ok() macro
expects us to pass the big-endian value we'd get by casting. We can
introduce a "native" variant which uses the host integer ordering.

Reported-by: Koakuma <koachan@protonmail.com>
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>
2025-01-22 10:45:09 +01:00
Jeff King
56c5e82ca8 parse_pack_header_option(): avoid unaligned memory writes
In order to recreate a pack header in our in-memory buffer, we cast the
buffer to a "struct pack_header" and assign the individual fields. This
is reported to cause SIGBUS on sparc64 due to alignment issues.

We can work around this by using put_be32() which will write individual
bytes into the buffer.

Reported-by: Koakuma <koachan@protonmail.com>
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>
2025-01-22 10:45:09 +01:00
Jeff King
b3c9b61383 packfile: factor out --pack_header argument parsing
Both index-pack and unpack-objects accept a --pack_header argument. This
is an undocumented internal argument used by receive-pack and fetch to
pass along information about the header of the pack, which they've
already read from the incoming stream.

In preparation for a bugfix, let's factor the duplicated code into a
common helper.

The callers are still responsible for identifying the option. While this
could likewise be factored out, it is more flexible this way (e.g., if
they ever started using parse-options and wanted to handle both the
stuck and unstuck forms).

Likewise, the callers are responsible for reporting errors, though they
both just call die(). I've tweaked unpack-objects to match index-pack in
marking the error for translation.

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>
2025-01-22 10:45:08 +01:00
Junio C Hamano
75bc40de27 bswap.h: squelch potential sparse -Wcast-truncate warnings
In put_be32(), we right-shift a uint32_t value various amounts and then
assign the low 8-bits to individual "unsigned char" bytes, throwing away
the high bits. For shifts smaller than 24 bits, those thrown away bits
will be arbitrary bits from the original uint32_t.

This works exactly as we want, but if you feed a constant, then sparse
complains. For example if we write this (which we plan to do in a future
patch):

  put_be32(hdr, PACK_SIGNATURE);

then "make sparse" produces:

  compat/bswap.h:175:22: error: cast truncates bits from constant value (5041 becomes 41)
  compat/bswap.h:176:22: error: cast truncates bits from constant value (504143 becomes 43)
  compat/bswap.h:177:22: error: cast truncates bits from constant value (5041434b becomes 4b)

And the same issue exists in the other put_be*() functions, when used
with a constant.

We can silence this warning by explicitly masking off the truncated
bits. The compiler is smart enough to know the result is the same, and
the asm generated by gcc (with both -O0 and -O2) is identical.

Curiously this line already exists:

	put_be32(&hdr_version, INDEX_EXTENSION_VERSION2);

in the fsmonitor.c file, but it does not get flagged because the CPP
macro expands to a small integer (2).

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>
2025-01-22 10:45:08 +01:00
Junio C Hamano
aec5e0eb80 Merge branch 'ps/object-collision-check'
CI jobs gave sporadic failures, which turns out that that the
object finalization code was giving an error when it did not have
to.

* ps/object-collision-check:
  object-file: retry linking file into place when occluding file vanishes
  object-file: don't special-case missing source file in collision check
  object-file: rename variables in `check_collision()`
  object-file: fix race in object collision check

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2025-01-22 10:40:11 +01:00
Junio C Hamano
9c83589c26 Merge branch 'jk/lsan-race-ignore-false-positive'
The code to check LSan results has been simplified and made more
robust.

* jk/lsan-race-ignore-false-positive:
  test-lib: add a few comments to LSan log checking
  test-lib: simplify lsan results check
  test-lib: invert return value of check_test_results_san_file_empty

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2025-01-22 10:38:04 +01:00
René Scharfe
c5490ce9d1 ref-filter: remove ref_format_clear()
Now that ref_format_clear() no longer releases any memory we don't need
it anymore.  Remove it and its counterpart, ref_format_init().

Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2025-01-21 09:06:24 -08:00
René Scharfe
7ee4fd18ac ref-filter: move is-base tip to used_atom
The string_list "is_base_tips" in struct ref_format stores the
committish part of "is-base:<committish>".  It has the same problems
that its sibling string_list "bases" had.  Fix them the same way as the
previous commit did for the latter, by replacing the string_list with
fields in "used_atom".

Helped-by: Jeff King <peff@peff.net>
Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2025-01-21 09:06:20 -08:00
René Scharfe
5e58db6575 ref-filter: move ahead-behind bases into used_atom
verify_ref_format() parses a ref-filter format string and stores
recognized items in the static array "used_atom".  For
"ahead-behind:<committish>" it stores the committish part in a
string_list member "bases" of struct ref_format.

ref_sorting_options() also parses bare ref-filter format items and
stores stores recognized ones in "used_atom" as well.  The committish
parts go to a dummy struct ref_format in parse_sorting_atom(), though,
and are leaked and forgotten.

If verify_ref_format() is called before ref_sorting_options(), like in
git for-each-ref, then all works well if the sort key is included in the
format string.  If it isn't then sorting cannot work as the committishes
are missing.

If ref_sorting_options() is called first, like in git branch, then we
have the additional issue that if the sort key is included in the format
string then filter_ahead_behind() can't see its committish, will not
generate any results for it and thus it will be expanded to an empty
string.

Fix those issues by replacing the string_list with a field in used_atom
for storing the committish.  This way it can be shared for handling both
ref-filter format strings and sorting options in the same command.

Reported-by: Ross Goldberg <ross.goldberg@gmail.com>
Helped-by: Jeff King <peff@peff.net>
Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2025-01-21 09:06:15 -08:00
Johannes Schindelin
f48c92b414 Rebase to v2.48.0 (#5361)
<details><summary>Range-diff relative to -rc2</summary>


* 1: 8c8a20738d = 1: bbc14d7107 t9350: point out that refs are not
updated correctly
* 2: 25fb03214d = 2: b5fe0f6cb4 transport-helper: add trailing --
* 3: dca2663322 = 3: c74f47bdb3 remote-helper: check helper status
after import/export
* 6: f6f9f1c5a4 = 4: 6166ef7964 gitk(Windows): avoid inadvertently
calling executables in the worktree
* 7: 47dc063320 = 5: dd17fae001 Always auto-gc after calling a
fast-import transport
* 10: c0d09b9c5f = 6: a1108cf540 mingw: include the Python parts in
the build
* 11: d55d5e5d28 = 7: a60cef9296 win32/pthread: avoid name clashes
with winpthread
* 12: 72f78bd097 = 8: 3eaa1ce48e git-compat-util: avoid redeclaring
_DEFAULT_SOURCE
* 13: f7e4509ffb = 9: 461207c9e8 Import the source code of mimalloc
v2.1.2
* 14: 0c0209d422 = 10: dfda515d0e mimalloc: adjust for building
inside Git
* 15: a27ec228d4 = 11: 1499dbda56 mimalloc: offer a build-time
option to enable it
* 4: b536507c35 = 12: ec0016cb64 mingw: demonstrate a problem with
certain absolute paths
* 5: 90288be17b = 13: c2b8b3d3d9 clean: do not traverse mount points
* 16: 2524a044fa = 14: 080c8517ef mimalloc: use "weak" random seed
when statically linked
* 8: 2dcf725f2e = 15: e75cb3b514 mingw: allow absolute paths without
drive prefix
* 9: 00dad35ac2 = 16: 64e8496b7e clean: remove mount points when
possible
* 17:  b8668153da =  17:  11ebfb3833 mingw: use mimalloc
* 18: 5dcfd019e1 = 18: 6b608e8991 transport: optionally disable
side-band-64k
* 23:  0dd5d9410a =  19:  0cb219f0a4 mingw: ensure valid CTYPE
* 24: bf75da68b3 = 20: 0bc4c90b37 mingw: demonstrate a `git add`
issue with NTFS junctions
* 26: 07676d96f1 = 21: 345d8dd1b6 mingw: allow `git.exe` to be used
instead of the "Git wrapper"
* 27: 6c91598dc4 = 22: 13709f0783 strbuf_realpath(): use
platform-dependent API if available
* 29: fe6fb0ec43 = 23: 3db90c39c0 mingw: ignore HOMEDRIVE/HOMEPATH
if it points to Windows' system directory
* 30: 058aad7a72 = 24: acc5a14127 http: use new "best effort"
strategy for Secure Channel revoke checking
* 20: 6d49ea61fc = 25: d7476fc7eb mingw: do resolve symlinks in
`getcwd()`
* 21: 09d7dec59c = 26: 2b6f2917bb mingw: fix fatal error working on
mapped network drives on Windows
* 31: 6c2313d64d = 27: d919252066 clink.pl: fix MSVC compile script
to handle libcurl-d.lib
* 32: 7231ff03b6 = 28: 132f4314d1 mingw: implement a
platform-specific `strbuf_realpath()`
* 22: d2efb3e4c1 = 29: ccdb636f7e vcxproj: unclash project
directories with build outputs
* 25: 6a67ad3cd3 = 30: c532ef35c7 t5505/t5516: allow running without
`.git/branches/` in the templates
* 28: f79ee51053 = 31: adfc048ec3 t5505/t5516: fix white-space
around redirectors
* 33: 432f1018a9 = 32: ca535032ad t3701: verify that we can add
*lots* of files interactively
* 34: ebd57fe043 = 33: c3d5ebcdf1 git add -i: handle CR/LF line
endings in the interactive input
* 45: a17f9f86ad = 34: 201c0e830f commit: accept "scissors" with
CR/LF line endings
* 46:  9874912bb2 =  35:  ae133a0ea9 t0014: fix indentation
* 47: 4a85fd17c5 = 36: ac73ea47ec git-gui: accommodate for
intent-to-add files
* 35: 5cc86b2fec = 37: 77283d028d clink.pl: fix libexpatd.lib link
error when using MSVC
* 36: 1430754f8a = 38: 4bff95d54c Makefile: clean up .ilk files when
MSVC=1
* 37: 5c8e388900 = 39: db01c407b8 vcbuild: add support for compiling
Windows resource files
* 38: e18b12ccf4 = 40: 8f5ad65c77 config.mak.uname: add git.rc to
MSVC builds
* 39: b442bcd8de = 41: 3e47c796eb clink.pl: ignore
no-stack-protector arg on MSVC=1 builds
* 40: bfd7b0fce4 = 42: b59e4b9353 clink.pl: move default linker
options for MSVC=1 builds
* 41: fbce80fb7b = 43: 49cf4b67ed buildsystems: remove duplicate
clause
* 48: 6612874501 = 44: 81ee80b54f vcpkg_install: detect lack of Git
* 42: 03f535e73e = 45: adb78670a8 vcxproj: handle resource files,
too
* 49: 75993b4a4f = 46: e3729ad925 vcpkg_install: add comment
regarding slow network connections
* 43: 5016af712e = 47: 69d15a3827 vcxproj: ignore
-fno-stack-protector and -fno-common
* 50: e96a3499ce = 48: 79bb88cfac vcxproj: support building
Windows/ARM64 binaries
* 44: 6f462b5f80 = 49: f1b2fd699f vcxproj: handle GUI programs, too
* 51: 0559b8f3bf = 50: ff822c640f vcbuild: install ARM64
dependencies when building ARM64 binaries
* 57:  5663ad415b =  51:  f45352ca45 cmake: install headless-git.
* 52: 358ba6b62f = 52: 6e69568529 vcbuild: add an option to install
individual 'features'
* 53: 7b331668db = 53: b3ab8b78d1 cmake: allow building for
Windows/ARM64
* 54: 15e901f834 = 54: d7655970bb ci(vs-build) also build
Windows/ARM64 artifacts
* 55: 040847f4c5 = 55: f8c6875658 Add schannel to curl installation
* 56: 1cd5f8bffd = 56: c80d4f9090 cmake(): allow setting HOST_CPU
for cross-compilation
* 64: 95727aca15 = 57: 3aeb23b738 CMake: default Visual Studio
generator has changed
* 68: beea9e12ca = 58: c20c6eee80 subtree: update `contrib/subtree`
`test` target
* 66: 127faab49a = 59: 1033d6fb5e .gitignore: add Visual Studio
CMakeSetting.json file
* 58: 6704142a96 = 60: 1e95a2f612 mingw: allow for longer paths in
`parse_interpreter()`
* 59: 296b420d82 = 61: 48c6336d00 compat/vcbuild: document preferred
way to build in Visual Studio
* 60: 8a42909e25 = 62: 921f35cada http: optionally send SSL client
certificate
* 71: 3e7da28ee9 = 63: 1fcbe5cba6 ci: run `contrib/subtree` tests in
CI builds
* 61: 10a5c81ac1 = 64: 6183d2da27 hash-object: demonstrate a
>4GB/LLP64 problem
* 62: 3bef351a5b = 65: 23fe600251 write_object_file_literally(): use
size_t
* 63: 2c008c51f8 = 66: c22d98bc72 object-file.c: use size_t for
header lengths
* 65: c35308a76a = 67: 4f197bd47d hash algorithms: use size_t for
section lengths
* 67: 3d25b0eff5 = 68: c4551e70db hash-object --stdin: verify that
it works with >4GB/LLP64
* 69: fafa720aae = 69: 40431da795 CMakeLists: add default
"x64-windows" arch for Visual Studio
* 70: 11b2ac66ec = 70: ce0d0a9baf hash-object: add another
>4GB/LLP64 test case
* 82: 4cd9933bb3 = 71: b045dfa18e setup: properly use "%(prefix)/"
when in WSL
* 72: 1bb4d11435 = 72: 86670c89a8 CMake: show Win32 and
Generator_platform build-option values
* 73: fff28fcf13 = 73: d13b2b6f0b init: do parse _all_ core.*
settings early
* 74: 1a67a18cf4 = 74: 1961e700e6 hash-object: add a >4GB/LLP64 test
case using filtered input
* 85: bffde5dd50 = 75: 307bb0547e compat/mingw.c: do not warn when
failing to get owner
* 75: 820a555c71 = 76: 7324a351e4 vcxproj: allow building with
`NO_PERL` again
* 76:  66d8ef53b1 =  77:  348fae0402 vcxproj: require C11
* 77: 5c867e7adc = 78: 102e426b4a vcxproj: ignore the `-pedantic`
option
* 78: 777ec5856d = 79: 32973aab63 vcxproj: include reftable when
committing `.vcxproj` files
* 79: 0aa5472d27 = 80: 60299ef25e vcxproj: handle libreftable_test,
too
* 80: af26bf72c0 = 81: a69adf6ed9 vcxproj: avoid escaping double
quotes in the defines
* 81: 9331662515 = 82: 331afd2601 ci: adjust Azure Pipeline for
`runs_on_pool`
* 84: eddaab6585 = 83: d4d7862dc6 ci: stop linking the `prove` cache
* 83: 0ff2c1268d = 84: cadcb6dd24 Add config option
`windows.appendAtomically`
* 89: 814d99aaee = 85: b4b814ecc7 ci: reinstate Azure Pipelines
support
* 86: e8fdcc39a9 = 86: c71eebaae7 mingw: $env:TERM="xterm-256color"
for newer OSes
* 87: beb405d40b = 87: 404e0aa054 winansi: check result and Buffer
before using Name
* 88: 02c0dca1bc = 88: 3f98d1317a mingw: change
core.fsyncObjectFiles = 1 by default
* 90: 876eee2c8f = 89: ebc3f7bc37 azure-pipeline: drop the
`GETTEXT_POISON` job
* 91: 136ed6b2e2 = 90: 3ec9280c32 azure-pipeline: stop hard-coding
`apt-get` calls
* 92: 3d2e22c575 = 91: 209f633b29 azure-pipeline: drop the code to
write to/read from a file share
* 93: 12b65ef9ee = 92: ac9ce7cd5c azure-pipeline: use partial
clone/parallel checkout to initialize minimal-sdk
* 94: e08e05b205 = 93: a671d4136f azure-pipeline: downcase the job
name of the `Linux32` job
* 95: e3fa52e1d6 = 94: 231a570c17 bswap.h: add support for built-in
bswap functions
* 96: 01e8056d79 = 95: a4cc607692 MinGW: link as terminal server
aware
* 97: 7acf493c8e = 96: 7e22815598 azure-pipeline: run
static-analysis on jammy
* 98:  7423fab61a =  97:  4c4a0d5e63 Fix Windows version resources
* 99: 3a39c43704 = 98: e80721de6f config.mak.uname: add support for
clangarm64
* 100: bd79a1de70 = 99: 12dfa6893c status: fix for old-style
submodules with commondir
* 101: 222abf90f2 = 100: d9aa4c7614 windows: skip linking
`git-<command>` for built-ins
* 102: 2f6d027242 = 101: 58f6351bfc http: optionally load libcurl
lazily
* 103: 1440baad21 = 102: 6f3580c949 http: support lazy-loading
libcurl also on Windows
* 104: 09a6270725 = 103: 5c064c2dda http: when loading libcurl
lazily, allow for multiple SSL backends
* 105: 8631bd25e5 = 104: f3cd3ed403 windows: fix Repository>Explore
Working Copy
* 106: f89dc5313b = 105: a8bd077c4b mingw: do load libcurl
dynamically by default
* 107: 48cc7ed780 = 106: 0959164055 Add a GitHub workflow to verify
that Git/Scalar work in Nano Server
* 108: 5079c0195f = 107: 171878e1b3 mingw: suggest
`windows.appendAtomically` in more cases
* 109: 526958a9ad = 108: a3742f4833 win32: use native ANSI sequence
processing, if possible
* 110:  8d4b504dff = 109:  52640776d3 git.rc: include winuser.h
* 113: 659c640e12 = 110: 4d9ebe3839 ci: work around a problem with
HTTP/2 vs libcurl v8.10.0
* 114: 1de9cad127 = 111: ef1206c7ae pack-objects: add
--full-name-hash option
* 115: ed17b4ff77 = 112: a79d35ac8a repack: test --full-name-hash
option
* 116: 0990abf98a = 113: 8da7363275 pack-objects: add
GIT_TEST_FULL_NAME_HASH
* 117: acfc3341f1 = 114: 9b1f343258 git-repack: update usage to
match docs
* 111: 5a7a5bac81 = 115: dbd4e4a01d common-main.c: fflush stdout
buffer upon exit
* 112: 7c23b9efa1 = 116: 7b12c55224 t5601/t7406(mingw): do run tests
with symlink support
* 121: d43345128b = 117: 43ad97032d win32: ensure that
`localtime_r()` is declared even in i686 builds
* 122: c12070c703 = 118: fd55edeb07 Fallback to AppData if
XDG_CONFIG_HOME is unset
* 123: 5e1a6837f8 = 119: f08d175d85 run-command: be helpful with Git
LFS fails on Windows 7
* 118: 33f3064093 = 120: fe91a8a193 p5313: add size comparison test
* 119: 9fb1426137 = 121: 9e9b2949a3 test-tool: add helper for
name-hash values
* 120: 131c260fc4 = 122: 36064b60c3 repack/pack-objects: mark
`--full-name-hash` as experimental
* 124: 74ce00b92e = 123: 98030c3bc2 path-walk: introduce an object
walk by path
* 125: a2cf338a39 = 124: 4534fc6d5f t6601: add helper for testing
path-walk API
* 126: e34dc7242a = 125: 048428acdf path-walk: allow consumer to
specify object types
* 127:  0e42bfa362 = 126:  a3d393ba9e path-walk: allow visiting tags
* 128: 63fa6342a3 = 127: e35f96d76f revision: create
mark_trees_uninteresting_dense()
* 129: e545bee799 = 128: ee8deefd88 path-walk: add
prune_all_uninteresting option
* 130: d90b21c3cd = 129: f997fc8a18 pack-objects: extract
should_attempt_deltas()
* 131: 159547f7c9 = 130: 7075c09679 pack-objects: add --path-walk
option
* 132: fc70c9fc1f = 131: 2d88d3f888 pack-objects: introduce
GIT_TEST_PACK_PATH_WALK
* 133:  34e991a53a = 132:  1d621e1bc2 repack: add --path-walk option
* 134: 557e23b741 = 133: 91c1e93319 pack-objects: enable --path-walk
via config
* 135: b1d96616a2 = 134: 14f998ccfd scalar: enable path-walk during
push via config
* 136: 7b59e6ca2a = 135: 4bad79d7d3 pack-objects: refactor path-walk
delta phase
* 137: a7681ff0cc = 136: 0603e43764 pack-objects: thread the
path-based compression
* 138: 9ed9a44c5a = 137: 23ae924500 path-walk API: avoid adding a
root tree more than once
* 140: 5de5395b06 = 138: 58eb7f1388 backfill: add builtin
boilerplate
* 141: ec146ba14f = 139: ebd1692609 backfill: basic functionality
and tests
* 142: dc949345c9 = 140: 6bbc831ec6 backfill: add --batch-size=<n>
option
* 143:  35b7e38d0f = 141:  4f329aa391 backfill: add --sparse option
* 144: 2264e15b42 = 142: 5126f20b04 backfill: assume --sparse when
sparse-checkout is enabled
* 145: a86d017035 = 143: d0bd4c04aa backfill: mark it as
experimental
* 146: c6b7ce0285 = 144: 2787935914 survey: stub in new experimental
'git-survey' command
* 147: 7d894d8f43 = 145: 81a04f41c9 survey: add command line opts to
select references
* 148: 0d8393e8c4 = 146: 3ee79f0a2b survey: start pretty printing
data in table form
* 149: db19259aeb = 147: 2f3acdf2c4 survey: add object count summary
* 150: 4019c9076f = 148: ea53fbb6b4 survey: summarize total sizes by
object type
* 151: 1edff6de14 = 149: e073a4283c survey: show progress during
object walk
* 152: e65957e9ef = 150: 2c1b1631d5 survey: add ability to track
prioritized lists
* 153: fc9fb68b33 = 151: 64b2ec2251 survey: add report of "largest"
paths
* 154: 5c03374fcd = 152: 59481d173f survey: add --top=<N> option and
config
* 155: c1267cca01 = 153: 31789fdd91 survey: clearly note the
experimental nature in the output
* 156: 084fec02a2 = 154: c847baace9 path-walk: improve path-walk
speed with many tags
* 19: 22ca7af048 = 155: 5c9651358f mingw: make sure `errno` is set
correctly when socket operations fail
* 139: 1350d79fe1 (upstream: d02c37c3e6) < -: ------------
t-reftable-basics: stop assuming that `malloc` is not a constant
* 271: af9a2b699f = 156: 78e72dcb91 compat/mingw: handle WSA errors
in strerror
* 272: 0cf45c8d9f ! 157: fd6b18f186 compat/mingw: drop outdated
comment

   ``````diff
   @@ Metadata
     ## Commit message ##
        compat/mingw: drop outdated comment
    
- The part about keeping the original error number hasn't been accurate
since
- commit c11f75c (mingw: make sure errno is set correctly when socket
- operations fail, 2019-11-25) and the part about strerror() not knowing
   -    about these errors is untrue since the previous commit.
+ This comment has been true for the longest time; The combination of
the
+ two preceding commits made it incorrect, so let's drop that comment.
    
        Signed-off-by: Matthias Aßhauer <mha1993@live.de>
        Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
   ``````

* 273: c4d7ea8372 = 158: 5ae96a2444 t0301: actually test
credential-cache on Windows
* 274: ef52c17b50 = 159: 09fe109da4 credential-cache: handle
ECONNREFUSED gracefully
* 157: 09c9eafeea = 160: 8765262b7e Win32: make FILETIME conversion
functions public
* 158: 8a2cf44a14 = 161: afb6c97110 Win32: dirent.c: Move opendir
down
* 159: 8bccc70af1 = 162: 539491295f mingw: make the dirent
implementation pluggable
* 160: d70dde087f = 163: 4d6c9ae3c6 Win32: make the lstat
implementation pluggable
* 161: 79b7550ae6 = 164: 6d933f6fce mingw: add infrastructure for
read-only file system level caches
* 162: 31d1d184a7 = 165: 4bd5d052dd mingw: add a cache below mingw's
lstat and dirent implementations
* 163: fedce44843 = 166: ac62ab4e13 fscache: load directories only
once
* 164: 101b990185 = 167: 0b4d50d1b3 fscache: add key for
GIT_TRACE_FSCACHE
* 165: 537c684adf = 168: 22e59f4a26 fscache: remember not-found
directories
* 166: 26e514b94c = 169: 6f5197b4b0 fscache: add a test for the
dir-not-found optimization
* 167: 4a0b366e4a = 170: 6b3627fd06 add: use preload-index and
fscache for performance
* 168: de1f16b8ef = 171: bd69cf7f40 dir.c: make add_excludes aware
of fscache during status
* 169: ccae4a722a = 172: 3de1d72906 fscache: make fscache_enabled()
public
* 170: 675d8dc7c4 = 173: b8686d71ca dir.c: regression fix for
add_excludes with fscache
* 171: 62a3d3ca3d = 174: b2c8d16d2f fetch-pack.c: enable fscache for
stats under .git/objects
* 172: 71c8974605 = 175: 2bdea0514f checkout.c: enable fscache for
checkout again
* 173: 7ffa2ecc49 = 176: ade2577d4c Enable the filesystem cache
(fscache) in refresh_index().
* 174: 0c81d792d9 = 177: 72e728293b fscache: use FindFirstFileExW to
avoid retrieving the short name
* 175: d27fb3c230 = 178: 24990f964b status: disable and free fscache
at the end of the status command
* 176: b0da78faa7 = 179: 17b2ca1d35 fscache: add GIT_TEST_FSCACHE
support
* 177: c27092b1de = 180: 71c001b3c5 fscache: add fscache hit
statistics
* 178: 409d6ec269 = 181: 3d55d81299 mem_pool: add GIT_TRACE_MEMPOOL
support
* 179: 0d603f9e58 = 182: b0d0b1427c fscache: fscache takes an
initial size
* 180: 580ced925d = 183: d04257110a fscache: update fscache to be
thread specific instead of global
* 181: 1ad0115e1d = 184: f5368b6253 fscache: teach fscache to use
mempool
* 182: 8e76d16a2b = 185: 31d40058eb fscache: make fscache_enable()
thread safe
* 184: fe8536ee57 = 186: cf693a8923 fscache: teach fscache to use
NtQueryDirectoryFile
* 186: f67147a0f6 = 187: e47cadc54e unpack-trees: enable fscache for
sparse-checkout
* 188: 8ee5310485 = 188: 5fc6a7c28a fscache: remember the reparse
tag for each entry
* 190: 00da8eea04 = 189: 014d3fe6dc fscache: implement an
FSCache-aware is_mount_point()
* 183: 8393a50ec2 = 190: 7182f923a8 git-gui: provide question helper
for retry fallback on Windows
* 192:  36b6ed30ff = 191:  bc90e75a3f clean: make use of FSCache
* 185: 6704d86034 = 192: 25f46e372f git gui: set
GIT_ASKPASS=git-gui--askpass if not set yet
* 193: 908c5a19b1 = 193: 138f2a25e2 gitk: Unicode file name support
* 187: 2bd96653e8 = 194: e1f73ec6c9 git-gui--askyesno: fix funny
text wrapping
* 194: 1a36bff0cc = 195: 5c6b2a6873 gitk: Use an external icon file
on Windows
* 189: 7117b15377 = 196: b532ee6052 git-gui--askyesno: allow
overriding the window title
* 195: 8999621557 = 197: 4a5f1dcc43 gitk: fix arrow keys in input
fields with Tcl/Tk >= 8.6
* 191: cd492f2f91 = 198: d033151da3 git-gui--askyesno (mingw): use
Git for Windows' icon, if available
* 196: cafd4841f8 = 199: 17d1088962 gitk: make the "list references"
default window width wider
* 197: 327543d17f = 200: 6adb8e4697 pack-objects (mingw):
demonstrate a segmentation fault with large deltas
* 198:  bfc3db8bb9 = 201:  94378c11ae mingw: support long paths
* 199: 05674cc789 = 202: a5d11abc13 Win32: fix 'lstat("dir/")' with
long paths
* 200: 4ec7736d89 = 203: 3c4cd629b6 win32(long path support): leave
drive-less absolute paths intact
* 201: 884eda4cbb = 204: 072902edbb mingw: Support
`git_terminal_prompt` with more terminals
* 202: 448abe11dd = 205: e79bbe4a3d compat/terminal.c: only use the
Windows console if bash 'read -r' fails
* 203: 7f91760897 = 206: 0449fa6f97 mingw (git_terminal_prompt): do
fall back to CONIN$/CONOUT$ method
* 204: af1cd456aa = 207: 37575e031e strbuf_readlink: don't call
readlink twice if hint is the exact link size
* 210: 5f4c415e89 = 208: 314d9aa624 compat/fsmonitor/fsm-*-win32:
support long paths
* 211: 4b2711a62f = 209: 22868008f3 clean: suggest using
`core.longPaths` if paths are too long to remove
* 205: dedb1ae9cc = 210: 16ba97eb38 strbuf_readlink: support link
targets that exceed PATH_MAX
* 206: 2e09e44445 = 211: 3bbb298a4c lockfile.c: use is_dir_sep()
instead of hardcoded '/' checks
* 207: aadf12406a = 212: 014c9ba727 Win32: don't call
GetFileAttributes twice in mingw_lstat()
* 208: de191d1118 = 213: a5e362e390 Win32: implement stat() with
symlink support
* 209: af7734ab2e = 214: 70e161c34d Win32: remove separate
do_lstat() function
* 212: 7a45cf7089 = 215: 6a57f096f1 Win32: let mingw_lstat() error
early upon problems with reparse points
* 213: 6c99a157e9 = 216: d1a637d8c0 mingw: teach fscache and dirent
about symlinks
* 214: 41c5c14fb1 = 217: b160896166 Win32: lstat(): return adequate
stat.st_size for symlinks
* 215:  65b8430fce = 218:  3b126ac38b Win32: factor out retry logic
* 216: a67d839ab2 = 219: 60b07aed45 Win32: change default of
'core.symlinks' to false
* 217: 24160dbefb = 220: eddaa1718b Win32: add symlink-specific
error codes
* 218: d3df2807d0 = 221: db44028fce Win32: mingw_unlink: support
symlinks to directories
* 219: 87b35ec1dc = 222: 9be895cbdf Win32: mingw_rename: support
renaming symlinks
* 220: 4a58657ad9 = 223: 0ee6c2c23e Win32: mingw_chdir: change to
symlink-resolved directory
* 221:  585b4bb51c = 224:  6fa7f5368c Win32: implement readlink()
* 222: 4236f8cb71 = 225: 16c8396db8 mingw: lstat: compute correct
size for symlinks
* 223: 17bf729c5e = 226: 4bcc8a54d8 Win32: implement basic symlink()
functionality (file symlinks only)
* 224: f7ab0fb397 = 227: 0a04e0774c Win32: symlink: add support for
symlinks to directories
* 225: 96891c3624 = 228: e4a2ade497 mingw: try to create symlinks
without elevated permissions
* 226: 85d41e4398 = 229: cffe5af35a mingw: emulate stat() a little
more faithfully
* 227: c80d1410f0 = 230: 71f5ae4dd1 mingw: special-case index
entries for symlinks with buggy size
* 228: 06376e6537 = 231: 3b7f7fa99e mingw: introduce code to detect
whether we're inside a Windows container
* 229: eb17c48a2d = 232: 7cd902e040 mingw: when running in a Windows
container, try to rename() harder
* 230: f33e574808 = 233: 11f08d458e mingw: move the
file_attr_to_st_mode() function definition
* 231: 167e81d42e = 234: f558a61b38 mingw: Windows Docker volumes
are *not* symbolic links
* 232: e13c7c6888 = 235: 249fd8ae6b Win32: symlink: move phantom
symlink creation to a separate function
* 234: ad1b7a4320 = 236: 4d5a59ac62 Introduce helper to create
symlinks that knows about index_state
* 235: 3199b1b732 = 237: 61e072f3d1 mingw: allow to specify the
symlink type in .gitattributes
* 236: faf1f46b16 = 238: b093fc05d4 Win32: symlink: add test for
`symlink` attribute
* 237: dfbdd01e8a = 239: 07d0a7a29b mingw: explicitly specify with
which cmd to prefix the cmdline
* 238: 0612f86152 = 240: 132edae753 mingw: when path_lookup()
failed, try BusyBox
* 239: 3b9554ef7f = 241: 95e3587440 test-lib: avoid unnecessary Perl
invocation
* 240: f6719f8c13 = 242: bcec4b73c9 test-tool: learn to act as a
drop-in replacement for `iconv`
* 241: d7f4c1d984 = 243: cf2505f6c0 tests(mingw): if `iconv` is
unavailable, use `test-helper --iconv`
* 242: f03dc970e2 = 244: 6c4d2587b1 gitattributes: mark .png files
as binary
* 233: 3e617a8144 = 245: e333decb9b mingw: work around rename()
failing on a read-only file
* 243: 14fa4bf093 = 246: 7a8d524aa8 tests: move test PNGs into
t/lib-diff/
* 244: 87dc864970 = 247: dbd5f28dfb tests: only override sort & find
if there are usable ones in /usr/bin/
* 245: 3789353ae4 = 248: 106450955a tests: use the correct path
separator with BusyBox
* 246: 6a6623b8ce = 249: d4424138d3 mingw: only use Bash-ism
`builtin pwd -W` when available
* 247: 7f70225772 = 250: 14549d6338 tests (mingw): remove
Bash-specific pwd option
* 248: 5503200290 = 251: ace3077a3a test-lib: add BUSYBOX
prerequisite
* 249: 7ccc72d4d6 = 252: 332f4145bb t5003: use binary file from
t/lib-diff/
* 250: bf6204fb3b = 253: 509990422e t5532: workaround for BusyBox on
Windows
* 251: 7c97cdd503 = 254: 680c13654c t5605: special-case hardlink
test for BusyBox-w32
* 252: 25a13abd59 = 255: bb27736b52 t5813: allow for $PWD to be a
Windows path
* 253: 7e1cf7133c = 256: ac2fe470fd t9200: skip tests when $PWD
contains a colon
* 254: 77fb64fc33 = 257: 9db019a61b mingw: add a Makefile target to
copy test artifacts
* 256: 0adaeae337 = 258: 1ecb133cc2 mingw: kill child processes in a
gentler way
* 258: 3a711ce108 = 259: 4238ff7c7e mingw: do not call
xutftowcs_path in mingw_mktemp
* 255: 2e1f7ed403 = 260: c4cee3523e mingw: optionally enable wsl
compability file mode bits
* 257:  64b0171160 = 261:  0eaad07959 mingw: really handle SIGINT
* 260: de57309669 = 262: e1a61a8c2d Partially un-revert "editor:
save and reset terminal after calling EDITOR"
* 264: 49453d0599 = 263: 6071d7ad49 Describe Git for Windows'
architecture [no ci]
* 265: 2890784120 = 264: d94525a8b1 Modify the Code of Conduct for
Git for Windows
* 266: 2b556c9825 = 265: 6e5660dd6d CONTRIBUTING.md: add guide for
first-time contributors
* 267: b7c9a2bf15 = 266: 07c3ffcd94 README.md: Add a
Windows-specific preamble
* 268:  1f22ae108d = 267:  126f9009d0 Add an issue template
* 259: a0a9279891 = 268: fc4f4cdda7 Add a GitHub workflow to monitor
component updates
* 269: 5b004bcd6d = 269: a1fc7cd285 Modify the GitHub Pull Request
template (to reflect Git for Windows)
* 261: db1e920795 = 270: e4fe80e736 reset: reinstate support for the
deprecated --stdin option
* 262: c359f03069 = 271: c3c769bc06 fsmonitor: reintroduce
core.useBuiltinFSMonitor
* 263: 8732d4127b = 272: b18e4dc5a6 dependabot: help keeping GitHub
Actions versions up to date
* 270: b6c04e48e4 = 273: ed5a452566 SECURITY.md: document Git for
Windows' policies
* 275: 9b81fae3f9 (upstream: 1fbb8d7ecb) < -: ------------
builtin/blame: fix out-of-bounds read with excessive `--abbrev`
* 276: 049f0cf1a5 (upstream: 64f3ff3ffc) < -: ------------
GIT-VERSION-GEN: allow it to be run in parallel

</details>
2025-01-17 09:22:26 +01:00
Johannes Schindelin
1c0790184d Merge tag 'v2.47.1.windows.2' into rebase-to-v2.48.0
This merges Git for Windows v2.47.1(2) which was released on January
14th, 2025, in an embargoed release that was massively coordinated
between GitHub Desktop, Visual Studio, Git Credential Manager, Git LFS,
Git and Git for Windows.

Most notably, this merges in the fixes for:

  * CVE-2024-50349: When prompting the user for a password in the
    terminal, Git does not neutralize control characters.
  * CVE-2024-52005: The sideband channel does not neutralize control
    characters.
  * CVE-2024-52006: Similar to CVE-2020-5260, affecting credential
    helpers that interpret Carriage Returns as newlines.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2025-01-16 14:05:16 +01:00
Karthik Nayak
bc67b4ab5f reftable: write correct max_update_index to header
In 297c09eabb (refs: allow multiple reflog entries for the same refname,
2024-12-16), the reftable backend learned to handle multiple reflog
entries within the same transaction. This was done modifying the
`update_index` for reflogs with multiple indices. During writing the
logs, the `max_update_index` of the writer was modified to ensure the
limits were raised to the modified `update_index`s.

However, since ref entries are written before the modification to the
`max_update_index`, if there are multiple blocks to be written, the
reftable backend writes the header with the old `max_update_index`. When
all logs are finally written, the footer will be written with the new
`min_update_index`. This causes a mismatch between the header and the
footer and causes the reftable file to be corrupted. The existing tests
only spawn a single block and since headers are lazily written with the
first block, the tests didn't capture this bug.

To fix the issue, the appropriate `max_update_index` limit must be set
even before the first block is written. Add a `max_index` field to the
transaction which holds the `max_index` within all its updates, then
propagate this value to the reftable backend, wherein this is used to
the set the `max_update_index` correctly.

Add a test which creates a few thousand reference updates with multiple
reflog entries, which should trigger the bug.

Reported-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2025-01-15 09:12:09 -08:00
Elijah Newren
191f0c8db2 object-name: be more strict in parsing describe-like output
From Documentation/revisions.txt:
    '<describeOutput>', e.g. 'v1.7.4.2-679-g3bee7fb'::
      Output from `git describe`; i.e. a closest tag, optionally
      followed by a dash and a number of commits, followed by a dash, a
      'g', and an abbreviated object name.
which means that output of the format
    ${REFNAME}-${INTEGER}-g${HASH}
should parse to fully expanded ${HASH}.  This is fine.  However, we
currently don't validate any of ${REFNAME}-${INTEGER}, we only parse
-g${HASH} and assume the rest is valid.  That is problematic, since it
breaks things like

    git cat-file -p branchname:path/to/file/named/i-gaffed

which, when commit (or tree or blob) affed exists, will not return us
information about the file we are looking for but will instead
erroneously tell us about object affed.

A few additional notes:
  - This is a slight backward incompatibility break, because we used
    to allow ${GARBAGE}-g${HASH} as a way to spell ${HASH}.  However,
    a backward incompatible break is necessary, because there is no
    other way for someone to be more specific and disambiguate that they
    want the blob master:path/to/who-gabbed instead of the object abbed.
  - There is a possibility that check_refname_format() rules change in
    the future.  However, we can only realistically loosen the rules
    for what that function accepts rather than tighten.  If we were to
    tighten the rules, some real world repositories may already have
    refnames that suddenly become unacceptable and we break those
    repositories.  As such, any describe-like syntax of the form
    ${VALID_FOR_A_REFNAME}-${INTEGER}-g${HASH} that is valid with the
    changes in this commit will remain valid in the future.
  - The fact that check_refname_format() rules could loosen in the
    future is probably also an important reason to make this change.  If
    the rules loosen, there might be additional cases within
    ${GARBAGE}-g${HASH} that become ambiguous in the future.  While
    abbreviated hashes can be disambiguated by abbreviating less, it may
    well be that these alternative object names have no way of being
    disambiguated (much like pathnames cannot be).  Accepting all random
    ${GARBAGE} thus makes it difficult for us to allow future
    extensions to object naming.

So, tighten up the parsing to make sure ${REFNAME} and ${INTEGER} are
present in the string, and would be considered a valid ref and
non-negative integer.

Also, add a few tests for git describe using object names of the form
    ${REVISION_NAME}${MODIFIERS}
since an early version of this patch failed on constructs like
    git describe v2.48.0-rc2-161-g6c2274cdbc^0

Reported-by: Gabriel Amaral <gabriel-amaral@github.com>
Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2025-01-13 11:48:43 -08:00
Elijah Newren
71e19a0031 object-name: fix resolution of object names containing curly braces
Given a branch name of 'foo{bar', commands like

    git cat-file -p foo{bar:README.md

should succeed (assuming that branch had a README.md file, of course).
However, the change in cce91a2cae (Change 'master@noon' syntax to
'master@{noon}'., 2006-05-19) presumed that curly braces would always
come after an '@' or '^' and be paired, causing e.g. 'foo{bar:README.md'
to entirely miss the ':' and assume there's no object being referenced.
In short, git would report:

    fatal: Not a valid object name foo{bar:README.md

Change the parsing to only make the assumption of paired curly braces
immediately after either a '@' or '^' character appears.

Add tests for this, as well as for a few other test cases that initial
versions of this patch broke:
  * 'foo@@{...}'
  * 'foo^{/${SEARCH_TEXT_WITH_COLON}}:${PATH}'

Note that we'd prefer not duplicating the special logic for "@^" characters
here, because if get_oid_basic() or interpret_nth_prior_checkout() or
get_oid_basic() or similar gain extra methods of using curly braces,
then the logic in get_oid_with_context_1() would need to be updated as
well.  But it's not clear how to refactor all of these to have a simple
common callpoint with the specialized logic.

Reported-by: Gabriel Amaral <gabriel-amaral@github.com>
Helped-by: Michael Haggerty <mhagger@github.com>
Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2025-01-13 11:48:28 -08:00
Bence Ferdinandy
447cdec2e9 fetch set_head: fix non-mirror remotes in bare repositories
In b1b713f722 (fetch set_head: handle mirrored bare repositories,
2024-11-22) it was implicitly assumed that all remotes will be mirrors
in a bare repository, thus fetching a non-mirrored remote could lead to
HEAD pointing to a non-existent reference. Make sure we only overwrite
HEAD if we are in a bare repository and fetching from a mirror.
Otherwise, proceed as normally, and create
refs/remotes/<nonmirrorremote>/HEAD instead.

Signed-off-by: Bence Ferdinandy <bence@ferdinandy.com>
Reported-by: Christian Hesse <list@eworm.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2025-01-13 09:16:52 -08:00
Johannes Schindelin
81e36eab91 Merge 'readme' into HEAD
Add a README.md for GitHub goodness.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2025-01-11 17:54:05 +01:00
Johannes Schindelin
ede6c1e69c Merge pull request #2837 from dscho/monitor-component-updates
Start monitoring updates of Git for Windows' component in the open
2025-01-11 17:54:05 +01:00
Johannes Schindelin
3645531b19 Merge branch 'deprecate-core.useBuiltinFSMonitor'
Originally introduced as `core.useBuiltinFSMonitor` in Git for Windows
and developed, improved and stabilized there, the built-in FSMonitor
only made it into upstream Git (after unnecessarily long hemming and
hawing and throwing overly perfectionist style review sticks into the
spokes) as `core.fsmonitor = true`.

In Git for Windows, with this topic branch, we re-introduce the
now-obsolete config setting, with warnings suggesting to existing users
how to switch to the new config setting, with the intention to
ultimately drop the patch at some stage.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2025-01-11 17:54:05 +01:00
Johannes Schindelin
34acea6245 Merge branch 'phase-out-reset-stdin'
This topic branch re-adds the deprecated --stdin/-z options to `git
reset`. Those patches were overridden by a different set of options in
the upstream Git project before we could propose `--stdin`.

We offered this in MinGit to applications that wanted a safer way to
pass lots of pathspecs to Git, and these applications will need to be
adjusted.

Instead of `--stdin`, `--pathspec-from-file=-` should be used, and
instead of `-z`, `--pathspec-file-nul`.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2025-01-11 17:54:04 +01:00