]> git.ipfire.org Git - thirdparty/git.git/log
thirdparty/git.git
4 weeks agopack-bitmap: fix memory leak if load_bitmap() failed
Taylor Blau [Tue, 1 Jul 2025 05:32:07 +0000 (05:32 +0000)] 
pack-bitmap: fix memory leak if load_bitmap() failed

After going through the "failed" label, load_bitmap() will return -1,
and its caller (either prepare_bitmap_walk() or prepare_bitmap_git())
will then call free_bitmap_index().

That function would have done:

    struct stored_bitmap *sb;
    kh_foreach_value(b->bitmaps, sb {
      ewah_pool_free(sb->root);
      free(sb);
    });

, but won't since load_bitmap() already called kh_destroy_oid_map() and
NULL'd the "bitmaps" pointer from within its "failed" label. Thus if you
got part of the way through loading bitmap entries and then failed, you
would leak all of the previous entries that you were able to load
successfully.

The solution is to remove the error handling code in load_bitmap(), because
its caller will always call free_bitmap_index() in case of an error.

Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Lidong Yan <502024330056@smail.nju.edu.cn>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agoGit 2.50-rc0 v2.50.0-rc0
Junio C Hamano [Wed, 28 May 2025 14:59:41 +0000 (07:59 -0700)] 
Git 2.50-rc0

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agoMerge branch 'jt/receive-pack-skip-connectivity-check'
Junio C Hamano [Wed, 28 May 2025 14:59:56 +0000 (07:59 -0700)] 
Merge branch 'jt/receive-pack-skip-connectivity-check'

"git receive-pack" optionally learns not to care about connectivity
check, which can be useful when the repository arranges to ensure
connectivity by some other means.

* jt/receive-pack-skip-connectivity-check:
  builtin/receive-pack: add option to skip connectivity check
  t5410: test receive-pack connectivity check

2 months agoMerge branch 'kn/passing-leak-tests'
Junio C Hamano [Wed, 28 May 2025 14:59:55 +0000 (07:59 -0700)] 
Merge branch 'kn/passing-leak-tests'

Remove the leftover hints to the test framework to mark tests that
do not pass the leak checker tests, as they should no longer be
needed.

* kn/passing-leak-tests:
  t: remove unexpected SANITIZE_LEAK variables

2 months agoThe eighteenth batch
Junio C Hamano [Tue, 27 May 2025 20:58:38 +0000 (13:58 -0700)] 
The eighteenth batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agoMerge branch 'kj/my-first-contribution-updates'
Junio C Hamano [Tue, 27 May 2025 20:59:12 +0000 (13:59 -0700)] 
Merge branch 'kj/my-first-contribution-updates'

Doc updates.

* kj/my-first-contribution-updates:
  docs: replace git_config to repo_config
  docs: clarify cmd_psuh signature and explain UNUSED macro
  docs: remove unused mentoring mailing list reference

2 months agoMerge branch 'es/meson-configure-build-options-fix'
Junio C Hamano [Tue, 27 May 2025 20:59:11 +0000 (13:59 -0700)] 
Merge branch 'es/meson-configure-build-options-fix'

Build procedure updates.

* es/meson-configure-build-options-fix:
  meson: reformat default options to workaround bug in `meson configure`

2 months agoMerge branch 'en/sequencer-comment-messages'
Junio C Hamano [Tue, 27 May 2025 20:59:11 +0000 (13:59 -0700)] 
Merge branch 'en/sequencer-comment-messages'

Prefix '#' to the commit title in the "rebase -i" todo file, just
like a merge commit being replayed.

* en/sequencer-comment-messages:
  sequencer: make it clearer that commit descriptions are just comments

2 months agoMerge branch 'js/misc-fixes'
Junio C Hamano [Tue, 27 May 2025 20:59:10 +0000 (13:59 -0700)] 
Merge branch 'js/misc-fixes'

Assorted fixes for issues found with CodeQL.

* js/misc-fixes:
  sequencer: stop pretending that an assignment is a condition
  bundle-uri: avoid using undefined output of `sscanf()`
  commit-graph: avoid using stale stack addresses
  trace2: avoid "futile conditional"
  Avoid redundant conditions
  fetch: avoid unnecessary work when there is no current branch
  has_dir_name(): make code more obvious
  upload-pack: rename `enum` to reflect the operation
  commit-graph: avoid malloc'ing a local variable
  fetch: carefully clear local variable's address after use
  commit: simplify code

2 months agoMerge branch 'sj/use-mmap-to-check-packed-refs'
Junio C Hamano [Tue, 27 May 2025 20:59:10 +0000 (13:59 -0700)] 
Merge branch 'sj/use-mmap-to-check-packed-refs'

