]> git.ipfire.org Git - thirdparty/git.git/log
thirdparty/git.git
5 hours agoMerge branch 'cb/daemon-leap-children' into seen seen
Junio C Hamano [Tue, 24 Jun 2025 16:50:25 +0000 (09:50 -0700)] 
Merge branch 'cb/daemon-leap-children' into seen

* cb/daemon-leap-children:
  daemon: explicitly allow EINTR during poll()
  daemon: use sigaction() to install child_handler()
  compat/posix.h: track SA_RESTART fallback

5 hours agoMerge branch 'ph/fetch-prune-optim' into seen
Junio C Hamano [Tue, 24 Jun 2025 16:49:55 +0000 (09:49 -0700)] 
Merge branch 'ph/fetch-prune-optim' into seen

* ph/fetch-prune-optim:
  refs: remove old refs_warn_dangling_symref
  fetch-prune: optimize dangling-ref reporting

5 hours agoMerge branch 'cc/fast-import-export-signature-names' into seen
Junio C Hamano [Tue, 24 Jun 2025 16:49:54 +0000 (09:49 -0700)] 
Merge branch 'cc/fast-import-export-signature-names' into seen

Clean up the way how signature on commit objects are exported to
and imported from fast-import stream.

* cc/fast-import-export-signature-names:
  fast-(import|export): improve on commit signature output format

5 hours agoMerge branch 'ac/deglobal-sparse-variables' into seen
Junio C Hamano [Tue, 24 Jun 2025 16:49:53 +0000 (09:49 -0700)] 
Merge branch 'ac/deglobal-sparse-variables' into seen

Two global variables related to sparse checkout have been moved to
the repository settings structure.

* ac/deglobal-sparse-variables:
  environment: remove the global variable 'sparse_expect_files_outside_of_patterns'
  environment: move access to "core.sparsecheckoutcone" into repo_settings
  environment: move access to "core.sparsecheckout" into repo_settings

5 hours agoMerge branch 'jc/tag-idempotent-no-op' into seen
Junio C Hamano [Tue, 24 Jun 2025 16:49:53 +0000 (09:49 -0700)] 
Merge branch 'jc/tag-idempotent-no-op' into seen

"git tag T O" when the tag T is already pointing at the object O is
a no-op; we used to but no longer error out such a request and
require "--force" and instead turn it into a no-op.

Comments?

* jc/tag-idempotent-no-op:
  tag: allow idempotent "git tag" without "--force"

5 hours agoMerge branch 'bs/config-mak-freebsd' into seen
Junio C Hamano [Tue, 24 Jun 2025 16:49:52 +0000 (09:49 -0700)] 
Merge branch 'bs/config-mak-freebsd' into seen

Drop FreeBSD 4 support and assume we are at least at FreeBSD 6 with
memmem() supported.

* bs/config-mak-freebsd:
  config.mak.uname: update settings for FreeBSD

5 hours agoMerge branch 'ow/rebase-verify-insn-fmt-before-initializing-state' into seen
Junio C Hamano [Tue, 24 Jun 2025 16:49:51 +0000 (09:49 -0700)] 
Merge branch 'ow/rebase-verify-insn-fmt-before-initializing-state' into seen

"git rebase -i" with bogus rebase.instructionFormat configuration
failed to produce the todo file after recording the state files,
leading to confused "git status"; this has been corrected.

Comments?
cf. <20250609221055.136074-1-oystwa@gmail.com>

* ow/rebase-verify-insn-fmt-before-initializing-state:
  rebase: write script before initializing state

5 hours agoMerge branch 'lm/add-p-context' into seen
Junio C Hamano [Tue, 24 Jun 2025 16:49:50 +0000 (09:49 -0700)] 
Merge branch 'lm/add-p-context' into seen

"git add/etc -p" now honors diff.context configuration variable,
and learns to honor -U<n> option.

* lm/add-p-context:
  add-patch: add diff.context command line overrides
  add-patch: respect diff.context configuration
  test: refactor to use "test_config"
  test: refactor to use "test_grep"

5 hours agoMerge branch 'sj/string-list-typefix' into seen
Junio C Hamano [Tue, 24 Jun 2025 16:49:49 +0000 (09:49 -0700)] 
Merge branch 'sj/string-list-typefix' into seen

Code and test clean-up around string-list API.

Comments?

* sj/string-list-typefix:
  u-string-list: move "remove duplicates" test to "u-string-list.c"
  u-string-list: move "filter string" test to "u-string-list.c"
  u-string-list: move "test_split_in_place" to "u-string-list.c"
  u-string-list: move "test_split" into "u-string-list.c"
  string-list: enable sign compare warnings check
  string-list: return index directly when inserting an existing element
  string-list: remove unused "insert_at" parameter from add_entry
  string-list: fix sign compare warnings for loop iterator

5 hours agoMerge branch 'cc/promisor-remote-capability' into seen
Junio C Hamano [Tue, 24 Jun 2025 16:49:49 +0000 (09:49 -0700)] 
Merge branch 'cc/promisor-remote-capability' into seen

The "promisor-remote" capability mechanism has been updated to
allow the "partialCloneFilter" settings and the "token" value to be
communicated from the server side.

Comments?

* cc/promisor-remote-capability:
  promisor-remote: use string constants for 'name' and 'url' too
  promisor-remote: allow a client to check fields
  promisor-remote: refactor how we parse advertised fields
  promisor-remote: allow a server to advertise more fields
  promisor-remote: refactor to get rid of 'struct strvec'

5 hours agoMerge branch 'ss/compat-bswap-revamp' into seen
Junio C Hamano [Tue, 24 Jun 2025 16:49:48 +0000 (09:49 -0700)] 
Merge branch 'ss/compat-bswap-revamp' into seen

Clean-up compat/bswap.h mess.

Comments?

* ss/compat-bswap-revamp:
  bswap.h: provide a built-in based version of bswap32/64 if possible
  bswap.h: remove optimized x86 version of bswap32/64
  bswap.h: always overwrite ntohl/ntohll macros
  bswap.h: define GIT_LITTLE_ENDIAN on MSVC as little endian
  bswap.h: add support for __BYTE_ORDER__

5 hours agoMerge branch 'bc/use-sha256-by-default-in-3.0' into seen
Junio C Hamano [Tue, 24 Jun 2025 16:49:47 +0000 (09:49 -0700)] 
Merge branch 'bc/use-sha256-by-default-in-3.0' into seen

Prepare to flip the default hash function to SHA-256.

* bc/use-sha256-by-default-in-3.0:
  Enable SHA-256 by default in breaking changes mode
  t5300: choose the built-in hash outside of a repo
  t4042: choose the built-in hash outside of a repo
  t1007: choose the built-in hash outside of a repo
  t: default to compile-time default hash if not set
  setup: use the default algorithm to initialize repo format
  Use original hash for legacy formats
  builtin: use default hash when outside a repository
  hash: add a constant for the original hash algorithm
  hash: add a constant for the default hash algorithm

5 hours agoMerge branch 'mc/netrc-service-names' into jch
Junio C Hamano [Tue, 24 Jun 2025 16:49:39 +0000 (09:49 -0700)] 
Merge branch 'mc/netrc-service-names' into jch

"netrc" credential helper has been improved to understand textual
service names (like smtp) in addition to the numeric port numbers
(like 25).

Comments.

* mc/netrc-service-names:
  contrib: better support symbolic port names in git-credential-netrc
  contrib: warn for invalid netrc file ports in git-credential-netrc
  contrib: use a more portable shebang for git-credential-netrc

5 hours agoMerge branch 'jc/cocci-dtype' into jch
Junio C Hamano [Tue, 24 Jun 2025 16:49:38 +0000 (09:49 -0700)] 
Merge branch 'jc/cocci-dtype' into jch

Catch direct access to .d_type member of struct dirent, as some
non-POSIX compliant systems we support lack it, and rewrite to use
DTYPE() macro, which is not quite the right thing to do.

* jc/cocci-dtype:
  cocci: do not directly access the .d_type member in struct dirent

5 hours agoMerge branch 'jc/coccicheck-fails-make-when-it-fails' into jch
Junio C Hamano [Tue, 24 Jun 2025 16:49:37 +0000 (09:49 -0700)] 
Merge branch 'jc/coccicheck-fails-make-when-it-fails' into jch

"make coccicheck" succeeds even when spatch made suggestions, which
has been updated to fail in such a case.

* jc/coccicheck-fails-make-when-it-fails:
  coccicheck: fail "make" when it fails

5 hours agoMerge branch 'tb/midx-avoid-cruft-packs' into jch
Junio C Hamano [Tue, 24 Jun 2025 16:49:36 +0000 (09:49 -0700)] 
Merge branch 'tb/midx-avoid-cruft-packs' into jch

"pack-objects" has been taught to avoid pointing into objects in
cruft packs from midx.

Ready?

