]> git.ipfire.org Git - thirdparty/git.git/log
thirdparty/git.git
12 months agodiff: let external diffs report that changes are uninteresting
René Scharfe [Sun, 9 Jun 2024 07:41:44 +0000 (09:41 +0200)] 
diff: let external diffs report that changes are uninteresting

The options --exit-code and --quiet instruct git diff to indicate
whether it found any significant changes by exiting with code 1 if it
did and 0 if there were none.  Currently this doesn't work if external
diff programs are involved, as we have no way to learn what they found.

Add that ability in the form of the new configuration options
diff.trustExitCode and diff.<driver>.trustExitCode and the environment
variable GIT_EXTERNAL_DIFF_TRUST_EXIT_CODE.  They pair with the config
options diff.external and diff.<driver>.command and the environment
variable GIT_EXTERNAL_DIFF, respectively.

The new options are off by default, keeping the old behavior.  Enabling
them indicates that the external diff returns exit code 1 if it finds
significant changes and 0 if it doesn't, like diff(1).

The name of the new options is taken from the git difftool and mergetool
options of similar purpose.  (There they enable passing on the exit code
of a diff tool and to infer whether a merge done by a merge tool is
successful.)

The new feature sets the diff flag diff_from_contents in
diff_setup_done() if we need the exit code and are allowed to call
external diffs.  This disables the optimization that avoids calling the
program with --quiet.  Add it back by skipping the call if the external
diff is not able to report empty diffs.  We can only do that check after
evaluating the file-specific attributes in run_external_diff().

If we do run the external diff with --quiet, send its output to
/dev/null.

I considered checking the output of the external diff to check whether
its empty.  It was added as 11be65cfa4 (diff: fix --exit-code with
external diff, 2024-05-05) and quickly reverted, as it does not work
with external diffs that do not write to stdout.  There's no reason why
a graphical diff tool would even need to write anything there at all.

I also considered using a non-zero exit code for empty diffs, which
could be done without adding new configuration options.  We'd need to
disable the optimization that allows git diff --quiet to skip calling
external diffs, though -- that might be quite surprising if graphical
diff programs are involved.  And assigning the opposite meaning of the
exit codes compared to diff(1) and git diff --exit-code to the external
diff can cause unnecessary confusion.

Suggested-by: Phillip Wood <phillip.wood123@gmail.com>
Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 months agouserdiff: add and use struct external_diff
René Scharfe [Sun, 9 Jun 2024 07:39:08 +0000 (09:39 +0200)] 
userdiff: add and use struct external_diff

Wrap the string specifying the external diff command in a new struct to
simplify adding attributes, which the next patch will do.

Make sure external_diff() still returns NULL if neither the environment
variable GIT_EXTERNAL_DIFF nor the configuration option diff.external is
set, to continue allowing its use in a boolean context.

Use a designated initializer for the default builtin userdiff driver to
adjust to the type change of the second struct member.  Spelling out
only the non-zero members improves readability as a nice side-effect.

No functional change intended.

Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 months agot4020: test exit code with external diffs
René Scharfe [Sun, 9 Jun 2024 07:38:24 +0000 (09:38 +0200)] 
t4020: test exit code with external diffs

Add tests to check the exit code of git diff with its options --quiet
and --exit-code when using an external diff program.  Currently we
cannot tell whether it found significant changes or not.

While at it, document briefly that --quiet turns off execution of
external diff programs because that behavior surprised me for a moment
while writing the tests.

Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 months agoMerge branch 'tb/midx-write-cleanup'
Junio C Hamano [Fri, 7 Jun 2024 17:57:23 +0000 (10:57 -0700)] 
Merge branch 'tb/midx-write-cleanup'

Code clean-up around writing the .midx files.

* tb/midx-write-cleanup:
  pack-bitmap.c: reimplement `midx_bitmap_filename()` with helper
  midx: replace `get_midx_rev_filename()` with a generic helper
  midx-write.c: support reading an existing MIDX with `packs_to_include`
  midx-write.c: extract `fill_packs_from_midx()`
  midx-write.c: extract `should_include_pack()`
  midx-write.c: pass `start_pack` to `compute_sorted_entries()`
  midx-write.c: reduce argument count for `get_sorted_entries()`
  midx-write.c: tolerate `--preferred-pack` without bitmaps

12 months agoThe eleventh batch
Junio C Hamano [Thu, 6 Jun 2024 19:49:06 +0000 (12:49 -0700)] 
The eleventh batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 months agoMerge branch 'mt/openindiana-scalar'
Junio C Hamano [Thu, 6 Jun 2024 19:49:25 +0000 (12:49 -0700)] 
Merge branch 'mt/openindiana-scalar'

Avoid removing the $(cwd) for portability.

* mt/openindiana-scalar:
  scalar: make enlistment delete to work on all POSIX platforms

12 months agoMerge branch 'rs/difftool-env-simplify'
Junio C Hamano [Thu, 6 Jun 2024 19:49:24 +0000 (12:49 -0700)] 
Merge branch 'rs/difftool-env-simplify'

Code simplification.

* rs/difftool-env-simplify:
  difftool: add env vars directly in run_file_diff()

12 months agoMerge branch 'th/quiet-lazy-fetch-from-promisor'
Junio C Hamano [Thu, 6 Jun 2024 19:49:23 +0000 (12:49 -0700)] 
Merge branch 'th/quiet-lazy-fetch-from-promisor'

The promisor.quiet configuration knob can be set to true to make
lazy fetching from promisor remotes silent.

* th/quiet-lazy-fetch-from-promisor:
  promisor-remote: add promisor.quiet configuration option

12 months agoMerge branch 'ps/leakfixes'
Junio C Hamano [Thu, 6 Jun 2024 19:49:23 +0000 (12:49 -0700)] 
Merge branch 'ps/leakfixes'

Leakfixes.

* ps/leakfixes:
  builtin/mv: fix leaks for submodule gitfile paths
  builtin/mv: refactor to use `struct strvec`
  builtin/mv duplicate string list memory
  builtin/mv: refactor `add_slash()` to always return allocated strings
  strvec: add functions to replace and remove strings
  submodule: fix leaking memory for submodule entries
  commit-reach: fix memory leak in `ahead_behind()`
  builtin/credential: clear credential before exit
  config: plug various memory leaks
  config: clarify memory ownership in `git_config_string()`
  builtin/log: stop using globals for format config
  builtin/log: stop using globals for log config
  convert: refactor code to clarify ownership of check_roundtrip_encoding
  diff: refactor code to clarify memory ownership of prefixes
  config: clarify memory ownership in `git_config_pathname()`
  http: refactor code to clarify memory ownership
  checkout: clarify memory ownership in `unique_tracking_name()`
  strbuf: fix leak when `appendwholeline()` fails with EOF
  transport-helper: fix leaking helper name

12 months agoThe tenth batch
Junio C Hamano [Mon, 3 Jun 2024 20:10:59 +0000 (13:10 -0700)] 
The tenth batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 months agoMerge branch 'th/push-local-ff-check-without-lazy-fetch'
Junio C Hamano [Mon, 3 Jun 2024 20:11:11 +0000 (13:11 -0700)] 
Merge branch 'th/push-local-ff-check-without-lazy-fetch'

When "git push" notices that the commit at the tip of the ref on
the other side it is about to overwrite does not exist locally, it
used to first try fetching it if the local repository is a partial
clone. The command has been taught not to do so and immediately
fail instead.

* th/push-local-ff-check-without-lazy-fetch:
  push: don't fetch commit object when checking existence

12 months agoMerge branch 'ps/fix-reinit-includeif-onbranch'
Junio C Hamano [Mon, 3 Jun 2024 20:11:11 +0000 (13:11 -0700)] 
Merge branch 'ps/fix-reinit-includeif-onbranch'

"git init" in an already created directory, when the user
configuration has includeif.onbranch, started to fail recently,
which has been corrected.

* ps/fix-reinit-includeif-onbranch:
  setup: fix bug with "includeIf.onbranch" when initializing dir

