]> git.ipfire.org Git - thirdparty/git.git/log
thirdparty/git.git
4 months agoMerge branch 'en/merge-tree-check'
Junio C Hamano [Tue, 27 May 2025 20:59:08 +0000 (13:59 -0700)] 
Merge branch 'en/merge-tree-check'

"git merge-tree" learned an option to see if it resolves cleanly
without actually creating a result.

* en/merge-tree-check:
  merge-tree: add a new --quiet flag
  merge-ort: add a new mergeability_only option

4 months agoMerge branch 'jk/no-funny-object-types'
Junio C Hamano [Tue, 27 May 2025 20:59:08 +0000 (13:59 -0700)] 
Merge branch 'jk/no-funny-object-types'

Support to create a loose object file with unknown object type has
been dropped.

* jk/no-funny-object-types:
  object-file: drop support for writing objects with unknown types
  hash-object: handle --literally with OPT_NEGBIT
  hash-object: merge HASH_* and INDEX_* flags
  hash-object: stop allowing unknown types
  t: add lib-loose.sh
  t/helper: add zlib test-tool
  oid_object_info(): drop type_name strbuf
  fsck: stop using object_info->type_name strbuf
  oid_object_info_convert(): stop using string for object type
  cat-file: use type enum instead of buffer for -t option
  object-file: drop OBJECT_INFO_ALLOW_UNKNOWN_TYPE flag
  cat-file: make --allow-unknown-type a noop
  object-file.h: fix typo in variable declaration

4 months agoMerge branch 'ly/commit-graph-fill-oids-leakfix'
Junio C Hamano [Tue, 27 May 2025 20:59:07 +0000 (13:59 -0700)] 
Merge branch 'ly/commit-graph-fill-oids-leakfix'

Leakfix.

* ly/commit-graph-fill-oids-leakfix:
  commit-graph: fix memory leak when `fill_oids_from_packs()` fails

4 months agoMerge branch 'ly/sequencer-rearrange-leakfix'
Junio C Hamano [Tue, 27 May 2025 20:59:07 +0000 (13:59 -0700)] 
Merge branch 'ly/sequencer-rearrange-leakfix'

Leakfix.

* ly/sequencer-rearrange-leakfix:
  sequencer: fix memory leak if `todo_list_rearrange_squash()` failed

4 months agoMerge branch 'ly/mailinfo-decode-header-leakfix'
Junio C Hamano [Tue, 27 May 2025 20:59:06 +0000 (13:59 -0700)] 
Merge branch 'ly/mailinfo-decode-header-leakfix'

Leakfix.

* ly/mailinfo-decode-header-leakfix:
  mailinfo: fix pointential memory leak if `decode_header` failed

4 months agoMerge branch 'md/userdiff-bash-shell-function'
Junio C Hamano [Tue, 27 May 2025 20:59:06 +0000 (13:59 -0700)] 
Merge branch 'md/userdiff-bash-shell-function'

The userdiff pattern for shell scripts has been updated to cope
with more bash-isms.

* md/userdiff-bash-shell-function:
  userdiff: extend Bash pattern to cover more shell function forms

4 months agoThe seventeenth batch
Junio C Hamano [Fri, 23 May 2025 22:33:39 +0000 (15:33 -0700)] 
The seventeenth batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 months agoMerge branch 'lo/json-writer-docs'
Junio C Hamano [Fri, 23 May 2025 22:34:09 +0000 (15:34 -0700)] 
Merge branch 'lo/json-writer-docs'

In-code docstring updates.

* lo/json-writer-docs:
  json-writer: describe the usage of jw_* functions
  json-writer: add docstrings to jw_* functions

4 months agoMerge branch 'en/replay-wo-the-repository'
Junio C Hamano [Fri, 23 May 2025 22:34:08 +0000 (15:34 -0700)] 
Merge branch 'en/replay-wo-the-repository'

The dependency on the_repository variable has been reduced from the
code paths in "git replay".

* en/replay-wo-the-repository:
  replay: replace the_repository with repo parameter passed to cmd_replay ()

4 months agoMerge branch 'ag/send-email-hostname-f'
Junio C Hamano [Fri, 23 May 2025 22:34:08 +0000 (15:34 -0700)] 
Merge branch 'ag/send-email-hostname-f'

Teach "git send-email" to also consult `hostname -f` for mail
domain to compute the identity given to SMTP servers.

* ag/send-email-hostname-f:
  send-email: try to get fqdn by running hostname -f on Linux and macOS

4 months agoMerge branch 'ps/ci-gitlab-enable-msvc-meson-job'
Junio C Hamano [Fri, 23 May 2025 22:34:07 +0000 (15:34 -0700)] 
Merge branch 'ps/ci-gitlab-enable-msvc-meson-job'

CI settings at GitLab has been updated to run MSVC based Meson job
automatically (as opposed to be done only upon manual request).

* ps/ci-gitlab-enable-msvc-meson-job:
  gitlab-ci: always run MSVC-based Meson job

4 months agoMerge branch 'ds/scalar-no-maintenance'
Junio C Hamano [Fri, 23 May 2025 22:34:07 +0000 (15:34 -0700)] 
Merge branch 'ds/scalar-no-maintenance'

Two "scalar" subcommands that adds a repository that hasn't been
under "scalar"'s control are taught an option not to enable the
scheduled maintenance on it.

* ds/scalar-no-maintenance:
  scalar reconfigure: improve --maintenance docs
  scalar reconfigure: add --maintenance=<mode> option
  scalar clone: add --no-maintenance option
  scalar register: add --no-maintenance option
  scalar: customize register_dir()'s behavior

4 months agoMerge branch 'ly/pack-bitmap-load-leakfix'
Junio C Hamano [Fri, 23 May 2025 22:34:07 +0000 (15:34 -0700)] 
Merge branch 'ly/pack-bitmap-load-leakfix'

Leakfix.

* ly/pack-bitmap-load-leakfix:
  pack-bitmap: fix memory leak if `load_bitmap_entries_v1` failed

4 months agoMerge branch 'js/ci-build-win-in-release-mode'
Junio C Hamano [Fri, 23 May 2025 22:34:06 +0000 (15:34 -0700)] 
Merge branch 'js/ci-build-win-in-release-mode'

win+Meson CI pipeline, unlike other pipelines for Windows,
used to build artifacts in develper mode, which has been changed to
build them in release mode for consistency.

* js/ci-build-win-in-release-mode:
  ci(win+Meson): build in Release mode

5 months agoThe sixteenth batch
Junio C Hamano [Mon, 19 May 2025 22:32:53 +0000 (15:32 -0700)] 
The sixteenth batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 months agoMerge branch 'ps/reftable-read-block-perffix'
Junio C Hamano [Mon, 19 May 2025 23:02:48 +0000 (16:02 -0700)] 
Merge branch 'ps/reftable-read-block-perffix'

Performance regression in not-yet-released code has been corrected.

* ps/reftable-read-block-perffix:
  reftable: fix perf regression when reading blocks of unwanted type

5 months agoMerge branch 'ly/reftable-writer-leakfix'
Junio C Hamano [Mon, 19 May 2025 23:02:47 +0000 (16:02 -0700)] 
Merge branch 'ly/reftable-writer-leakfix'

Leakfix.

* ly/reftable-writer-leakfix:
  reftable/writer: fix memory leak when `writer_index_hash()` fails
  reftable/writer: fix memory leak when `padded_write()` fails

5 months agoMerge branch 'jk/oidmap-cleanup'
Junio C Hamano [Mon, 19 May 2025 23:02:47 +0000 (16:02 -0700)] 
Merge branch 'jk/oidmap-cleanup'

Code cleanup.

* jk/oidmap-cleanup:
  raw_object_store: drop extra pointer to replace_map
  oidmap: add size function
  oidmap: rename oidmap_free() to oidmap_clear()