* tb/midx-avoid-cruft-packs:
  repack: exclude cruft pack(s) from the MIDX where possible
  pack-objects: introduce '--stdin-packs=follow'
  pack-objects: swap 'show_{object,commit}_pack_hint'
  pack-objects: fix typo in 'show_object_pack_hint()'
  pack-objects: perform name-hash traversal for unpacked objects
  pack-objects: declare 'rev_info' for '--stdin-packs' earlier
  pack-objects: factor out handling '--stdin-packs'
  pack-objects: limit scope in 'add_object_entry_from_pack()'
  pack-objects: use standard option incompatibility functions

5 hours agoMerge branch 'ja/doc-git-log-markup' into jch
Junio C Hamano [Tue, 24 Jun 2025 16:49:36 +0000 (09:49 -0700)] 
Merge branch 'ja/doc-git-log-markup' into jch

Doc mark-up updates.

Review?

* ja/doc-git-log-markup:
  doc: git-log: convert log config to new doc format
  doc: git-log: convert diff options to new doc format
  doc: git-log: convert pretty formats to new doc format
  doc: git-log: convert pretty options to new doc format
  doc: git-log: convert rev list options to new doc format
  doc: git-log: convert line range format to new doc format
  doc: git-log: convert line range options to new doc format
  doc: git-log convert rev-list-description to new doc format
  doc: convert git-log to new documentation format

5 hours agoMerge branch 'kj/renamed-submodule' into jch
Junio C Hamano [Tue, 24 Jun 2025 16:49:35 +0000 (09:49 -0700)] 
Merge branch 'kj/renamed-submodule' into jch

The case where a new submodule takes a path where used to be a
completely different subproject is now dealt a bit better than
before.

Comments?

* kj/renamed-submodule:
  submodule: skip redundant active entries when pattern covers path
  submodule: prevent overwriting .gitmodules entry on path reuse

5 hours agoMerge branch 'kn/fetch-push-bulk-ref-update-fixup' into jch
Junio C Hamano [Tue, 24 Jun 2025 16:49:34 +0000 (09:49 -0700)] 
Merge branch 'kn/fetch-push-bulk-ref-update-fixup' into jch

Additional fixes to the base topic.

Comments?

* kn/fetch-push-bulk-ref-update-fixup:
  receive-pack: handle reference deletions separately
  refs/files: skip updates with errors in batched updates

5 hours agoMerge branch 'kn/fetch-push-bulk-ref-update' into jch
Junio C Hamano [Tue, 24 Jun 2025 16:49:34 +0000 (09:49 -0700)] 
Merge branch 'kn/fetch-push-bulk-ref-update' into jch

"git push" and "git fetch" are taught to update refs in batches to
gain performance.

Tentatively kicked out of 'next' to give its fix-up topic a chance to reboot.

* kn/fetch-push-bulk-ref-update:
  receive-pack: use batched reference updates
  send-pack: fix memory leak around duplicate refs
  fetch: use batched reference updates
  refs: add function to translate errors to strings

5 hours agoMerge branch 'tb/prepare-midx-pack-cleanup' into jch
Junio C Hamano [Tue, 24 Jun 2025 16:49:33 +0000 (09:49 -0700)] 
Merge branch 'tb/prepare-midx-pack-cleanup' into jch

Improvement on Multi-pack-index API.

* tb/prepare-midx-pack-cleanup:
  midx: return a `packed_git` pointer from `prepare_midx_pack()`
  midx-write.c: extract inner loop from fill_packs_from_midx()
  midx-write.c: guard against incremental MIDXs in want_included_pack()
  midx: access pack names through `nth_midxed_pack_name()`

5 hours agoMerge branch 'ly/load-bitmap-leakfix' into jch
Junio C Hamano [Tue, 24 Jun 2025 16:49:33 +0000 (09:49 -0700)] 
Merge branch 'ly/load-bitmap-leakfix' into jch

Leakfix with a new and a bit invasive test.

Comments?

* ly/load-bitmap-leakfix:
  pack-bitmap: add load corrupt bitmap test
  pack-bitmap: reword comments in test_bitmap_commits()
  pack-bitmap: fix memory leak if load_bitmap() failed

5 hours agoMerge branch 'ps/object-store' into jch
Junio C Hamano [Tue, 24 Jun 2025 16:49:32 +0000 (09:49 -0700)] 
Merge branch 'ps/object-store' into jch

Code clean-up around object access API.

Comments?

* ps/object-store:
  odb: rename `read_object_with_reference()`
  odb: rename `pretend_object_file()`
  odb: rename `has_object()`
  odb: rename `repo_read_object_file()`
  odb: rename `oid_object_info()`
  odb: trivial refactorings to get rid of `the_repository`
  odb: get rid of `the_repository` when handling submodule sources
  odb: get rid of `the_repository` when handling the primary source
  odb: get rid of `the_repository` in `for_each()` functions
  odb: get rid of `the_repository` when handling alternates
  odb: get rid of `the_repository` in `odb_mkstemp()`
  odb: get rid of `the_repository` in `assert_oid_type()`
  odb: get rid of `the_repository` in `find_odb()`
  odb: introduce parent pointers
  object-store: rename files to "odb.{c,h}"
  object-store: rename `object_directory` to `odb_source`
  object-store: rename `raw_object_store` to `object_database`

5 hours agoMerge branch 'sk/reftable-clarify-tests' into jch
Junio C Hamano [Tue, 24 Jun 2025 16:49:31 +0000 (09:49 -0700)] 
Merge branch 'sk/reftable-clarify-tests' into jch

The reftable unit tests are now ported to the "clar" unit testing
framework.

* sk/reftable-clarify-tests:
  t/unit-tests: finalize migration of reftable-related tests
  t/unit-tests: convert reftable stack test to use clar
  t/unit-tests: convert reftable record test to use clar
  t/unit-tests: convert reftable readwrite test to use clar
  t/unit-tests: convert reftable table test to use clar
  t/unit-tests: convert reftable pq test to use clar
  t/unit-tests: convert reftable merged test to use clar
  t/unit-tests: convert reftable block test to use clar
  t/unit-tests: convert reftable basics test to use clar test framework
  t/unit-tests: implement clar specific reftable test helper functions

5 hours ago### match next
Junio C Hamano [Tue, 24 Jun 2025 16:49:31 +0000 (09:49 -0700)] 
### match next

5 hours agoMerge branch 'jk/submodule-remote-lookup-cleanup' into jch
Junio C Hamano [Tue, 24 Jun 2025 16:49:30 +0000 (09:49 -0700)] 
Merge branch 'jk/submodule-remote-lookup-cleanup' into jch

Updating submodules from the upstream did not work well when
submodule's HEAD is detached, which has been improved.

* jk/submodule-remote-lookup-cleanup:
  submodule: look up remotes by URL first
  submodule: move get_default_remote_submodule()
  submodule--helper: improve logic for fallback remote name
  remote: remove the_repository from some functions
  dir: move starts_with_dot(_dot)_slash to dir.h
  remote: fix tear down of struct remote
  remote: remove branch->merge_name and fix branch_release()

5 hours agoMerge branch 'jk/test-seq-format' into jch
Junio C Hamano [Tue, 24 Jun 2025 16:49:29 +0000 (09:49 -0700)] 
Merge branch 'jk/test-seq-format' into jch

A test helper "test_seq" function learned the "-f <fmt>" option,
which allowed us to simplify a lot of test scripts.

* jk/test-seq-format:
  test-lib: teach test_seq the -f option
  t7422: replace confusing printf with echo

5 hours agoMerge branch 'jt/imap-send-message-fix' into jch
Junio C Hamano [Tue, 24 Jun 2025 16:49:29 +0000 (09:49 -0700)] 
Merge branch 'jt/imap-send-message-fix' into jch

Update some error messages from "git imap-send".

* jt/imap-send-message-fix:
  imap-send: improve error messages with configuration hints
  imap-send: fix confusing 'store' terminology in error message

5 hours agoMerge branch 'ps/contrib-sweep' into jch
Junio C Hamano [Tue, 24 Jun 2025 16:49:29 +0000 (09:49 -0700)] 
Merge branch 'ps/contrib-sweep' into jch

Remove bunch of stuff from contrib/ hierarchy.

* ps/contrib-sweep:
  contrib: remove some scripts in "stats" directory
  contrib: remove "git-new-workdir"
  contrib: remove "emacs" directory
  contrib: remove "git-resurrect.sh"
  contrib: remove "persistent-https" remote helper
  contrib: remove "mw-to-git"
  contrib: remove "hooks" directory
  contrib: remove "thunderbird-patch-inline"
  contrib: remove remote-helper stubs
  contrib: remove "examples" directory
  contrib: remove "remotes2config.sh"

5 hours agoMerge branch 'jc/merge-compact-summary' into jch
Junio C Hamano [Tue, 24 Jun 2025 16:49:28 +0000 (09:49 -0700)] 
Merge branch 'jc/merge-compact-summary' into jch