12 months agoSync with 'maint'
Junio C Hamano [Fri, 31 May 2024 22:50:54 +0000 (15:50 -0700)] 
Sync with 'maint'

12 months agoPost 2.45.2 updates
Junio C Hamano [Fri, 31 May 2024 20:51:15 +0000 (13:51 -0700)] 
Post 2.45.2 updates

Merge down a handful of topics to adjust tests and CI to make them
work better, without changing Git itself, and a bit of developer
docs update:

 * Tests that try to corrupt in-repository files in chunked format did
   not work well on macOS due to its broken "mv", which has been
   worked around.

 * Unbreak CI jobs so that we do not attempt to use Python 2 that has
   been removed from the platform.

 * Git 2.43 started using the tree of HEAD as the source of attributes
   in a bare repository, which has severe performance implications.
   For now, revert the change, without ripping out a more explicit
   support for the attr.tree configuration variable.

 * Windows CI running in GitHub Actions started complaining about the
   order of arguments given to calloc(); the imported regex code uses
   the wrong order almost consistently, which has been corrected.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 months agoMerge branch 'jk/ci-macos-gcc13-fix' into maint-2.45
Junio C Hamano [Fri, 31 May 2024 22:28:21 +0000 (15:28 -0700)] 
Merge branch 'jk/ci-macos-gcc13-fix' into maint-2.45

CI fix.

* jk/ci-macos-gcc13-fix:
  ci: stop installing "gcc-13" for osx-gcc
  ci: avoid bare "gcc" for osx-gcc job
  ci: drop mention of BREW_INSTALL_PACKAGES variable

12 months agoMerge branch 'ma/win32-unix-domain-socket' into maint-2.45
Junio C Hamano [Fri, 31 May 2024 22:28:21 +0000 (15:28 -0700)] 
Merge branch 'ma/win32-unix-domain-socket' into maint-2.45

Build fix.

* ma/win32-unix-domain-socket:
  win32: fix building with NO_UNIX_SOCKETS

12 months agoMerge branch 'jt/doc-submitting-rerolled-series' into maint-2.45
Junio C Hamano [Fri, 31 May 2024 22:28:20 +0000 (15:28 -0700)] 
Merge branch 'jt/doc-submitting-rerolled-series' into maint-2.45

Developer doc update.

* jt/doc-submitting-rerolled-series:
  doc: clarify practices for submitting updated patch versions

12 months agoMerge branch 'jc/doc-manpages-l10n' into maint-2.45
Junio C Hamano [Fri, 31 May 2024 22:28:20 +0000 (15:28 -0700)] 
Merge branch 'jc/doc-manpages-l10n' into maint-2.45

The SubmittingPatches document now refers folks to manpages
translation project.

* jc/doc-manpages-l10n:
  SubmittingPatches: advertise git-manpages-l10n project a bit

12 months agoMerge branch 'jc/compat-regex-calloc-fix' into maint-2.45
Junio C Hamano [Fri, 31 May 2024 22:28:19 +0000 (15:28 -0700)] 
Merge branch 'jc/compat-regex-calloc-fix' into maint-2.45

Windows CI running in GitHub Actions started complaining about the
order of arguments given to calloc(); the imported regex code uses
the wrong order almost consistently, which has been corrected.

* jc/compat-regex-calloc-fix:
  compat/regex: fix argument order to calloc(3)

12 months agoMerge branch 'jc/no-default-attr-tree-in-bare' into maint-2.45
Junio C Hamano [Fri, 31 May 2024 22:28:19 +0000 (15:28 -0700)] 
Merge branch 'jc/no-default-attr-tree-in-bare' into maint-2.45

Git 2.43 started using the tree of HEAD as the source of attributes
in a bare repository, which has severe performance implications.
For now, revert the change, without ripping out a more explicit
support for the attr.tree configuration variable.

* jc/no-default-attr-tree-in-bare:
  stop using HEAD for attributes in bare repository by default

12 months agoMerge branch 'ps/ci-python-2-deprecation' into maint-2.45
Junio C Hamano [Fri, 31 May 2024 22:28:18 +0000 (15:28 -0700)] 
Merge branch 'ps/ci-python-2-deprecation' into maint-2.45

Unbreak CI jobs so that we do not attempt to use Python 2 that has
been removed from the platform.

* ps/ci-python-2-deprecation:
  ci: fix Python dependency on Ubuntu 24.04

12 months agoMerge branch 'jc/test-workaround-broken-mv' into maint-2.45
Junio C Hamano [Fri, 31 May 2024 22:28:18 +0000 (15:28 -0700)] 
Merge branch 'jc/test-workaround-broken-mv' into maint-2.45

Tests that try to corrupt in-repository files in chunked format did
not work well on macOS due to its broken "mv", which has been
worked around.

* jc/test-workaround-broken-mv:
  t/lib-chunk: work around broken "mv" on some vintage of macOS

12 months agoMerge branch 'jc/git-gui-maintainer-update' into maint-2.45
Junio C Hamano [Fri, 31 May 2024 22:28:17 +0000 (15:28 -0700)] 
Merge branch 'jc/git-gui-maintainer-update' into maint-2.45

* jc/git-gui-maintainer-update:
  SubmittingPatches: welcome the new maintainer of git-gui part

12 months agoSync with Git 2.45.2
Junio C Hamano [Fri, 31 May 2024 00:25:37 +0000 (17:25 -0700)] 
Sync with Git 2.45.2

12 months agoGit 2.45.2 v2.45.2
Junio C Hamano [Fri, 31 May 2024 00:18:43 +0000 (17:18 -0700)] 
Git 2.45.2

Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 months agoMerge branch 'jc/fix-2.45.1-and-friends-for-maint' into maint-2.45
Junio C Hamano [Fri, 31 May 2024 00:17:21 +0000 (17:17 -0700)] 
Merge branch 'jc/fix-2.45.1-and-friends-for-maint' into maint-2.45

* jc/fix-2.45.1-and-friends-for-maint:
  Revert "fsck: warn about symlink pointing inside a gitdir"
  Revert "Add a helper function to compare file contents"
  clone: drop the protections where hooks aren't run
  tests: verify that `clone -c core.hooksPath=/dev/null` works again
  Revert "core.hooksPath: add some protection while cloning"
  init: use the correct path of the templates directory again
  hook: plug a new memory leak
  ci: stop installing "gcc-13" for osx-gcc
  ci: avoid bare "gcc" for osx-gcc job
  ci: drop mention of BREW_INSTALL_PACKAGES variable
  send-email: avoid creating more than one Term::ReadLine object
  send-email: drop FakeTerm hack

12 months agoGit 2.44.2 v2.44.2
Junio C Hamano [Fri, 31 May 2024 00:13:43 +0000 (17:13 -0700)] 
Git 2.44.2

Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 months agoMerge branch 'fixes/2.45.1/2.44' into maint-2.44
Junio C Hamano [Fri, 31 May 2024 00:11:02 +0000 (17:11 -0700)] 
Merge branch 'fixes/2.45.1/2.44' into maint-2.44

* fixes/2.45.1/2.44:
  Revert "fsck: warn about symlink pointing inside a gitdir"
  Revert "Add a helper function to compare file contents"
  clone: drop the protections where hooks aren't run
  tests: verify that `clone -c core.hooksPath=/dev/null` works again
  Revert "core.hooksPath: add some protection while cloning"
  init: use the correct path of the templates directory again
  hook: plug a new memory leak
  ci: stop installing "gcc-13" for osx-gcc
  ci: avoid bare "gcc" for osx-gcc job
  ci: drop mention of BREW_INSTALL_PACKAGES variable
  send-email: avoid creating more than one Term::ReadLine object
  send-email: drop FakeTerm hack