The code path to access the "packed-refs" file while "fsck" is
taught to mmap the file, instead of reading the whole file in the
memory.

* sj/use-mmap-to-check-packed-refs:
  packed-backend: mmap large "packed-refs" file during fsck
  packed-backend: extract snapshot allocation in `load_contents`
  packed-backend: fsck should warn when "packed-refs" file is empty

2 months agoMerge branch 'jc/doc-synopsis-option-markup'
Junio C Hamano [Tue, 27 May 2025 20:59:10 +0000 (13:59 -0700)] 
Merge branch 'jc/doc-synopsis-option-markup'

Doc mark-up fixes.

* jc/doc-synopsis-option-markup:
  git-var doc: fix usage of $ENV_VAR vs ENV_VAR
  git-verify-* doc: update mark-up of synopsis option descriptions
  git-{var,write-tree} docs: update mark-up of synopsis option descriptions
  git-daemon doc: update mark-up of synopsis option descriptions

2 months agoMerge branch 'ds/sparse-apply-add-p'
Junio C Hamano [Tue, 27 May 2025 20:59:09 +0000 (13:59 -0700)] 
Merge branch 'ds/sparse-apply-add-p'

"git apply" and "git add -i/-p" code paths no longer unnecessarily
expand sparse-index while working.

* ds/sparse-apply-add-p:
  p2000: add performance test for patch-mode commands
  reset: integrate sparse index with --patch
  git add: make -p/-i aware of sparse index
  apply: integrate with the sparse index

2 months agoMerge branch 'rj/build-tweaks-part2'
Junio C Hamano [Tue, 27 May 2025 20:59:09 +0000 (13:59 -0700)] 
Merge branch 'rj/build-tweaks-part2'

Updates to meson-based build procedure.

* rj/build-tweaks-part2:
  configure.ac: upgrade to a compilation check for sysinfo
  meson.build: correct setting of GIT_EXEC_PATH
  meson: correct path to system config/attribute files
  meson: correct install location of YAML.pm
  meson.build: quote the GITWEBDIR build configuration

2 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

2 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

2 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

2 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

2 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

2 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

2 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>
2 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

2 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 ()

2 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

2 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

2 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

2 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

2 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

2 months agot: remove unexpected SANITIZE_LEAK variables
Karthik Nayak [Tue, 20 May 2025 14:40:12 +0000 (16:40 +0200)] 
t: remove unexpected SANITIZE_LEAK variables

As of 1fc7ddf35b (test-lib: unconditionally enable leak checking,
2024-11-20), both the `GIT_TEST_PASSING_SANITIZE_LEAK` and
`TEST_PASSES_SANITIZE_LEAK` variables no longer have any meaning, the
leak checks are enabled by default. However, some newly added tests
include them by mistake. Let's clean this up.

Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
Acked-by: Justin Tobler <jltobler@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agobuiltin/receive-pack: add option to skip connectivity check
Justin Tobler [Tue, 20 May 2025 16:32:18 +0000 (11:32 -0500)] 
builtin/receive-pack: add option to skip connectivity check

During git-receive-pack(1), connectivity of the object graph is
validated to ensure that the received packfile does not leave the
repository in a broken state. This is done via git-rev-list(1) and
walking the objects, which can be expensive for large repositories.

Generally, this check is critical to avoid an incomplete received
packfile from corrupting a repository. Server operators may have
additional knowledge though around exactly how Git is being used on the
server-side which can be used to facilitate more efficient connectivity
computation of incoming objects.

For example, if it can be ensured that all objects in a repository are
connected and do not depend on any missing objects, the connectivity of
newly written objects can be checked by walking the object graph
containing only the new objects from the updated tips and identifying
the missing objects which represent the boundary between the new objects
and the repository. These boundary objects can be checked in the
canonical repository to ensure the new objects connect as expected and
thus avoid walking the rest of the object graph.

Git itself cannot make the guarantees required for such an optimization
as it is possible for a repository to contain an unreachable object that
references a missing object without the repository being considered
corrupt.

Introduce the --skip-connectivity-check option for git-receive-pack(1)
which bypasses this connectivity check to give more control to the
server-side. Note that without proper server-side validation of newly
received objects handled outside of Git, usage of this option risks
corrupting a repository.

Signed-off-by: Justin Tobler <jltobler@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agot5410: test receive-pack connectivity check
Justin Tobler [Tue, 20 May 2025 16:32:17 +0000 (11:32 -0500)] 
t5410: test receive-pack connectivity check