"git merge/pull" has been taught the "--compact-summary" option to
use the compact-summary format, intead of diffstat, when showing
the summary of the incoming changes.

* jc/merge-compact-summary:
  merge/pull: extend merge.stat configuration variable to cover --compact-summary
  merge/pull: add the "--compact-summary" option

5 hours agoMerge branch 'bc/stash-export-import' into jch
Junio C Hamano [Tue, 24 Jun 2025 16:49:28 +0000 (09:49 -0700)] 
Merge branch 'bc/stash-export-import' into jch

An interchange format for stash entries is defined, and subcommand
of "git stash" to import/export has been added.

* bc/stash-export-import:
  builtin/stash: provide a way to import stashes from a ref
  builtin/stash: provide a way to export stashes to a ref
  builtin/stash: factor out revision parsing into a function
  object-name: make get_oid quietly return an error

5 hours agoMerge branch 'ag/imap-send-resurrection' into jch
Junio C Hamano [Tue, 24 Jun 2025 16:49:27 +0000 (09:49 -0700)] 
Merge branch 'ag/imap-send-resurrection' into jch

"git imap-send" has been broken for a long time, which has been
resurrected and then taught to talk OAuth2.0 etc.

* ag/imap-send-resurrection:
  imap-send: fix minor mistakes in the logs
  imap-send: display the destination mailbox when sending a message
  imap-send: display port alongwith host when git credential is invoked
  imap-send: add ability to list the available folders
  imap-send: enable specifying the folder using the command line
  imap-send: add PLAIN authentication method to OpenSSL
  imap-send: add support for OAuth2.0 authentication
  imap-send: gracefully fail if CRAM-MD5 authentication is requested without OpenSSL
  imap-send: fix memory leak in case auth_cram_md5 fails
  imap-send: fix bug causing cfg->folder being set to NULL

5 hours agoMerge branch 'jc/cocci-avoid-regexp-constraint' into jch
Junio C Hamano [Tue, 24 Jun 2025 16:49:26 +0000 (09:49 -0700)] 
Merge branch 'jc/cocci-avoid-regexp-constraint' into jch

Avoid regexp_constraint and instead use comparison_constraint when
listing functions to exclude from application of coccinelle rules,
as spatch can be built with different regexp engine X-<.

* jc/cocci-avoid-regexp-constraint:
  cocci: matching (multiple) identifiers

5 hours agoMerge branch 'jg/mailinfo-leakfix' into jch
Junio C Hamano [Tue, 24 Jun 2025 16:49:26 +0000 (09:49 -0700)] 
Merge branch 'jg/mailinfo-leakfix' into jch

Leakfix.

* jg/mailinfo-leakfix:
  mailinfo.c: fix memory leak in function handle_content_type()

5 hours agoMerge branch 'jc/diff-no-index-with-pathspec-fix' into jch
Junio C Hamano [Tue, 24 Jun 2025 16:49:25 +0000 (09:49 -0700)] 
Merge branch 'jc/diff-no-index-with-pathspec-fix' into jch

Recent code added a direct access to the d_type member in "struct
dirent", but some platforms lack it, which has been corrected.

* jc/diff-no-index-with-pathspec-fix:
  diff-no-index: do not reference .d_type member of struct dirent

5 hours agoMerge branch 'ps/maintenance-ref-lock' into jch
Junio C Hamano [Tue, 24 Jun 2025 16:49:23 +0000 (09:49 -0700)] 
Merge branch 'ps/maintenance-ref-lock' into jch

"git maintenance" lacked the care "git gc" had to avoid holding
onto the repository lock for too long during packing refs, which
has been remedied.

* ps/maintenance-ref-lock:
  builtin/maintenance: fix locking race when handling "gc" task
  builtin/gc: avoid global state in `gc_before_repack()`
  usage: allow dying without writing an error message
  builtin/maintenance: fix locking race with refs and reflogs tasks
  builtin/maintenance: split into foreground and background tasks
  builtin/maintenance: fix typedef for function pointers
  builtin/maintenance: extract function to run tasks
  builtin/maintenance: stop modifying global array of tasks
  builtin/maintenance: mark "--task=" and "--schedule=" as incompatible
  builtin/maintenance: centralize configuration of explicit tasks
  builtin/gc: drop redundant local variable
  builtin/gc: use designated field initializers for maintenance tasks

5 hours agoMerge branch 'jc/you-still-use-whatchanged' into jch
Junio C Hamano [Tue, 24 Jun 2025 16:49:22 +0000 (09:49 -0700)] 
Merge branch 'jc/you-still-use-whatchanged' into jch

"git whatchanged" that is longer to type than "git log --raw"
which is its modern rough equivalent has outlived its usefulness
more than 10 years ago.  Plan to deprecate and remove it.

* jc/you-still-use-whatchanged:
  whatschanged: list it in BreakingChanges document
  whatchanged: remove when built with WITH_BREAKING_CHANGES
  whatchanged: require --i-still-use-this
  tests: prepare for a world without whatchanged
  doc: prepare for a world without whatchanged
  you-still-use-that??: help deprecating commands for removal

5 hours agoThe third batch main master
Junio C Hamano [Tue, 24 Jun 2025 16:47:25 +0000 (09:47 -0700)] 
The third batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 hours agoMerge branch 'ly/run-builtin-use-passed-in-repo'
Junio C Hamano [Tue, 24 Jun 2025 16:48:52 +0000 (09:48 -0700)] 
Merge branch 'ly/run-builtin-use-passed-in-repo'

Code clean-up.

* ly/run-builtin-use-passed-in-repo:
  git.c: remove the_repository dependence in run_builtin()

5 hours agoMerge branch 'rm/t2400-modernize'
Junio C Hamano [Tue, 24 Jun 2025 16:48:52 +0000 (09:48 -0700)] 
Merge branch 'rm/t2400-modernize'

Test clean-up.

* rm/t2400-modernize:
  t2400: replace 'test -[efd]' with 'test_path_is_*'

5 hours agoMerge branch 'sa/multi-mailmap-fix'
Junio C Hamano [Tue, 24 Jun 2025 16:48:51 +0000 (09:48 -0700)] 
Merge branch 'sa/multi-mailmap-fix'

When asking to apply mailmap to both author and committer field
while showing a commit object, the field that appears later was not
correctly parsed and replaced, which has been corrected.

* sa/multi-mailmap-fix:
  cat-file: fix mailmap application for different author and committer

5 hours agoMerge branch 'jc/cg-let-bss-do-its-job'
Junio C Hamano [Tue, 24 Jun 2025 16:48:50 +0000 (09:48 -0700)] 
Merge branch 'jc/cg-let-bss-do-its-job'

Clarify "do not explicitly initialize to zero" rule in the
CodingGuidelines document.

* jc/cg-let-bss-do-its-job:
  CodingGuidelines: let BSS do its job

5 hours agoMerge branch 'ac/preload-index-wo-the-repository'
Junio C Hamano [Tue, 24 Jun 2025 16:48:49 +0000 (09:48 -0700)] 
Merge branch 'ac/preload-index-wo-the-repository'

Code clean-up.

* ac/preload-index-wo-the-repository:
  preload-index: stop depending on 'the_repository'
  environment: remove the global variable 'core_preload_index'

5 hours agoMerge branch 'ly/prepare-show-merge-leakfix'
Junio C Hamano [Tue, 24 Jun 2025 16:48:49 +0000 (09:48 -0700)] 
Merge branch 'ly/prepare-show-merge-leakfix'

Leakfix.

* ly/prepare-show-merge-leakfix:
  revision: fix memory leak in prepare_show_merge()

5 hours agoMerge branch 'kj/stash-onbranch-submodule-fix'
Junio C Hamano [Tue, 24 Jun 2025 16:48:48 +0000 (09:48 -0700)] 
Merge branch 'kj/stash-onbranch-submodule-fix'

"git stash" recorded a wrong branch name when submodules are
present in the current checkout, which has been corrected.

* kj/stash-onbranch-submodule-fix:
  stash: fix incorrect branch name in stash message

5 hours agoMerge branch 'ag/send-email-edit-threading-fix'
Junio C Hamano [Tue, 24 Jun 2025 16:48:47 +0000 (09:48 -0700)] 
Merge branch 'ag/send-email-edit-threading-fix'

"git send-email" incremented its internal message counter when a
message was edited, which made logic that treats the first message
specially misbehave, which has been corrected.

* ag/send-email-edit-threading-fix:
  send-email: show the new message id assigned by outlook in the logs
  send-email: fix bug resulting in broken threads if a message is edited

5 hours agoMerge branch 'pw/stash-p-pathspec-fixes'
Junio C Hamano [Tue, 24 Jun 2025 16:48:47 +0000 (09:48 -0700)] 
Merge branch 'pw/stash-p-pathspec-fixes'

"git stash -p <pathspec>" improvements.