12 months agoGit 2.43.5 v2.43.5
Junio C Hamano [Fri, 31 May 2024 00:06:24 +0000 (17:06 -0700)] 
Git 2.43.5

Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 months agoMerge branch 'fixes/2.45.1/2.43' into maint-2.43
Junio C Hamano [Fri, 31 May 2024 00:04:37 +0000 (17:04 -0700)] 
Merge branch 'fixes/2.45.1/2.43' into maint-2.43

* fixes/2.45.1/2.43:
  Revert "fsck: warn about symlink pointing inside a gitdir"
  Revert "Add a helper function to compare file contents"
  clone: drop the protections where hooks aren't run
  tests: verify that `clone -c core.hooksPath=/dev/null` works again
  Revert "core.hooksPath: add some protection while cloning"
  init: use the correct path of the templates directory again
  hook: plug a new memory leak
  ci: stop installing "gcc-13" for osx-gcc
  ci: avoid bare "gcc" for osx-gcc job
  ci: drop mention of BREW_INSTALL_PACKAGES variable
  send-email: avoid creating more than one Term::ReadLine object
  send-email: drop FakeTerm hack

12 months agoGit 2.42.3 v2.42.3
Junio C Hamano [Fri, 31 May 2024 00:03:31 +0000 (17:03 -0700)] 
Git 2.42.3

Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 months agoMerge branch 'fixes/2.45.1/2.42' into maint-2.42
Junio C Hamano [Fri, 31 May 2024 00:00:57 +0000 (17:00 -0700)] 
Merge branch 'fixes/2.45.1/2.42' into maint-2.42

* fixes/2.45.1/2.42:
  Revert "fsck: warn about symlink pointing inside a gitdir"
  Revert "Add a helper function to compare file contents"
  clone: drop the protections where hooks aren't run
  tests: verify that `clone -c core.hooksPath=/dev/null` works again
  Revert "core.hooksPath: add some protection while cloning"
  init: use the correct path of the templates directory again
  hook: plug a new memory leak
  ci: stop installing "gcc-13" for osx-gcc
  ci: avoid bare "gcc" for osx-gcc job
  ci: drop mention of BREW_INSTALL_PACKAGES variable
  send-email: avoid creating more than one Term::ReadLine object
  send-email: drop FakeTerm hack

12 months agoGit 2.41.2 v2.41.2
Junio C Hamano [Fri, 31 May 2024 00:00:29 +0000 (17:00 -0700)] 
Git 2.41.2

Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 months agoMerge branch 'fixes/2.45.1/2.41' into maint-2.41
Junio C Hamano [Thu, 30 May 2024 23:58:12 +0000 (16:58 -0700)] 
Merge branch 'fixes/2.45.1/2.41' into maint-2.41

* fixes/2.45.1/2.41:
  Revert "fsck: warn about symlink pointing inside a gitdir"
  Revert "Add a helper function to compare file contents"
  clone: drop the protections where hooks aren't run
  tests: verify that `clone -c core.hooksPath=/dev/null` works again
  Revert "core.hooksPath: add some protection while cloning"
  init: use the correct path of the templates directory again
  hook: plug a new memory leak
  ci: stop installing "gcc-13" for osx-gcc
  ci: avoid bare "gcc" for osx-gcc job
  ci: drop mention of BREW_INSTALL_PACKAGES variable
  send-email: avoid creating more than one Term::ReadLine object
  send-email: drop FakeTerm hack

12 months agoGit 2.40.3 v2.40.3
Junio C Hamano [Thu, 30 May 2024 23:57:31 +0000 (16:57 -0700)] 
Git 2.40.3

Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 months agoMerge branch 'fixes/2.45.1/2.40' into maint-2.40
Junio C Hamano [Thu, 30 May 2024 23:54:42 +0000 (16:54 -0700)] 
Merge branch 'fixes/2.45.1/2.40' into maint-2.40

* fixes/2.45.1/2.40:
  Revert "fsck: warn about symlink pointing inside a gitdir"
  Revert "Add a helper function to compare file contents"
  clone: drop the protections where hooks aren't run
  tests: verify that `clone -c core.hooksPath=/dev/null` works again
  Revert "core.hooksPath: add some protection while cloning"
  init: use the correct path of the templates directory again
  hook: plug a new memory leak
  ci: stop installing "gcc-13" for osx-gcc
  ci: avoid bare "gcc" for osx-gcc job
  ci: drop mention of BREW_INSTALL_PACKAGES variable
  send-email: avoid creating more than one Term::ReadLine object
  send-email: drop FakeTerm hack

12 months agoGit 2.39.5 v2.39.5
Junio C Hamano [Thu, 30 May 2024 23:52:52 +0000 (16:52 -0700)] 
Git 2.39.5

12 months agoMerge branch 'jc/fix-2.45.1-and-friends-for-2.39' into maint-2.39
Junio C Hamano [Thu, 30 May 2024 23:38:58 +0000 (16:38 -0700)] 
Merge branch 'jc/fix-2.45.1-and-friends-for-2.39' into maint-2.39

* jc/fix-2.45.1-and-friends-for-2.39:
  Revert "fsck: warn about symlink pointing inside a gitdir"
  Revert "Add a helper function to compare file contents"
  clone: drop the protections where hooks aren't run
  tests: verify that `clone -c core.hooksPath=/dev/null` works again
  Revert "core.hooksPath: add some protection while cloning"
  init: use the correct path of the templates directory again
  hook: plug a new memory leak
  ci: stop installing "gcc-13" for osx-gcc
  ci: avoid bare "gcc" for osx-gcc job
  ci: drop mention of BREW_INSTALL_PACKAGES variable
  send-email: avoid creating more than one Term::ReadLine object
  send-email: drop FakeTerm hack

12 months agoThe ninth batch
Junio C Hamano [Thu, 30 May 2024 21:14:56 +0000 (14:14 -0700)] 
The ninth batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 months agoMerge branch 'jc/fix-2.45.1-and-friends-for-maint'
Junio C Hamano [Thu, 30 May 2024 21:15:16 +0000 (14:15 -0700)] 
Merge branch 'jc/fix-2.45.1-and-friends-for-maint'

Adjust jc/fix-2.45.1-and-friends-for-2.39 for more recent
maintenance track.

* jc/fix-2.45.1-and-friends-for-maint:
  Revert "fsck: warn about symlink pointing inside a gitdir"
  Revert "Add a helper function to compare file contents"
  clone: drop the protections where hooks aren't run
  tests: verify that `clone -c core.hooksPath=/dev/null` works again
  Revert "core.hooksPath: add some protection while cloning"
  init: use the correct path of the templates directory again
  hook: plug a new memory leak
  ci: stop installing "gcc-13" for osx-gcc
  ci: avoid bare "gcc" for osx-gcc job
  ci: drop mention of BREW_INSTALL_PACKAGES variable
  send-email: avoid creating more than one Term::ReadLine object
  send-email: drop FakeTerm hack

12 months agoMerge branch 'jc/add-patch-enforce-single-letter-input'
Junio C Hamano [Thu, 30 May 2024 21:15:16 +0000 (14:15 -0700)] 
Merge branch 'jc/add-patch-enforce-single-letter-input'

"git add -p" learned to complain when an answer with more than one
letter is given to a prompt that expects a single letter answer.

* jc/add-patch-enforce-single-letter-input:
  add-patch: enforce only one-letter response to prompts

12 months agoMerge branch 'gt/unit-test-strcmp-offset'
Junio C Hamano [Thu, 30 May 2024 21:15:15 +0000 (14:15 -0700)] 
Merge branch 'gt/unit-test-strcmp-offset'

The strcmp-offset tests have been rewritten using the unit test
framework.

* gt/unit-test-strcmp-offset:
  t/: port helper/test-strcmp-offset.c to unit-tests/t-strcmp-offset.c

12 months agoMerge branch 'es/chainlint-ncores-fix'
Junio C Hamano [Thu, 30 May 2024 21:15:15 +0000 (14:15 -0700)] 
Merge branch 'es/chainlint-ncores-fix'

The chainlint script (invoked during "make test") did nothing when
it failed to detect the number of available CPUs.  It now falls
back to 1 CPU to avoid the problem.