As part of git-recieve-pack(1), the connectivity of objects is checked.
Add a test validating that git-receive-pack(1) fails due to an incoming
packfile that would leave the repository with missing objects. Instead
of creating a new test file, "t5410" is generalized for receive-pack
testing.

Signed-off-by: Justin Tobler <jltobler@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 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>
2 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

2 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

2 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()

2 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'

2 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`

2 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

2 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

2 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

2 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

2 months agoconfigure.ac: upgrade to a compilation check for sysinfo
Ramsay Jones [Mon, 19 May 2025 16:25:23 +0000 (17:25 +0100)] 
configure.ac: upgrade to a compilation check for sysinfo

Commit f5e3c6c57d ("meson: do a full usage-based compile check for
sysinfo", 2025-04-25) updated the 'sysinfo()' check, as part of the
meson build, due to the failure of the check on Solaris. Prior to
that commit, the meson build only checked the availability of the
'<sys/sysinfo.h>' header file. On Solaris, both the header and the
'sysinfo()' function exist, but are completely unrelated to the same
function on Linux (and cygwin).

Commit 50dec7c566 ("config.mak.uname: add sysinfo() configuration for
cygwin", 2025-04-17) added a similar 'sysinfo()' check to the autoconf
build. This check looked for the 'sysinfo()' function itself, rather
than just the header, but it will fail (incorrectly set HAVE_SYSINFO)
for the same reason.

In order to correctly identify the 'sysinfo()' function we require as
part of 'git-gc' (used in the 'total_ram() function), we also upgrade
to a compilation check, in a similar way to the meson commit. Note that
since commit c9a51775a3 ("builtin/gc.c: correct RAM calculation when
using sysinfo", 2025-04-17) both the 'totalram' and 'mem_unit' fields
of the 'struct sysinfo' are used, so the new check includes both of
those fields in the compile check.

Signed-off-by: Ramsay Jones <ramsay@ramsayjones.plus.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agomeson.build: correct setting of GIT_EXEC_PATH
Ramsay Jones [Mon, 19 May 2025 16:25:22 +0000 (17:25 +0100)] 
meson.build: correct setting of GIT_EXEC_PATH

For the non-'runtime prefix' case, the meson build sets the GIT_EXEC_PATH
build variable to an absolute path equivalent to <prefix>/libexec/git-core.
In comparison, the default make build sets it to a relative path equivalent
to 'libexec/git-core'. Indeed, the make build requires the use of some
means outside of the Makefile (eg. config.mak[.*] or the command-line)
to set GIT_EXEC_PATH to anything other than 'libexec/git-core'.

For example, the make invocation:

  $ make gitexecdir=/some/other/bin all install

will build git with GIT_EXEC_PATH set to '/some/other/bin' and install
the 'library' executables to that location. However, without setting the
'gitexecdir' make variable, irrespective of the 'runtime prefix' setting,
the GIT_EXEC_PATH is always set to 'libexec/git-core'.

The meson built-in 'libexecdir' option can be used to provide a similar
configurability. The default value for the option is 'libexec'. Attempting
to set the option to '' on the command-line, will reset it to the '.'
string, presumably to ensure a relative path value.

This commit allows the meson build, similar to the above, to configure the
project like:

  $ meson setup --buildtype=debugoptimized -Dprefix=$HOME -Dpcre2=disabled \
      -Dlibexecdir=/some/other/bin build

so that the GIT_EXEC_PATH is set to '/some/other/bin'. Absent the
-Dlibexecdir argument, the GIT_EXEC_PATH is set to 'libexec/git-core'.

In order to correct the value of GIT_EXEC_PATH, default the value to the
static string value 'libexec/git-core', and only override if the value
of the 'libexecdir' option has a value different to 'libexec' or '.'.
Also, like the Makefile, add a check for an absolute path when the
runtime prefix option is true (and if so, error out).

Signed-off-by: Ramsay Jones <ramsay@ramsayjones.plus.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agomeson: correct path to system config/attribute files
Ramsay Jones [Mon, 19 May 2025 16:25:21 +0000 (17:25 +0100)] 
meson: correct path to system config/attribute files

The path to the system-wide config and attributes files are not being
set correctly in the meson build. Unless explicitly overridden on the
command line during setup, the 'gitconfig' and 'gitattributes' options
are defaulting to absolute paths in the '/etc' system directory. This
is only appropriate if the <prefix> is set specifically to '/usr'.

The directory in which these files are placed is generally referred to
as the 'system configuration directory' or 'sysconfdir' for short. When
the prefix is '/usr' then the sysconfdir is usually set to '/etc', but
any other value for prefix results in the relative directory value 'etc'
instead. (eg if prefix is '/usr/local', then the 'etc' relative value
results in a system configuration directory of '/usr/local/etc'). When
setting the 'sysconfdir' builtin option value, the meson system uses
exactly this algorithm, so we can use get_option('sysconfdir') directly
when setting the (non-overridden) build variables.

In order to allow for overriding from the command line, remove the
default values specified for the 'gitconfig' and 'gitattributes' options
in the 'meson_options.txt' file. This allows the user to specify any
pathname for those options, while being able to test for the unset
(empty) value. An absolute pathname will be used unchanged and a relative
pathname will be appended to '<prefix>/'. These values are then used to
set the 'ETC_GITCONFIG' and 'ETC_GITATTRIBUTES' build variables which are,
in turn, passed to the compiler as '-D' arguments.

When the 'gitconfig' or 'gitattributes' options are not used, then use
the built-in 'sysconfdir' and set the ETC_GITCONFIG build variable to
the string "<sysconfdir>/gitconfig". Similarly, set ETC_ATTRIBUTES to
"<sysconfdir>/gitattributes".

Signed-off-by: Ramsay Jones <ramsay@ramsayjones.plus.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agomeson: correct install location of YAML.pm
Ramsay Jones [Mon, 19 May 2025 16:25:20 +0000 (17:25 +0100)] 
meson: correct install location of YAML.pm

When executing an 'meson install' the YAML.pm file is incorrectly
placed in the <prefix>/share/perl5/Git/SVN directory. The YAML.pm
file should be placed in a 'Memoize' subdirectory instead. In order
to correct the location, update the 'install_dir' of the relevant
target in the 'perl/Git/SVN/Memoize/meson.build' file.

Signed-off-by: Ramsay Jones <ramsay@ramsayjones.plus.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agomeson.build: quote the GITWEBDIR build configuration
Ramsay Jones [Mon, 19 May 2025 16:25:19 +0000 (17:25 +0100)] 
meson.build: quote the GITWEBDIR build configuration

The build configuration options with (non-empty) values, for example
filesystem paths potentially containing spaces, have been set using
the '.set_quoted()' method. However, the GITWEBDIR value has been
set using the '.set()' method instead. In order to correctly quote
the GITWEBDIR value, replace the '.set()' method with '.set_quoted()'.

Signed-off-by: Ramsay Jones <ramsay@ramsayjones.plus.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agomeson: reformat default options to workaround bug in `meson configure`
Eli Schwartz [Mon, 19 May 2025 17:09:42 +0000 (13:09 -0400)] 
meson: reformat default options to workaround bug in `meson configure`

Since 13cb20fc46 ("meson: fix compilation with Visual Studio",
2025-01-22) it has not been possible to list build options via `meson
configure`. This is due to Meson's static analysis of build options
failing to handle constant folding, and thinking we set a totally
invalid default `-std=`.

This is reported upstream but we anyways need to work with existing
versions. It turns out there is a simple solution: turn the entire
default option into a conditional branch, which means Meson sees either
nothing, or everything.

As a result, Git users can once again see pretty-printed options before
building.

Reported-by: Ramsay Jones <ramsay@ramsayjones.plus.com>
Bug: https://github.com/mesonbuild/meson/issues/14623
Signed-off-by: Eli Schwartz <eschwartz@gentoo.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agodocs: replace git_config to repo_config
K Jayatheerth [Sun, 18 May 2025 07:43:17 +0000 (13:13 +0530)] 
docs: replace git_config to repo_config

Since this document was written, the built-in API has been
updated a few times, but the document was left stale.

Adjust to the current best practices by calling repo_config() on the
repository instance the subcommand implementation receives as a
parameter, instead of calling git_config() that used to be the
common practice.

Signed-off-by: K Jayatheerth <jayatheerthkulkarni2005@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agodocs: clarify cmd_psuh signature and explain UNUSED macro
K Jayatheerth [Sun, 18 May 2025 07:43:16 +0000 (13:13 +0530)] 
docs: clarify cmd_psuh signature and explain UNUSED macro

The sample program, as written, would no longer build for at least two
reasons:

 - Since this document was first written, the convention to call a
   subcommand implementation has changed, and cmd_psuh() now needs
   to accept the fourth parameter, repository.

 - These days, compiler warning options for developers include one
   that detects and complains about unused parameters, so ones that
   are deliberately unused have to be marked as such.

Update the old-style examples to adjust to the current practices,
with explanations as needed.

Signed-off-by: K Jayatheerth <jayatheerthkulkarni2005@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agodocs: remove unused mentoring mailing list reference
K Jayatheerth [Sun, 18 May 2025 07:43:15 +0000 (13:13 +0530)] 
docs: remove unused mentoring mailing list reference

The git-mentoring group was initially created to help newcomers
with their development itches. However, in practice,
most of their questions were already being addressed
directly on the mailing list, and contributors consistently
received helpful responses there.

Remove the mentoring group details from the Documentation.

Signed-off-by: K Jayatheerth <jayatheerthkulkarni2005@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 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>
2 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>
2 months agosequencer: make it clearer that commit descriptions are just comments
Elijah Newren [Fri, 16 May 2025 16:26:26 +0000 (16:26 +0000)] 
sequencer: make it clearer that commit descriptions are just comments

Every once in a while, users report that editing the commit summaries
in the todo list does not get reflected in the rebase operation,
suggesting that users are (a) only using one-line commit messages, and
(b) not understanding that the commit summaries are merely helpful
comments to help them find the right hashes.

It may be difficult to correct users' poor commit messages, but we can
at least try to make it clearer that the commit summaries are not
directives of some sort by inserting a comment character.  Hopefully
that leads to them looking a little further and noticing the hints at
the bottom to use 'reword' or 'edit' directives.

Yes, this change may look funny at first since it hardcodes '#' rather
than using comment_line_str.  However:

  * comment_line_str exists to allow disambiguation between lines in
    a commit message and lines that are instructions to users editing
    the commit message.  No such disambiguation is needed for these
    comments that occur on the same line after existing directives
  * the exact "comment" character(s) on regular pick lines used aren't
    actually important; I could have used anything, including completely
    random variable length text for each line and it'd work because we
    ignore everything after 'pick' and the hash.
  * The whole point of this change is to signal to users that they
    should NOT be editing any part of the line after the hash (and if
    they do so, their edits will be ignored), while the whole point of
    comment_line_str is to allow highly flexible editing.  So making
    it more general by using comment_line_str actually feels
    counterproductive.
  * The character for merge directives absolutely must be '#'; that
    has been deeply hardcoded for a long time (see below), and will
    break if some other comment character is used instead.  In a
    desire to have pick and merge directives be similar, I use the
    same comment character for both.
  * Perhaps merge directives could be fixed to not be inflexible about
    the comment character used, if someone feels highly motivated, but
    I think that should be done in a separate follow-on patch.

Here are (some of?) the locations where '#' has already been hardcoded
for a long time for merges:

  1) In check_label_or_ref_arg():
case TODO_LABEL:
/*
 * '#' is not a valid label as the merge command uses it to
 * separate merge parents from the commit subject.
 */

  2) In do_merge():

/*
 * For octopus merges, the arg starts with the list of revisions to be
 * merged. The list is optionally followed by '#' and the oneline.
 */
merge_arg_len = oneline_offset = arg_len;
for (p = arg; p - arg < arg_len; p += strspn(p, " \t\n")) {
if (!*p)
break;
if (*p == '#' && (!p[1] || isspace(p[1]))) {

  3) In label_oid():

if ((buf->len == the_hash_algo->hexsz &&
     !get_oid_hex(label, &dummy)) ||
    (buf->len == 1 && *label == '#') ||
    hashmap_get_from_hash(&state->labels,
  strihash(label), label)) {
/*
 * If the label already exists, or if the label is a
 * valid full OID, or the label is a '#' (which we use
 * as a separator between merge heads and oneline), we
 * append a dash and a number to make it unique.
 */

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agop2000: add performance test for patch-mode commands
Derrick Stolee [Fri, 16 May 2025 14:55:30 +0000 (14:55 +0000)] 
p2000: add performance test for patch-mode commands

The previous three changes contributed performance improvements to 'git
apply', 'git add -p', and 'git reset -p' when using a sparse index. The
improvement to 'git apply' also improved 'git checkout -p'. Add
performance tests to demonstrate this (and to help validate that
performance remains good in the future).

In the truncated test output below, we see that the full checkout
performance changes within noise expectations, but the sparse index
cases improve 33% and then 96% for 'git add -p' and 41% and then 95% for
'git reset -p'. 'git checkout -p' improves immediatley by 91% because it
does not need any change to its builtin.

  Test                                    HEAD~4  HEAD~3       HEAD~2       HEAD~1
  -------------------------------------------------------------------------------------
  2000.118: ... git add -p (full-v3)        0.79  0.79  +0.0%  0.82  +3.8%  0.82  +3.8%
  2000.119: ... git add -p (full-v4)        0.74  0.76  +2.7%  0.74  +0.0%  0.76  +2.7%
  2000.120: ... git add -p (sparse-v3)      1.94  1.28 -34.0%  0.07 -96.4%  0.07 -96.4%
  2000.121: ... git add -p (sparse-v4)      1.93  1.28 -33.7%  0.06 -96.9%  0.06 -96.9%
  2000.122: ... git checkout -p (full-v3)   1.18  1.18  +0.0%  1.18  +0.0%  1.19  +0.8%
  2000.123: ... git checkout -p (full-v4)   1.10  1.12  +1.8%  1.11  +0.9%  1.11  +0.9%
  2000.124: ... git checkout -p (sparse-v3) 1.31  0.11 -91.6%  0.11 -91.6%  0.11 -91.6%
  2000.125: ... git checkout -p (sparse-v4) 1.29  0.11 -91.5%  0.11 -91.5%  0.11 -91.5%
  2000.126: ... git reset -p (full-v3)      0.81  0.80  -1.2%  0.83  +2.5%  0.83  +2.5%
  2000.127: ... git reset -p (full-v4)      0.78  0.77  -1.3%  0.77  -1.3%  0.78  +0.0%
  2000.128: ... git reset -p (sparse-v3)    1.58  0.92 -41.8%  0.91 -42.4%  0.07 -95.6%
  2000.129: ... git reset -p (sparse-v4)    1.58  0.92 -41.8%  0.92 -41.8%  0.07 -95.6%

It is worth noting that if our test was more involved and had multiple
hunks to evaluate, then the time spent in 'git apply' would dominate due
to multiple index loads and writes. As it stands, we need the sparse
index improvement in 'git add -p' itself to confirm this performance
improvement.

Since the change for 'git add -i' is identical, we avoid a second test
case for that similar operation.

Signed-off-by: Derrick Stolee <stolee@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agoreset: integrate sparse index with --patch
Derrick Stolee [Fri, 16 May 2025 14:55:29 +0000 (14:55 +0000)] 
reset: integrate sparse index with --patch

Similar to the previous change for 'git add -p', the reset builtin
checked for integration with the sparse index after possibly redirecting
its logic toward the interactive logic. This means that the builtin
would expand the sparse index to a full one upon read.

Move this check earlier within cmd_reset() to improve performance here.

Add tests to guarantee that we are not universally expanding the index.
Add behavior tests to check that we are doing the same operations as a
full index.

Signed-off-by: Derrick Stolee <stolee@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agogit add: make -p/-i aware of sparse index
Derrick Stolee [Fri, 16 May 2025 14:55:28 +0000 (14:55 +0000)] 
git add: make -p/-i aware of sparse index

It is slow to expand a sparse index in-memory due to parsing of trees.
We aim to minimize that performance cost when possible. 'git add -p'
uses 'git apply' child processes to modify the index, but still there
are some expansions that occur.

It turns out that control flows out of cmd_add() in the interactive
cases before the lines that confirm that the builtin is integrated with
the sparse index.

Moving that integration point earlier in cmd_add() allows 'git add -i'
and 'git add -p' to operate without expanding a sparse index to a full
one.

Add test cases that confirm that these interactive add options work with
the sparse index.

Signed-off-by: Derrick Stolee <stolee@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agoapply: integrate with the sparse index
Derrick Stolee [Fri, 16 May 2025 14:55:27 +0000 (14:55 +0000)] 
apply: integrate with the sparse index

The sparse index allows storing directory entries in the index, marked
with the skip-wortkree bit and pointing to a tree object. This may be an
unexpected data shape for some implementation areas, so we are rolling
it out incrementally on a builtin-per-builtin basis.

This change enables the sparse index for 'git apply'. The main
motivation for this change is that 'git apply' is used as a child
process of 'git add -p' and expanding the sparse index for each of those
child processes can lead to significant performance issues.

The good news is that the actual index manipulation code used by 'git
apply' is already integrated with the sparse index, so the only product
change is to mark the builtin as allowing the sparse index so it isn't
inflated on read.

The more involved part of this change is around adding tests that verify
how 'git apply' behaves in a sparse-checkout environment and whether or
not the index expands in certain operations.

Signed-off-by: Derrick Stolee <stolee@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 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>
2 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>
2 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>
2 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>
2 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>
2 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>
2 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>
2 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>
2 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>
2 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>
2 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>
2 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>
2 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>
2 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>
2 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>
2 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>
2 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>
2 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_

2 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

2 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

2 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

2 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

2 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>
2 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>
2 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>
2 months agosequencer: stop pretending that an assignment is a condition
Johannes Schindelin [Thu, 15 May 2025 13:11:49 +0000 (13:11 +0000)] 
sequencer: stop pretending that an assignment is a condition

In 3e81bccdf3 (sequencer: factor out todo command name parsing,
2019-06-27), a `return` statement was introduced that basically was a
long sequence of conditions, combined with `&&`, except for the last
condition which is not really a condition but an assignment.

The point of this construct was to return 1 (i.e. `true`) from the
function if all of those conditions held true, and also assign the `bol`
pointer to the end of the parsed command.

Some static analyzers are really unhappy about such constructs. And
human readers are at least puzzled, if not confused, by seeing a single
`=` inside a chain of conditions where they would have expected to see
`==` instead and, based on experience, immediately suspect a typo.

Let's help all of this by turning this into the more verbose, more
readable form of an `if` construct that both assigns the pointer as well
as returns 1 if all of the conditions hold true.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agobundle-uri: avoid using undefined output of `sscanf()`
Johannes Schindelin [Thu, 15 May 2025 13:11:48 +0000 (13:11 +0000)] 
bundle-uri: avoid using undefined output of `sscanf()`

In c429bed102 (bundle-uri: store fetch.bundleCreationToken, 2023-01-31)
code was introduced that assumes that an `sscanf()` call leaves its
output variables unchanged unless the return value indicates success.

However, the POSIX documentation makes no such guarantee:
https://pubs.opengroup.org/onlinepubs/9699919799/functions/sscanf.html

So let's make sure that the output variable `maxCreationToken` is
always well-defined.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agocommit-graph: avoid using stale stack addresses
Johannes Schindelin [Thu, 15 May 2025 13:11:47 +0000 (13:11 +0000)] 
commit-graph: avoid using stale stack addresses

The code is a bit too hard to reason about to fully assess whether the
`fill_commit_graph_info()` function is called at all after
`write_commit_graph()` returns (and hence the stack variable
`topo_levels` goes out of context).

Let's simply make sure that the stack address is no longer used at that
stage, thereby making the code quite a bit easier to reason about.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agotrace2: avoid "futile conditional"
Johannes Schindelin [Thu, 15 May 2025 13:11:46 +0000 (13:11 +0000)] 
trace2: avoid "futile conditional"

CodeQL reports empty `if` blocks that only contain a comment as "futile
conditional". The comment talks about potential plans to turn this into
a warning, but that seems not to have been necessary. Replace the entire
construct with a concise comment.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agoAvoid redundant conditions
Johannes Schindelin [Thu, 15 May 2025 13:11:45 +0000 (13:11 +0000)] 
Avoid redundant conditions

While `if (i <= 0) ... else if (i > 0) ...` is technically equivalent to
`if (i <= 0) ... else ...`, the latter is vastly easier to read because
it avoids writing out a condition that is unnecessary. Let's drop such
unnecessary conditions.

Pointed out by CodeQL.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agofetch: avoid unnecessary work when there is no current branch
Johannes Schindelin [Thu, 15 May 2025 13:11:44 +0000 (13:11 +0000)] 
fetch: avoid unnecessary work when there is no current branch

As pointed out by CodeQL, `branch_get()` may return `NULL`, in which
case `branch_has_merge_config()` would return early, but we can even
avoid enumerating the refs prefixes in that case, saving even more CPU
cycles.

Technically, we should enclose these two statements in an `if (branch)
{...}` block, but the indentation is already quite deep, therefore I
refrained from doing that.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agohas_dir_name(): make code more obvious
Johannes Schindelin [Thu, 15 May 2025 13:11:43 +0000 (13:11 +0000)] 
has_dir_name(): make code more obvious

One thing that might be non-obvious to readers (or to analyzers like
CodeQL) is that the function essentially does nothing when the Git index
is empty, and in particular that it does not look at the value of
`len_eq_last` (which would be uninitialized at that point).

Let's make this much easier to understand, by returning early if the Git
index is empty, and by avoiding empty `else` blocks.

This commit changes indentation and is hence best viewed using
`--ignore-space-change`.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agoupload-pack: rename `enum` to reflect the operation
Johannes Schindelin [Thu, 15 May 2025 13:11:42 +0000 (13:11 +0000)] 
upload-pack: rename `enum` to reflect the operation

While 3145ea957d (upload-pack: introduce fetch server command,
2018-03-15) added support for the `fetch` command, from the server's
point of view it is an upload, and hence the `enum` should really be
called `upload_state` instead of `fetch_state`. Likewise, rename its
values.

This also helps unconfuse CodeQL which would otherwise be at sixes or
sevens about having _two_ non-local definitions of the same `enum` with
the same values.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agocommit-graph: avoid malloc'ing a local variable
Johannes Schindelin [Thu, 15 May 2025 13:11:41 +0000 (13:11 +0000)] 
commit-graph: avoid malloc'ing a local variable

We do need a context to write the commit graph, but that context is only
needed during the life time of `commit_graph_write()`, therefore it can
easily be a stack variable.

This also helps CodeQL recognize that it is safe to assign the address
of other local variables to the context's fields.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agofetch: carefully clear local variable's address after use
Johannes Schindelin [Thu, 15 May 2025 13:11:40 +0000 (13:11 +0000)] 
fetch: carefully clear local variable's address after use

As pointed out by CodeQL, it is a potentially dangerous practice to
store local variables' addresses in non-local structs. Yet this is
exactly what happens with the `acked_commits` attribute that is used in
`cmd_fetch()`: The pointer to a local variable is assigned to it.

Now, it is Git's convention that `cmd_*()` functions are essentially
only returning just before exiting the process, therefore there is
little danger that this attribute is used after the code flow returns
from that function.

However, code in `cmd_*()` function is often so useful that it gets
lifted into a library function, at which point this issue could become a
real problem.

Let's make sure to clear the `acked_commits` attribute out after it was
used, and before the function returns (at which point the address would
go stale).

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agocommit: simplify code
Johannes Schindelin [Thu, 15 May 2025 13:11:39 +0000 (13:11 +0000)] 
commit: simplify code

The difference of two unsigned integers is defined to be unsigned, and
therefore it is misleading to check whether it is greater than zero
(instead, the more natural way would be to check whether the difference
is zero or not).

Let's instead avoid the subtraction altogether, and compare the two
operands directly, which makes the code more obvious as a side effect.

Pointed out by CodeQL's rule with the ID
`cpp/unsigned-difference-expression-compared-zero`.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 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>
2 months agopacked-backend: mmap large "packed-refs" file during fsck
shejialuo [Wed, 14 May 2025 15:50:42 +0000 (23:50 +0800)] 
packed-backend: mmap large "packed-refs" file during fsck

During fsck, we use "strbuf_read" to read the content of "packed-refs"
without using mmap mechanism. This is a bad practice which would consume
more memory than using mmap mechanism. Besides, as all code paths in
"packed-backend.c" use this way, we should make "fsck" align with the
current codebase.

As we have introduced the helper function "allocate_snapshot_buffer", we
can simply use this function to use mmap mechanism.

Suggested-by: Jeff King <peff@peff.net>
Suggested-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: shejialuo <shejialuo@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agopacked-backend: extract snapshot allocation in `load_contents`
shejialuo [Wed, 14 May 2025 15:50:35 +0000 (23:50 +0800)] 
packed-backend: extract snapshot allocation in `load_contents`

"load_contents" would choose which way to load the content of the
"packed-refs". However, we cannot directly use this function when
checking the consistency due to we don't want to open the file. And we
also need to reuse the logic to avoid causing repetition.

Let's create a new helper function "allocate_snapshot_buffer" to extract
the snapshot allocation logic in "load_contents" and update the
"load_contents" to align with the behavior.

Suggested-by: Jeff King <peff@peff.net>
Suggested-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: shejialuo <shejialuo@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agopacked-backend: fsck should warn when "packed-refs" file is empty
shejialuo [Wed, 14 May 2025 15:50:26 +0000 (23:50 +0800)] 
packed-backend: fsck should warn when "packed-refs" file is empty

We assume the "packed-refs" won't be empty and instead has at least one
line in it (even when there are no refs packed, there is the file header
line). Because there is no terminating LF in the empty file, we will
report "packedRefEntryNotTerminated(ERROR)" to the user.

However, the runtime code paths would accept an empty "packed-refs"
file, for example, "create_snapshot" would simply return the "snapshot"
without checking the content of "packed-refs". So, we should skip
checking the content of "packed-refs" when it is empty during fsck.

After 694b7a1999 (repack_without_ref(): write peeled refs in the
rewritten file, 2013-04-22), we would always write a header into the
"packed-refs" file. So, versions of Git that are not too ancient never
write such an empty "packed-refs" file.

As an empty file often indicates a sign of a filesystem-level issue, the
way we want to resolve this inconsistency is not make everybody totally
silent but notice and report the anomaly.

Let's create a "FSCK_INFO" message id "EMPTY_PACKED_REFS_FILE" to report
to the users that "packed-refs" is empty.

Signed-off-by: shejialuo <shejialuo@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 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>
2 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>
2 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>
2 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