* pw/stash-p-pathspec-fixes:
  stash: allow "git stash [<options>] --patch <pathspec>" to assume push
  stash: allow "git stash -p <pathspec>" to assume push again

5 hours agoMerge branch 'pw/subtree-gpg-sign'
Junio C Hamano [Tue, 24 Jun 2025 16:48:46 +0000 (09:48 -0700)] 
Merge branch 'pw/subtree-gpg-sign'

"git subtree" (in contrib/) learns to grok GPG signing its commits.

* pw/subtree-gpg-sign:
  contrib/subtree: add -S/--gpg-sign
  contrib/subtree: parse using --stuck-long

6 hours agodaemon: explicitly allow EINTR during poll()
Carlo Marcelo Arenas Belón [Tue, 24 Jun 2025 14:08:42 +0000 (14:08 +0000)] 
daemon: explicitly allow EINTR during poll()

If the setup for the SIGCHLD signal handler sets SA_RESTART, poll()
might not return with -1 and set errno to EINTR when a signal is
received.

Since the logic to reap zombie childs relies om those interruptions
make sure to explicitly disable SA_RESTART around this function.

Add a Makefile flag for portability to systems that don't have the
functionality to change those flags or where it is not needed.

Signed-off-by: Carlo Marcelo Arenas Belón <carenas@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 hours agodaemon: use sigaction() to install child_handler()
Carlo Marcelo Arenas Belón [Tue, 24 Jun 2025 14:08:41 +0000 (14:08 +0000)] 
daemon: use sigaction() to install child_handler()

In a future change, the flags used for processing SIGCHLD will need to
be updated, which is only possible by using sigaction().

Replace the call, which hs the added benefit of using BSD semantics
reliably and therefore not needing the rearming call.

Signed-off-by: Carlo Marcelo Arenas Belón <carenas@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 hours agocompat/posix.h: track SA_RESTART fallback
Carlo Marcelo Arenas Belón [Tue, 24 Jun 2025 14:08:40 +0000 (14:08 +0000)] 
compat/posix.h: track SA_RESTART fallback

Systems without SA_RESTART where using custom CFLAGS instead of
the standard header file.

Consolidate that, so it will be easier to use in a future commit.

Signed-off-by: Carlo Marcelo Arenas Belón <carenas@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 hours agocontrib: better support symbolic port names in git-credential-netrc
Maxim Cournoyer [Tue, 24 Jun 2025 01:48:57 +0000 (10:48 +0900)] 
contrib: better support symbolic port names in git-credential-netrc

To improve support for symbolic port names in netrc files, this
changes does the following:

 - Treat symbolic port names as ports, not protocols in git-credential-netrc
 - Validate the SMTP server port provided to send-email
 - Convert the above symbolic port names to their numerical values.

Before this change, it was not possible to have a SMTP server port set
to "smtps" in a netrc file (e.g. Emacs' ~/.authinfo.gpg), as it would
be registered as a protocol and break the match for a "smtp" protocol
host, as queried for by git-send-email.

Signed-off-by: Maxim Cournoyer <maxim@guixotic.coop>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 hours agocontrib: warn for invalid netrc file ports in git-credential-netrc
Maxim Cournoyer [Tue, 24 Jun 2025 01:48:56 +0000 (10:48 +0900)] 
contrib: warn for invalid netrc file ports in git-credential-netrc

Invalid ports were previously silently dropped; now a warning message
is produced.

Signed-off-by: Maxim Cournoyer <maxim@guixotic.coop>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 hours agocontrib: use a more portable shebang for git-credential-netrc
Maxim Cournoyer [Tue, 24 Jun 2025 01:48:55 +0000 (10:48 +0900)] 
contrib: use a more portable shebang for git-credential-netrc

While the installed scripts have their Perl shebang set to PERL_PATH,
it is nevertheless useful to be able to run the uninstalled script for
manual tests while developing. This change makes the shebang more
portable by having the perl command looked from PATH instead of from a
fixed location.

Signed-off-by: Maxim Cournoyer <maxim@guixotic.coop>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 hours agotest-lib: teach test_seq the -f option
Jeff King [Mon, 23 Jun 2025 10:56:25 +0000 (06:56 -0400)] 
test-lib: teach test_seq the -f option

The "seq" tool has a "-f" option to produce printf-style formatted
lines. Let's teach our test_seq helper the same trick. This lets us get
rid of some shell loops in test snippets (which are particularly verbose
in our test suite because we have to "|| return 1" to keep the &&-chain
going).

This converts a few call-sites I found by grepping around the test
suite. A few notes on these:

  - In "seq", the format specifier is a "%g" float. Since test_seq only
    supports integers, I've kept the more natural "%d" (which is what
    these call sites were using already).

  - Like "seq", test_seq automatically adds a newline to the specified
    format. This is what all callers are doing already except for t0021,
    but there we do not care about the exact format. We are just trying
    to printf a large number of bytes to a file. It's not worth
    complicating other callers or adding an option to avoid the newline
    in that caller.

  - Most conversions are just replacing a shell loop (which does get rid
    of an extra fork, since $() requires a subshell). In t0612 we can
    replace an awk invocation, which I think makes the end result more
    readable, as there's less quoting.

  - In t7422 we can replace one loop, but sadly we have to leave the
    loop directly above it. This is because that earlier loop wants to
    include the seq value twice in the output, which test_seq does not
    support (nor does regular seq). If you run:

      test_seq -f "foo-%d %d" 10

    the second "%d" will always be the empty string. You might naively
    think that test_seq could add some extra arguments, like:

      # 3 ought to be enough for anyone...
      printf "$fmt\n" "$i "$i" $i"

    but that just triggers printf to format multiple lines, one per
    extra set of arguments.

    So we'd have to actually parse the format string, figure out how
    many "%" placeholders are there, and then feed it that many
    instances of the sequence number. The complexity isn't worth it.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
22 hours agorefs: remove old refs_warn_dangling_symref
Phil Hord [Mon, 23 Jun 2025 23:43:27 +0000 (16:43 -0700)] 
refs: remove old refs_warn_dangling_symref

The dangling warning function that takes a single ref to search for
is no longer used.  Remove it.

Signed-off-by: Phil Hord <phil.hord@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
22 hours agofetch-prune: optimize dangling-ref reporting
Phil Hord [Mon, 23 Jun 2025 23:43:26 +0000 (16:43 -0700)] 
fetch-prune: optimize dangling-ref reporting

When pruning during `git fetch` we check each pruned ref against the
ref_store one at a time to decide whether to report it as dangling.
This causes every local ref to be scanned for each ref being pruned.

If there are N refs in the repo and M refs being pruned, this code is
O(M*N). However, `git remote prune` uses a very similar function that
is only O(N*log(M)).

Remove the wasteful ref scanning for each pruned ref and use the faster
version already available in refs_warn_dangling_symrefs.

In a repo with 126,000 refs, where I was pruning 28,000 refs, this
code made about 3.6 billion calls to strcmp and consumed 410 seconds
of CPU. (Invariably in that time, my remote would timeout and the
fetch would fail anyway.)

After this change, the same operation completes in under a second.

Signed-off-by: Phil Hord <phil.hord@gmail.com>
Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
22 hours agosubmodule: look up remotes by URL first
Jacob Keller [Mon, 23 Jun 2025 23:11:35 +0000 (16:11 -0700)] 
submodule: look up remotes by URL first

The get_default_remote_submodule() function performs a lookup to find
the appropriate remote to use within a submodule. The function first
checks to see if it can find the remote for the current branch. If this
fails, it then checks to see if there is exactly one remote. It will use
this, before finally falling back to "origin" as the default.

If a user happens to rename their default remote from origin, either
manually or by setting something like clone.defaultRemoteName, this
fallback will not work.

In such cases, the submodule logic will try to use a non-existent
remote. This usually manifests as a failure to trigger the submodule
update.

The parent project already knows and stores the submodule URL in either
.gitmodules or its .git/config.

Add a new repo_remote_from_url() helper which will iterate over all the
remotes in a repository and return the first remote which has a matching
URL.

Refactor get_default_remote_submodule to find the submodule and get its
URL. If a valid URL exists, first try to obtain a remote using the new
repo_remote_from_url(). Fall back to the repo_default_remote()
otherwise.

The fallback logic is kept in case for some reason the user has manually
changed the URL within the submodule. Additionally, we still try to use
a remote rather than directly passing the URL in the
fetch_in_submodule() logic. This ensures that an update will properly
update the remote refs within the submodule as expected, rather than
just fetching into FETCH_HEAD.

Signed-off-by: Jacob Keller <jacob.keller@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
22 hours agosubmodule: move get_default_remote_submodule()
Jacob Keller [Mon, 23 Jun 2025 23:11:34 +0000 (16:11 -0700)] 
submodule: move get_default_remote_submodule()

A future refactor got get_default_remote_submodule() is going to depend on
resolve_relative_url(). That function depends on get_default_remote().

Move get_default_remote_submodule() after resolve_relative_url() first
to make the additional functionality easier to review.