5 months agoMerge branch 'rc/t1001-test-path-is-file'
Junio C Hamano [Mon, 19 May 2025 23:02:46 +0000 (16:02 -0700)] 
Merge branch 'rc/t1001-test-path-is-file'

Test update.

* rc/t1001-test-path-is-file:
  t1001: replace 'test -f' with 'test_path_is_file'

5 months agoMerge branch 'ly/am-split-stgit-leakfix'
Junio C Hamano [Mon, 19 May 2025 23:02:46 +0000 (16:02 -0700)] 
Merge branch 'ly/am-split-stgit-leakfix'

Leakfix.

* ly/am-split-stgit-leakfix:
  builtin/am: fix memory leak in `split_mail_stgit_series`

5 months agoMerge branch 'bc/make-avoid-unneeded-rebuild-with-compdb-dir'
Junio C Hamano [Mon, 19 May 2025 23:02:45 +0000 (16:02 -0700)] 
Merge branch 'bc/make-avoid-unneeded-rebuild-with-compdb-dir'

Build performance fix.

* bc/make-avoid-unneeded-rebuild-with-compdb-dir:
  Makefile: avoid constant rebuilds with compilation database

5 months agoMerge branch 'ag/doc-send-email'
Junio C Hamano [Mon, 19 May 2025 23:02:45 +0000 (16:02 -0700)] 
Merge branch 'ag/doc-send-email'

The `send-email` documentation has been updated with OAuth2.0
related examples.

* ag/doc-send-email:
  docs: add credential helper for outlook and gmail in OAuth list of helpers
  docs: improve send-email documentation
  send-mail: improve checks for valid_fqdn

5 months agoMerge branch 'sc/bundle-uri-use-all-refs-in-bundle'
Junio C Hamano [Mon, 19 May 2025 23:02:45 +0000 (16:02 -0700)] 
Merge branch 'sc/bundle-uri-use-all-refs-in-bundle'

Bundle-URI feature did not use refs recorded in the bundle other
than normal branches as anchoring points to optimize the follow-up
fetch during "git clone"; now it is told to utilize all.

* sc/bundle-uri-use-all-refs-in-bundle:
  bundle-uri: add test for bundle-uri clones with tags
  bundle-uri: copy all bundle references ino the refs/bundle space

5 months agoMerge branch 'pw/sequencer-reflog-use-after-free'
Junio C Hamano [Mon, 19 May 2025 23:02:44 +0000 (16:02 -0700)] 
Merge branch 'pw/sequencer-reflog-use-after-free'

Use-after-free fix in the sequencer.

* pw/sequencer-reflog-use-after-free:
  sequencer: rework reflog message handling
  sequencer: move reflog message functions

5 months agomerge-tree: add a new --quiet flag
Elijah Newren [Fri, 16 May 2025 20:04:18 +0000 (20:04 +0000)] 
merge-tree: add a new --quiet flag

Git Forges may be interested in whether two branches can be merged while
not being interested in what the resulting merge tree is nor which files
conflicted.  For such cases, add a new --quiet flag which
will make use of the new mergeability_only flag added to merge-ort in
the previous commit.  This option allows the merge machinery to, in the
outer layer of the merge:
    * exit early when a conflict is detected
    * avoid writing (most) merged blobs/trees to the object store

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 months agomerge-ort: add a new mergeability_only option
Elijah Newren [Fri, 16 May 2025 20:04:17 +0000 (20:04 +0000)] 
merge-ort: add a new mergeability_only option

Git Forges may be interested in whether two branches can be merged while
not being interested in what the resulting merge tree is nor which files
conflicted.  For such cases, add a new mergeability_only option.  This
option allows the merge machinery to, in the "outer layer" of the merge:
  * exit upon first[-ish] conflict
  * avoid (not prevent) writing merged blobs/trees to the object store

I have a number of qualifiers there, so let me explain each:

"outer layer":

Note that since the recursive merge of merge bases (corresponding to
call_depth > 0) can conflict without the outer final merge
(corresponding to call_depth == 0) conflicting, we can't short-circuit
nor avoid writing merged blobs/trees to the object store during those
inner merges.

"first-ish conflict":

The current patch only exits early from process_entries() on the first
conflict it detects, but conflicts could have been detected in a
previous function call, namely detect_and_process_renames().  However:
  * conflicts detected by detect_and_process_renames() are quite rare
    conflict types
  * the detection would still come after regular rename detection
    (which is the expensive part of detect_and_process_renames()), so
    it is not saving us much in computation time given that
    process_entries() directly follows detect_and_process_renames()
  * [this overlaps with the next bullet point] process_entries() is the
    place where virtually all object writing occurs (object writing is
    sometimes more of a concern for Forges than computation time), so
    exiting early here isn't saving us much in object writes either
  * the code changes needed to handle an earlier exit are slightly
    more invasive in detect_and_process_renames() than for
    process_entries().
Given the rareness of the even earlier conflicts, the limited savings
we'd get from exiting even earlier, and in an attempt to keep this
patch simpler, we don't guarantee that we actually exit on the first
conflict detected.  We can always revisit this decision later if we
decide that a further micro-optimization to exit slightly earlier in
rare cases is worthwhile.

"avoid (not prevent) writing objects":

The detect_and_process_renames() call can also write objects to the
object store, when rename/rename conflicts involve one (or more) files
that have also been modified on both sides.  Because of this alternate
call path leading to handle_content_merges(), our "early exit" does not
prevent writing objects entirely, even within the "outer layer"
(i.e. even within call_depth == 0).  I figure that's fine though, since
we're already writing objects for the inner merges (i.e. for call_depth
> 0), which are likely going to represent vastly more objects than files
involved in rename/rename+modify/modify cases in the outer merge, on
average.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 months agouserdiff: extend Bash pattern to cover more shell function forms
Moumita Dhar [Fri, 16 May 2025 14:45:12 +0000 (20:15 +0530)] 
userdiff: extend Bash pattern to cover more shell function forms

The previous function regex required explicit matching of function
bodies using `{`, `(`, `((`, or `[[`, which caused several issues:

- It failed to capture valid functions where `{` was on the next line
  due to line continuation (`\`).
- It did not recognize functions with single  command body, such as
  `x () echo hello`.

Replacing the function body matching logic with `.*$`, ensures
that everything on the function definition line is captured.

Additionally, the word regex is refined to better recognize shell
syntax, including additional parameter expansion operators and
command-line options.

Signed-off-by: Moumita Dhar <dhar61595@gmail.com>
Acked-by: Johannes Sixt <j6t@kdbg.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 months agoobject-file: drop support for writing objects with unknown types
Jeff King [Fri, 16 May 2025 04:50:13 +0000 (00:50 -0400)] 
object-file: drop support for writing objects with unknown types

Since "hash-object --literally" no longer supports objects with unknown
types, there are now no callers of write_object_file_literally() and its
helpers. Let's drop them to simplify the code.

In particular, this gets rid of some ugly copy-and-paste code from
write_object_file_literally(), which is a parallel implementation of
write_object_file(). When the split was originally made, the two weren't
that long, but commits like 63a6745a07 (object-file: update the loose
object map when writing loose objects, 2023-10-01) ended up having to
duplicate some tricky code.

This patch drops all of that duplication and should make things less
error-prone going forward.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 months agohash-object: handle --literally with OPT_NEGBIT
Jeff King [Fri, 16 May 2025 04:50:10 +0000 (00:50 -0400)] 
hash-object: handle --literally with OPT_NEGBIT

Since we recently removed the hash_literally() function, the hash-object
--literally option has been simplified to just removing the
INDEX_FORMAT_CHECK flag. Rather than pass it around as a separate bool,
we can just have the option parser remove the bit from the set of flags
directly. This simplifies the helper functions.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 months agohash-object: merge HASH_* and INDEX_* flags
Jeff King [Fri, 16 May 2025 04:50:08 +0000 (00:50 -0400)] 
hash-object: merge HASH_* and INDEX_* flags

The hash-object command has its own custom flag bits that it sets based
on command-line options. But since we dropped hash_literally() in the
previous commit, the only thing we do with those flag bits is convert
them directly into "index_flags" to pass to index_fd().

This extra layer of indirection makes the code harder to read and reason
about. Let's just use the INDEX_* flags directly.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 months agohash-object: stop allowing unknown types
Jeff King [Fri, 16 May 2025 04:50:05 +0000 (00:50 -0400)] 
hash-object: stop allowing unknown types

When passed the "--literally" option, hash-object will allow any
arbitrary string for its "-t" type option. Such objects are only useful
for testing or debugging, as they cannot be used in the normal way
(e.g., you cannot fetch their contents!).

Let's drop this feature, which will eventually let us simplify the
object-writing code. This is technically backwards incompatible, but
since such objects were never really functional, it seems unlikely that
anybody will notice.

We will retain the --literally flag, as it also instructs hash-object
not to worry about other format issues (e.g., type-specific things that
fsck would complain about). The documentation does not need to be
updated, as it was always vague about which checks we're loosening (it
uses only the phrase "any garbage").

The code change is a bit hard to verify from just the patch text. We can
drop our local hash_literally() helper, but it was really just wrapping
write_object_file_literally(). We now replace that with calling
index_fd(), as we do for the non-literal code path, but dropping the
INDEX_FORMAT_CHECK flag. This ends up being the same semantically as
what the _literally() code path was doing (modulo handling unknown
types, which is our goal).

We'll be able to clean up these code paths a bit more in subsequent
patches.

The existing test is flipped to show that we now reject the unknown
type. The additional "extra-long type" test is now redundant, as we bail
early upon seeing a bogus type.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 months agot: add lib-loose.sh
Jeff King [Fri, 16 May 2025 04:50:02 +0000 (00:50 -0400)] 
t: add lib-loose.sh

This commit adds a shell library for writing raw loose objects into the
object database. Normally this is done with hash-object, but the
specific intent here is to allow broken objects that hash-object may not
support.

We'll convert several cases that use "hash-object --literally" to write
objects with invalid types. That works currently, but dropping this
dependency will allow us to remove that feature and simplify the
object-writing code.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 months agot/helper: add zlib test-tool
Jeff King [Fri, 16 May 2025 04:49:59 +0000 (00:49 -0400)] 
t/helper: add zlib test-tool

It's occasionally useful when testing or debugging to be able to do raw
zlib inflate/deflate operations (e.g., to check the bytes of a specific
loose or packed object).

Even though zlib's deflate algorithm is used by many other programs,
this is surprisingly hard to do in a portable way. E.g., gzip can do
this if you manually munge some header bytes. But the result is somewhat
arcane, and we don't assume gzip is available anyway. Likewise, pigz
will handle raw zlib, but we can't assume it is available.

So let's introduce a short test helper for just doing zlib operations.
We'll use it in subsequent patches to add some new tests, but it would
also have come in handy a few times in the past:

  - The hard-coded pack data from 3b910d0c5e (add tests for indexing
    packs with delta cycles, 2013-08-23) could probably be generated on
    the fly.

  - Likewise we could avoid the hard-coded data from 0b1493c2d4
    (git_inflate(): skip zlib_post_call() sanity check on Z_NEED_DICT,
    2025-02-25). Though note this would require support for more zlib
    options.

  - It would have helped with the debugging documented in 41dfbb2dbe
    (howto: add article on recovering a corrupted object, 2013-10-25).

I'll leave refactoring existing tests for another day, but I hope the
examples above show the general utility.

I aimed for simplicity in the code. In particular, it will read all
input into a memory buffer, rather than streaming. That makes the zlib
loops harder to get wrong (which has been a source of subtle bugs in the
past).

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 months agooid_object_info(): drop type_name strbuf
Jeff King [Fri, 16 May 2025 04:49:56 +0000 (00:49 -0400)] 
oid_object_info(): drop type_name strbuf

We provide a mechanism for callers to get the object type as a raw
string, rather than an object_type enum. This was in theory useful for
returning types that are not representable in the enum, but we consider
any such type to be an error, and there are no callers that use the
strbuf anymore.

Let's drop support to simplify the code a bit.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 months agofsck: stop using object_info->type_name strbuf
Jeff King [Fri, 16 May 2025 04:49:53 +0000 (00:49 -0400)] 
fsck: stop using object_info->type_name strbuf

When fsck-ing a loose object, we use object_info's type_name strbuf to
record the parsed object type as a string. For most objects this is
redundant with the object_type enum, but it does let us report the
string when we encounter an object with an unknown type (for which there
is no matching enum value).

There are a few downsides, though:

  1. The code to report these cases is not actually robust. Since we did
     not pass a strbuf to unpack_loose_header(), we only retrieved types
     from headers up to 32 bytes. In longer cases, we'd simply say
     "object corrupt or missing".

  2. This is the last caller that uses object_info's type_name strbuf
     support. It would be nice to refactor it so that we can simplify
     that code.

  3. Likewise, we'll check the hash of the object using its unknown type
     (again, as long as that type is short enough). That depends on the
     hash_object_file_literally() code, which we'd eventually like to
     get rid of.

So we can simplify things by bailing immediately in read_loose_object()
when we encounter an unknown type. This has a few user-visible effects:

  a. Instead of producing a single line of error output like this:

       error: 26ed13ce3564fbbb44e35bde42c7da717ea004a6: object is of unknown type 'bogus': .git/objects/26/ed13ce3564fbbb44e35bde42c7da717ea004a6

     we'll now issue two lines (the first from read_loose_object() when
     we see the unparsable header, and the second from the fsck code,
     since we couldn't read the object):

       error: unable to parse type from header 'bogus 4' of .git/objects/26/ed13ce3564fbbb44e35bde42c7da717ea004a6
       error: 26ed13ce3564fbbb44e35bde42c7da717ea004a6: object corrupt or missing: .git/objects/26/ed13ce3564fbbb44e35bde42c7da717ea004a6

     This is a little more verbose, but this sort of error should be
     rare (such objects are almost impossible to work with, and cannot
     be transferred between repositories as they are not representable
     in packfiles). And as a bonus, reporting the broken header in full
     could help with debugging other cases (e.g., a header like "blob
     xyzzy\0" would fail in parsing the size, but previously we'd not
     have showed the offending bytes).

  b. An object with an unknown type will be reported as corrupt, without
     actually doing a hash check. Again, I think this is unlikely to
     matter in practice since such objects are totally unusable.

We'll update one fsck test to match the new error strings. And we can
remove another test that covered the case of an object with an unknown
type _and_ a hash corruption. Since we'll skip the hash check now in
this case, the test is no longer interesting.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 months agooid_object_info_convert(): stop using string for object type
Jeff King [Fri, 16 May 2025 04:49:50 +0000 (00:49 -0400)] 
oid_object_info_convert(): stop using string for object type

In oid_object_info_convert(), we convert objects between their sha1 and
sha256 variants. To do this, we naturally need to know the type, which
we get from oid_object_info_extended() using its type_name strbuf
option.

But getting the value as a string (versus an object_type enum) is not
helpful. Since we do not allow unknown types, the regular enum is
sufficient. And the resulting code is a bit simpler, as we no longer
have to manage the extra allocation nor convert the string to an enum
ourselves.

Note that at first glance, it might seem like we should retain the error
check for "type == -1" to catch bogus types found by the underlying
parser. But we don't need it, as an unknown type would have yielded an
error from the call to oid_object_info_extended(), which would already
have caused us to return an error.

In fact, I suspect this was always impossible to trigger. Even when we
were converting the string to a type enum ourselves, an invalid type
would never have escaped oid_object_info_extended(), since we never
passed the (now removed) OBJECT_INFO_ALLOW_UNKNOWN_TYPE option.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 months agocat-file: use type enum instead of buffer for -t option
Jeff King [Fri, 16 May 2025 04:49:47 +0000 (00:49 -0400)] 
cat-file: use type enum instead of buffer for -t option

Now that we no longer support OBJECT_INFO_ALLOW_UNKNOWN_TYPE, there is
no need to pass a strbuf into oid_object_info_extended() to record the
type. The regular object_type enum is sufficient to capture all of the
types we will allow.

This simplifies the code a bit, and will eventually let us drop
object_info's type_name strbuf support.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 months agoobject-file: drop OBJECT_INFO_ALLOW_UNKNOWN_TYPE flag
Jeff King [Fri, 16 May 2025 04:49:45 +0000 (00:49 -0400)] 
object-file: drop OBJECT_INFO_ALLOW_UNKNOWN_TYPE flag

Since cat-file dropped its "--allow-unknown-type" option in the previous
commit, there are no more uses of the internal flag that implemented it.
Let's drop it.

That in turn lets us drop the strbuf parameter of unpack_loose_header(),
which now is always NULL. And without that, we can drop all of the
additional code to inflate larger headers into the strbuf.

Arguably we could drop ULHR_TOO_LONG, as no callers really care about
the distinction from ULHR_BAD. But it's easy enough to retain, and it
does let us produce a slightly more specific message in one instance.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 months agocat-file: make --allow-unknown-type a noop
Jeff King [Fri, 16 May 2025 04:49:35 +0000 (00:49 -0400)] 
cat-file: make --allow-unknown-type a noop

The cat-file command has some minor support for handling objects with
"unknown" types. I.e., strings that are not "blob", "commit", "tree", or
"tag".

In theory this could be used for debugging or experimenting with
extensions to Git. But in practice this support is not very useful:

  1. You can get the type and size of such objects, but nothing else.
     Not even the contents!

  2. Only loose objects are supported, since packfiles use numeric ids
     for the types, rather than strings.

  3. Likewise you cannot ever transfer objects between repositories,
     because they cannot be represented in the packfiles used for the
     on-the-wire protocol.

The support for these unknown types complicates the object-parsing code,
and has led to bugs such as b748ddb7a4 (unpack_loose_header(): fix
infinite loop on broken zlib input, 2025-02-25). So let's drop it.

The first step is to remove the user-facing parts, which are accessible
only via cat-file. This is technically backwards-incompatible, but given
the limitations listed above, these objects couldn't possibly be useful
in any workflow.

However, we can't just rip out the option entirely. That would hurt a
caller who ran:

  git cat-file -t --allow-unknown-object <oid>

and fed it normal, well-formed objects. There --allow-unknown-type was
doing nothing, but we wouldn't want to start bailing with an error. So
to protect any such callers, we'll retain --allow-unknown-type as a
noop.

The code change is fairly small (but we'll able to clean up more code in
follow-on patches). The test updates drop any use of the option. We
still retain tests that feed the broken objects to cat-file without
--allow-unknown-type, as we should continue to confirm that those
objects are rejected. Note that in one spot we can drop a layer of loop,
re-indenting the body; viewing the diff with "-w" helps there.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 months agoobject-file.h: fix typo in variable declaration
Jeff King [Fri, 16 May 2025 04:49:28 +0000 (00:49 -0400)] 
object-file.h: fix typo in variable declaration

This should be "compat", not "comapt".

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 months agojson-writer: describe the usage of jw_* functions
Lucas Seiki Oshiro [Fri, 16 May 2025 01:01:59 +0000 (22:01 -0300)] 
json-writer: describe the usage of jw_* functions

Provide an overview of the set of functions used for manipulating
`json_writer`s, by describing what functions should be used for
each JSON-related task.

Helped-by: Junio C Hamano <gitster@pobox.com>
Helped-by: Patrick Steinhardt <ps@pks.im>
Helped-by: Karthik Nayak <karthik.188@gmail.com>
Signed-off-by: Lucas Seiki Oshiro <lucasseikioshiro@gmail.com>
Acked-by: Karthik Nayak <karthik.188@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 months agojson-writer: add docstrings to jw_* functions
Lucas Seiki Oshiro [Fri, 16 May 2025 01:01:58 +0000 (22:01 -0300)] 
json-writer: add docstrings to jw_* functions

Add a docstring for each function that manipulates json_writers.

Helped-by: Junio C Hamano <gitster@pobox.com>
Helped-by: Patrick Steinhardt <ps@pks.im>
Helped-by: Karthik Nayak <karthik.188@gmail.com>
Signed-off-by: Lucas Seiki Oshiro <lucasseikioshiro@gmail.com>
Acked-by: Karthik Nayak <karthik.188@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 months agoThe fifteenth batch
Junio C Hamano [Fri, 16 May 2025 00:27:23 +0000 (17:27 -0700)] 
The fifteenth batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 months agoMerge branch 'tb/macos-false-but-the-compiler-does-not-know-it-fix'
Junio C Hamano [Fri, 16 May 2025 00:24:57 +0000 (17:24 -0700)] 
Merge branch 'tb/macos-false-but-the-compiler-does-not-know-it-fix'

Workaround for older macOS ld.

* tb/macos-false-but-the-compiler-does-not-know-it-fix:
  intialize false_but_the_compiler_does_not_know_it_

5 months agoMerge branch 'jc/t6011-mv-ro-fix'
Junio C Hamano [Fri, 16 May 2025 00:24:56 +0000 (17:24 -0700)] 
Merge branch 'jc/t6011-mv-ro-fix'

Test fix.

* jc/t6011-mv-ro-fix:
  t6011: fix misconversion from perl to sed

5 months agoMerge branch 'dd/meson-perl-custom-path'
Junio C Hamano [Fri, 16 May 2025 00:24:56 +0000 (17:24 -0700)] 
Merge branch 'dd/meson-perl-custom-path'

Meson-based build framework update.

* dd/meson-perl-custom-path:
  meson: allow customize perl installation path

5 months agoMerge branch 'ps/maintenance-missing-tasks'
Junio C Hamano [Fri, 16 May 2025 00:24:55 +0000 (17:24 -0700)] 
Merge branch 'ps/maintenance-missing-tasks'

Make repository clean-up tasks "gc" can do available to "git
maintenance" front-end.

* ps/maintenance-missing-tasks:
  builtin/maintenance: introduce "rerere-gc" task
  builtin/gc: move rerere garbage collection into separate function
  builtin/maintenance: introduce "worktree-prune" task
  builtin/gc: move pruning of worktrees into a separate function
  builtin/gc: remove global variables where it is trivial to do
  builtin/gc: fix indentation of `cmd_gc()` parameters

5 months agoMerge branch 'cf/wrapper-bsd-eloop'
Junio C Hamano [Fri, 16 May 2025 00:24:55 +0000 (17:24 -0700)] 
Merge branch 'cf/wrapper-bsd-eloop'

The fallback implementation of open_nofollow() depended on
open("symlink", O_NOFOLLOW) to set errno to ELOOP, but a few BSD
derived systems use different errno, which has been worked around.

* cf/wrapper-bsd-eloop:
  wrapper: NetBSD gives EFTYPE and FreeBSD gives EMFILE where POSIX uses ELOOP

5 months agocommit-graph: fix memory leak when `fill_oids_from_packs()` fails
Lidong Yan [Fri, 9 May 2025 08:30:35 +0000 (08:30 +0000)] 
commit-graph: fix memory leak when `fill_oids_from_packs()` fails

In commit-graph.c:fill_oids_from_packs, if open_pack_index failed,
memory allocated and returned by add_packed_git will leak. Simply
add close_pack and free(p) will solve this problem.

Signed-off-by: Lidong Yan <502024330056@smail.nju.edu.cn>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 months agosequencer: fix memory leak if `todo_list_rearrange_squash()` failed
Lidong Yan [Wed, 14 May 2025 13:53:28 +0000 (13:53 +0000)] 
sequencer: fix memory leak if `todo_list_rearrange_squash()` failed

In sequencer.c:todo_list_rearrange_squash, if it fails, memory
allocated in `next`, `tail`, `subjects` and `subject2item` will leak.
Jump to cleanup label before return could fix this leak problem.

Signed-off-by: Lidong Yan <502024330056@smail.nju.edu.cn>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 months agomailinfo: fix pointential memory leak if `decode_header` failed
Lidong Yan [Tue, 13 May 2025 02:49:10 +0000 (02:49 +0000)] 
mailinfo: fix pointential memory leak if `decode_header` failed

In mailinfo.c:decode_header, if convert_to_utf8 failed, the strbuf stored
in dec will leak. Simply add strbuf_release and free(dec) will solve
this problem.

Signed-off-by: Lidong Yan <502024330056@smail.nju.edu.cn>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 months agoreplay: replace the_repository with repo parameter passed to cmd_replay ()
Elijah Newren [Wed, 14 May 2025 20:33:25 +0000 (20:33 +0000)] 
replay: replace the_repository with repo parameter passed to cmd_replay ()

Replace the_repository everywhere with repo, feed repo from cmd_replay()
to all the other functions in the file that need it, and remove the
UNUSED annotation on repo.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 months agoscalar reconfigure: improve --maintenance docs
Derrick Stolee [Wed, 14 May 2025 13:52:44 +0000 (09:52 -0400)] 
scalar reconfigure: improve --maintenance docs

The --maintenance option for 'scalar reconfigure' has three possible
values. Improve the documentation by specifying the option in the -h
help menu and usage information.

Signed-off-by: Derrick Stolee <stolee@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 months agosend-email: try to get fqdn by running hostname -f on Linux and macOS
Aditya Garg [Mon, 12 May 2025 08:11:19 +0000 (08:11 +0000)] 
send-email: try to get fqdn by running hostname -f on Linux and macOS

`hostname` is a popular command available on both Linux and macOS. As
per the man-page[1], `hostname -f` command returns the fully qualified
domain name (FQDN) of the system. The current Net::Domain perl module
being used in the script for the same has been quite unrealiable in many
cases. Thankfully, we now have a better check for valid_fqdn, which does
reject the invalid FQDNs given by this module properly, but at the same
time, it will result in a fallback to 'localhost.localdomain' being
used. `hostname -f` has been quite reliable (probably even more reliable
than the Net::Domain module) and before falling back to
'localhost.localdomain', we should try to use it. Interestingly, the
`hostname` command is actually used by perl modules like Net::Domain[2]
and Sys::Hostname[3] to get the hostname. So, lets give `hostname -f` a
chance as well!

[1]: https://man7.org/linux/man-pages/man1/hostname.1.html
[2]: https://github.com/Perl/perl5/blob/blead/cpan/libnet/lib/Net/Domain.pm#L88
[3]: https://github.com/Perl/perl5/blob/blead/ext/Sys-Hostname/Hostname.pm#L93

Signed-off-by: Aditya Garg <gargaditya08@live.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 months agoThe fourteenth batch
Junio C Hamano [Tue, 13 May 2025 21:05:18 +0000 (14:05 -0700)] 
The fourteenth batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 months agoMerge branch 'kj/glob-path-with-special-char'
Junio C Hamano [Tue, 13 May 2025 21:05:07 +0000 (14:05 -0700)] 
Merge branch 'kj/glob-path-with-special-char'

"git add 'f?o'" did not add 'foo' if 'f?o', an unusual pathname,
also existed on the working tree, which has been corrected.

* kj/glob-path-with-special-char:
  dir.c: literal match with wildcard in pathspec should still glob

5 months agoMerge branch 'kh/docfixes'
Junio C Hamano [Tue, 13 May 2025 21:05:07 +0000 (14:05 -0700)] 
Merge branch 'kh/docfixes'

Docfixes.

* kh/docfixes:
  doc: branch: fix inline-verbatim
  doc: reflog: fix `drop` subheading

5 months agoMerge branch 'js/ci-buildsystems-cleanup'
Junio C Hamano [Tue, 13 May 2025 21:05:06 +0000 (14:05 -0700)] 
Merge branch 'js/ci-buildsystems-cleanup'

Code clean-up around stale CI elements and building with Visual Studio.

* js/ci-buildsystems-cleanup:
  config.mak.uname: drop the `vcxproj` target
  contrib/buildsystems: drop support for building . vcproj/.vcxproj files
  ci: stop linking the `prove` cache

5 months agoMerge branch 'ps/ci-test-aggreg-fix-for-meson'
Junio C Hamano [Tue, 13 May 2025 21:05:06 +0000 (14:05 -0700)] 
Merge branch 'ps/ci-test-aggreg-fix-for-meson'

Test result aggregation did not work in Meson based CI jobs.

* ps/ci-test-aggreg-fix-for-meson:
  ci: fix aggregation of test results with Meson

5 months agoMerge branch 'en/get-tree-entry-doc'
Junio C Hamano [Tue, 13 May 2025 21:05:05 +0000 (14:05 -0700)] 
Merge branch 'en/get-tree-entry-doc'

Doc update.

* en/get-tree-entry-doc:
  tree-walk.h: fix incorrect API comment

5 months agogitlab-ci: always run MSVC-based Meson job
Patrick Steinhardt [Mon, 28 Apr 2025 09:32:12 +0000 (11:32 +0200)] 
gitlab-ci: always run MSVC-based Meson job

With 7304bd2bc39 (ci: wire up Visual Studio build with Meson,
2025-01-22) we have introduced a CI job that builds and tests Git with
Microsoft Visual Studio via Meson. This job is only being executed by
default on GitHub Workflows though -- on GitLab CI it is marked as a
"manual" job, so the developer has to actively trigger these jobs.

The consequence of this split is that any breakage specific to this job
is only noticed by developers who mainly work with GitHub. Let's improve
this situation by also running the job by default on GitLab CI.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 months agoThe thirteenth batch
Junio C Hamano [Mon, 12 May 2025 21:22:59 +0000 (14:22 -0700)] 
The thirteenth batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 months agoMerge branch 'ps/meson-bin-sh'
Junio C Hamano [Mon, 12 May 2025 21:22:50 +0000 (14:22 -0700)] 
Merge branch 'ps/meson-bin-sh'

Meson-based build framework update.

* ps/meson-bin-sh:
  meson: prefer shell at "/bin/sh"
  meson: report detected runtime executable paths

5 months agoMerge branch 'ng/xdiff-truly-minimal'
Junio C Hamano [Mon, 12 May 2025 21:22:50 +0000 (14:22 -0700)] 
Merge branch 'ng/xdiff-truly-minimal'

"git diff --minimal" used to give non-minimal output when its
optimization kicked in, which has been disabled.

* ng/xdiff-truly-minimal:
  xdiff: disable cleanup_records heuristic with --minimal

5 months agoMerge branch 'ds/fix-thin-fix'
Junio C Hamano [Mon, 12 May 2025 21:22:49 +0000 (14:22 -0700)] 
Merge branch 'ds/fix-thin-fix'

"git index-pack --fix-thin" used to abort to prevent a cycle in
delta chains from forming in a corner case even when there is no
such cycle.

* ds/fix-thin-fix:
  index-pack: allow revisiting REF_DELTA chains
  t5309: create failing test for 'git index-pack'
  test-tool: add pack-deltas helper

5 months agoMerge branch 'jc/ci-skip-unavailable-external-software'
Junio C Hamano [Mon, 12 May 2025 21:22:49 +0000 (14:22 -0700)] 
Merge branch 'jc/ci-skip-unavailable-external-software'

Further refinement on CI messages when an optional external
software is unavailable (e.g. due to third-party service outage).

* jc/ci-skip-unavailable-external-software:
  ci: download JGit from maven, not eclipse.org
  ci: update the message for unavailble third-party software

5 months agoMerge branch 'ps/object-store-cleanup'
Junio C Hamano [Mon, 12 May 2025 21:22:48 +0000 (14:22 -0700)] 
Merge branch 'ps/object-store-cleanup'

Further code clean-up in the object-store layer.

* ps/object-store-cleanup:
  object-store: drop `repo_has_object_file()`
  treewide: convert users of `repo_has_object_file()` to `has_object()`
  object-store: allow fetching objects via `has_object()`
  object-store: move function declarations to their respective subsystems
  object-store: move and rename `odb_pack_keep()`
  object-store: drop `loose_object_path()`
  object-store: move `struct packed_git` into "packfile.h"

5 months agoMerge branch 'ag/send-email-outlook'
Junio C Hamano [Mon, 12 May 2025 21:22:47 +0000 (14:22 -0700)] 
Merge branch 'ag/send-email-outlook'

Update send-email to work better with Outlook's smtp server.

* ag/send-email-outlook:
  send-email: add --[no-]outlook-id-fix option
  send-email: retrieve Message-ID from outlook SMTP server

5 months agoraw_object_store: drop extra pointer to replace_map
Jeff King [Mon, 12 May 2025 18:52:33 +0000 (14:52 -0400)] 
raw_object_store: drop extra pointer to replace_map

We store the replacement data in an oidmap, which is itself a pointer in
the raw_object_store struct. But there's no need for an extra pointer
indirection here. It is always allocated and initialized along with the
containing struct, and we never check it for NULL-ness.

Let's embed the map directly in the struct, which is simpler and avoids
extra pointer chasing.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 months agooidmap: add size function
Jeff King [Mon, 12 May 2025 18:51:30 +0000 (14:51 -0400)] 
oidmap: add size function

Callers which want to know how many items are in an oidmap have to look
at the underlying hashmap struct, leaking an implementation detail.
Let's provide a type-appropriate wrapper and use it.

Note in the call from lookup_replace_object(), the caller was actually
looking at the hashmap's tablesize parameter (the allocated size of the
table) rather than hashmap_get_size(), the number of items in the table.
This probably should have been checking the number of items all along,
but the two are functionally equivalent here since we only add to the
map and never remove anything. Thus if there was any allocation, it was
because there is at least one item.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 months agooidmap: rename oidmap_free() to oidmap_clear()
Jeff King [Mon, 12 May 2025 18:50:28 +0000 (14:50 -0400)] 
oidmap: rename oidmap_free() to oidmap_clear()

This function does not free the oidmap struct itself; it just drops all
items from the map (using hashmap_clear_() internally). It should be
called oidmap_clear(), per CodingGuidelines.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 months agopack-bitmap: fix memory leak if `load_bitmap_entries_v1` failed
Lidong Yan [Mon, 12 May 2025 12:22:10 +0000 (12:22 +0000)] 
pack-bitmap: fix memory leak if `load_bitmap_entries_v1` failed

In pack-bitmap.c:load_bitmap_entries_v1, the function `read_bitmap_1`
allocates a bitmap and reads index data into it. However, if any of
the validation checks following the allocation fail, the allocated bitmap
is not freed, resulting in a memory leak. To avoid this, the validation
checks should be performed before the bitmap is allocated.

Signed-off-by: Lidong Yan <502024330056@smail.nju.edu.cn>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 months agoreftable: fix perf regression when reading blocks of unwanted type
Patrick Steinhardt [Mon, 12 May 2025 15:15:56 +0000 (17:15 +0200)] 
reftable: fix perf regression when reading blocks of unwanted type

In fd888311fbc (reftable/table: move reading block into block reader,
2025-04-07), we have refactored how reftable blocks are read so that
most of the logic is contained in the "block.c" subsystem itself. Most
importantly, the whole logic to read the data itself is now contained in
that subsystem.

This change caused a significant performance regression though when
reading blocks that aren't of the specific type one is searching for:

    Benchmark 1: update-ref: create 100k refs (revision = fd888311fbc~)
      Time (mean ± σ):      2.171 s ±  0.028 s    [User: 1.189 s, System: 0.977 s]
      Range (min … max):    2.117 s …  2.206 s    10 runs

    Benchmark 2: update-ref: create 100k refs (revision = fd888311fbc)
      Time (mean ± σ):      3.418 s ±  0.030 s    [User: 2.371 s, System: 1.037 s]
      Range (min … max):    3.377 s …  3.473 s    10 runs

    Summary
      update-ref: create 100k refs (revision = fd888311fbc~) ran
        1.57 ± 0.02 times faster than update-ref: create 100k refs (revision = fd888311fbc)

The root caute of the performance regression is that we changed when
exactly blocks of an uninteresting type are being discarded. Previous to
the refactoring in the mentioned commit we'd load the block data, read
its type, notice that it's not the wanted type and discard the block.
After the commit though we don't discard the block immediately, but we
fully decode it only to realize that it's not the desired type. We then
discard the block again, but have already performed a bunch of pointless
work.

Fix the regression by making `reftable_block_init()` return early in
case the block is not of the desired type. This fixes the performance
hit:

    Benchmark 1: update-ref: create 100k refs (revision = HEAD~)
      Time (mean ± σ):      2.712 s ±  0.018 s    [User: 1.990 s, System: 0.716 s]
      Range (min … max):    2.682 s …  2.741 s    10 runs

    Benchmark 2: update-ref: create 100k refs (revision = HEAD)
      Time (mean ± σ):      1.670 s ±  0.012 s    [User: 0.991 s, System: 0.676 s]
      Range (min … max):    1.652 s …  1.693 s    10 runs

    Summary
      update-ref: create 100k refs (revision = HEAD) ran
        1.62 ± 0.02 times faster than update-ref: create 100k refs (revision = HEAD~)

Note that the baseline performance is lower than in the original due to
a couple of unrelated performance improvements that have landed since
the original commit.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 months agobuiltin/am: fix memory leak in `split_mail_stgit_series`
Lidong Yan [Mon, 12 May 2025 02:07:27 +0000 (02:07 +0000)] 
builtin/am: fix memory leak in `split_mail_stgit_series`

In builtin/am.c:split_mail_stgit_series, if `fopen` failed,
`series_dir_buf` allocated by `xstrdup` will leak. Add `free` in
`!fp` if branch will prevent the leak.

Signed-off-by: Lidong Yan <502024330056@smail.nju.edu.cn>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 months agot1001: replace 'test -f' with 'test_path_is_file'
Rodrigo Carvalho [Sat, 10 May 2025 23:09:09 +0000 (20:09 -0300)] 
t1001: replace 'test -f' with 'test_path_is_file'

'test_path_is_file' is a modern path checking method in Git's development.
 Replace the basic shell command 'test -f' with this approach.

Signed-off-by: Rodrigo Carvalho <rodrigorsdc@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 months agoreftable/writer: fix memory leak when `writer_index_hash()` fails
Lidong Yan [Mon, 12 May 2025 12:49:04 +0000 (12:49 +0000)] 
reftable/writer: fix memory leak when `writer_index_hash()` fails

In reftable/writer.c:writer_index_hash(), if `reftable_buf_add` failed,
key allocated by `reftable_malloc` will not be insert into `obj_index_tree`
thus leaks. Simple add reftable_free(key) will solve this problem.

Signed-off-by: Lidong Yan <502024330056@smail.nju.edu.cn>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 months agoreftable/writer: fix memory leak when `padded_write()` fails
Lidong Yan [Mon, 12 May 2025 12:49:03 +0000 (12:49 +0000)] 
reftable/writer: fix memory leak when `padded_write()` fails

In reftable/writer.c:padded_write(), if w->writer failed, zeroed
allocated in `reftable_calloc` will leak. w->writer could be
`reftable_write_data` in reftable/stack.c, and could fail due to
some write error. Simply add reftable_free(zeroed) will solve this
problem.

Signed-off-by: Lidong Yan <502024330056@smail.nju.edu.cn>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 months agoMakefile: avoid constant rebuilds with compilation database
brian m. carlson [Fri, 9 May 2025 21:12:02 +0000 (21:12 +0000)] 
Makefile: avoid constant rebuilds with compilation database

Many contributors to software use a Language Server Protocol
implementation to allow their editor to learn structural information
about the code they write and provide additional features, such as
jumping to the declaration or definition of a function or type.  In C,
the usual implementation is clangd, which requires compiling with clang.

Because C and C++ projects lack a standard file system layout and build
system, unlike languages such as Rust and Go, clangd requires a
compilation database to be generated by the clang compiler in order to
pass the proper compilation flags and discover all of the files
necessary to make the LSP work.  This is done by setting
GENERATE_COMPILATION_DATABASE to "yes".

However, when that's enabled and the user runs "make" a second time,
all of the files are re-compiled, which is inconvenient for contributors
to Git, since it makes small changes or rebases recompile the entirety
of the codebase.  This happens because the directory holding the
compilation database is updated anytime an object is built, so its
modification date will always be newer than the first object built.

To solve this, use the same trick we do just above for the .depend
directory and filter the compilation database directory out if it
already exists, which avoids making it a target to be built.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Helped-by: Philippe Blain <levraiphilippeblain@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 months agosequencer: rework reflog message handling
Phillip Wood [Fri, 9 May 2025 16:22:27 +0000 (16:22 +0000)] 
sequencer: rework reflog message handling

It has been reported that "git rebase --rebase-merges" can create
corrupted reflog entries like

    e9c962f2ea0 HEAD@{8}: <binary>�: Merged in <branch> (pull request #4441)

This is due to a use-after-free bug that happens because
reflog_message() uses a static `struct strbuf` and is not called to
update the current reflog message stored in `ctx->reflog_message` when
creating the merge. This means `ctx->reflog_message` points to a stale
reflog message that has been freed by subsequent call to
reflog_message() by a command such as `reset` that used the return value
directly rather than storing the result in `ctx->reflog_message`.

Fix this by creating the reflog message nearer to where the commit is
created and storing it in a local variable which is passed as an
additional parameter to run_git_commit() rather than storing the message
in `struct replay_ctx`. This makes it harder to forget to call
`reflog_message()` before creating a commit and using a variable with a
narrower scope means that a stale value cannot carried across a from one
iteration of the loop to the next which should prevent any similar
use-after-free bugs in the future.

A existing test is modified to demonstrate that merges are now created
with the correct reflog message.

Reported-by: Kristoffer Haugsbakk <code@khaugsbakk.name>
Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 months agosequencer: move reflog message functions
Phillip Wood [Fri, 9 May 2025 16:22:26 +0000 (16:22 +0000)] 
sequencer: move reflog message functions

In the next commit these functions will be called from pick_one_commit()
so move them above that function to avoid a forward declaration.

Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 months agoMerge branch 'master' of https://github.com/j6t/gitk
Junio C Hamano [Fri, 9 May 2025 20:16:51 +0000 (13:16 -0700)] 
Merge branch 'master' of https://github.com/j6t/gitk

* 'master' of https://github.com/j6t/gitk:
  gitk: add Tamil translation
  gitk: limit PATH search to bare executable names
  gitk: _search_exe is no longer needed
  gitk: override $PATH search only on Windows
  gitk: adjust indentation to match the style used in this script

5 months agoMerge branch 'master' of https://github.com/j6t/git-gui
Junio C Hamano [Fri, 9 May 2025 20:14:36 +0000 (13:14 -0700)] 
Merge branch 'master' of https://github.com/j6t/git-gui

* 'master' of https://github.com/j6t/git-gui:
  git-gui: treat the message template file as a built file
  git-gui: heed core.commentChar/commentString
  git-gui: po/README: update repository location and maintainer

5 months agoMerge branch 'js/po-update-workflow'
Johannes Sixt [Fri, 9 May 2025 17:16:41 +0000 (19:16 +0200)] 
Merge branch 'js/po-update-workflow'

* js/po-update-workflow:
  git-gui: treat the message template file as a built file
  git-gui: po/README: update repository location and maintainer

Signed-off-by: Johannes Sixt <j6t@kdbg.org>
5 months agoMerge branch 'at/translation-tamil'
Johannes Sixt [Fri, 9 May 2025 16:01:02 +0000 (18:01 +0200)] 
Merge branch 'at/translation-tamil'

* at/translation-tamil:
  gitk: add Tamil translation

Signed-off-by: Johannes Sixt <j6t@kdbg.org>
5 months agoThe twelfth batch
Junio C Hamano [Thu, 8 May 2025 18:12:02 +0000 (11:12 -0700)] 
The twelfth batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 months agoMerge branch 'js/diff-codeql-false-positive-workaround'
Junio C Hamano [Thu, 8 May 2025 19:36:32 +0000 (12:36 -0700)] 
Merge branch 'js/diff-codeql-false-positive-workaround'

Work around false positive given by CodeQL.

* js/diff-codeql-false-positive-workaround:
  diff: check range before dereferencing an array element

5 months agoMerge branch 'ps/mv-contradiction-fix'
Junio C Hamano [Thu, 8 May 2025 19:36:31 +0000 (12:36 -0700)] 
Merge branch 'ps/mv-contradiction-fix'

"git mv a a/b dst" would ask to move the directory 'a' itself, as
well as its contents, in a single destination directory, which is
a contradicting request that is impossible to satisfy. This case is
now detected and the command errors out.

* ps/mv-contradiction-fix:
  builtin/mv: convert assert(3p) into `BUG()`
  builtin/mv: bail out when trying to move child and its parent

5 months agoMerge branch 'en/hashmap-clear-fix'
Junio C Hamano [Thu, 8 May 2025 19:36:31 +0000 (12:36 -0700)] 
Merge branch 'en/hashmap-clear-fix'

hashmap API clean-up to ensure hashmap_clear() leaves a cleared map
in a reusable state.

* en/hashmap-clear-fix:
  hashmap: ensure hashmaps are reusable after hashmap_clear()

5 months agodocs: add credential helper for outlook and gmail in OAuth list of helpers
Aditya Garg [Thu, 8 May 2025 17:14:29 +0000 (17:14 +0000)] 
docs: add credential helper for outlook and gmail in OAuth list of helpers

This commit adds the `git-credential-outlook` and `git-credential-gmail`
helpers to the list of OAuth helpers.

Signed-off-by: Aditya Garg <gargaditya08@live.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 months agodocs: improve send-email documentation
Aditya Garg [Thu, 8 May 2025 17:14:28 +0000 (17:14 +0000)] 
docs: improve send-email documentation

OAuth2.0 is a new authentication method that is being used by many email
providers, including Outlook and Gmail. Recently, the Authen::SASL perl
module has been updated to support OAuth2.0 authentication, thus making
the git-send-email script be able to use this authentication method as
well. So lets improve the documentation to reflect this change.

I also had a hard time finding a reliable OAuth2.0 access token
generator for Outlook and Gmail. So I added a link to the such
generators which I developed myself after seaching through lots of code
and API documentation to make things easier for others.

Signed-off-by: Aditya Garg <gargaditya08@live.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 months agosend-mail: improve checks for valid_fqdn
Aditya Garg [Thu, 8 May 2025 17:14:27 +0000 (17:14 +0000)] 
send-mail: improve checks for valid_fqdn

The current implementation of a valid Fully Qualified Domain Name
is not that strict. It just checks whether it has a dot (.) and
if using macOS, it should not end with .local. As per RFC1035[1],
from what I understood, the following checks need to be done:

- The domain must contain atleast one dot
- Each label (separated by dots) must be 1-63 characters long
- Labels must start and end with an alphanumeric character
- Labels can contain alphanumeric characters and hyphens

Here are some examples of valid and invalid labels:

'example.com',          # Valid
'sub.example.com',      # Valid
'my-domain.org',        # Valid
'localhost',            # Invalid (no dot)
'MacBook..',            # Invalid (double dots)
'-example.com',         # Invalid (starts with a hyphen)
'example-.com',         # Invalid (ends with a hyphen)
'example..com',         # Invalid (double dots)
'example',              # Invalid (no TLD)
'example.local',        # Invalid on macOS
'valid-domain.co.uk',   # Valid
'123.example.com',      # Valid
'example.com.',         # Invalid (trailing dot)
'toolonglabeltoolonglabeltoolonglabeltoolonglabeltoolonglabeltoolonglabel.com', # Invalid (label > 63 chars)

Due to current implementation, I was not able to send emails from
Ubuntu. Upon debugging, I found that the SMTP domain being passed
to Outlook's servers was not valid.

Net::SMTP=GLOB(0x5db4351225f8)>>> EHLO MacBook..
Net::SMTP=GLOB(0x5db4351225f8)<<< 501 5.5.4 Invalid domain name
Net::SMTP=GLOB(0x5db4351225f8)>>> HELO MacBook..

Notice that an invalid domain name "MacBook.." is sent by git-send-email.
We have a fallback code that checks output from Net::Domain::domainname()
or asking domain method of an Net::SMTP instance to detect a misconfigured
hostname and replace it with fallback "localhost.localdomain", but the
valid_fqdn apparently is failing to say "MacBook.." is not a valid fqdn.

With this patch, the rule used in valid_fqdn is tightened, the beginning
part of the SMTP exchange looked like this:

Net::SMTP=GLOB(0x58c8af71e930)>>> EHLO localhost.localdomain
Net::SMTP=GLOB(0x58c8af71e930)<<< 250-PN4P287CA0064.outlook.office365.com Hello

[1]: https://datatracker.ietf.org/doc/html/rfc1035

Signed-off-by: Aditya Garg <gargaditya08@live.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 months agomeson: allow customize perl installation path
Đoàn Trần Công Danh [Thu, 8 May 2025 08:24:40 +0000 (15:24 +0700)] 
meson: allow customize perl installation path

Some distros, notably Fedora, want to install non-core Perl libraries
into specific directory, namely /usr/share/perl5/vendor_perl.

The Makefile build system allows this by overriding perllibdir variable,
let's make meson works on par with our Makefile.

Signed-off-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 months agoscalar reconfigure: add --maintenance=<mode> option
Derrick Stolee [Wed, 7 May 2025 01:50:37 +0000 (01:50 +0000)] 
scalar reconfigure: add --maintenance=<mode> option

When users want to enable the latest and greatest configuration options
recommended by Scalar after a Git upgrade, 'scalar reconfigure --all' is
a great option that iterates over all repos in the multi-valued
'scalar.repos' config key.

However, this feature previously forced users to enable background
maintenance. In some environments this is not preferred.

Add a new --maintenance=<mode> option to 'scalar reconfigure' that
provides options for enabling (default), disabling, or leaving
background maintenance config as-is.

Helped-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Derrick Stolee <stolee@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 months agoscalar clone: add --no-maintenance option
Derrick Stolee [Wed, 7 May 2025 01:50:36 +0000 (01:50 +0000)] 
scalar clone: add --no-maintenance option

When creating a new enlistment via 'scalar clone', the default is to set
up situations that work for most user scenarios. Background maintenance
is one of those highly-recommended options for most users.

However, when using 'scalar clone' to create an enlistment in a
different situation, such as prepping a VM image, it may be valuable to
disable background maintenance so the manual maintenance steps do not
get blocked by concurrent background maintenance activities.

Add a new --no-maintenance option to 'scalar clone'.

Signed-off-by: Derrick Stolee <stolee@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 months agoscalar register: add --no-maintenance option
Derrick Stolee [Wed, 7 May 2025 01:50:35 +0000 (01:50 +0000)] 
scalar register: add --no-maintenance option

When registering a repository with Scalar to get the latest opinionated
configuration, the 'scalar register' command will also set up background
maintenance. This is a recommended feature for most user scenarios.

However, this is not always recommended in some scenarios where
background modifications may interfere with foreground activities.
Specifically, setting up a clone for use in automation may require doing
certain maintenance steps in the foreground that could become blocked by
concurrent background maintenance operations.

Allow the user to specify --no-maintenance to 'scalar register'. This
requires updating the method prototype for register_dir(), so use the
default of enabling this value when otherwise specified.

Signed-off-by: Derrick Stolee <stolee@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 months agoscalar: customize register_dir()'s behavior
Derrick Stolee [Wed, 7 May 2025 01:50:34 +0000 (01:50 +0000)] 
scalar: customize register_dir()'s behavior

In advance of adding a --[no-]maintenance option to several 'scalar'
subcommands, extend the register_dir() method to include an option for
how it should handle background maintenance.

It's important that we understand the context of toggle_maintenance()
that will enable _or disable_ maintenance depending on its input value.
Add a doc comment with this information.

Similarly, update register_dir() to either enable maintenance or leave
it alone.

Signed-off-by: Derrick Stolee <stolee@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 months agogit-gui: treat the message template file as a built file
Johannes Sixt [Tue, 24 Dec 2024 13:47:08 +0000 (14:47 +0100)] 
git-gui: treat the message template file as a built file

Follow the lead of 5377abc0c9d5 ("po/git.pot: don't check in result
of "make pot"", 2022-05-26) in the Git repository and do not track
git-gui.pot anymore.

Instead, translators are expected to integrate an up-to-date version
from the master branch into their translation file using

   make ALL_POFILES=po/xx.po update-po

Update README to describe the new process. It is now understood that
different translations need not be based on the same message template
file, but rather individual translators should base their translation
on the most up-to-date code. Remove the section that addresses the
i18n coordinator as it does not apply when no common base is required
among translators.

Signed-off-by: Johannes Sixt <j6t@kdbg.org>
5 months agobuiltin/maintenance: introduce "rerere-gc" task
Patrick Steinhardt [Wed, 7 May 2025 07:21:42 +0000 (09:21 +0200)] 
builtin/maintenance: introduce "rerere-gc" task

While git-gc(1) knows to garbage collect the rerere cache,
git-maintenance(1) does not yet have a task for this cleanup. Introduce
a new "rerere-gc" task to plug this gap.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 months agobuiltin/gc: move rerere garbage collection into separate function
Patrick Steinhardt [Wed, 7 May 2025 07:21:41 +0000 (09:21 +0200)] 
builtin/gc: move rerere garbage collection into separate function

In a subsequent commit we are going to introduce a new "rerere-gc" task
for git-maintenance(1). To prepare for this, refactor the code that
spawns `git rerere gc` into a separate function.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 months agobuiltin/maintenance: introduce "worktree-prune" task
Patrick Steinhardt [Wed, 7 May 2025 07:21:40 +0000 (09:21 +0200)] 
builtin/maintenance: introduce "worktree-prune" task

While git-gc(1) knows to prune stale worktrees, git-maintenance(1) does
not yet have a task for this cleanup. Introduce a new "worktree-prune"
task to plug this gap.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>