]> git.ipfire.org Git - thirdparty/git.git/log
thirdparty/git.git
18 months agoMerge branch 'jk/avoid-redef-system-functions-2.30' into jk/avoid-redef-system-functions
Junio C Hamano [Mon, 5 Dec 2022 03:16:00 +0000 (12:16 +0900)] 
Merge branch 'jk/avoid-redef-system-functions-2.30' into jk/avoid-redef-system-functions

* jk/avoid-redef-system-functions-2.30:
  git-compat-util: undefine system names before redeclaring them

18 months agogit-compat-util: undefine system names before redeclaring them
Jeff King [Fri, 2 Dec 2022 11:05:38 +0000 (06:05 -0500)] 
git-compat-util: undefine system names before redeclaring them

When we define a macro to point a system function (e.g., flockfile) to
our custom wrapper, we should make sure that the system did not already
define it as a macro. This is rarely a problem, but can cause
compilation failures if both of these are true:

  - we decide to define our own wrapper even though the system provides
    the function; we know this happens at least with uclibc, which may
    declare flockfile, etc, without _POSIX_THREAD_SAFE_FUNCTIONS

  - the system version is declared as a macro; we know this happens at
    least with uclibc's version of getc_unlocked()

So just handling getc_unlocked() would be sufficient to deal with the
real-world case we've seen. But since it's easy to do, we may as well be
defensive about the other macro wrappers added in the previous patch.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
18 months agoMerge branch 'jk/avoid-redef-system-functions-2.30'
Junio C Hamano [Thu, 1 Dec 2022 00:17:22 +0000 (09:17 +0900)] 
Merge branch 'jk/avoid-redef-system-functions-2.30'

* jk/avoid-redef-system-functions-2.30
  git-compat-util: avoid redefining system function names

18 months agoMerge branch 'jk/avoid-redef-system-functions-2.30' into maint
Junio C Hamano [Thu, 1 Dec 2022 00:14:46 +0000 (09:14 +0900)] 
Merge branch 'jk/avoid-redef-system-functions-2.30' into maint

* jk/avoid-redef-system-functions-2.30:
  git-compat-util: avoid redefining system function names

18 months agogit-compat-util: avoid redefining system function names
Jeff King [Wed, 30 Nov 2022 21:15:14 +0000 (16:15 -0500)] 
git-compat-util: avoid redefining system function names

Our git-compat-util header defines a few noop wrappers for system
functions if they are not available. This was originally done with a
macro, but in 15b52a44e0 (compat-util: type-check parameters of no-op
replacement functions, 2020-08-06) we switched to inline functions,
because it gives us basic type-checking.

This can cause compilation failures when the system _does_ declare those
functions but we choose not to use them, since the compiler will
complain about the redeclaration. This was seen in the real world when
compiling against certain builds of uclibc, which may leave
_POSIX_THREAD_SAFE_FUNCTIONS unset, but still declare flockfile() and
funlockfile().