Signed-off-by: Jacob Keller <jacob.keller@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
22 hours agosubmodule--helper: improve logic for fallback remote name
Jacob Keller [Mon, 23 Jun 2025 23:11:33 +0000 (16:11 -0700)] 
submodule--helper: improve logic for fallback remote name

The repo_get_default_remote() function in submodule--helper currently
tries to figure out the proper remote name to use for a submodule based
on a few factors.

First, it tries to find the remote for the currently checked out branch.
This works if the submodule is configured to checkout to a branch
instead of a detached HEAD state.

In the detached HEAD state, the code calls back to using "origin", on
the assumption that this is the default remote name. Some users may
change this, such as by setting clone.defaultRemoteName, or by changing
the remote name manually within the submodule repository.

As a first step to improving this situation, refactor to reuse the logic
from remotes_remote_for_branch(). This function uses the remote from the
branch if it has one. If it doesn't then it checks to see if there is
exactly one remote. It uses this remote first before attempting to fall
back to "origin".

To allow using this helper function, introduce a repo_default_remote()
helper to remote.c which takes a repository structure. This helper will
load the remote configuration and get the "HEAD" branch. Then it will
call remotes_remote_for_branch to find the default remote.

Replace calls of repo_get_default_remote() with the calls to this new
function. To maintain consistency with the existing callers, continue
copying the returned string with xstrdup.

This isn't a perfect solution for users who change remote names, but it
should help in cases where the remote name is changed but users haven't
added any additional remotes.

Signed-off-by: Jacob Keller <jacob.keller@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
22 hours agoremote: remove the_repository from some functions
Jacob Keller [Mon, 23 Jun 2025 23:11:32 +0000 (16:11 -0700)] 
remote: remove the_repository from some functions

The remotes_remote_get_1 (and its caller, remotes_remote_get, have an
implicit dependency on the_repository due to calling
read_branches_file() and read_remotes_file(), both of which use
the_repository. The branch_get() function calls set_merge() which has an
implicit dependency on the_repository as well.

Because of this use of the_repository, the helper functions cannot be
used in code paths which operate on other repositories. A future
refactor of the submodule--helper will want to make use of some of these
functions.

Refactor to break the dependency by passing struct repository *repo
instead of struct remote_state *remote_state in a few places.

The public callers and many other helper functions still depend on
the_repository. A repo-aware function will be exposed in a following
change for git submodule--helper.

Signed-off-by: Jacob Keller <jacob.keller@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
22 hours agodir: move starts_with_dot(_dot)_slash to dir.h
Jacob Keller [Mon, 23 Jun 2025 23:11:31 +0000 (16:11 -0700)] 
dir: move starts_with_dot(_dot)_slash to dir.h

Both submodule--helper.c and submodule-config.c have an implementation
of starts_with_dot_slash and starts_with_dot_dot_slash. The dir.h header
has starts_with_dot(_dot)_slash_native, which sets PATH_MATCH_NATIVE.

Move the helpers to dir.h as static inlines. I thought about renaming
them to postfix with _platform but that felt too long and ugly. On the
other hand it might be slightly confusing with _native.

This simplifies a submodule refactor which wants to use the helpers
earlier in the submodule--helper.c file.

Signed-off-by: Jacob Keller <jacob.keller@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
22 hours agoremote: fix tear down of struct remote
Jacob Keller [Mon, 23 Jun 2025 23:11:30 +0000 (16:11 -0700)] 
remote: fix tear down of struct remote

The remote_clear() function failed to free the remote->push and
remote->fetch refspec fields.

This should be caught by the leak sanitizer. However, for callers which
use ``the_repository``, the values never go out of scope and the
sanitizer doesn't complain.

A future change is going to add a caller of read_config() for a
submodule repository structure, which would result in the leak sanitizer
complaining.

Fix remote_clear(), updating it to properly call refspec_clear() for
both the push and fetch members.

Signed-off-by: Jacob Keller <jacob.keller@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
22 hours agoremote: remove branch->merge_name and fix branch_release()
Jacob Keller [Mon, 23 Jun 2025 23:11:29 +0000 (16:11 -0700)] 
remote: remove branch->merge_name and fix branch_release()

The branch structure has both branch->merge_name and branch->merge for
tracking the merge information. The former is allocated by add_merge()
and stores the names read from the configuration file. The latter is
allocated by set_merge() which is called by branch_get() when an
external caller requests a branch.

This leads to the confusing situation where branch->merge_nr tracks both
the size of branch->merge (once its allocated) and branch->merge_name.
The branch_release() function incorrectly assumes that branch->merge is
always set when branch->merge_nr is non-zero, and can potentially crash
if read_config() is called without branch_get() being called on every
branch.

In addition, branch_release() fails to free some of the memory
associated with the structure including:

 * Failure to free the refspec_item containers in branch->merge[i]
 * Failure to free the strings in branch->merge_name[i]
 * Failure to free the branch->merge_name parent array.

The set_merge() function sets branch->merge_nr to 0 when there is no
valid remote_name, to avoid external callers seeing a non-zero merge_nr
but a NULL merge array. This results in failure to release most of the
merge data as well.

These issues could be fixed directly, and indeed I initially proposed
such a change at [1] in the past. While this works, there was some
confusion during review because of the inconsistencies.

Instead, its time to clean up the situation properly. Remove
branch->merge_name entirely. Instead, allocate branch->merge earlier
within add_merge() instead of within set_merge(). Instead of having
set_merge() copy from merge_name[i] to merge[i]->src, just have
add_merge() directly initialize merge[i]->src.

Modify the add_merge() to call xstrdup() itself, instead of having
the caller of add_merge() do so. This makes it more obvious which code
owns the memory.

Update all callers which use branch->merge_name[i] to use
branch->merge[i]->src instead.

Add a merge_clear() function which properly releases all of the
merge-related memory, and which sets branch->merge_nr to zero. Use this
both in branch_release() and in set_merge(), fixing the leak when
set_merge() finds no valid remote_name.

Add a set_merge variable to the branch structure, which indicates
whether set_merge() has been called. This replaces the previous use of a
NULL check against the branch->merge array.

With these changes, the merge array is always allocated when merge_nr is
non-zero.

This use of refspec_item to store the names should be safe. External
callers should be using branch_get() to obtain a pointer to the branch,
which will call set_merge(), and the callers internal to remote.c
already handle the partially initialized refpsec_item structure safely.

This end result is cleaner, and avoids duplicating the merge names
twice.

Signed-off-by: Jacob Keller <jacob.keller@gmail.com>
Link: [1] https://lore.kernel.org/git/20250617-jk-submodule-helper-use-url-v2-1-04cbb003177d@gmail.com/
Signed-off-by: Junio C Hamano <gitster@pobox.com>
23 hours agorepack: exclude cruft pack(s) from the MIDX where possible
Taylor Blau [Mon, 23 Jun 2025 22:32:32 +0000 (18:32 -0400)] 
repack: exclude cruft pack(s) from the MIDX where possible

In ddee3703b3 (builtin/repack.c: add cruft packs to MIDX during
geometric repack, 2022-05-20), repack began adding cruft pack(s) to the
MIDX with '--write-midx' to ensure that the resulting MIDX was always
closed under reachability in order to generate reachability bitmaps.

While the previous patch added the '--stdin-packs=follow' option to
pack-objects, it is not yet on by default. Given that, suppose you have
a once-unreachable object packed in a cruft pack, which later becomes
reachable from one or more objects in a geometrically repacked pack.
That once-unreachable object *won't* appear in the new pack, since the
cruft pack was not specified as included or excluded when the
geometrically repacked pack was created with 'pack-objects
--stdin-packs' (*not* '--stdin-packs=follow', which is not on). If that
new pack is included in a MIDX without the cruft pack, then trying to
generate bitmaps for that MIDX may fail. This happens when the bitmap
selection process picks one or more commits which reach the
once-unreachable objects.

To mitigate this failure mode, commit ddee3703b3 ensures that the MIDX
will be closed under reachability by including cruft pack(s). If cruft
pack(s) were not included, we would fail to generate a MIDX bitmap. But
ddee3703b3 alludes to the fact that this is sub-optimal by saying

    [...] it's desirable to avoid including cruft packs in the MIDX
    because it causes the MIDX to store a bunch of objects which are
    likely to get thrown away.

, which is true, but hides an even larger problem. If repositories
rarely prune their unreachable objects and/or have many of them, the
MIDX must keep track of a large number of objects which bloats the MIDX
and slows down object lookup.

This is doubly unfortunate because the vast majority of objects in cruft
pack(s) are unlikely to be read. But any object lookups that go through
the MIDX must binary search over them anyway, slowing down object
lookups using the MIDX.

This patch causes geometrically-repacked packs to contain a copy of any
once-unreachable object(s) with 'git pack-objects --stdin-packs=follow',
allowing us to avoid including any cruft packs in the MIDX. This is
because a sequence of geometrically-repacked packs that were all
generated with '--stdin-packs=follow' are guaranteed to have their union
be closed under reachability.

Note that you cannot guarantee that a collection of packs is closed
under reachability if not all of them were generated with "following" as
above. One tell-tale sign that not all geometrically-repacked packs in
the MIDX were generated with "following" is to see if there is a pack in
the existing MIDX that is not going to be somehow represented (either
verbatim or as part of a geometric rollup) in the new MIDX.

If there is, then starting to generate packs with "following" during
geometric repacking won't work, since it's open to the same race as
described above.

But if you're starting from scratch (e.g., building the first MIDX after
an all-into-one '--cruft' repack), then you can guarantee that the union
of subsequently generated packs from geometric repacking *is* closed
under reachability.