* es/chainlint-ncores-fix:
  chainlint.pl: latch CPU count directly reported by /proc/cpuinfo
  chainlint.pl: fix incorrect CPU count on Linux SPARC
  chainlint.pl: make CPU count computation more robust

12 months agoMerge branch 'js/doc-decisions'
Junio C Hamano [Thu, 30 May 2024 21:15:14 +0000 (14:15 -0700)] 
Merge branch 'js/doc-decisions'

The project decision making policy has been documented.

* js/doc-decisions:
  doc: describe the project's decision-making process

12 months agoMerge branch 'jc/undecided-is-not-necessarily-sha1-fix'
Junio C Hamano [Thu, 30 May 2024 21:15:13 +0000 (14:15 -0700)] 
Merge branch 'jc/undecided-is-not-necessarily-sha1-fix'

The base topic started to make it an error for a command to leave
the hash algorithm unspecified, which revealed a few commands that
were not ready for the change.  Give users a knob to revert back to
the "default is sha-1" behaviour as an escape hatch, and start
fixing these breakages.

* jc/undecided-is-not-necessarily-sha1-fix:
  apply: fix uninitialized hash function
  builtin/hash-object: fix uninitialized hash function
  builtin/patch-id: fix uninitialized hash function
  t1517: test commands that are designed to be run outside repository
  setup: add an escape hatch for "no more default hash algorithm" change

12 months agoMerge branch 'ps/refs-without-the-repository-updates'
Junio C Hamano [Thu, 30 May 2024 21:15:12 +0000 (14:15 -0700)] 
Merge branch 'ps/refs-without-the-repository-updates'

Further clean-up the refs subsystem to stop relying on
the_repository, and instead use the repository associated to the
ref_store object.

* ps/refs-without-the-repository-updates:
  refs/packed: remove references to `the_hash_algo`
  refs/files: remove references to `the_hash_algo`
  refs/files: use correct repository
  refs: remove `dwim_log()`
  refs: drop `git_default_branch_name()`
  refs: pass repo when peeling objects
  refs: move object peeling into "object.c"
  refs: pass ref store when detecting dangling symrefs
  refs: convert iteration over replace refs to accept ref store
  refs: retrieve worktree ref stores via associated repository
  refs: refactor `resolve_gitlink_ref()` to accept a repository
  refs: pass repo when retrieving submodule ref store
  refs: track ref stores via strmap
  refs: implement releasing ref storages
  refs: rename `init_db` callback to avoid confusion
  refs: adjust names for `init` and `init_db` callbacks

12 months agoMerge branch 'ps/reftable-reusable-iterator'
Junio C Hamano [Thu, 30 May 2024 21:15:12 +0000 (14:15 -0700)] 
Merge branch 'ps/reftable-reusable-iterator'

Code clean-up to make the reftable iterator closer to be reusable.

* ps/reftable-reusable-iterator:
  reftable/merged: adapt interface to allow reuse of iterators
  reftable/stack: provide convenience functions to create iterators
  reftable/reader: adapt interface to allow reuse of iterators
  reftable/generic: adapt interface to allow reuse of iterators
  reftable/generic: move seeking of records into the iterator
  reftable/merged: simplify indices for subiterators
  reftable/merged: split up initialization and seeking of records
  reftable/reader: set up the reader when initializing table iterator
  reftable/reader: inline `reader_seek_internal()`
  reftable/reader: separate concerns of table iter and reftable reader
  reftable/reader: unify indexed and linear seeking
  reftable/reader: avoid copying index iterator
  reftable/block: use `size_t` to track restart point index

12 months agoMerge branch 'ps/reftable-write-options'
Junio C Hamano [Thu, 30 May 2024 21:15:11 +0000 (14:15 -0700)] 
Merge branch 'ps/reftable-write-options'

The knobs to tweak how reftable files are written have been made
available as configuration variables.

* ps/reftable-write-options:
  refs/reftable: allow configuring geometric factor
  reftable: make the compaction factor configurable
  refs/reftable: allow disabling writing the object index
  refs/reftable: allow configuring restart interval
  reftable: use `uint16_t` to track restart interval
  refs/reftable: allow configuring block size
  reftable/dump: support dumping a table's block structure
  reftable/writer: improve error when passed an invalid block size
  reftable/writer: drop static variable used to initialize strbuf
  reftable: pass opts as constant pointer
  reftable: consistently refer to `reftable_write_options` as `opts`

12 months agoMerge branch 'ps/undecided-is-not-necessarily-sha1'
Junio C Hamano [Thu, 30 May 2024 21:15:10 +0000 (14:15 -0700)] 
Merge branch 'ps/undecided-is-not-necessarily-sha1'

Before discovering the repository details, We used to assume SHA-1
as the "default" hash function, which has been corrected. Hopefully
this will smoke out codepaths that rely on such an unwarranted
assumptions.

* ps/undecided-is-not-necessarily-sha1:
  repository: stop setting SHA1 as the default object hash
  oss-fuzz/commit-graph: set up hash algorithm
  builtin/shortlog: don't set up revisions without repo
  builtin/diff: explicitly set hash algo when there is no repo
  builtin/bundle: abort "verify" early when there is no repository
  builtin/blame: don't access potentially unitialized `the_hash_algo`
  builtin/rev-parse: allow shortening to more than 40 hex characters
  remote-curl: fix parsing of detached SHA256 heads
  attr: fix BUG() when parsing attrs outside of repo
  attr: don't recompute default attribute source
  parse-options-cb: only abbreviate hashes when hash algo is known
  path: move `validate_headref()` to its only user
  path: harden validation of HEAD with non-standard hashes

12 months agopack-bitmap.c: reimplement `midx_bitmap_filename()` with helper
Taylor Blau [Wed, 29 May 2024 22:55:45 +0000 (18:55 -0400)] 
pack-bitmap.c: reimplement `midx_bitmap_filename()` with helper

Now that we have the `get_midx_filename_ext()` helper, we can
reimplement the `midx_bitmap_filename()` function in terms of it.

Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 months agomidx: replace `get_midx_rev_filename()` with a generic helper
Taylor Blau [Wed, 29 May 2024 22:55:42 +0000 (18:55 -0400)] 
midx: replace `get_midx_rev_filename()` with a generic helper

Commit f894081deae (pack-revindex: read multi-pack reverse indexes,
2021-03-30) introduced the `get_midx_rev_filename()` helper (later
modified by commit 60980aed786 (midx.c: write MIDX filenames to
strbuf, 2021-10-26)).

This function returns the location of the classic ".rev" files we used
to write for MIDXs (prior to 95e8383bac1 (midx.c: make changing the
preferred pack safe, 2022-01-25)), which is always of the form:

    $GIT_DIR/objects/pack/multi-pack-index-$HASH.rev

Replace this function with a generic helper that populates a strbuf with
the above form, replacing the ".rev" extension with a caller-provided
argument.

This will allow us to remove a similarly-defined function in the
pack-bitmap code (used to determine the location of a MIDX .bitmap file)
by reimplementing it in terms of `get_midx_filename_ext()`.

Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 months agomidx-write.c: support reading an existing MIDX with `packs_to_include`
Taylor Blau [Wed, 29 May 2024 22:55:39 +0000 (18:55 -0400)] 
midx-write.c: support reading an existing MIDX with `packs_to_include`

Avoid unconditionally copying all packs from an existing MIDX into a new
MIDX by checking that packs added via `fill_packs_from_midx()` don't
appear in the `to_include` set, if one was provided.

Do so by calling `should_include_pack()` from both `add_pack_to_midx()`
and `fill_packs_from_midx()`.

In order to make this work, teach `should_include_pack()` a new
"exclude_from_midx" parameter, which allows skipping the first check.
This is done so that the caller in `fill_packs_from_midx()` doesn't
reject all of the packs it provided since they appear in an existing
MIDX by definition.