It can also be seen on any platform that has setitimer() if you choose
to compile without it (which plausibly could happen if the system
implementation is buggy). E.g., on Linux:

  $ make NO_SETITIMER=IWouldPreferNotTo git.o
      CC git.o
  In file included from builtin.h:4,
                   from git.c:1:
  git-compat-util.h:344:19: error: conflicting types for ‘setitimer’; have ‘int(int,  const struct itimerval *, struct itimerval *)’
    344 | static inline int setitimer(int which UNUSED,
        |                   ^~~~~~~~~
  In file included from git-compat-util.h:234:
  /usr/include/x86_64-linux-gnu/sys/time.h:155:12: note: previous declaration of ‘setitimer’ with type ‘int(__itimer_which_t,  const struct itimerval * restrict,  struct itimerval * restrict)’
    155 | extern int setitimer (__itimer_which_t __which,
        |            ^~~~~~~~~
  make: *** [Makefile:2714: git.o] Error 1

Here I think the compiler is complaining about the lack of "restrict"
annotations in our version, but even if we matched it completely (and
there is no way to match all platforms anyway), it would still complain
about a static declaration following a non-static one. Using macros
doesn't have this problem, because the C preprocessor rewrites the name
in our code before we hit this level of compilation.

One way to fix this would just be to revert most of 15b52a44e0. What we
really cared about there was catching build problems with
precompose_argv(), which most platforms _don't_ build, and which is our
custom function. So we could just switch the system wrappers back to
macros; most people build the real versions anyway, and they don't
change. So the extra type-checking isn't likely to catch bugs.

But with a little work, we can have our cake and eat it, too. If we
define the type-checking wrappers with a unique name, and then redirect
the system names to them with macros, we still get our type checking,
but without redeclaring the system function names.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
18 months agoGit 2.39-rc1 v2.39.0-rc1
Junio C Hamano [Wed, 30 Nov 2022 02:00:35 +0000 (11:00 +0900)] 
Git 2.39-rc1

Signed-off-by: Junio C Hamano <gitster@pobox.com>
18 months agoMerge branch 'ps/gnumake-4.4-fix'
Junio C Hamano [Wed, 30 Nov 2022 01:57:19 +0000 (10:57 +0900)] 
Merge branch 'ps/gnumake-4.4-fix'

* ps/gnumake-4.4-fix:
  Makefile: avoid multiple patterns when recipes generate one file

18 months agoA bit more before -rc1
Junio C Hamano [Tue, 29 Nov 2022 01:40:38 +0000 (10:40 +0900)] 
A bit more before -rc1

Signed-off-by: Junio C Hamano <gitster@pobox.com>
18 months agoMerge branch 'ab/doc-synopsis-and-cmd-usage'
Junio C Hamano [Tue, 29 Nov 2022 01:41:06 +0000 (10:41 +0900)] 
Merge branch 'ab/doc-synopsis-and-cmd-usage'

Doc and message fix.

* ab/doc-synopsis-and-cmd-usage:
  i18n: fix command template placeholder format

18 months agoMerge branch 'km/merge-recursive-typofix'
Junio C Hamano [Tue, 29 Nov 2022 01:41:06 +0000 (10:41 +0900)] 
Merge branch 'km/merge-recursive-typofix'

Fix an old typo in an error message.

* km/merge-recursive-typofix:
  merge-recursive: fix variable typo in error message

18 months agoMerge branch 'jx/ci-ubuntu-fix'
Junio C Hamano [Tue, 29 Nov 2022 01:41:05 +0000 (10:41 +0900)] 
Merge branch 'jx/ci-ubuntu-fix'

Adjust the GitHub CI to newer ubuntu release.

* jx/ci-ubuntu-fix:
  ci: install python on ubuntu
  ci: use the same version of p4 on both Linux and macOS
  ci: remove the pipe after "p4 -V" to catch errors
  github-actions: run gcc-8 on ubuntu-20.04 image

18 months agoMerge branch 'jh/trace2-timers-and-counters'
Junio C Hamano [Tue, 29 Nov 2022 01:41:05 +0000 (10:41 +0900)] 
Merge branch 'jh/trace2-timers-and-counters'

Test fix.

* jh/trace2-timers-and-counters:
  trace2 tests: guard pthread test with "PTHREAD"

18 months agoMerge branch 'ah/chainlint-cpuinfo-parse-fix'
Junio C Hamano [Tue, 29 Nov 2022 01:41:05 +0000 (10:41 +0900)] 
Merge branch 'ah/chainlint-cpuinfo-parse-fix'

The format of a line in /proc/cpuinfo that describes a CPU on s390x
looked different from everybody else, and the code in chainlint.pl
failed to parse it.

* ah/chainlint-cpuinfo-parse-fix:
  chainlint.pl: fix /proc/cpuinfo regexp

18 months agoMerge branch 'gc/resolve-alternate-symlinks'
Junio C Hamano [Tue, 29 Nov 2022 01:41:05 +0000 (10:41 +0900)] 
Merge branch 'gc/resolve-alternate-symlinks'

Resolve symbolic links when processing the locations of alternate
object stores, since failing to do so can lead to confusing and buggy
behavior.

* gc/resolve-alternate-symlinks:
  object-file: use real paths when adding alternates

18 months agoAnother batch before -rc1
Junio C Hamano [Mon, 28 Nov 2022 02:49:55 +0000 (11:49 +0900)] 
Another batch before -rc1

Signed-off-by: Junio C Hamano <gitster@pobox.com>
18 months agoMerge branch 'ab/fewer-the-index-macros'
Junio C Hamano [Mon, 28 Nov 2022 03:13:46 +0000 (12:13 +0900)] 
Merge branch 'ab/fewer-the-index-macros'

Progress on removing 'the_index' convenience wrappers.

* ab/fewer-the-index-macros:
  cocci: apply "pending" index-compatibility to some "builtin/*.c"
  cache.h & test-tool.h: add & use "USE_THE_INDEX_VARIABLE"
  {builtin/*,repository}.c: add & use "USE_THE_INDEX_VARIABLE"
  cocci: apply "pending" index-compatibility to "t/helper/*.c"
  cocci & cache.h: apply variable section of "pending" index-compatibility
  cocci & cache.h: apply a selection of "pending" index-compatibility
  cocci: add a index-compatibility.pending.cocci
  read-cache API & users: make discard_index() return void
  cocci & cache.h: remove rarely used "the_index" compat macros
  builtin/{grep,log}.: don't define "USE_THE_INDEX_COMPATIBILITY_MACROS"
  cache.h: remove unused "the_index" compat macros

18 months agoMerge branch 'sg/plug-line-log-leaks'
Junio C Hamano [Mon, 28 Nov 2022 03:13:45 +0000 (12:13 +0900)] 
Merge branch 'sg/plug-line-log-leaks'

A handful of leaks in the line-log machinery have been plugged.

* sg/plug-line-log-leaks:
  diff.c: use diff_free_queue()
  line-log: free the diff queues' arrays when processing merge commits
  line-log: free diff queue when processing non-merge commits

18 months agoMerge branch 'es/locate-httpd-module-location-in-test'
Junio C Hamano [Mon, 28 Nov 2022 03:13:45 +0000 (12:13 +0900)] 
Merge branch 'es/locate-httpd-module-location-in-test'

Add one more candidate directory that may house httpd modules while
running tests.

* es/locate-httpd-module-location-in-test:
  lib-httpd: extend module location auto-detection

18 months agoMerge branch 'zk/push-use-bitmaps'
Junio C Hamano [Mon, 28 Nov 2022 03:13:44 +0000 (12:13 +0900)] 
Merge branch 'zk/push-use-bitmaps'

Test fix.

* zk/push-use-bitmaps:
  t5516: fail to run in verbose mode

18 months agoMerge branch 'ew/prune-with-missing-objects-pack'
Junio C Hamano [Mon, 28 Nov 2022 03:13:43 +0000 (12:13 +0900)] 
Merge branch 'ew/prune-with-missing-objects-pack'

"git prune" may try to iterate over .git/objects/pack for trash
files to remove in it, and loudly fail when the directory is
missing, which is not necessary.  The command has been taught to
ignore such a failure.

* ew/prune-with-missing-objects-pack:
  prune: quiet ENOENT on missing directories

18 months agoMerge branch 'rs/list-objects-filter-leakfix'
Junio C Hamano [Mon, 28 Nov 2022 03:13:43 +0000 (12:13 +0900)] 
Merge branch 'rs/list-objects-filter-leakfix'

Leakfix.

* rs/list-objects-filter-leakfix:
  list-objects-filter: plug combine_filter_data leak

18 months agoMerge branch 'pw/config-int-parse-fixes'
Junio C Hamano [Mon, 28 Nov 2022 03:13:43 +0000 (12:13 +0900)] 
Merge branch 'pw/config-int-parse-fixes'

Assorted fixes of parsing end-user input as integers.

* pw/config-int-parse-fixes:
  git_parse_signed(): avoid integer overflow
  config: require at least one digit when parsing numbers
  git_parse_unsigned: reject negative values

18 months agoMerge branch 'jk/parse-object-type-mismatch'
Junio C Hamano [Mon, 28 Nov 2022 03:13:42 +0000 (12:13 +0900)] 
Merge branch 'jk/parse-object-type-mismatch'

`parse_object()` hardening when checking for the existence of a
suspected blob object.

* jk/parse-object-type-mismatch:
  parse_object(): simplify blob conditional
  parse_object(): check on-disk type of suspected blob
  parse_object(): drop extra "has" check before checking object type

18 months agoMakefile: avoid multiple patterns when recipes generate one file
Paul Smith [Sun, 27 Nov 2022 22:42:51 +0000 (17:42 -0500)] 
Makefile: avoid multiple patterns when recipes generate one file

A GNU make pattern rule with multiple targets has always meant that
a single invocation of the recipe will build all the targets.
However in older versions of GNU make a recipe that did not really
build all the targets would be tolerated.

Starting with GNU make 4.4 this behavior is deprecated and pattern
rules are expected to generate files to match all the patterns.
If not all targets are created then GNU make will not consider any
target up to date and will re-run the recipe when it is run again.

Modify Documentation/Makefile to split the man page-creating pattern
rule into a separate pattern rule for each pattern.

Reported-by: Alexander Kanavin <alex.kanavin@gmail.com>
Signed-off-by: Paul Smith <psmith@gnu.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
18 months agoi18n: fix command template placeholder format
Jean-Noël Avila [Sat, 26 Nov 2022 17:24:02 +0000 (17:24 +0000)] 
i18n: fix command template placeholder format

Signed-off-by: Jean-Noël Avila <jn.avila@free.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
18 months agomerge-recursive: fix variable typo in error message
Kyle Meyer [Fri, 25 Nov 2022 17:37:45 +0000 (12:37 -0500)] 
merge-recursive: fix variable typo in error message

Signed-off-by: Kyle Meyer <kyle@kyleam.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
18 months agoci: install python on ubuntu
Jiang Xin [Fri, 25 Nov 2022 09:59:54 +0000 (17:59 +0800)] 
ci: install python on ubuntu

Python is missing from the default ubuntu-22.04 runner image, which
prevents git-p4 from working. To install python on ubuntu, we need
to provide the correct package names:

 * On Ubuntu 18.04 (bionic), "/usr/bin/python2" is provided by the
   "python" package, and "/usr/bin/python3" is provided by the "python3"
   package.

 * On Ubuntu 20.04 (focal) and above, "/usr/bin/python2" is provided by
   the "python2" package which has a different name from bionic, and
   "/usr/bin/python3" is provided by "python3".

Since the "ubuntu-latest" runner image has a higher version, its
safe to use "python2" or "python3" package name.

Helped-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Jiang Xin <zhiyou.jx@alibaba-inc.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
18 months agoci: use the same version of p4 on both Linux and macOS
Jiang Xin [Fri, 25 Nov 2022 09:59:53 +0000 (17:59 +0800)] 
ci: use the same version of p4 on both Linux and macOS

There would be a segmentation fault when running p4 v16.2 on ubuntu
22.04 which is the latest version of ubuntu runner image for github
actions.

By checking each version from [1], p4d version 21.1 and above can work
properly on ubuntu 22.04. But version 22.x will break some p4 test
cases. So p4 version 21.x is exactly the version we can use.

With this update, the versions of p4 for Linux and macOS happen to be
the same. So we can add the version number directly into the "P4WHENCE"
variable, and reuse it in p4 installation for macOS.

By removing the "LINUX_P4_VERSION" variable from "ci/lib.sh", the
comment left above has nothing to do with p4, but still applies to
git-lfs. Since we have a fixed version of git-lfs installed on Linux,
we may have a different version on macOS.

[1]: https://cdist2.perforce.com/perforce/

Reviewed-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Helped-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Jiang Xin <zhiyou.jx@alibaba-inc.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
18 months agoci: remove the pipe after "p4 -V" to catch errors
Jiang Xin [Fri, 25 Nov 2022 09:59:52 +0000 (17:59 +0800)] 
ci: remove the pipe after "p4 -V" to catch errors

When installing p4 as a dependency, we used to pipe output of "p4 -V"
and "p4d -V" to validate the installation and output a condensed version
information. But this would hide potential errors of p4 and would stop
with an empty output. E.g.: p4d version 16.2 running on ubuntu 22.04
causes sigfaults, even before it produces any output.

By removing the pipe after "p4 -V" and "p4d -V", we may get a
verbose output, and stop immediately on errors because we have "set
-e" in "ci/lib.sh". Since we won't look at these trace logs unless
something fails, just including the raw output seems most sensible.

Reviewed-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Helped-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Jiang Xin <zhiyou.jx@alibaba-inc.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
18 months agogithub-actions: run gcc-8 on ubuntu-20.04 image
Jiang Xin [Fri, 25 Nov 2022 09:59:51 +0000 (17:59 +0800)] 
github-actions: run gcc-8 on ubuntu-20.04 image

GitHub starts to upgrade its runner image "ubuntu-latest" from version
"ubuntu-20.04" to version "ubuntu-22.04". It will fail to find and
install "gcc-8" package on the new runner image.

Change some of the runner images from "ubuntu-latest" to "ubuntu-20.04"
in order to install "gcc-8" as a dependency.

The first revision of this patch tried to replace "$runs_on_pool" in
"ci/*.sh" with a new "$runs_on_os" environment variable based on the
"os" field in the matrix strategy. But these "os" fields in matrix
strategies are obsolete legacies from commit [1] and commit [2], and
are no longer useful. So remove these unused "os" fields.

[1]: c08bb26010 (CI: rename the "Linux32" job to lower-case "linux32",
                 2021-11-23)
[2]: 25715419bf (CI: don't run "make test" twice in one job, 2021-11-23)

Reviewed-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Helped-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Jiang Xin <zhiyou.jx@alibaba-inc.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
18 months agoobject-file: use real paths when adding alternates
Glen Choo [Thu, 24 Nov 2022 00:55:31 +0000 (00:55 +0000)] 
object-file: use real paths when adding alternates

When adding an alternate ODB, we check if the alternate has the same
path as the object dir, and if so, we do nothing. However, that
comparison does not resolve symlinks. This makes it possible to add the
object dir as an alternate, which may result in bad behavior. For
example, it can trick "git repack -a -l -d" (possibly run by "git gc")
into thinking that all packs come from an alternate and delete all
objects.

rm -rf test &&
git clone https://github.com/git/git test &&
(
cd test &&
ln -s objects .git/alt-objects &&
# -c repack.updateserverinfo=false silences a warning about not
# being able to update "info/refs", it isn't needed to show the
# bad behavior
GIT_ALTERNATE_OBJECT_DIRECTORIES=".git/alt-objects" git \
-c repack.updateserverinfo=false repack -a -l -d  &&
# It's broken!
git status
# Because there are no more objects!
ls .git/objects/pack
)

Fix this by resolving symlinks and relative paths before comparing the
alternate and object dir. This lets us clean up a number of issues noted
in 37a95862c6 (alternates: re-allow relative paths from environment,
2016-11-07):

- Now that we compare the real paths, duplicate detection is no longer
  foiled by relative paths.
- Using strbuf_realpath() allows us to "normalize" paths that
  strbuf_normalize_path() can't, so we can stop silently ignoring errors
  when "normalizing" paths from the environment.
- We now store an absolute path based on getcwd() (the "future
  direction" named in 37a95862c6), so chdir()-ing in the process no
  longer changes the directory pointed to by the alternate. This is a
  change in behavior, but a desirable one.

Signed-off-by: Glen Choo <chooglen@google.com>
Acked-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
18 months agotrace2 tests: guard pthread test with "PTHREAD"
Ævar Arnfjörð Bjarmason [Thu, 24 Nov 2022 21:48:21 +0000 (22:48 +0100)] 
trace2 tests: guard pthread test with "PTHREAD"

Since 81071626ba1 (trace2: add global counter mechanism, 2022-10-24)
these tests have been failing when git is compiled with NO_PTHREADS=Y,
which is always the case e.g. if 'uname -s' is "NONSTOP_KERNEL".

Reported-by: Randall S. Becker <randall.becker@nexbridge.ca>
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
18 months agoGit 2.39-rc0 v2.39.0-rc0
Junio C Hamano [Wed, 23 Nov 2022 02:09:23 +0000 (11:09 +0900)] 
Git 2.39-rc0

Signed-off-by: Junio C Hamano <gitster@pobox.com>
18 months agoMerge branch 'mh/gitcredentials-generate'
Junio C Hamano [Wed, 23 Nov 2022 02:22:25 +0000 (11:22 +0900)] 
Merge branch 'mh/gitcredentials-generate'

Doc update.

* mh/gitcredentials-generate:
  Docs: describe how a credential-generating helper works

18 months agoMerge branch 'ps/receive-use-only-advertised'
Junio C Hamano [Wed, 23 Nov 2022 02:22:25 +0000 (11:22 +0900)] 
Merge branch 'ps/receive-use-only-advertised'

"git receive-pack" used to use all the local refs as the boundary for
checking connectivity of the data "git push" sent, but now it uses
only the refs that it advertised to the pusher. In a repository with
the .hideRefs configuration, this reduces the resources needed to
perform the check.
cf. <221028.86bkpw805n.gmgdl@evledraar.gmail.com>
cf. <xmqqr0yrizqm.fsf@gitster.g>

* ps/receive-use-only-advertised:
  receive-pack: only use visible refs for connectivity check
  rev-parse: add `--exclude-hidden=` option
  revision: add new parameter to exclude hidden refs
  revision: introduce struct to handle exclusions
  revision: move together exclusion-related functions
  refs: get rid of global list of hidden refs
  refs: fix memory leak when parsing hideRefs config

18 months agoMerge branch 'jt/submodule-on-demand'
Junio C Hamano [Wed, 23 Nov 2022 02:22:25 +0000 (11:22 +0900)] 
Merge branch 'jt/submodule-on-demand'

Push all submodules recursively with
'--recurse-submodules=on-demand'.

* jt/submodule-on-demand:
  Doc: document push.recurseSubmodules=only

18 months agoMerge branch 'sz/macos-fsmonitor-symlinks'
Junio C Hamano [Wed, 23 Nov 2022 02:22:25 +0000 (11:22 +0900)] 
Merge branch 'sz/macos-fsmonitor-symlinks'

Fix an issue where core.fsmonitor on macOS would not notice created
or modified symbolic links.

* sz/macos-fsmonitor-symlinks:
  fsmonitor--daemon: on macOS support symlink

18 months agoMerge branch 'ew/delta-islands-free'
Junio C Hamano [Wed, 23 Nov 2022 02:22:25 +0000 (11:22 +0900)] 
Merge branch 'ew/delta-islands-free'

Free structures related to delta islands after use.

* ew/delta-islands-free:
  delta-islands: free island-related data after use

18 months agoMerge branch 'mg/notes-newline'
Junio C Hamano [Wed, 23 Nov 2022 02:22:24 +0000 (11:22 +0900)] 
Merge branch 'mg/notes-newline'

Avoid a stray empty newline in the template when creating new notes.

* mg/notes-newline:
  notes: avoid empty line in template

18 months agoMerge branch 'tb/howto-maintain-git-fixes'
Junio C Hamano [Wed, 23 Nov 2022 02:22:24 +0000 (11:22 +0900)] 
Merge branch 'tb/howto-maintain-git-fixes'

A pair of bugfixes to the Documentation/howto/maintain-git.txt guide.

* tb/howto-maintain-git-fixes:
  Documentation: build redo-seen.sh from jch..seen
  Documentation: build redo-jch.sh from master..jch

18 months agoMerge branch 'es/chainlint-lineno'
Junio C Hamano [Wed, 23 Nov 2022 02:22:24 +0000 (11:22 +0900)] 
Merge branch 'es/chainlint-lineno'

Teach chainlint.pl to show corresponding line numbers when printing
the source of a test.

* es/chainlint-lineno:
  chainlint: prefix annotated test definition with line numbers
  chainlint: latch line numbers at which each token starts and ends
  chainlint: sidestep impoverished macOS "terminfo"

18 months agoMerge branch 'pw/rebase-no-reflog-action'
Junio C Hamano [Wed, 23 Nov 2022 02:22:24 +0000 (11:22 +0900)] 
Merge branch 'pw/rebase-no-reflog-action'

Avoid setting GIT_REFLOG_ACTION to improve readability of the
sequencer internals.

* pw/rebase-no-reflog-action:
  rebase: stop exporting GIT_REFLOG_ACTION
  sequencer: stop exporting GIT_REFLOG_ACTION

18 months agoMerge branch 'ab/t7610-timeout'
Junio C Hamano [Wed, 23 Nov 2022 02:22:24 +0000 (11:22 +0900)] 
Merge branch 'ab/t7610-timeout'

Fix a source of flakiness in CI when compiling with SANITIZE=leak.

* ab/t7610-timeout:
  t7610: use "file:///dev/null", not "/dev/null", fixes MinGW
  t7610: fix flaky timeout issue, don't clone from example.com

18 months agoMerge branch 'rp/maintenance-qol'
Junio C Hamano [Wed, 23 Nov 2022 02:22:23 +0000 (11:22 +0900)] 
Merge branch 'rp/maintenance-qol'

'git maintenance register' is taught to write configuration to an
arbitrary path, and 'git for-each-repo' is taught to expand tilde
characters in paths.

* rp/maintenance-qol:
  builtin/gc.c: fix use-after-free in maintenance_unregister()
  maintenance --unregister: fix uninit'd data use & -Wdeclaration-after-statement
  maintenance: add option to register in a specific config
  for-each-repo: interpolate repo path arguments

18 months agoMerge branch 'pw/strict-label-lookups'
Junio C Hamano [Wed, 23 Nov 2022 02:22:23 +0000 (11:22 +0900)] 
Merge branch 'pw/strict-label-lookups'

Correct an error where `git rebase` would mistakenly use a branch or
tag named "refs/rewritten/xyz" when missing a rebase label.

* pw/strict-label-lookups:
  sequencer: tighten label lookups
  sequencer: unify label lookup

18 months agoMerge branch 'gc/redact-h2h3-headers'
Junio C Hamano [Wed, 23 Nov 2022 02:22:23 +0000 (11:22 +0900)] 
Merge branch 'gc/redact-h2h3-headers'

Redact headers from cURL's h2h3 module in GIT_CURL_VERBOSE and
others.

* gc/redact-h2h3-headers:
  http: redact curl h2h3 headers in info
  t: run t5551 tests with both HTTP and HTTP/2

18 months agoMerge branch 'ab/coccicheck-incremental'
Junio C Hamano [Wed, 23 Nov 2022 02:22:23 +0000 (11:22 +0900)] 
Merge branch 'ab/coccicheck-incremental'

"make coccicheck" is time consuming. It has been made to run more
incrementally.

* ab/coccicheck-incremental:
  Makefile: don't create a ".build/.build/" for cocci, fix output
  spatchcache: add a ccache-alike for "spatch"
  cocci: run against a generated ALL.cocci
  cocci rules: remove <id>'s from rules that don't need them
  Makefile: copy contrib/coccinelle/*.cocci to build/
  cocci: optimistically use COMPUTE_HEADER_DEPENDENCIES
  cocci: make "coccicheck" rule incremental
  cocci: split off "--all-includes" from SPATCH_FLAGS
  cocci: split off include-less "tests" from SPATCH_FLAGS
  Makefile: split off SPATCH_BATCH_SIZE comment from "cocci" heading
  Makefile: have "coccicheck" re-run if flags change
  Makefile: add ability to TAB-complete cocci *.patch rules
  cocci rules: remove unused "F" metavariable from pending rule
  Makefile + shared.mak: rename and indent $(QUIET_SPATCH_T)

18 months agoMerge branch 'es/chainlint-output'
Junio C Hamano [Wed, 23 Nov 2022 02:22:23 +0000 (11:22 +0900)] 
Merge branch 'es/chainlint-output'

Teach chainlint.pl to annotate the original test definition instead
of the token stream.

* es/chainlint-output:
  chainlint: annotate original test definition rather than token stream
  chainlint: latch start/end position of each token
  chainlint: tighten accuracy when consuming input stream
  chainlint: add explanatory comments

18 months agoMerge branch 'js/remove-stale-scalar-repos'
Junio C Hamano [Wed, 23 Nov 2022 02:22:23 +0000 (11:22 +0900)] 
Merge branch 'js/remove-stale-scalar-repos'

'scalar reconfigure -a' is taught to automatically remove
scalar.repo entires which no longer exist.

* js/remove-stale-scalar-repos:
  tests(scalar): tighten the stale `scalar.repo` test some
  scalar reconfigure -a: remove stale `scalar.repo` entries

18 months agoMerge branch 'dd/bisect-helper-subcommand'
Junio C Hamano [Wed, 23 Nov 2022 02:22:22 +0000 (11:22 +0900)] 
Merge branch 'dd/bisect-helper-subcommand'

Fix a regression in the bisect-helper which mistakenly treats
arguments to the command given to 'git bisect run' as arguments to
the helper.

* dd/bisect-helper-subcommand:
  bisect--helper: parse subcommand with OPT_SUBCOMMAND
  bisect--helper: move all subcommands into their own functions
  bisect--helper: remove unused options

18 months agoMerge branch 'ab/submodule-helper-prep-only'
Junio C Hamano [Wed, 23 Nov 2022 02:22:22 +0000 (11:22 +0900)] 
Merge branch 'ab/submodule-helper-prep-only'

Preparation to remove git-submodule.sh and replace it with a builtin.

* ab/submodule-helper-prep-only:
  submodule--helper: use OPT_SUBCOMMAND() API
  submodule--helper: drop "update --prefix <pfx>" for "-C <pfx> update"
  submodule--helper: remove --prefix from "absorbgitdirs"
  submodule API & "absorbgitdirs": remove "----recursive" option
  submodule.c: refactor recursive block out of absorb function
  submodule tests: test for a "foreach" blind-spot
  submodule--helper: fix a memory leak in "status"
  submodule tests: add tests for top-level flag output
  submodule--helper: move "config" to a test-tool

18 months agochainlint.pl: fix /proc/cpuinfo regexp
Andreas Hasenack [Tue, 22 Nov 2022 20:27:41 +0000 (20:27 +0000)] 
chainlint.pl: fix /proc/cpuinfo regexp

29fb2ec3 (chainlint.pl: validate test scripts in parallel,
2022-09-01) introduced a function that gets the number of cores from
/proc/cpuinfo on some systems, notably linux.

The regexp it uses (^processor\s*:) fails to match the desired lines in
the s390x architecture, where they look like this:

    processor 0: version = FF, identification = 148F67, machine = 2964

As a result, on s390x that function returns 0 as the number of cores,
and the chainlint.pl script exits without doing anything.

Signed-off-by: Andreas Hasenack <andreas.hasenack@canonical.com>
Acked-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
18 months agoparse_object(): simplify blob conditional
Ævar Arnfjörð Bjarmason [Mon, 21 Nov 2022 19:26:55 +0000 (14:26 -0500)] 
parse_object(): simplify blob conditional

Commit 8db2dad7a0 (parse_object(): check on-disk type of suspected blob,
2022-11-17) simplified the conditional for checking if we might have a
blob. But we can simplify it further. In:

  !obj || (obj && obj->type == OBJ_BLOB)

the short-circuit "OR" means "obj" will always be true on the right-hand
side. The compiler almost certainly optimized that out anyway, but
dropping it makes the conditional easier to understand for humans.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
18 months agolib-httpd: extend module location auto-detection
Eric Sunshine [Mon, 21 Nov 2022 03:01:35 +0000 (03:01 +0000)] 
lib-httpd: extend module location auto-detection

Although it is possible to manually set LIB_HTTPD_PATH and
LIB_HTTPD_MODULE_PATH to point at the location of `httpd` and its
modules, doing so is cumbersome and easily forgotten. To address this,
0d344738dc (t/lib-http.sh: Restructure finding of default httpd
location, 2010-01-02) enhanced lib-httpd.sh to automatically detect the
location of `httpd` and its modules in order to facilitate out-of-the-
box testing on a wider range of platforms. Follow that lead by further
enhancing it to automatically detect the `httpd` modules on Void Linux,
as well.

Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
18 months agot5516: fail to run in verbose mode
Jiang Xin [Mon, 21 Nov 2022 13:40:40 +0000 (21:40 +0800)] 
t5516: fail to run in verbose mode

The test case "push with config push.useBitmap" of t5516 was introduced
in commit 82f67ee13f (send-pack.c: add config push.useBitmaps,
2022-06-17). It won't work in verbose mode, e.g.:

    $ sh t5516-fetch-push.sh --run='1,115' -v

This is because "git-push" will run in a tty in this case, and the
subcommand "git pack-objects" will contain an argument "--progress"
instead of "-q". Adding a specific option "--quiet" to "git push" will
get a stable result for t5516.

Signed-off-by: Jiang Xin <zhiyou.jx@alibaba-inc.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
18 months agolist-objects-filter: plug combine_filter_data leak
René Scharfe [Sun, 20 Nov 2022 11:00:52 +0000 (12:00 +0100)] 
list-objects-filter: plug combine_filter_data leak

filter_combine__init() allocates a struct combine_filter_data object and
assigns it to the filter_data member of struct filter_options.  Release
it in the complementing filter_combine__free().

Reported-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
18 months agoprune: quiet ENOENT on missing directories
Eric Wong [Sat, 19 Nov 2022 20:12:13 +0000 (20:12 +0000)] 
prune: quiet ENOENT on missing directories

$GIT_DIR/objects/pack may be removed to save inodes in shared
repositories.  Quiet down prune in cases where either
$GIT_DIR/objects or $GIT_DIR/objects/pack is non-existent,
but emit the system error in other cases to help users diagnose
permissions problems or resource constraints.

Signed-off-by: Eric Wong <e@80x24.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
18 months agococci: apply "pending" index-compatibility to some "builtin/*.c"
Ævar Arnfjörð Bjarmason [Sat, 19 Nov 2022 13:07:38 +0000 (14:07 +0100)] 
cocci: apply "pending" index-compatibility to some "builtin/*.c"

Apply "index-compatibility.pending.cocci" rule to "builtin/*", but
exclude those where we conflict with in-flight changes.

As a result some of them end up using only "the_index", so let's have
them use the more narrow "USE_THE_INDEX_VARIABLE" rather than
"USE_THE_INDEX_COMPATIBILITY_MACROS".

Manual changes not made by coccinelle, that were squashed in:

* Whitespace-wrap argument lists for repo_hold_locked_index(),
  repo_read_index_preload() and repo_refresh_and_write_index(), in cases
  where the line became too long after the transformation.
* Change "refresh_cache()" to "refresh_index()" in a comment in
  "builtin/update-index.c".
* For those whose call was followed by perror("<macro-name>"), change
  it to perror("<function-name>"), referring to the new function.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
18 months agocache.h & test-tool.h: add & use "USE_THE_INDEX_VARIABLE"
Ævar Arnfjörð Bjarmason [Sat, 19 Nov 2022 13:07:37 +0000 (14:07 +0100)] 
cache.h & test-tool.h: add & use "USE_THE_INDEX_VARIABLE"

In a preceding commit we fully applied the
"index-compatibility.pending.cocci" rule to "t/helper/*".

Let's now stop defining "USE_THE_INDEX_COMPATIBILITY_MACROS" in
test-tool.h itself, and instead instead define
"USE_THE_INDEX_VARIABLE" in the individual test helpers that need
it. This mirrors how we do the same thing in the "builtin/" directory.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
18 months ago{builtin/*,repository}.c: add & use "USE_THE_INDEX_VARIABLE"
Ævar Arnfjörð Bjarmason [Sat, 19 Nov 2022 13:07:36 +0000 (14:07 +0100)] 
{builtin/*,repository}.c: add & use "USE_THE_INDEX_VARIABLE"

Split up the "USE_THE_INDEX_COMPATIBILITY_MACROS" into that setting
and a more narrow "USE_THE_INDEX_VARIABLE". In the case of these
built-ins we only need "the_index" variable, but not the compatibility
wrapper for functions we're not using.

Let's then have some users of "USE_THE_INDEX_COMPATIBILITY_MACROS" use
this more narrow and descriptive define.

For context: The USE_THE_INDEX_COMPATIBILITY_MACROS macro was added to
test-tool.h in f8adbec9fea (cache.h: flip
NO_THE_INDEX_COMPATIBILITY_MACROS switch, 2019-01-24).

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
18 months agococci: apply "pending" index-compatibility to "t/helper/*.c"
Ævar Arnfjörð Bjarmason [Sat, 19 Nov 2022 13:07:35 +0000 (14:07 +0100)] 
cocci: apply "pending" index-compatibility to "t/helper/*.c"

Apply the "index-compatibility.pending.cocci" rule to the "t/helper/*"
directory, a subsequent commit will extend cache.h to further narrow
down the use of "USE_THE_INDEX_COMPATIBILITY_MACROS" in this area.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
18 months agococci & cache.h: apply variable section of "pending" index-compatibility
Ævar Arnfjörð Bjarmason [Sat, 19 Nov 2022 13:07:34 +0000 (14:07 +0100)] 
cocci & cache.h: apply variable section of "pending" index-compatibility

Mostly apply the part of "index-compatibility.pending.cocci" that
renames the global variables like "active_nr", which are a shorthand
to referencing (in that case) a struct member as "the_index.cache_nr".

In doing so move more of "index-compatibility.pending.cocci" to
"index-compatibility.cocci".

In the case of "active_nr" we'd have a textual conflict with
"ab/various-leak-fixes" in "next"[1]. Let's exclude that specific case
while moving the rule over from "pending".

1. 407b94280f8 (commit: discard partial cache before (re-)reading it,
   2022-11-08)

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
18 months agococci & cache.h: apply a selection of "pending" index-compatibility
Ævar Arnfjörð Bjarmason [Sat, 19 Nov 2022 13:07:33 +0000 (14:07 +0100)] 
cocci & cache.h: apply a selection of "pending" index-compatibility

Apply a selection of rules in "index-compatibility.pending.cocci"
tree-wide, and in doing so migrate them to
"index-compatibility.cocci".

As in preceding commits the only manual changes here are the macro
removals in "cache.h", and the update to the '*.cocci" rules. The rest
of the C code changes are the result of applying those updated rules.

Move rules for some rarely used cache compatibility macros from
"index-compatibility.pending.cocci" to "index-compatibility.cocci" and
apply them.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
18 months agococci: add a index-compatibility.pending.cocci
Ævar Arnfjörð Bjarmason [Sat, 19 Nov 2022 13:07:32 +0000 (14:07 +0100)] 
cocci: add a index-compatibility.pending.cocci

Add a coccinelle rule which covers the rest of the macros guarded by
"USE_THE_INDEX_COMPATIBILITY_MACROS" cache.h. If the result of this
were applied it can be reduced down to just:

#ifdef USE_THE_INDEX_COMPATIBILITY_MACROS
extern struct index_state the_index;
#endif

But that patch is just under 2000 lines, so let's first add this as a
"pending", and then incrementally pick changes from it in subsequent
commits. In doing that we'll migrate rules from this
"index-compatibility.pending.cocci" to the "index-compatibility.cocci"
created in a preceding commit.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
18 months agoread-cache API & users: make discard_index() return void
Ævar Arnfjörð Bjarmason [Sat, 19 Nov 2022 13:07:31 +0000 (14:07 +0100)] 
read-cache API & users: make discard_index() return void

The discard_index() function has not returned non-zero since
7a51ed66f65 (Make on-disk index representation separate from in-core
one, 2008-01-14), but we've had various code in-tree still acting as
though that might be the case.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
18 months agococci & cache.h: remove rarely used "the_index" compat macros
Ævar Arnfjörð Bjarmason [Sat, 19 Nov 2022 13:07:30 +0000 (14:07 +0100)] 
cocci & cache.h: remove rarely used "the_index" compat macros

Since 4aab5b46f44 (Make read-cache.c "the_index" free., 2007-04-01)
we've been undergoing a slow migration away from these macros, but
haven't made much progress since f8adbec9fea (cache.h: flip
NO_THE_INDEX_COMPATIBILITY_MACROS switch, 2019-01-24).

Let's move forward a bit by changing the users of those macros that
are rare enough that we can convert them in one go, and then remove
the compatibility shim.

The only manual change to the C code here is to "cache.h", the rest is
all the result of applying the new "index-compatibility.cocci".

Even though it's a one-off, let's keep the coccinelle rules for
now. We'll extend them in subsequent commits, and this will help
anything that's in-flight or out-of-tree to migrate.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
18 months agobuiltin/{grep,log}.: don't define "USE_THE_INDEX_COMPATIBILITY_MACROS"
Ævar Arnfjörð Bjarmason [Sat, 19 Nov 2022 13:07:29 +0000 (14:07 +0100)] 
builtin/{grep,log}.: don't define "USE_THE_INDEX_COMPATIBILITY_MACROS"

Adding "USE_THE_INDEX_COMPATIBILITY_MACROS" to these two appears to
have been unnecessary from the start, as going back and compiling
f8adbec9fea (cache.h: flip NO_THE_INDEX_COMPATIBILITY_MACROS switch,
2019-01-24) without that addition works.

Let's not have these ask for the compatibility macros from cache.h
that they don't need.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
18 months agocache.h: remove unused "the_index" compat macros
Ævar Arnfjörð Bjarmason [Sat, 19 Nov 2022 13:07:28 +0000 (14:07 +0100)] 
cache.h: remove unused "the_index" compat macros

The "active_alloc" macro added in 228e94f9357 (Move index-related
variables into a structure., 2007-04-01) has not been used since
4aab5b46f44 (Make read-cache.c "the_index" free., 2007-04-01). Let's
remove it.

The rest of these are likewise unused, so let's not keep them
around. E.g. 12cd0bf9b02 (dir: stop using the index compatibility
macros, 2017-05-05) is the last use of "cache_dir_exists".

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
18 months agoThe thirteenth batch
Taylor Blau [Fri, 18 Nov 2022 23:48:53 +0000 (18:48 -0500)] 
The thirteenth batch

Signed-off-by: Taylor Blau <me@ttaylorr.com>
18 months agoMerge branch 'en/sparse-checkout-design'
Taylor Blau [Fri, 18 Nov 2022 23:44:01 +0000 (18:44 -0500)] 
Merge branch 'en/sparse-checkout-design'

Design doc.

* en/sparse-checkout-design:
  sparse-checkout.txt: new document with sparse-checkout directions

18 months agoMerge branch 'jk/branch-delete-detached'
Taylor Blau [Fri, 18 Nov 2022 23:44:00 +0000 (18:44 -0500)] 
Merge branch 'jk/branch-delete-detached'

Fix a bug where `git branch -d` did not work on an orphaned HEAD.

* jk/branch-delete-detached:
  branch: gracefully handle '-d' on orphan HEAD

18 months agoMerge branch 'mh/credential-unrecognized-attrs'
Taylor Blau [Fri, 18 Nov 2022 23:43:59 +0000 (18:43 -0500)] 
Merge branch 'mh/credential-unrecognized-attrs'

Docfix.

* mh/credential-unrecognized-attrs:
  docs: clarify that credential discards unrecognised attributes

18 months agoMerge branch 'vd/skip-cache-tree-update'
Taylor Blau [Fri, 18 Nov 2022 23:43:56 +0000 (18:43 -0500)] 
Merge branch 'vd/skip-cache-tree-update'

Avoid calling 'cache_tree_update()' when doing so would be redundant.

* vd/skip-cache-tree-update:
  rebase: use 'skip_cache_tree_update' option
  read-tree: use 'skip_cache_tree_update' option
  reset: use 'skip_cache_tree_update' option
  unpack-trees: add 'skip_cache_tree_update' option
  cache-tree: add perf test comparing update and prime

18 months agoMerge branch 'mh/increase-credential-cache-timeout'
Taylor Blau [Fri, 18 Nov 2022 23:43:55 +0000 (18:43 -0500)] 
Merge branch 'mh/increase-credential-cache-timeout'

Update the credential-cache documentation to provide a more realistic
example.

* mh/increase-credential-cache-timeout:
  Documentation: increase example cache timeout to 1 hour

18 months agoMerge branch 'vd/update-refs-delete'
Taylor Blau [Fri, 18 Nov 2022 23:43:10 +0000 (18:43 -0500)] 
Merge branch 'vd/update-refs-delete'

`git rebase --update-refs` would delete references when all `update-ref`
commands in the sequencer were removed, which has been corrected.

* vd/update-refs-delete:
  rebase --update-refs: avoid unintended ref deletion

18 months agoMerge branch 'tb/repack-expire-to'
Taylor Blau [Fri, 18 Nov 2022 23:43:09 +0000 (18:43 -0500)] 
Merge branch 'tb/repack-expire-to'

"git repack" learns to send cruft objects out of the way into
packfiles outside the repository.

* tb/repack-expire-to:
  builtin/repack.c: implement `--expire-to` for storing pruned objects
  builtin/repack.c: write cruft packs to arbitrary locations
  builtin/repack.c: pass "cruft_expiration" to `write_cruft_pack`
  builtin/repack.c: pass "out" to `prepare_pack_objects`

18 months agoMerge branch 'ab/sha-makefile-doc'
Taylor Blau [Fri, 18 Nov 2022 23:43:07 +0000 (18:43 -0500)] 
Merge branch 'ab/sha-makefile-doc'

Makefile comments updates and reordering to clarify knobs used to
choose SHA implementations.

* ab/sha-makefile-doc:
  Makefile: discuss SHAttered in *_SHA{1,256} discussion
  Makefile: document default SHA-1 backend on OSX
  Makefile & test-tool: replace "DC_SHA1" variable with a "define"
  Makefile: document SHA-1 and SHA-256 default and selection order
  Makefile: document default SHA-256 backend
  Makefile: rephrase the discussion of *_SHA1 knobs
  Makefile: create and use sections for "define" flag listing
  Makefile: correct DC_SHA1 documentation
  INSTALL: remove discussion of SHA-1 backends
  Makefile: always (re)set DC_SHA1 on fallback

18 months agoMerge branch 'ab/misc-hook-submodule-run-command'
Taylor Blau [Fri, 18 Nov 2022 23:43:04 +0000 (18:43 -0500)] 
Merge branch 'ab/misc-hook-submodule-run-command'

Various test updates.

* ab/misc-hook-submodule-run-command:
  run-command tests: test stdout of run_command_parallel()
  submodule tests: reset "trace.out" between "grep" invocations
  hook tests: fix redirection logic error in 96e7225b310

18 months agodelta-islands: free island-related data after use
Eric Wong [Thu, 17 Nov 2022 23:06:58 +0000 (23:06 +0000)] 
delta-islands: free island-related data after use

On my use case involving 771 islands of Linux on kernel.org,
this reduces memory usage by around 25MB.  The bulk of that
comes from free_remote_islands, since free_config_regexes only
saves around 40k.

This memory is saved early in the memory-intensive pack process,
making it available for the remainder of the long process.

Signed-off-by: Eric Wong <e@80x24.org>
Co-authored-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Taylor Blau <me@ttaylorr.com>
18 months agoparse_object(): check on-disk type of suspected blob
Jeff King [Thu, 17 Nov 2022 22:41:16 +0000 (17:41 -0500)] 
parse_object(): check on-disk type of suspected blob

In parse_object(), we try to handle blobs by streaming rather than
loading them entirely into memory. The most common case here will be
that we haven't seen the object yet and check oid_object_info(), which
tells us we have a blob.

But we trigger this code on one other case: when we have an in-memory
object struct with type OBJ_BLOB (and without its "parsed" flag set,
since otherwise we'd return early from the function). This indicates
that some other part of the code suspected we have a blob (e.g., it was
mentioned by a tree or tag) but we haven't yet looked at the on-disk
copy.

In this case before hitting the streaming path, we check if we have the
object on-disk at all. This is mostly pointless extra work, as the
streaming path would complain if it couldn't open the object (albeit
with the message "hash mismatch", which is a little misleading).

But it's also insufficient to catch all problems. The streaming code
will only tell us "yes, the on-disk object matches the oid". But it
doesn't actually confirm that what we found was indeed a blob, and
neither does repo_has_object_file().

One way to improve this would be to teach stream_object_signature() to
check the type (either by returning it to us to check, or taking an
"expected" type). But there's an even simpler fix here: if we suspect
the object is a blob, just call oid_object_info() to confirm that we
have it on-disk, and that it really is a blob.

This is slightly less efficient than teaching stream_object_signature()
to do it (since it has to open the object already). But this case very
rarely comes up. In practice, we usually don't have any clue what the
type is, in which case we already call oid_object_info(). This
"suspected" case happens only when some other code created an object
struct but didn't actually parse the blob, which is actually tricky to
trigger at all (see the discussion of the test below).

I reworked the conditional a bit so that instead of:

  if ((suspected_blob && oid_object_info() == OBJ_BLOB)
      (no_clue && oid_object_info() == OBJ_BLOB)

we have the simpler:

  if ((suspected_blob || no_clue) && oid_object_info() == OBJ_BLOB)

This is shorter, but also reflects what we really want say, which is
"have we ruled out this being a blob; if not, check it on-disk".

In either case, if oid_object_info() fails to tell us it's a blob, we'll
skip the streaming code path and call repo_read_object_file(), just as
before. And if we really do have a mismatch with the existing object
struct, we'll eventually call lookup_commit(), etc, via
parse_object_buffer(), which will complain that it doesn't match our
existing obj->type.

So this fixes one of the lingering expect_failure cases from 0616617c7e
(t: introduce tests for unexpected object types, 2019-04-09).  That test
works by peeling a tag that claims to point to a blob (triggering us to
create the struct), but really points to something else, which we later
discover when we call parse_object() as part of the actual traversal).
Prior to this commit, we'd quietly check the sha1 and mark the blob as
"parsed". Now we correctly complain about the mismatch.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Taylor Blau <me@ttaylorr.com>
18 months agoparse_object(): drop extra "has" check before checking object type
Jeff King [Thu, 17 Nov 2022 22:37:58 +0000 (17:37 -0500)] 
parse_object(): drop extra "has" check before checking object type

When parsing an object of unknown type, we check to see if it's a blob,
so we can use our streaming code path. This uses oid_object_info() to
check the type, but before doing so we call repo_has_object_file(). This
latter is pointless, as oid_object_info() will already fail if the
object is missing. Checking it ahead of time just complicates the code
and is a waste of resources (albeit small).

Let's drop the redundant check.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Taylor Blau <me@ttaylorr.com>
18 months agoreceive-pack: only use visible refs for connectivity check
Patrick Steinhardt [Thu, 17 Nov 2022 05:47:04 +0000 (06:47 +0100)] 
receive-pack: only use visible refs for connectivity check

When serving a push, git-receive-pack(1) needs to verify that the
packfile sent by the client contains all objects that are required by
the updated references. This connectivity check works by marking all
preexisting references as uninteresting and using the new reference tips
as starting point for a graph walk.

Marking all preexisting references as uninteresting can be a problem
when it comes to performance. Git forges tend to do internal bookkeeping
to keep alive sets of objects for internal use or make them easy to find
via certain references. These references are typically hidden away from
the user so that they are neither advertised nor writeable. At GitLab,
we have one particular repository that contains a total of 7 million
references, of which 6.8 million are indeed internal references. With
the current connectivity check we are forced to load all these
references in order to mark them as uninteresting, and this alone takes
around 15 seconds to compute.

We can optimize this by only taking into account the set of visible refs
when marking objects as uninteresting. This means that we may now walk
more objects until we hit any object that is marked as uninteresting.
But it is rather unlikely that clients send objects that make large
parts of objects reachable that have previously only ever been hidden,
whereas the common case is to push incremental changes that build on top
of the visible object graph.

This provides a huge boost to performance in the mentioned repository,
where the vast majority of its refs hidden. Pushing a new commit into
this repo with `transfer.hideRefs` set up to hide 6.8 million of 7 refs
as it is configured in Gitaly leads to a 4.5-fold speedup:

    Benchmark 1: main
      Time (mean ± σ):     30.977 s ±  0.157 s    [User: 30.226 s, System: 1.083 s]
      Range (min … max):   30.796 s … 31.071 s    3 runs

    Benchmark 2: pks-connectivity-check-hide-refs
      Time (mean ± σ):      6.799 s ±  0.063 s    [User: 6.803 s, System: 0.354 s]
      Range (min … max):    6.729 s …  6.850 s    3 runs

    Summary
      'pks-connectivity-check-hide-refs' ran
        4.56 ± 0.05 times faster than 'main'

As we mostly go through the same codepaths even in the case where there
are no hidden refs at all compared to the code before there is no change
in performance when no refs are hidden:

    Benchmark 1: main
      Time (mean ± σ):     48.188 s ±  0.432 s    [User: 49.326 s, System: 5.009 s]
      Range (min … max):   47.706 s … 48.539 s    3 runs

    Benchmark 2: pks-connectivity-check-hide-refs
      Time (mean ± σ):     48.027 s ±  0.500 s    [User: 48.934 s, System: 5.025 s]
      Range (min … max):   47.504 s … 48.500 s    3 runs

    Summary
      'pks-connectivity-check-hide-refs' ran
        1.00 ± 0.01 times faster than 'main'

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Taylor Blau <me@ttaylorr.com>
18 months agorev-parse: add `--exclude-hidden=` option
Patrick Steinhardt [Thu, 17 Nov 2022 05:47:00 +0000 (06:47 +0100)] 
rev-parse: add `--exclude-hidden=` option

Add a new `--exclude-hidden=` option that is similar to the one we just
added to git-rev-list(1). Given a section name `uploadpack` or `receive`
as argument, it causes us to exclude all references that would be hidden
by the respective `$section.hideRefs` configuration.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Taylor Blau <me@ttaylorr.com>
18 months agorevision: add new parameter to exclude hidden refs
Patrick Steinhardt [Thu, 17 Nov 2022 05:46:56 +0000 (06:46 +0100)] 
revision: add new parameter to exclude hidden refs

Users can optionally hide refs from remote users in git-upload-pack(1),
git-receive-pack(1) and others via the `transfer.hideRefs`, but there is
not an easy way to obtain the list of all visible or hidden refs right
now. We'll require just that though for a performance improvement in our
connectivity check.

Add a new option `--exclude-hidden=` that excludes any hidden refs from
the next pseudo-ref like `--all` or `--branches`.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Taylor Blau <me@ttaylorr.com>
18 months agorevision: introduce struct to handle exclusions
Patrick Steinhardt [Thu, 17 Nov 2022 05:46:51 +0000 (06:46 +0100)] 
revision: introduce struct to handle exclusions

The functions that handle exclusion of refs work on a single string
list. We're about to add a second mechanism for excluding refs though,
and it makes sense to reuse much of the same architecture for both kinds
of exclusion.

Introduce a new `struct ref_exclusions` that encapsulates all the logic
related to excluding refs and move the `struct string_list` that holds
all wildmatch patterns of excluded refs into it. Rename functions that
operate on this struct to match its name.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Taylor Blau <me@ttaylorr.com>
18 months agorevision: move together exclusion-related functions
Patrick Steinhardt [Thu, 17 Nov 2022 05:46:47 +0000 (06:46 +0100)] 
revision: move together exclusion-related functions

Move together the definitions of functions that handle exclusions of
refs so that related functionality sits in a single place, only.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Taylor Blau <me@ttaylorr.com>
18 months agorefs: get rid of global list of hidden refs
Patrick Steinhardt [Thu, 17 Nov 2022 05:46:43 +0000 (06:46 +0100)] 
refs: get rid of global list of hidden refs

We're about to add a new argument to git-rev-list(1) that allows it to
add all references that are visible when taking `transfer.hideRefs` et
al into account. This will require us to potentially parse multiple sets
of hidden refs, which is not easily possible right now as there is only
a single, global instance of the list of parsed hidden refs.

Refactor `parse_hide_refs_config()` and `ref_is_hidden()` so that both
take the list of hidden references as input and adjust callers to keep a
local list, instead. This allows us to easily use multiple hidden-ref
lists. Furthermore, it allows us to properly free this list before we
exit.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Taylor Blau <me@ttaylorr.com>
18 months agorefs: fix memory leak when parsing hideRefs config
Patrick Steinhardt [Thu, 17 Nov 2022 05:46:39 +0000 (06:46 +0100)] 
refs: fix memory leak when parsing hideRefs config

When parsing the hideRefs configuration, we first duplicate the config
value so that we can modify it. We then subsequently append it to the
`hide_refs` string list, which is initialized with `strdup_strings`
enabled. As a consequence we again reallocate the string, but never
free the first duplicate and thus have a memory leak.

While we never clean up the static `hide_refs` variable anyway, this is
no excuse to make the leak worse by leaking every value twice. We are
also about to change the way this variable will be handled so that we do
indeed start to clean it up. So let's fix the memory leak by using the
`string_list_append_nodup()` so that we pass ownership of the allocated
string to `hide_refs`.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Taylor Blau <me@ttaylorr.com>
18 months agonotes: avoid empty line in template
Michael J Gruber [Wed, 16 Nov 2022 15:56:40 +0000 (16:56 +0100)] 
notes: avoid empty line in template

When `git notes` prepares the template it adds an empty newline between
the comment header and the content:

>
> #
> # Write/edit the notes for the following object:
>
> # commit 0f3c55d4c2b7864bffb2d92278eff08d0b2e083f
> # etc

This is wrong structurally because that newline is part of the comment,
too, and thus should be commented. Also, it throws off some positioning
strategies of editors and plugins, and it differs from how we do commit
templates.

Change this to follow the standard set by `git commit`:

>
> #
> # Write/edit the notes for the following object:
> #
> # commit 0f3c55d4c2b7864bffb2d92278eff08d0b2e083f
>

Tests pass unchanged after this code change.

Signed-off-by: Michael J Gruber <git@grubix.eu>
Signed-off-by: Taylor Blau <me@ttaylorr.com>
18 months agot7610: use "file:///dev/null", not "/dev/null", fixes MinGW
Ævar Arnfjörð Bjarmason [Tue, 15 Nov 2022 23:40:14 +0000 (00:40 +0100)] 
t7610: use "file:///dev/null", not "/dev/null", fixes MinGW

On MinGW the "/dev/null" is translated to "nul" on command-lines, even
though as in this case it'll never end up referring to an actual file.

So on Windows the fix for the previous "example.com" timeout issue in
8354cf752ec (t7610: fix flaky timeout issue, don't clone from
example.com, 2022-11-05) would yield:

  fatal: repo URL: 'nul' must be absolute or begin with ./|../

Let's evade this yet again by prefixing this with "file://", which
makes this pass in the Windows CI.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Taylor Blau <me@ttaylorr.com>
18 months agobuiltin/gc.c: fix use-after-free in maintenance_unregister()
Taylor Blau [Tue, 15 Nov 2022 18:53:17 +0000 (13:53 -0500)] 
builtin/gc.c: fix use-after-free in maintenance_unregister()

While trying to fix a move based on an uninitialized value (along with a
declaration after the first statement), be0fd57228
(maintenance --unregister: fix uninit'd data use &
-Wdeclaration-after-statement, 2022-11-15) unintentionally introduced a
use-after-free.

The problem arises when `maintenance_unregister()` sees a non-NULL
`config_file` string and thus tries to call
git_configset_get_value_multi() to lookup the corresponding values.

We store the result off, and then call git_configset_clear(), which
frees the pointer that we just stored. We then try to read that
now-freed pointer a few lines below, and there we have our
use-after-free:

    $ ./t7900-maintenance.sh -vxi --run=23 --valgrind
    [...]
    + git maintenance unregister --config-file ./other
    ==3048727== Invalid read of size 8
    ==3048727==    at 0x1869CA: maintenance_unregister (gc.c:1590)
    ==3048727==    by 0x188F42: cmd_maintenance (gc.c:2651)
    ==3048727==    by 0x128C62: run_builtin (git.c:466)
    ==3048727==    by 0x12907E: handle_builtin (git.c:721)
    ==3048727==    by 0x1292EC: run_argv (git.c:788)
    ==3048727==    by 0x12988E: cmd_main (git.c:926)
    ==3048727==    by 0x21ED39: main (common-main.c:57)
    ==3048727==  Address 0x4b38bc8 is 24 bytes inside a block of size 64 free'd
    ==3048727==    at 0x484617B: free (vg_replace_malloc.c:872)
    ==3048727==    by 0x2D207E: free_individual_entries (hashmap.c:188)
    ==3048727==    by 0x2D2153: hashmap_clear_ (hashmap.c:207)
    ==3048727==    by 0x270B5C: git_configset_clear (config.c:2375)
    ==3048727==    by 0x1869AC: maintenance_unregister (gc.c:1585)
    ==3048727==    by 0x188F42: cmd_maintenance (gc.c:2651)
    ==3048727==    by 0x128C62: run_builtin (git.c:466)
    ==3048727==    by 0x12907E: handle_builtin (git.c:721)
    ==3048727==    by 0x1292EC: run_argv (git.c:788)
    ==3048727==    by 0x12988E: cmd_main (git.c:926)
    ==3048727==    by 0x21ED39: main (common-main.c:57)
    [...]

Resolve this via a partial-revert of be0fd57228. The config_set struct
now gets a zero initialization, which makes free()-ing it a noop even
without calling git_configset_init(). When we do initialize it to a
non-zero value, it is only free()'d after our last read of `list`.

Signed-off-by: Taylor Blau <me@ttaylorr.com>
18 months agomaintenance --unregister: fix uninit'd data use & -Wdeclaration-after-statement
Ævar Arnfjörð Bjarmason [Tue, 15 Nov 2022 16:04:27 +0000 (17:04 +0100)] 
maintenance --unregister: fix uninit'd data use & -Wdeclaration-after-statement

Since (maintenance: add option to register in a specific config,
2022-11-09) we've been unable to build with "DEVELOPER=1" without
"DEVOPTS=no-error", as the added code triggers a
"-Wdeclaration-after-statement" warning.

And worse than that, the data handed to git_configset_clear() is
uninitialized, as can be spotted with e.g.:

./t7900-maintenance.sh -vixd --run=23 --valgrind
[...]
+ git maintenance unregister --force
Conditional jump or move depends on uninitialised value(s)
   at 0x6B5F1E: git_configset_clear (config.c:2367)
   by 0x4BA64E: maintenance_unregister (gc.c:1619)
   by 0x4BD278: cmd_maintenance (gc.c:2650)
   by 0x409905: run_builtin (git.c:466)
   by 0x40A21C: handle_builtin (git.c:721)
   by 0x40A58E: run_argv (git.c:788)
   by 0x40AF68: cmd_main (git.c:926)
   by 0x5D39FE: main (common-main.c:57)
 Uninitialised value was created by a stack allocation
   at 0x4BA22C: maintenance_unregister (gc.c:1557)

Let's fix both of these issues, and also move the scope of the
variable to the "if" statement it's used in, to make it obvious where
it's used.

Helped-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Taylor Blau <me@ttaylorr.com>
18 months agomaintenance: add option to register in a specific config
Ronan Pigott [Wed, 9 Nov 2022 19:07:08 +0000 (12:07 -0700)] 
maintenance: add option to register in a specific config

maintenance register currently records the maintenance repo exclusively
within the user's global configuration, but other configuration files
may be relevant when running maintenance if they are included from the
global config. This option allows the user to choose where maintenance
repos are recorded.

Signed-off-by: Ronan Pigott <ronan@rjp.ie>
Signed-off-by: Taylor Blau <me@ttaylorr.com>
18 months agofor-each-repo: interpolate repo path arguments
Ronan Pigott [Wed, 9 Nov 2022 19:07:07 +0000 (12:07 -0700)] 
for-each-repo: interpolate repo path arguments

This is a quality of life change for git-maintenance, so repos can be
recorded with the tilde syntax. The register subcommand will not record
repos in this format by default.

Signed-off-by: Ronan Pigott <ronan@rjp.ie>
Signed-off-by: Taylor Blau <me@ttaylorr.com>
18 months agoThe twelfth batch
Taylor Blau [Tue, 15 Nov 2022 00:56:07 +0000 (19:56 -0500)] 
The twelfth batch

Signed-off-by: Taylor Blau <me@ttaylorr.com>
18 months agoMerge branch 'vh/my-first-contribution-typo'
Taylor Blau [Tue, 15 Nov 2022 00:53:55 +0000 (19:53 -0500)] 
Merge branch 'vh/my-first-contribution-typo'

Documentation fix.

* vh/my-first-contribution-typo:
  Documentation: fix typo

18 months agoMerge branch 'ks/partialclone-casing'
Taylor Blau [Tue, 15 Nov 2022 00:53:43 +0000 (19:53 -0500)] 
Merge branch 'ks/partialclone-casing'

Documentation fix.

* ks/partialclone-casing:
  repository-version.txt: partialClone casing change

18 months agoMerge branch 'mh/password-can-be-pat'
Taylor Blau [Tue, 15 Nov 2022 00:53:41 +0000 (19:53 -0500)] 
Merge branch 'mh/password-can-be-pat'

Documentation update to git-credential(1).

* mh/password-can-be-pat:
  Documentation/gitcredentials.txt: mention password alternatives

18 months agoMerge branch 'js/ci-set-output'
Taylor Blau [Tue, 15 Nov 2022 00:53:38 +0000 (19:53 -0500)] 
Merge branch 'js/ci-set-output'

Update the actions/github-script dependency in CI to avoid a
deprecation warning.

* js/ci-set-output:
  ci: use a newer `github-script` version

18 months agoMerge branch 'ab/rev-info-init'
Taylor Blau [Tue, 15 Nov 2022 00:53:37 +0000 (19:53 -0500)] 
Merge branch 'ab/rev-info-init'

Progress on being able to initialize a rev_info struct with a macro.

* ab/rev-info-init:
  revisions API: extend the nascent REV_INFO_INIT macro