(One exception here is when "starting from scratch" results in a noop
repack, e.g., because the non-cruft pack(s) in a repository already form
a geometric progression. Since we can't tell whether or not those were
generated with '--stdin-packs=follow', they may depend on
once-unreachable objects, so we have to include the cruft pack in the
MIDX in this case.)

Detect when this is the case and avoid including cruft packs in the MIDX
where possible. The existing behavior remains the default, and the new
behavior is available with the config 'repack.midxMustIncludeCruft' set
to 'false'.

Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
23 hours agopack-objects: introduce '--stdin-packs=follow'
Taylor Blau [Mon, 23 Jun 2025 22:32:30 +0000 (18:32 -0400)] 
pack-objects: introduce '--stdin-packs=follow'

When invoked with '--stdin-packs', pack-objects will generate a pack
which contains the objects found in the "included" packs, less any
objects from "excluded" packs.

Packs that exist in the repository but weren't specified as either
included or excluded are in practice treated like the latter, at least
in the sense that pack-objects won't include objects from those packs.
This behavior forces us to include any cruft pack(s) in a repository's
multi-pack index for the reasons described in ddee3703b3
(builtin/repack.c: add cruft packs to MIDX during geometric repack,
2022-05-20).

The full details are in ddee3703b3, but the gist is if you
have a once-unreachable object in a cruft pack which later becomes
reachable via one or more commits in a pack generated with
'--stdin-packs', you *have* to include that object in the MIDX via the
copy in the cruft pack, otherwise we cannot generate reachability
bitmaps for any commits which reach that object.

Note that the traversal here is best-effort, similar to the existing
traversal which provides name-hash hints. This means that the object
traversal may hand us back a blob that does not actually exist. We
*won't* see missing trees/commits with 'ignore_missing_links' because:

 - missing commit parents are discarded at the commit traversal stage by
   revision.c::process_parents()

 - missing tag objects are discarded by revision.c::handle_commit()

 - missing tree objects are discarded by the list-objects code in
   list-objects.c::process_tree()

But we have to handle potentially-missing blobs specially by making a
separate check to ensure they exist in the repository. Failing to do so
would mean that we'd add an object to the packing list which doesn't
actually exist, rendering us unable to write out the pack.

This prepares us for new repacking behavior which will "resurrect"
objects found in cruft or otherwise unspecified packs when generating
new packs. In the context of geometric repacking, this may be used to
maintain a sequence of geometrically-repacked packs, the union of which
is closed under reachability, even in the case described earlier.

Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
23 hours agopack-objects: swap 'show_{object,commit}_pack_hint'
Taylor Blau [Mon, 23 Jun 2025 22:32:27 +0000 (18:32 -0400)] 
pack-objects: swap 'show_{object,commit}_pack_hint'

show_commit_pack_hint() has heretofore been a noop, so its position
within its compilation unit only needs to appear before its first use.

But the following commit will sometimes have `show_commit_pack_hint()`
call `show_object_pack_hint()`, so reorder the former to appear after
the latter to minimize the code movement in that patch.

Suggested-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
23 hours agopack-objects: fix typo in 'show_object_pack_hint()'
Taylor Blau [Mon, 23 Jun 2025 22:32:24 +0000 (18:32 -0400)] 
pack-objects: fix typo in 'show_object_pack_hint()'

Noticed-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
23 hours agopack-objects: perform name-hash traversal for unpacked objects
Taylor Blau [Mon, 23 Jun 2025 22:32:21 +0000 (18:32 -0400)] 
pack-objects: perform name-hash traversal for unpacked objects

With '--unpacked', pack-objects adds loose objects (which don't appear
in any of the excluded packs from '--stdin-packs') to the output pack
without considering them as reachability tips for the name-hash
traversal.

This was an oversight in the original implementation of '--stdin-packs',
since the code which enumerates and adds loose objects to the output
pack (`add_unreachable_loose_objects()`) did not have access to the
'rev_info' struct found in `read_packs_list_from_stdin()`.

Excluding unpacked objects from that traversal doesn't affect the
correctness of the resulting pack, but it does make it harder to
discover good deltas for loose objects.

Now that the 'rev_info' struct is declared outside of
`read_packs_list_from_stdin()`, we can pass it to
`add_objects_in_unpacked_packs()` and add any loose objects as tips to
the above-mentioned traversal, in theory producing slightly tighter
packs as a result.

Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
23 hours agopack-objects: declare 'rev_info' for '--stdin-packs' earlier
Taylor Blau [Mon, 23 Jun 2025 22:32:18 +0000 (18:32 -0400)] 
pack-objects: declare 'rev_info' for '--stdin-packs' earlier

Once 'read_packs_list_from_stdin()' has called for_each_object_in_pack()
on each of the input packs, we do a reachability traversal to discover
names for any objects we picked up so we can generate name hash values
and hopefully get higher quality deltas as a result.

A future commit will change the purpose of this reachability traversal
to find and pack objects which are reachable from commits in the input
packs, but are packed in an unknown (not included nor excluded) pack.

Extract the code which initializes and performs the reachability
traversal to take place in the caller, not the callee, which prepares us
to share this code for the '--unpacked' case (see the function
add_unreachable_loose_objects() for more details).

Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
23 hours agopack-objects: factor out handling '--stdin-packs'
Taylor Blau [Mon, 23 Jun 2025 22:32:15 +0000 (18:32 -0400)] 
pack-objects: factor out handling '--stdin-packs'

At the bottom of cmd_pack_objects() we check which mode the command is
running in (e.g., generating a cruft pack, handling '--stdin-packs',
using the internal rev-list, etc.) and handle the mode appropriately.

The '--stdin-packs' case is handled inline (dating back to its
introduction in 339bce27f4 (builtin/pack-objects.c: add '--stdin-packs'
option, 2021-02-22)) since it is relatively short. Extract the body of
"if (stdin_packs)" into its own function to prepare for the
implementation to become lengthier in a following commit.

Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
23 hours agopack-objects: limit scope in 'add_object_entry_from_pack()'
Taylor Blau [Mon, 23 Jun 2025 22:32:13 +0000 (18:32 -0400)] 
pack-objects: limit scope in 'add_object_entry_from_pack()'

In add_object_entry_from_pack() we declare 'revs' (given to us through
the miscellaneous context argument) earlier in the "if (p)" conditional
than is necessary.  Move it down as far as it can go to reduce its
scope.

Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
23 hours agopack-objects: use standard option incompatibility functions
Taylor Blau [Mon, 23 Jun 2025 22:32:10 +0000 (18:32 -0400)] 
pack-objects: use standard option incompatibility functions

pack-objects has a handful of explicit checks for pairs of command-line
options which are mutually incompatible. Many of these pre-date
a699367bb8 (i18n: factorize more 'incompatible options' messages,
2022-01-31).

Convert the explicit checks into die_for_incompatible_opt2() calls,
which simplifies the implementation and standardizes pack-objects'
output when given incompatible options (e.g., --stdin-packs with
--filter gives different output than --keep-unreachable with
--unpack-unreachable).

There is one minor piece of test fallout in t5331 that expects the old
format, which has been corrected.

Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
28 hours agot7422: replace confusing printf with echo
Jeff King [Mon, 23 Jun 2025 10:55:42 +0000 (06:55 -0400)] 
t7422: replace confusing printf with echo

While looping over a counter "i", we do:

  printf "[submodule \"sm-$i\"]\npath = recursive-submodule-path-$i\n" "$i"

So we are passing "$i" as an argument to be filled in, but there is no
"%" placeholder in the format string, which is a bit confusing to read.

We could switch both instances of "$i" to "%d" (and pass $i twice). But
that makes the line even longer. Let's just keep interpolating the value
in the string, and drop the confusing extra "$i" argument.

And since we are not using any printf specifiers at all, it becomes
clear that we can swap it out for echo. We do use a "\n" in the middle
of the string, but breaking this into two separate echo statements
actually makes it easier to read.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
29 hours agococcicheck: fail "make" when it fails
Junio C Hamano [Mon, 23 Jun 2025 16:14:11 +0000 (09:14 -0700)] 
coccicheck: fail "make" when it fails