The sum total of this change is that we are now able to read and
reference objects in an existing MIDX even when given a non-NULL
`packs_to_include`. This is a prerequisite step for incremental MIDXs,
which need to load any existing MIDX (if one is present) in order to
determine whether or not an object already appears in an earlier portion
of the MIDX to avoid duplicating it across multiple portions.

Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 months agomidx-write.c: extract `fill_packs_from_midx()`
Taylor Blau [Wed, 29 May 2024 22:55:36 +0000 (18:55 -0400)] 
midx-write.c: extract `fill_packs_from_midx()`

When write_midx_internal() loads an existing MIDX, all packs are copied
forward into the new MIDX. Improve the readability of
write_midx_internal() by extracting this functionality out into a
separate function.

Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 months agomidx-write.c: extract `should_include_pack()`
Taylor Blau [Wed, 29 May 2024 22:55:32 +0000 (18:55 -0400)] 
midx-write.c: extract `should_include_pack()`

The add_pack_to_midx() callback used via for_each_file_in_pack_dir() is
used to add packs with .idx files to the MIDX being written.

Within this function, we have a pair of checks that discards packs
which:

  - appear in an existing MIDX, if we successfully read an existing MIDX
    from disk

  - or, appear in the "to_include" list, if invoking the MIDX write
    machinery with the `--stdin-packs` command-line argument.

A future commit will want to call a slight variant of these checks from
the code that reuses all packs from an existing MIDX, as well as the
current location via add_pack_to_midx(). The latter will be modified in
subsequent commits to only reuse packs which appear in the to_include
list, if one was given.

Prepare for that step by extracting these checks as a subroutine that
may be called from both places.

Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 months agomidx-write.c: pass `start_pack` to `compute_sorted_entries()`
Taylor Blau [Wed, 29 May 2024 22:55:28 +0000 (18:55 -0400)] 
midx-write.c: pass `start_pack` to `compute_sorted_entries()`

The function `compute_sorted_entries()` is broadly responsible for
building an array of the objects to be written into a MIDX based on the
provided list of packs.

If we have loaded an existing MIDX, however, we may not use all of its
packs, despite loading them into the ctx->info array.

The existing implementation simply skips past the first
ctx->m->num_packs (if ctx->m is non-NULL, indicating that we loaded an
existing MIDX). This is because we read objects in packs from an
existing MIDX via the MIDX itself, rather than from the pack-level
fanout to guarantee a de-duplicated result (see: a40498a1265 (midx: use
existing midx when writing new one, 2018-07-12)).

Future changes (outside the scope of this patch series) to the MIDX code
will require us to skip *at most* that number[^1].

We could tag each pack with a bit that indicates the pack's contents
should be included in the MIDX. But we can just as easily determine the
number of packs to skip by passing in the number of packs we learned
about after processing an existing MIDX.

[^1]: Kind of. The real number will be bounded by the number of packs in
  a MIDX layer, and the number of packs in its base layer(s), but that
  concept hasn't been fully defined yet.

Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 months agomidx-write.c: reduce argument count for `get_sorted_entries()`
Taylor Blau [Wed, 29 May 2024 22:55:23 +0000 (18:55 -0400)] 
midx-write.c: reduce argument count for `get_sorted_entries()`

The function `midx-write.c::get_sorted_entries()` is responsible for
constructing the array of OIDs from a given list of packs which will
comprise the MIDX being written.

The singular call-site for this function looks something like:

    ctx.entries = get_sorted_entries(ctx.m, ctx.info, ctx.nr,
                                     &ctx.entries_nr,
                                     ctx.preferred_pack_idx);

This function has five formal arguments, all of which are members of the
shared `struct write_midx_context` used to track various pieces of
information about the MIDX being written.

The function `get_sorted_entries()` dates back to fe1ed56f5e4 (midx:
sort and deduplicate objects from packfiles, 2018-07-12), which came
shortly after 396f257018a (multi-pack-index: read packfile list,
2018-07-12). The latter patch introduced the `pack_list` structure,
which was a precursor to the structure we now know as
`write_midx_context` (c.f. 577dc49696a (midx: rename pack_info to
write_midx_context, 2021-02-18)).

At the time, `get_sorted_entries()` likely could have used the pack_list
structure introduced earlier in 396f257018a, but understandably did not
since the structure only contained three fields (only two of which were
relevant to `get_sorted_entries()`) at the time.

Simplify the declaration of this function by taking a single pointer to
the whole `struct write_midx_context` instead of various members within
it. Since this function is now computing the entire result (populating
both `ctx->entries`, and `ctx->entries_nr`), rename it to something that
doesn't start with "get_" to make clear that this function has a
side-effect.

Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 months agomidx-write.c: tolerate `--preferred-pack` without bitmaps
Taylor Blau [Wed, 29 May 2024 22:55:19 +0000 (18:55 -0400)] 
midx-write.c: tolerate `--preferred-pack` without bitmaps