With "make coccicheck", we generate contrib/coccinelle/*.cocci.patch
files that contain changes suggested by semantic patches, but "make"
succeeds.  Admittedly, not many developers may run "make coccicheck"
in the first place, but it makes it harder to notice when they do
run it after they introduced an iffy piece of code.

Check that the resulting cocci.patch files are all empty.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 days agococci: do not directly access the .d_type member in struct dirent
Junio C Hamano [Wed, 18 Jun 2025 18:07:20 +0000 (11:07 -0700)] 
cocci: do not directly access the .d_type member in struct dirent

In "struct dirent", the presence of the .d_type member should not be
assumed and the code should instead use DTYPE() macro, with possibly
a fallback check to determine the type of the file.

Add a rule to catch direct access to the .d_type member and use
DTYPE() macro instead, except in the emulation code paths that work
on platforms that do have the member.  This is probably not sufficient
to notice the lack of necessary fallback code.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 days agococci: matching (multiple) identifiers
Junio C Hamano [Wed, 18 Jun 2025 17:55:02 +0000 (10:55 -0700)] 
cocci: matching (multiple) identifiers

"make coccicheck" seems to work OK at GitHub CI using

    $ spatch --version
    spatch version 1.1.1 compiled with OCaml version 4.13.1
    OCaml scripting support: yes
    Python scripting support: yes
    Syntax of regular expressions: PCRE

but not with

    $ spatch --version
    spatch version 1.3 compiled with OCaml version 5.3.0
    OCaml scripting support: yes
    Python scripting support: yes
    Syntax of regular expressions: Str

Judging from https://ocaml.org/manual/5.3/api/Str.html, I suspect
that this probably is caused by the distinction between BRE vs PCRE.
As there is no reasonably clean way to write the multiple choice
matches portably between these two pattern languages, let's stop
using regexp_constraint and use compare_constraint instead when
listing the function names to exclude.

There are other uses of "!~" but they all want to match a single
simple token, that should work fine either with BRE or PCRE.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 days agoimap-send: improve error messages with configuration hints
Jörg Thalheim [Fri, 20 Jun 2025 15:56:14 +0000 (17:56 +0200)] 
imap-send: improve error messages with configuration hints

Replace basic error messages with more helpful ones that guide users
on how to resolve configuration issues. When imap.host or imap.folder
are missing, provide the exact git config commands needed to fix the
problem, along with examples of typical values.

Use the advise() API to display hints in a multi-line format with
proper "hint:" prefixes for each line.

Signed-off-by: Jörg Thalheim <joerg@thalheim.io>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 days agoimap-send: fix confusing 'store' terminology in error message
Jörg Thalheim [Fri, 20 Jun 2025 15:56:13 +0000 (17:56 +0200)] 
imap-send: fix confusing 'store' terminology in error message

The error message 'no imap store specified' is misleading because
it refers to 'store' when the actual missing configuration is
'imap.folder'. Update the message to use the correct terminology
that matches the configuration variable name.

This reduces confusion for users who might otherwise look for
non-existent 'imap.store' configuration when they see this error.

Signed-off-by: Jörg Thalheim <joerg@thalheim.io>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 days agoreceive-pack: handle reference deletions separately
Karthik Nayak [Fri, 20 Jun 2025 07:15:45 +0000 (09:15 +0200)] 
receive-pack: handle reference deletions separately

In 9d2962a7c4 (receive-pack: use batched reference updates, 2025-05-19)
we updated the 'git-receive-pack(1)' command to use batched reference
updates. One edge case which was missed during this implementation was
when a user pushes multiple branches such as:

  delete refs/heads/branch/conflict
  create refs/heads/branch

Before using batched updates, the references would be applied
sequentially and hence no conflicts would arise. With batched updates,
while the first update applies, the second fails due to D/F conflict. A
similar issue was present in 'git-fetch(1)' and was fixed by separating
out reference pruning into a separate transaction in the commit 'fetch:
use batched reference updates'. Apply a similar mechanism for
'git-receive-pack(1)' and separate out reference deletions into its own
batch.

This means 'git-receive-pack(1)' will now use up to two transactions,
whereas before using batched updates it would use _at least_ two
transactions. So using batched updates is still the better option.

Add a test to validate this behavior.

Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 days agorefs/files: skip updates with errors in batched updates
Karthik Nayak [Fri, 20 Jun 2025 07:15:44 +0000 (09:15 +0200)] 
refs/files: skip updates with errors in batched updates

The commit 23fc8e4f61 (refs: implement batch reference update support,
2025-04-08) introduced support for batched reference updates. This
allows users to batch updates together, while allowing some of the
updates to fail.

Under the hood, batched updates use the reference transaction mechanism.
Each update which fails is marked as such. Any failed updates must be
skipped over in the rest of the code, as they wouldn't apply any more.
In two of the loops within 'files_transaction_finish()' of the files
backend, the failed updates aren't skipped over. This can cause a
SEGFAULT otherwise. Add the missing skips and a test to validate the
same.

Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 days agoMerge branch 'ag/imap-send-resurrection' into jt/imap-send-message-fix
Junio C Hamano [Fri, 20 Jun 2025 15:29:34 +0000 (08:29 -0700)] 
Merge branch 'ag/imap-send-resurrection' into jt/imap-send-message-fix

* ag/imap-send-resurrection:
  imap-send: fix minor mistakes in the logs
  imap-send: display the destination mailbox when sending a message
  imap-send: display port alongwith host when git credential is invoked
  imap-send: add ability to list the available folders
  imap-send: enable specifying the folder using the command line
  imap-send: add PLAIN authentication method to OpenSSL
  imap-send: add support for OAuth2.0 authentication
  imap-send: gracefully fail if CRAM-MD5 authentication is requested without OpenSSL
  imap-send: fix memory leak in case auth_cram_md5 fails
  imap-send: fix bug causing cfg->folder being set to NULL

4 days agoimap-send: fix minor mistakes in the logs
Aditya Garg [Fri, 20 Jun 2025 06:40:33 +0000 (12:10 +0530)] 
imap-send: fix minor mistakes in the logs

Some minor mistakes have been found in the logs. Most of them include
error messages starting with a capital letter, and ending with a period.
Abbreviations like "IMAP" and "OK" should also be in uppercase. Another
mistake was that the error message showing unknown authentication
mechanism used was displaying the host rather than the mechanism in the
logs. Fix them.

Signed-off-by: Aditya Garg <gargaditya08@live.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 days agoimap-send: display the destination mailbox when sending a message
Aditya Garg [Fri, 20 Jun 2025 06:40:32 +0000 (12:10 +0530)] 
imap-send: display the destination mailbox when sending a message

Whenever we sent a message using the `imap-send` command, it would
display a log showing the number of messages which are to be sent.
For example:

    sending 1 message
     100% (1/1) done

This had been made more informative by adding the name of the destination
folder as well:

    Sending 1 message to Drafts folder...
     100% (1/1) done

Signed-off-by: Aditya Garg <gargaditya08@live.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 days agoimap-send: display port alongwith host when git credential is invoked
Aditya Garg [Fri, 20 Jun 2025 06:40:31 +0000 (12:10 +0530)] 
imap-send: display port alongwith host when git credential is invoked

When requesting for passsword, git credential helper used to display
only the host name. For example:

    Password for 'imaps://gargaditya08%40live.com@outlook.office365.com':

Now, it will display the port along with the host name:

    Password for 'imaps://gargaditya08%40live.com@outlook.office365.com:993':

This has been done to make credential helpers more specific for ports.
Also, this behaviour will also mimic git send-email, which displays
the port along with the host name when requesting for a password.

Signed-off-by: Aditya Garg <gargaditya08@live.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 days agoimap-send: add ability to list the available folders
Aditya Garg [Fri, 20 Jun 2025 06:40:30 +0000 (12:10 +0530)] 
imap-send: add ability to list the available folders

Various IMAP servers have different ways to name common folders.
For example, the folder where all deleted messages are stored is often
named "[Gmail]/Trash" on Gmail servers, and "Deleted" on Outlook.
Similarly, the Drafts folder is simply named "Drafts" on Outlook, but
on Gmail it is named "[Gmail]/Drafts".

This commit adds a `--list` command to the `imap-send` tool that lists
the available folders on the IMAP server, allowing users to see
which folders are available and how they are named. A sample output
looks like this when run against a Gmail server:

    Fetching the list of available folders...
    * LIST (\HasNoChildren) "/" "INBOX"
    * LIST (\HasChildren \Noselect) "/" "[Gmail]"
    * LIST (\All \HasNoChildren) "/" "[Gmail]/All Mail"
    * LIST (\Drafts \HasNoChildren) "/" "[Gmail]/Drafts"
    * LIST (\HasNoChildren \Important) "/" "[Gmail]/Important"
    * LIST (\HasNoChildren \Sent) "/" "[Gmail]/Sent Mail"
    * LIST (\HasNoChildren \Junk) "/" "[Gmail]/Spam"
    * LIST (\Flagged \HasNoChildren) "/" "[Gmail]/Starred"
    * LIST (\HasNoChildren \Trash) "/" "[Gmail]/Trash"

For OpenSSL, this is achived by running the 'IMAP LIST' command and
parsing the response. This command is specified in RFC6154:
https://datatracker.ietf.org/doc/html/rfc6154#section-5.1

For libcurl, the example code published in the libcurl documentation
is used to implement this functionality:
https://curl.se/libcurl/c/imap-list.html

Signed-off-by: Aditya Garg <gargaditya08@live.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 days agoimap-send: enable specifying the folder using the command line
Aditya Garg [Fri, 20 Jun 2025 06:40:29 +0000 (12:10 +0530)] 
imap-send: enable specifying the folder using the command line

Some users may very often want to imap-send messages to a folder
other than the default set in the config. Add a command line
argument for the same.

While at it, fix minor mark-up inconsistencies in the existing
documentation text.

Signed-off-by: Aditya Garg <gargaditya08@live.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 days agoimap-send: add PLAIN authentication method to OpenSSL
Aditya Garg [Fri, 20 Jun 2025 06:40:28 +0000 (12:10 +0530)] 
imap-send: add PLAIN authentication method to OpenSSL

The current implementation for PLAIN in imap-send works just fine
if using curl, but if attempted to use for OpenSSL, it is treated
as an invalid mechanism. The default implementation for OpenSSL is
IMAP LOGIN command rather than AUTH PLAIN. Since AUTH PLAIN is
still used today by many email providers in form of app passwords,
lets add an implementation that can use AUTH PLAIN if specified.

Signed-off-by: Aditya Garg <gargaditya08@live.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 days agoimap-send: add support for OAuth2.0 authentication
Aditya Garg [Fri, 20 Jun 2025 06:40:27 +0000 (12:10 +0530)] 
imap-send: add support for OAuth2.0 authentication

OAuth2.0 is a new way of authentication supported by various email providers
these days. OAUTHBEARER and XOAUTH2 are the two most common mechanisms used
for OAuth2.0. OAUTHBEARER is described in RFC5801[1] and RFC7628[2], whereas
XOAUTH2 is Google's proprietary mechanism (See [3]).

[1]: https://datatracker.ietf.org/doc/html/rfc5801
[2]: https://datatracker.ietf.org/doc/html/rfc7628
[3]: https://developers.google.com/workspace/gmail/imap/xoauth2-protocol#initial_client_response

Signed-off-by: Aditya Garg <gargaditya08@live.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 days agoimap-send: gracefully fail if CRAM-MD5 authentication is requested without OpenSSL
Aditya Garg [Fri, 20 Jun 2025 06:40:26 +0000 (12:10 +0530)] 
imap-send: gracefully fail if CRAM-MD5 authentication is requested without OpenSSL

Unlike PLAIN, XOAUTH2 and OAUTHBEARER, CRAM-MD5 authentication is not
supported by libcurl and requires OpenSSL. If the user tries to use
CRAM-MD5 authentication without OpenSSL, the previous behaviour was to
attempt to authenticate and fail with a die(error). Handle this in a
better way by first checking if OpenSSL is available and then attempting
to authenticate. If OpenSSL is not available, print an error message and
exit gracefully.

Signed-off-by: Aditya Garg <gargaditya08@live.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 days agoimap-send: fix memory leak in case auth_cram_md5 fails
Aditya Garg [Fri, 20 Jun 2025 06:40:25 +0000 (12:10 +0530)] 
imap-send: fix memory leak in case auth_cram_md5 fails

This patch fixes a memory leak by running free(response) in case
auth_cram_md5 fails.

Signed-off-by: Aditya Garg <gargaditya08@live.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 days agoimap-send: fix bug causing cfg->folder being set to NULL
Aditya Garg [Fri, 20 Jun 2025 06:40:24 +0000 (12:10 +0530)] 
imap-send: fix bug causing cfg->folder being set to NULL

6d1f198f34 (imap-send: fix leaking memory in `imap_server_conf`, 2024-06-07)
resulted a change in static int git_imap_config which resulted in cfg->folder
being incorrectly set to NULL in case imap.user, imap.pass, imap.tunnel and
imap.authmethod were defined. Because of this, since Git 2.46.0,
git-imap-send is not usable at all. The bug seems to have been unnoticed for
a long time, likely due to better options like git-send-email.

Signed-off-by: Aditya Garg <gargaditya08@live.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 days agoEnable SHA-256 by default in breaking changes mode
brian m. carlson [Fri, 20 Jun 2025 01:19:42 +0000 (01:19 +0000)] 
Enable SHA-256 by default in breaking changes mode

Our document on breaking changes indicates that we intend to default to
SHA-256 in Git 3.0.  Since most people choose the default option, this
is an important security upgrade to our defaults.

To allow people to test this case, when WITH_BREAKING_CHANGES is set in
the configuration, build Git with SHA-256 as the default hash.  Update
the testsuite to reflect this configuration so that the tests pass.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 days agot5300: choose the built-in hash outside of a repo
brian m. carlson [Fri, 20 Jun 2025 01:19:41 +0000 (01:19 +0000)] 
t5300: choose the built-in hash outside of a repo

Right now, the built-in default hash is always SHA-1, but that will
change in a future commit.  Instead of assuming that operating outside
of a repository will always use SHA-1, look up the default hash
algorithm for operating outside of a repository using an appropriate
environment variable, which will always be correct.

Additionally, for operations outside of a repository, use the
DEFAULT_HASH_ALGORITHM prerequisite rather than SHA1.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 days agot4042: choose the built-in hash outside of a repo
brian m. carlson [Fri, 20 Jun 2025 01:19:40 +0000 (01:19 +0000)] 
t4042: choose the built-in hash outside of a repo

Right now, the built-in default hash is always SHA-1, but that will
change in a future commit.  Instead of assuming that operating outside
of a repository will always use SHA-1, provide constants for both
algorithms and then simply ask test_oid for the built-in hash instead,
which will always be correct.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 days agot1007: choose the built-in hash outside of a repo
brian m. carlson [Fri, 20 Jun 2025 01:19:39 +0000 (01:19 +0000)] 
t1007: choose the built-in hash outside of a repo

Right now, the built-in default hash is always SHA-1, but that will
change in a future commit.  Instead of assuming that operating outside
of a repository will always use SHA-1, simply ask test_oid for the
built-in hash instead, which will always be correct.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 days agot: default to compile-time default hash if not set
brian m. carlson [Fri, 20 Jun 2025 01:19:38 +0000 (01:19 +0000)] 
t: default to compile-time default hash if not set

Right now, the default compile-time hash is SHA-1.  However, in the
future, this might change and it would be helpful to gracefully handle
this case in our testsuite.

To avoid making these assumptions, let's introduce a variable that
contains the built-in default hash and use it in our setup code as the
fallback value if no hash was explicitly set.  For now, this is always
SHA-1, but in a future commit, we'll allow adjusting this and the
variable will be more useful.

To allow us to make our tests more robust, allow test_oid to take the
--hash=builtin option to specify this hash, whatever it is.

Additionally, add a DEFAULT_HASH_ALGORITHM prerequisite to check for the
compile-time hash.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 days agosetup: use the default algorithm to initialize repo format
brian m. carlson [Fri, 20 Jun 2025 01:19:37 +0000 (01:19 +0000)] 
setup: use the default algorithm to initialize repo format

When we define a new repository format with REPOSITORY_FORMAT_INIT, we
always use GIT_HASH_SHA1, and this value ends up getting used as the
default value to initialize a repository if none of the command line,
environment, or config tell us to do otherwise.

Because we might not always want to use SHA-1 as the default, let's
instead specify the default hash algorithm constant so that we will use
whatever the specified default is.  However, to make sure we continue to
read repositories without a specified hash algorithm as SHA-1, default
the repository format to the original hash algorithm (SHA-1) when
reading the repository format.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 days agoUse original hash for legacy formats
brian m. carlson [Fri, 20 Jun 2025 01:19:36 +0000 (01:19 +0000)] 
Use original hash for legacy formats

We have a large variety of data formats and protocols where no hash
algorithm was defined and the default was assumed to always be SHA-1.
Instead of explicitly stating SHA-1, let's use the constant to represent
the original hash algorithm (which is still SHA-1) so that it's clear
for documentary purposes that it's a legacy fallback option and not an
intentional choice to use SHA-1.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 days agobuiltin: use default hash when outside a repository
brian m. carlson [Fri, 20 Jun 2025 01:19:35 +0000 (01:19 +0000)] 
builtin: use default hash when outside a repository

We have some commands that can operate inside or outside a repository.
If we're operating outside a repository, we clearly cannot use the
repository's hash algorithm as a default since it doesn't exist, so
instead, let's pick the default instead of specifically SHA-1.  Right
now this results in no functional change since the default is SHA-1, but
that may change in the future.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>