When passing a preferred pack to the MIDX write machinery, we ensure
that the given preferred pack is non-empty since 5d3cd09a808 (midx:
reject empty `--preferred-pack`'s, 2021-08-31).

However packs are only loaded (via `write_midx_internal()`, though a
subsequent patch will refactor this code out to its own function) when
the `MIDX_WRITE_REV_INDEX` flag is set.

So if a caller runs:

    $ git multi-pack-index write --preferred-pack=...

with both (a) an existing MIDX, and (b) specifies a pack from that MIDX
as the preferred one, without passing `--bitmap`, then the check added
in 5d3cd09a808 will result in a segfault.

Note that packs loaded from disk which don't appear in an existing MIDX
do not trigger this issue, as those packs are loaded unconditionally. We
conditionally load packs from a MIDX since we tolerate MIDXs whose
packs do not resolve (i.e., via the MIDX write after removing
unreferenced packs via 'git multi-pack-index expire').

In practice, this isn't possible to trigger when running `git
multi-pack-index write` from `git repack`, as the latter always passes
`--stdin-packs`, which prevents us from loading an existing MIDX, as it
forces all packs to be read from disk.

But a future commit in this series will change that behavior to
unconditionally load an existing MIDX, even with `--stdin-packs`, making
this behavior trigger-able from 'repack' much more easily.

Prevent this from being an issue by removing the segfault altogether by
calling `prepare_midx_pack()` on packs loaded from an existing MIDX when
either the `MIDX_WRITE_REV_INDEX` flag is set *or* we specified a
`--preferred-pack`.

Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 months agoThe eighth batch
Junio C Hamano [Tue, 28 May 2024 18:01:03 +0000 (11:01 -0700)] 
The eighth batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 months agoMerge branch 'ps/leakfixes-base'
Junio C Hamano [Tue, 28 May 2024 18:17:11 +0000 (11:17 -0700)] 
Merge branch 'ps/leakfixes-base'

* ps/leakfixes-base:
  t: mark a bunch of tests as leak-free
  ci: add missing dependency for TTY prereq

12 months agoMerge branch 'kn/osxkeychain-skip-idempotent-store'
Junio C Hamano [Tue, 28 May 2024 18:17:11 +0000 (11:17 -0700)] 
Merge branch 'kn/osxkeychain-skip-idempotent-store'

The credential helper that talks with osx keychain learned to avoid
storing back the authentication material it just got received from
the keychain.

* kn/osxkeychain-skip-idempotent-store:
  osxkeychain: state to skip unnecessary store operations
  osxkeychain: exclusive lock to serialize execution of operations

12 months agoMerge branch 'jc/format-patch-more-aggressive-range-diff'
Junio C Hamano [Tue, 28 May 2024 18:17:10 +0000 (11:17 -0700)] 
Merge branch 'jc/format-patch-more-aggressive-range-diff'

The default "creation-factor" used by "git format-patch" has been
raised to make it more aggressively find matching commits.

* jc/format-patch-more-aggressive-range-diff:
  format-patch: run range-diff with larger creation-factor

12 months agoMerge branch 'jc/rev-parse-fatal-doc'
Junio C Hamano [Tue, 28 May 2024 18:17:10 +0000 (11:17 -0700)] 
Merge branch 'jc/rev-parse-fatal-doc'

Doc update.

* jc/rev-parse-fatal-doc:
  rev-parse: document how --is-* options work outside a repository

12 months agoMerge branch 'jc/t0017-clarify-bogus-expectation'
Junio C Hamano [Tue, 28 May 2024 18:17:09 +0000 (11:17 -0700)] 
Merge branch 'jc/t0017-clarify-bogus-expectation'

Test clean-up.

* jc/t0017-clarify-bogus-expectation:
  t0017: clarify dubious test set-up

12 months agoMerge branch 'ds/send-email-per-message-block'
Junio C Hamano [Tue, 28 May 2024 18:17:09 +0000 (11:17 -0700)] 
Merge branch 'ds/send-email-per-message-block'

Preliminary code clean-up for "git send-email".

* ds/send-email-per-message-block:
  send-email: move newline characters out of a few translatable strings

12 months agoMerge branch 'ps/complete-config-w-subcommands'
Junio C Hamano [Tue, 28 May 2024 18:17:08 +0000 (11:17 -0700)] 
Merge branch 'ps/complete-config-w-subcommands'

The command line completion script (in contrib/) has been adjusted
to the recent update to "git config" that adopted subcommand based
UI.

* ps/complete-config-w-subcommands:
  completion: adapt git-config(1) to complete subcommands

12 months agoMerge branch 'jc/doc-diff-name-only'
Junio C Hamano [Tue, 28 May 2024 18:17:08 +0000 (11:17 -0700)] 
Merge branch 'jc/doc-diff-name-only'

The documentation for "git diff --name-only" has been clarified
that it is about showing the names in the post-image tree.

* jc/doc-diff-name-only:
  diff: document what --name-only shows

12 months agoMerge branch 'tb/pack-bitmap-write-cleanups'
Junio C Hamano [Tue, 28 May 2024 18:17:07 +0000 (11:17 -0700)] 
Merge branch 'tb/pack-bitmap-write-cleanups'

The pack bitmap code saw some clean-up to prepare for a follow-up topic.

* tb/pack-bitmap-write-cleanups:
  pack-bitmap: introduce `bitmap_writer_free()`
  pack-bitmap-write.c: avoid uninitialized 'write_as' field
  pack-bitmap: drop unused `max_bitmaps` parameter
  pack-bitmap: avoid use of static `bitmap_writer`
  pack-bitmap-write.c: move commit_positions into commit_pos fields
  object.h: add flags allocated by pack-bitmap.h

12 months agoMerge branch 'ps/builtin-config-cleanup'
Junio C Hamano [Tue, 28 May 2024 18:17:07 +0000 (11:17 -0700)] 
Merge branch 'ps/builtin-config-cleanup'

Code clean-up to reduce inter-function communication inside
builtin/config.c done via the use of global variables.

* ps/builtin-config-cleanup: (21 commits)
  builtin/config: pass data between callbacks via local variables
  builtin/config: convert flags to a local variable
  builtin/config: track "fixed value" option via flags only
  builtin/config: convert `key` to a local variable
  builtin/config: convert `key_regexp` to a local variable
  builtin/config: convert `regexp` to a local variable
  builtin/config: convert `value_pattern` to a local variable
  builtin/config: convert `do_not_match` to a local variable
  builtin/config: move `respect_includes_opt` into location options
  builtin/config: move default value into display options
  builtin/config: move type options into display options
  builtin/config: move display options into local variables
  builtin/config: move location options into local variables
  builtin/config: refactor functions to have common exit paths
  config: make the config source const
  builtin/config: check for writeability after source is set up
  builtin/config: move actions into `cmd_config_actions()`
  builtin/config: move legacy options into `cmd_config()`
  builtin/config: move subcommand options into `cmd_config()`
  builtin/config: move legacy mode into its own function
  ...

12 months agoMerge branch 'ps/pseudo-ref-terminology'
Junio C Hamano [Tue, 28 May 2024 18:17:06 +0000 (11:17 -0700)] 
Merge branch 'ps/pseudo-ref-terminology'

Terminology to call various ref-like things are getting
straightened out.

* ps/pseudo-ref-terminology:
  refs: refuse to write pseudorefs
  ref-filter: properly distinuish pseudo and root refs
  refs: pseudorefs are no refs
  refs: classify HEAD as a root ref
  refs: do not check ref existence in `is_root_ref()`
  refs: rename `is_special_ref()` to `is_pseudo_ref()`
  refs: rename `is_pseudoref()` to `is_root_ref()`
  Documentation/glossary: define root refs as refs
  Documentation/glossary: clarify limitations of pseudorefs
  Documentation/glossary: redefine pseudorefs as special refs

12 months agoMerge branch 'kn/patch-iteration-doc'
Junio C Hamano [Tue, 28 May 2024 18:17:06 +0000 (11:17 -0700)] 
Merge branch 'kn/patch-iteration-doc'

Doc updates.

* kn/patch-iteration-doc:
  SubmittingPatches: add section for iterating patches

12 months agoMerge branch 'mt/t0211-typofix'
Junio C Hamano [Tue, 28 May 2024 18:17:05 +0000 (11:17 -0700)] 
Merge branch 'mt/t0211-typofix'

Test fix.

* mt/t0211-typofix:
  t/t0211-trace2-perf.sh: fix typo patern -> pattern

12 months agoMerge branch 'jc/doc-manpages-l10n'
Junio C Hamano [Tue, 28 May 2024 18:17:05 +0000 (11:17 -0700)] 
Merge branch 'jc/doc-manpages-l10n'

The SubmittingPatches document now refers folks to manpages
translation project.

* jc/doc-manpages-l10n:
  SubmittingPatches: advertise git-manpages-l10n project a bit

12 months agobuiltin/mv: fix leaks for submodule gitfile paths
Patrick Steinhardt [Mon, 27 May 2024 11:47:23 +0000 (13:47 +0200)] 
builtin/mv: fix leaks for submodule gitfile paths

Similar to the preceding commit, we have effectively given tracking
memory ownership of submodule gitfile paths. Refactor the code to start
tracking allocated strings in a separate `struct strvec` such that we
can easily plug those leaks. Mark now-passing tests as leak free.

Note that ideally, we wouldn't require two separate data structures to
track those paths. But we do need to store `NULL` pointers for the
gitfile paths such that we can indicate that its corresponding entries
in the other arrays do not have such a path at all. And given that
`struct strvec`s cannot store `NULL` pointers we cannot use them to
store this information.

There is another small gotcha that is easy to miss: you may be wondering
why we don't want to store `SUBMODULE_WITH_GITDIR` in the strvec. This
is because this is a mere sentinel value and not actually a string at
all.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 months agobuiltin/mv: refactor to use `struct strvec`
Patrick Steinhardt [Mon, 27 May 2024 11:47:18 +0000 (13:47 +0200)] 
builtin/mv: refactor to use `struct strvec`

Memory allocation patterns in git-mv(1) are extremely hard to follow:
We copy around string pointers into manually-managed arrays, some of
which alias each other, but only sometimes, while we also drop some of
those strings at other times without ever daring to free them.

While this may be my own subjective feeling, it seems like others have
given up as the code has multiple calls to `UNLEAK()`. These are not
sufficient though, and git-mv(1) is still leaking all over the place
even with them.

Refactor the code to instead track strings in `struct strvec`. While
this has the effect of effectively duplicating some of the strings
without an actual need, it is way easier to reason about and fixes all
of the aliasing of memory that has been going on. It allows us to get
rid of the `UNLEAK()` calls and also fixes leaks that those calls did
not paper over.

Mark tests which are now leak-free accordingly.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 months agobuiltin/mv duplicate string list memory
Patrick Steinhardt [Mon, 27 May 2024 11:47:13 +0000 (13:47 +0200)] 
builtin/mv duplicate string list memory

makes the next patch easier, where we will migrate to the paths being
owned by a strvec. given that we are talking about command line
parameters here it's also not like we have tons of allocations that this
would save

while at it, fix a memory leak

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 months agobuiltin/mv: refactor `add_slash()` to always return allocated strings
Patrick Steinhardt [Mon, 27 May 2024 11:47:09 +0000 (13:47 +0200)] 
builtin/mv: refactor `add_slash()` to always return allocated strings

The `add_slash()` function will only conditionally return an allocated
string when the passed-in string did not yet have a trailing slash. This
makes the memory ownership harder to track than really necessary.

It's dubious whether this optimization really buys us all that much. The
number of times we execute this function is bounded by the number of
arguments to git-mv(1), so in the typical case we may end up saving an
allocation or two.

Simplify the code to unconditionally return allocated strings.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 months agostrvec: add functions to replace and remove strings
Patrick Steinhardt [Mon, 27 May 2024 11:47:04 +0000 (13:47 +0200)] 
strvec: add functions to replace and remove strings

Add two functions that allow to replace and remove strings contained in
the strvec. This will be used by a subsequent commit that refactors
git-mv(1).

While at it, add a bunch of unit tests that cover both old and new
functionality.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 months agosubmodule: fix leaking memory for submodule entries
Patrick Steinhardt [Mon, 27 May 2024 11:46:59 +0000 (13:46 +0200)] 
submodule: fix leaking memory for submodule entries

In `free_one_config()` we never end up freeing the `url` and `ignore`
fields and thus leak memory. Fix those leaks and mark now-passing tests
as leak free.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 months agocommit-reach: fix memory leak in `ahead_behind()`
Patrick Steinhardt [Mon, 27 May 2024 11:46:54 +0000 (13:46 +0200)] 
commit-reach: fix memory leak in `ahead_behind()`

We use a priority queue in `ahead_behind()` to compute the ahead/behind
count for commits. We may not iterate through all commits part of that
queue though in case all of its entries are stale. Consequently, as we
never make the effort to release the remaining commits, we end up
leaking bit arrays that we have allocated for each of the contained
commits.

Plug this leak and mark the corresponding test as leak free.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 months agobuiltin/credential: clear credential before exit
Patrick Steinhardt [Mon, 27 May 2024 11:46:49 +0000 (13:46 +0200)] 
builtin/credential: clear credential before exit

We never release memory associated with `struct credential`. Fix this
and mark the corresponding test as leak free.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 months agoconfig: plug various memory leaks
Patrick Steinhardt [Mon, 27 May 2024 11:46:44 +0000 (13:46 +0200)] 
config: plug various memory leaks

Now that memory ownership rules around `git_config_string()` and
`git_config_pathname()` are clearer, it also got easier to spot that
the returned memory needs to be free'd. Plug a subset of those cases and
mark now-passing tests as leak free.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 months agoconfig: clarify memory ownership in `git_config_string()`
Patrick Steinhardt [Mon, 27 May 2024 11:46:39 +0000 (13:46 +0200)] 
config: clarify memory ownership in `git_config_string()`

The out parameter of `git_config_string()` is a `const char **` even
though we transfer ownership of memory to the caller. This is quite
misleading and has led to many memory leaks all over the place. Adapt
the parameter to instead be `char **`.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 months agobuiltin/log: stop using globals for format config
Patrick Steinhardt [Mon, 27 May 2024 11:46:34 +0000 (13:46 +0200)] 
builtin/log: stop using globals for format config

This commit does the exact same as the preceding commit, only for the
format configuration instead of the log configuration.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 months agobuiltin/log: stop using globals for log config
Patrick Steinhardt [Mon, 27 May 2024 11:46:30 +0000 (13:46 +0200)] 
builtin/log: stop using globals for log config

We're using global variables to store the log configuration. Many of
these can be set both via the command line and via the config, and
depending on how they are being set, they may contain allocated strings.
This leads to hard-to-track memory ownership and memory leaks.

Refactor the code to instead use a `struct log_config` that is being
allocated on the stack. This allows us to more clearly scope the
variables, track memory ownership and ultimately release the memory.

This also prepares us for a change to `git_config_string()`, which will
be adapted to have a `char **` out parameter instead of `const char **`.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 months agoconvert: refactor code to clarify ownership of check_roundtrip_encoding
Patrick Steinhardt [Mon, 27 May 2024 11:46:25 +0000 (13:46 +0200)] 
convert: refactor code to clarify ownership of check_roundtrip_encoding

The `check_roundtrip_encoding` variable is tracked in a `const char *`
even though it may contain allocated strings at times. The result is
that those strings may be leaking because we never free them.

Refactor the code to always store allocated strings in this variable.
The default value is handled in `check_roundtrip()` now, which is the
only user of the variable.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 months agodiff: refactor code to clarify memory ownership of prefixes
Patrick Steinhardt [Mon, 27 May 2024 11:46:20 +0000 (13:46 +0200)] 
diff: refactor code to clarify memory ownership of prefixes

The source and destination prefixes are tracked in a `const char *`
array, but may at times contain allocated strings. The result is that
those strings may be leaking because we never free them.

Refactor the code to always store allocated strings in those variables,
freeing them as required. This requires us to handle the default values
a bit different compared to before. But given that there is only a
single callsite where we use the variables to `struct diff_options` it's
easy to handle the defaults there.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 months agoconfig: clarify memory ownership in `git_config_pathname()`
Patrick Steinhardt [Mon, 27 May 2024 11:46:15 +0000 (13:46 +0200)] 
config: clarify memory ownership in `git_config_pathname()`

The out parameter of `git_config_pathname()` is a `const char **` even
though we transfer ownership of memory to the caller. This is quite
misleading and has led to many memory leaks all over the place. Adapt
the parameter to instead be `char **`.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 months agohttp: refactor code to clarify memory ownership
Patrick Steinhardt [Mon, 27 May 2024 11:46:10 +0000 (13:46 +0200)] 
http: refactor code to clarify memory ownership

There are various variables assigned via `git_config_string()` and
`git_config_pathname()` which are never free'd. This bug is relatable
because the out parameter of those functions are a `const char **`, even
though memory ownership is transferred to the caller.

We're about to adapt the functions to instead use `char **`. Prepare the
code accordingly. Note that the `(const char **)` casts will go away
once we have adapted the functions.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 months agocheckout: clarify memory ownership in `unique_tracking_name()`
Patrick Steinhardt [Mon, 27 May 2024 11:46:06 +0000 (13:46 +0200)] 
checkout: clarify memory ownership in `unique_tracking_name()`

The function `unique_tracking_name()` returns an allocated string, but
does not clearly indicate this because its return type is `const char *`
instead of `char *`. This has led to various callsites where we never
free its returned memory at all, which causes memory leaks.

Plug those leaks and mark now-passing tests as leak free.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 months agostrbuf: fix leak when `appendwholeline()` fails with EOF
Patrick Steinhardt [Mon, 27 May 2024 11:46:01 +0000 (13:46 +0200)] 
strbuf: fix leak when `appendwholeline()` fails with EOF

In `strbuf_appendwholeline()` we call `strbuf_getwholeline()` with a
temporary buffer. In case the call returns an error we indicate this by
returning EOF, but never release the temporary buffer. This can cause a
leak though because `strbuf_getwholeline()` calls getline(3). Quoting
its documentation:

    If *lineptr was set to NULL before the call, then the buffer
    should be freed by the user program even on failure.

Consequently, the temporary buffer may hold allocated memory even when
the call to `strbuf_getwholeline()` fails.

Fix this by releasing the temporary buffer on error.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 months agot: mark a bunch of tests as leak-free
Patrick Steinhardt [Mon, 27 May 2024 11:45:52 +0000 (13:45 +0200)] 
t: mark a bunch of tests as leak-free

There are a bunch of tests which do not have any leaks:

  - t0411: Introduced via 5c5a4a1c05 (t0411: add tests for cloning from
    partial repo, 2024-01-28), passes since its inception.

  - t0610: Introduced via 57db2a094d (refs: introduce reftable backend,
    2024-02-07), passes since its inception.

  - t2405: Passes since 6741e917de (repository: avoid leaking
    `fsmonitor` data, 2024-04-12).

  - t7423: Introduced via b20c10fd9b (t7423: add tests for symlinked
    submodule directories, 2024-01-28), passes since e8d0608944
    (submodule: require the submodule path to contain directories only,
    2024-03-26). The fix is not obviously related, but probably works
    because we now die early in many code paths.

  - t9xxx: All of these are exercising CVS-related tooling and pass
    since at least Git v2.40. It's likely that these pass for a long
    time already, but nobody ever noticed because Git developers do not
    tend to have CVS on their machines.

Mark all of these tests as passing.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 months agotransport-helper: fix leaking helper name
Patrick Steinhardt [Mon, 27 May 2024 11:45:56 +0000 (13:45 +0200)] 
transport-helper: fix leaking helper name

When initializing the transport helper in `transport_get()`, we
allocate the name of the helper. We neither end up transferring
ownership of the name, nor do we free it. The associated memory thus
leaks.

Fix this memory leak by freeing the string at the calling side in
`transport_get()`. `transport_helper_init()` now creates its own copy of
the string and thus can free it as required.

An alterantive way to fix this would be to transfer ownership of the
string passed into `transport_helper_init()`, which would avoid the call
to xstrdup(1). But it does make for a more surprising calling convention
as we do not typically transfer ownership of strings like this.

Mark now-passing tests as leak free.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 months agoci: add missing dependency for TTY prereq
Patrick Steinhardt [Mon, 27 May 2024 11:45:47 +0000 (13:45 +0200)] 
ci: add missing dependency for TTY prereq

In "t/lib-terminal.sh", we declare a lazy prerequisite for tests that
require a TTY. The prerequisite uses a Perl script to figure out whether
we do have a usable TTY or not and thus implicitly depends on the PERL
prerequisite, as well. Furthermore though, the script requires another
dependency that is easy to miss, namely on the IO::Pty module. If that
module is not installed, then the script will exit early due to an
reason unrelated to missing TTYs.

This easily leads to missing test coverage. But most importantly, our CI
systems are missing this dependency and thus don't execute those tests
at all. Fix this.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 months agodifftool: add env vars directly in run_file_diff()
René Scharfe [Sun, 26 May 2024 20:16:50 +0000 (22:16 +0200)] 
difftool: add env vars directly in run_file_diff()

Add the environment variables of the child process directly using
strvec_push() instead of building an array out of them and then adding
that using strvec_pushv().  The new code is shorter and avoids magic
array index values and fragile array padding.

Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
13 months agopromisor-remote: add promisor.quiet configuration option
Tom Hughes [Sat, 25 May 2024 10:09:27 +0000 (11:09 +0100)] 
promisor-remote: add promisor.quiet configuration option

Add a configuration option to allow output from the promisor
fetching objects to be suppressed.

This allows us to stop commands like 'git blame' being swamped
with progress messages and gc notifications from the promisor
when used in a partial clone.

Signed-off-by: Tom Hughes <tom@compton.nu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
13 months agoMerge branch 'fixes/2.45.1/2.44' into jc/fix-2.45.1-and-friends-for-maint
Junio C Hamano [Fri, 24 May 2024 23:59:12 +0000 (16:59 -0700)] 
Merge branch 'fixes/2.45.1/2.44' into jc/fix-2.45.1-and-friends-for-maint

* fixes/2.45.1/2.44:
  Revert "fsck: warn about symlink pointing inside a gitdir"
  Revert "Add a helper function to compare file contents"
  clone: drop the protections where hooks aren't run
  tests: verify that `clone -c core.hooksPath=/dev/null` works again
  Revert "core.hooksPath: add some protection while cloning"
  init: use the correct path of the templates directory again
  hook: plug a new memory leak
  ci: stop installing "gcc-13" for osx-gcc
  ci: avoid bare "gcc" for osx-gcc job
  ci: drop mention of BREW_INSTALL_PACKAGES variable
  send-email: avoid creating more than one Term::ReadLine object
  send-email: drop FakeTerm hack

13 months agoMerge branch 'fixes/2.45.1/2.43' into fixes/2.45.1/2.44
Junio C Hamano [Fri, 24 May 2024 23:58:35 +0000 (16:58 -0700)] 
Merge branch 'fixes/2.45.1/2.43' into fixes/2.45.1/2.44

* fixes/2.45.1/2.43:
  Revert "fsck: warn about symlink pointing inside a gitdir"
  Revert "Add a helper function to compare file contents"
  clone: drop the protections where hooks aren't run
  tests: verify that `clone -c core.hooksPath=/dev/null` works again
  Revert "core.hooksPath: add some protection while cloning"
  init: use the correct path of the templates directory again
  hook: plug a new memory leak
  ci: stop installing "gcc-13" for osx-gcc
  ci: avoid bare "gcc" for osx-gcc job
  ci: drop mention of BREW_INSTALL_PACKAGES variable
  send-email: avoid creating more than one Term::ReadLine object
  send-email: drop FakeTerm hack

13 months agoMerge branch 'fixes/2.45.1/2.42' into fixes/2.45.1/2.43
Junio C Hamano [Fri, 24 May 2024 23:58:11 +0000 (16:58 -0700)] 
Merge branch 'fixes/2.45.1/2.42' into fixes/2.45.1/2.43

* fixes/2.45.1/2.42:
  Revert "fsck: warn about symlink pointing inside a gitdir"
  Revert "Add a helper function to compare file contents"
  clone: drop the protections where hooks aren't run
  tests: verify that `clone -c core.hooksPath=/dev/null` works again
  Revert "core.hooksPath: add some protection while cloning"
  init: use the correct path of the templates directory again
  hook: plug a new memory leak
  ci: stop installing "gcc-13" for osx-gcc
  ci: avoid bare "gcc" for osx-gcc job
  ci: drop mention of BREW_INSTALL_PACKAGES variable
  send-email: avoid creating more than one Term::ReadLine object
  send-email: drop FakeTerm hack

13 months agoMerge branch 'fixes/2.45.1/2.41' into fixes/2.45.1/2.42
Junio C Hamano [Fri, 24 May 2024 23:57:43 +0000 (16:57 -0700)] 
Merge branch 'fixes/2.45.1/2.41' into fixes/2.45.1/2.42

* fixes/2.45.1/2.41:
  Revert "fsck: warn about symlink pointing inside a gitdir"
  Revert "Add a helper function to compare file contents"
  clone: drop the protections where hooks aren't run
  tests: verify that `clone -c core.hooksPath=/dev/null` works again
  Revert "core.hooksPath: add some protection while cloning"
  init: use the correct path of the templates directory again
  hook: plug a new memory leak
  ci: stop installing "gcc-13" for osx-gcc
  ci: avoid bare "gcc" for osx-gcc job
  ci: drop mention of BREW_INSTALL_PACKAGES variable
  send-email: avoid creating more than one Term::ReadLine object
  send-email: drop FakeTerm hack

13 months agoMerge branch 'fixes/2.45.1/2.40' into fixes/2.45.1/2.41
Junio C Hamano [Fri, 24 May 2024 23:57:01 +0000 (16:57 -0700)] 
Merge branch 'fixes/2.45.1/2.40' into fixes/2.45.1/2.41

* fixes/2.45.1/2.40:
  Revert "fsck: warn about symlink pointing inside a gitdir"
  Revert "Add a helper function to compare file contents"
  clone: drop the protections where hooks aren't run
  tests: verify that `clone -c core.hooksPath=/dev/null` works again
  Revert "core.hooksPath: add some protection while cloning"
  init: use the correct path of the templates directory again
  hook: plug a new memory leak
  ci: stop installing "gcc-13" for osx-gcc
  ci: avoid bare "gcc" for osx-gcc job
  ci: drop mention of BREW_INSTALL_PACKAGES variable
  send-email: avoid creating more than one Term::ReadLine object
  send-email: drop FakeTerm hack